Subject: Re: egcs patch for mipseb support
To: None <tech-toolchain@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-toolchain
Date: 02/15/2000 00:04:41
In <Pine.NEB.4.21.0002131042160.25756-100000@shark.int.duh.org>
tv@pobox.com wrote:

> : If nobody objects, I would like to commit this.
> : Comments?
> 
> Please do, and whoever does the merge back to gcc-2.96 (probably me, but
> that depends on free time constraints) will need to pick up the changes for 
> integration.

I check egcs-20000207 snapshot and notice there are some changes
around config/mips from egcs-1.1.2. HOSTS_WORDS_BIG_ENDIAN is
changed to LIBGCC2_WORDS_BIG_ENDIAN, so I wonder whether it is
appropriate to use TARGET_WORDS_BIG_ENDIAN.

Now I modify the mipseb patch for more consistency:

- use TARGET_ENDIAN_DEFAULT to switch endian in
  dist/gcc/config/mips/netbsd.h
- define TARGET_ENDIAN_DEFAULT in usr.bin/egcs/arch/mips/tm.h with
  ifdef mipseb or mipsel
- add -Dmipseb or -Dmipsel to CPPFLAGS in usr.bin/egcs/Makefile.inc

To build on dist/gcc:

- make both t-mipseb and t-mipsel to specify TARGET_ENDIAN_DEFAULT
  and add them to tmake_file

Which patch is proper? Suggestions?

---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp


--- dist/gcc/config.sub	Mon Aug 17 02:36:45 1998
+++ /usr/src/gnu/dist/gcc/config.sub	Fri Feb 11 13:14:35 2000
@@ -154,7 +154,7 @@
 		| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
 		| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
 		| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
-		| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
+		| mips64 | mipsel | mipseb | mips64el | mips64orion | mips64orionel \
 		| mipstx39 | mipstx39el \
 		| sparc | sparclet | sparclite | sparc64 | v850)
 		basic_machine=$basic_machine-unknown
@@ -182,7 +182,7 @@
 	      | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
 	      | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
 	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
-	      | sparc64-* | mips64-* | mipsel-* \
+	      | sparc64-* | mips64-* | mipsel-* | mipseb-* \
 	      | mips64el-* | mips64orion-* | mips64orionel-*  \
 	      | mipstx39-* | mipstx39el-* \
 	      | f301-*)
--- dist/gcc/configure.in	Thu May 27 23:45:00 1999
+++ /usr/src/gnu/dist/gcc/configure.in	Mon Feb 14 19:24:45 2000
@@ -2012,7 +2012,16 @@
 		xm_file=mips/xm-netbsd.h
 		# On NetBSD, the headers are already okay, except for math.h.
 		fixincludes=fixinc.wrap
-		tmake_file=t-netbsd
+		tmake_file="t-netbsd mips/t-mipsel"
+		xmake_file=none
+		;;
+	mipseb-*-netbsd*)
+		tm_file=mips/netbsd.h
+		xm_file=mips/xm-netbsd.h
+		# On NetBSD, the headers are already okay, except for math.h.
+		fixincludes=fixinc.wrap
+		tmake_file="t-netbsd mips/t-mipseb"
+		xmake_file=none
 		;;
 	mips*el-*-openbsd*)	# mips little endian
 		target_cpu_default="MASK_GAS|MASK_ABICALLS"
@@ -2408,6 +2417,7 @@
 		# On NetBSD, the headers are already okay, except for math.h.
 		fixincludes=fixinc.wrap
 		tmake_file=t-netbsd
+		xmake_file=none
 		;;
 	powerpc-*-eabiaix*)
 		tm_file=rs6000/eabiaix.h
--- dist/gcc/configure	Thu May 27 23:45:00 1999
+++ /usr/src/gnu/dist/gcc/configure	Mon Feb 14 18:57:58 2000
@@ -3991,7 +3991,16 @@
 		xm_file=mips/xm-netbsd.h
 		# On NetBSD, the headers are already okay, except for math.h.
 		fixincludes=fixinc.wrap
-		tmake_file=t-netbsd
+		tmake_file="t-netbsd mips/t-mipsel"
+		xmake_file=none
+		;;
+	mipseb-*-netbsd*)
+		tm_file=mips/netbsd.h
+		xm_file=mips/xm-netbsd.h
+		# On NetBSD, the headers are already okay, except for math.h.
+		fixincludes=fixinc.wrap
+		tmake_file="t-netbsd mips/t-mipseb"
+		xmake_file=none
 		;;
 	mips*el-*-openbsd*)	# mips little endian
 		target_cpu_default="MASK_GAS|MASK_ABICALLS"
@@ -4387,6 +4396,7 @@
 		# On NetBSD, the headers are already okay, except for math.h.
 		fixincludes=fixinc.wrap
 		tmake_file=t-netbsd
+		xmake_file=none
 		;;
 	powerpc-*-eabiaix*)
 		tm_file=rs6000/eabiaix.h
--- dist/gcc/config/mips/netbsd.h	Wed Sep 29 22:19:13 1999
+++ /usr/src/gnu/dist/gcc/config/mips/netbsd.h	Mon Feb 14 18:58:51 2000
@@ -20,7 +20,9 @@
 
 /* Define default target values. */
 
+#ifndef TARGET_ENDIAN_DEFAULT
 #define TARGET_ENDIAN_DEFAULT 0
+#endif
 #define TARGET_DEFAULT MASK_GAS
 
 #ifdef hpcmips /* XXX should use distinct target name -uch */
@@ -45,10 +47,17 @@
 /* Define mips-specific netbsd predefines... */
 
 #undef CPP_PREDEFINES
+#if TARGET_ENDIAN_DEFAULT == MASK_BIG_ENDIAN
+#define CPP_PREDEFINES \
+ "-D__ANSI_COMPAT -DMIPSEB -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD \
+  -D__NetBSD__ -D__ELF__ -Dmips -D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
+  -D_R3000 -Asystem(unix) -Asystem(NetBSD) -Amachine(mips)"
+#else
 #define CPP_PREDEFINES \
  "-D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD \
   -D__NetBSD__ -D__ELF__ -Dmips -D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
   -D_R3000 -Asystem(unix) -Asystem(NetBSD) -Amachine(mips)"
+#endif
 
 /* Always uses gas.  */
 
--- /dev/null	Mon Feb 14 22:50:07 2000
+++ /usr/src/gnu/dist/gcc/config/mips/t-mipseb	Mon Feb 14 18:56:41 2000
@@ -0,0 +1 @@
+T_CFLAGS +=-DTARGET_ENDIAN_DEFAULT=MASK_BIG_ENDIAN
--- /dev/null	Mon Feb 14 22:50:07 2000
+++ /usr/src/gnu/dist/gcc/config/mips/t-mipsel	Mon Feb 14 18:56:59 2000
@@ -0,0 +1 @@
+T_CFLAGS +=-DTARGET_ENDIAN_DEFAULT=0
--- usr.bin/egcs/Makefile.inc	Sun Oct 10 01:10:19 1999
+++ /usr/src/gnu/usr.bin/egcs/Makefile.inc	Mon Feb 14 19:00:46 2000
@@ -23,6 +23,7 @@
 
 .if (${MACHINE_ARCH} == "mipsel") || (${MACHINE_ARCH} == "mipseb")
 ARCHSUBDIR= mips
+CPPFLAGS+=	-D${MACHINE_ARCH}
 .else
 ARCHSUBDIR= ${MACHINE_ARCH}
 .endif
--- usr.bin/egcs/arch/mips/tm.h	Tue Aug 18 05:26:07 1998
+++ /usr/src/gnu/usr.bin/egcs/arch/mips/tm.h	Mon Feb 14 19:01:39 2000
@@ -1,3 +1,11 @@
 /*	$NetBSD: tm.h,v 1.2 1998/08/17 20:26:07 tv Exp $	*/
 
+#ifdef mipseb
+#define TARGET_ENDIAN_DEFAULT MASK_BIG_ENDIAN
+#else
+#ifdef mipsel
+#define TARGET_ENDIAN_DEFAULT 0
+#endif
+#endif
+
 #include "mips/netbsd.h"