[PATCH] Add sh5*-*-netbsd* sh64*-*-netbsd* targets

Jason R Thorpe thorpej@wasabisystems.com
Mon Jun 3 22:01:00 GMT 2002


This actually adds 4 targets:

	sh5-*-netbsd*		SHmedia, big-endian, 32-bit default
	sh5le-*-netbsd*		SHmedia, little-endian, 32-bit default

	sh64-*-netbsd*		SHmedia, big-endian, 64-bit default
	sh64le-*-netbsd*	SHmedia, little-endian, 64-bit default

...it also makes the existing sh-netbsdelf configuration use more of
the common sh-elf configuration bits.

This configuration is a work-in-progress (much like the NetBSD port
itself) .. the profiling support will get filled in later once we
figure out what that will look like for NetBSD on this target.

Committed to trunk.

        * config.gcc (sh5-*-netbsd*, sh5l*-*-netbsd*)
        (sh64-*-netbsd*, sh64l*-*-netbsd*): New targets. 
        * config/sh/netbsd-elf.h (TARGET_VERSION_ENDIAN)
        (TARGET_VERSION_CPU): Define according to the 
        default target. 
        (TARGET_VERSION): Use TARGET_VERSION_ENDIAN and
        TARGET_VERSION_CPU. 
        (TARGET_OS_CPP_BUILTINS): Use NETBSD_OS_CPP_BUILTINS_LP64
        if TARGET_SHMEDIA64.
        (LINK_DEFAULT_CPU_EMUL): Define according to the 
        default target.
        (SUBTARGET_LINK_EMUL_SUFFIX): Define.
        (SUBTARGET_LINK_SPEC): Define.
        (LINK_SPEC): Use SH_LINK_SPEC. 
        (ASM_SPEC): Remove. 
        (TARGET_DEFAULT): Use TARGET_CPU_DEFAULT. 
        (FUNCTION_PROFILER): Add cases for TARGET_SHMEDIA32
        and TARGET_SHMEDIA64 which abort, for now. 
        * config/sh/t-netbsd-sh5: New file.
        * config/sh/t-netbsd-sh5-32: New file.
        * config/sh/t-netbsd-sh5-64: New file. 

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.202
diff -u -r1.202 config.gcc
--- config.gcc	31 May 2002 04:00:40 -0000	1.202
+++ config.gcc	4 Jun 2002 03:57:56 -0000
@@ -2248,7 +2248,8 @@
 	fi
 	float_format=sh
 	;;
-sh-*-netbsdelf* | shl*-*-netbsdelf*)
+sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
+  sh64-*-netbsd* | sh64l*-*-netbsd*)
 	tm_file="${tm_file} dbxelf.h elfos.h sh/elf.h netbsd.h netbsd-elf.h sh/netbsd-elf.h"
 	tmake_file="${tmake_file} sh/t-sh sh/t-elf"
 	case $machine in
@@ -2260,7 +2261,23 @@
 		tmake_file="${tmake_file} sh/t-be"
 		;;
 	esac
-	tmake_file="${tmake_file} sh/t-netbsd"
+	case $machine in
+	sh5*-*)
+		# SHmedia, 32-bit ABI
+		target_cpu_default="SH5_BIT|SH4_BIT|SH3E_BIT"
+		tmake_file="${tmake_file} sh/t-netbsd-sh5 sh/t-netbsd-sh5-32"
+		;;
+	sh64*-*)
+		# SHmedia, 64-bit ABI
+		target_cpu_default="SH5_BIT|SH4_BIT"
+		tmake_file="${tmake_file} sh/t-netbsd-sh5 sh/t-netbsd-sh5-64"
+		;;
+	*)
+		# SH3, software floating point
+		target_cpu_default="SH1_BIT|SH2_BIT|SH3_BIT"
+		tmake_file="${tmake_file} sh/t-netbsd"
+		;;
+	esac
 	float_format=sh
 	;;
 sh-*-*)
Index: config/sh/netbsd-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/netbsd-elf.h,v
retrieving revision 1.1
diff -u -r1.1 netbsd-elf.h
--- config/sh/netbsd-elf.h	31 May 2002 01:31:26 -0000	1.1
+++ config/sh/netbsd-elf.h	4 Jun 2002 03:58:13 -0000
@@ -20,69 +20,111 @@
 Boston, MA 02111-1307, USA.  */
 
 /* Run-time Target Specification.  */
-#undef TARGET_VERSION
 #if TARGET_ENDIAN_DEFAULT == LITTLE_ENDIAN_BIT
-#define TARGET_VERSION  fputs (" (NetBSD/shle ELF)", stderr);
+#define TARGET_VERSION_ENDIAN "le"
 #else
-#define TARGET_VERSION	fputs (" (NetBSD/sh ELF)", stderr);
+#define TARGET_VERSION_ENDIAN ""
 #endif
 
+#if TARGET_CPU_DEFAULT & SH5_BIT
+#if TARGET_CPU_DEFAULT & SH3E_BIT
+#define TARGET_VERSION_CPU "sh5"
+#else
+#define TARGET_VERSION_CPU "sh64"
+#endif /* SH3E_BIT */
+#else
+#define TARGET_VERSION_CPU "sh"
+#endif /* SH5_BIT */
+
+#undef TARGET_VERSION
+#define TARGET_VERSION	fprintf (stderr, " (NetBSD/%s%s ELF)",		\
+                                 TARGET_VERSION_CPU, TARGET_VERSION_ENDIAN)
+
+
 #define TARGET_OS_CPP_BUILTINS()					\
   do									\
     {									\
       NETBSD_OS_CPP_BUILTINS_ELF();					\
+      if (TARGET_SHMEDIA64)						\
+	NETBSD_OS_CPP_BUILTINS_LP64();					\
       builtin_define ("__NO_LEADING_UNDERSCORES__");			\
     }									\
   while (0)
 
 /* Provide a LINK_SPEC appropriate for a NetBSD/sh ELF target.
-   This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
-   the SH target.  */
+   We use the SH_LINK_SPEC from sh/sh.h, and define the appropriate
+   SUBTARGET_LINK_SPEC that pulls in what we need from a generic
+   NetBSD ELF LINK_SPEC.  */
+
+/* LINK_EMUL_PREFIX from sh/elf.h */
+
+#undef LINK_DEFAULT_CPU_EMUL
+#if TARGET_CPU_DEFAULT & SH5_BIT
+#if TARGET_CPU_DEFAULT & SH3E_BIT
+#define LINK_DEFAULT_CPU_EMUL "32"
+#else
+#define LINK_DEFAULT_CPU_EMUL "64"
+#endif /* SH3E_BIT */
+#else
+#define LINK_DEFAULT_CPU_EMUL ""
+#endif /* SH5_BIT */
 
-#undef LINK_SPEC
-#define LINK_SPEC							\
-  "%{assert*} %{R*}							\
-   %{mb:-m shelf_nbsd}							\
-   %{ml:-m shlelf_nbsd}							\
-   %{mrelax:-relax}							\
-   %{shared:-shared}							\
-   %{!shared:								\
-     -dc -dp								\
-     %{!nostdlib:							\
-       %{!r*:								\
-	 %{!e*:-e __start}}}						\
-     %{!static:								\
-       %{rdynamic:-export-dynamic}					\
-       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}	\
+#undef SUBTARGET_LINK_EMUL_SUFFIX
+#define SUBTARGET_LINK_EMUL_SUFFIX "_nbsd"
+
+#undef SUBTARGET_LINK_SPEC
+#define SUBTARGET_LINK_SPEC \
+  "%{assert*} %{R*} \
+   %{shared:-shared} \
+   %{!shared: \
+     -dc -dp \
+     %{!nostdlib: \
+       %{!r*: \
+	 %{!e*:-e __start}}} \
+     %{!static: \
+       %{rdynamic:-export-dynamic} \
+       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
      %{static:-static}}"
 
+#undef LINK_SPEC
+#define LINK_SPEC SH_LINK_SPEC
+
 
 /* Provide a CPP_SPEC appropriate for NetBSD.  */
 #undef SUBTARGET_CPP_SPEC
 #define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
 
-/* Restore the ASM_SPEC from sh/sh.h; sh/elf.h clobbers it.  */
-#undef ASM_SPEC
-#define ASM_SPEC  "%(subtarget_asm_endian_spec) %{mrelax:-relax}"
-
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT \
-  (SH1_BIT|SH2_BIT|SH3_BIT | USERMODE_BIT | TARGET_ENDIAN_DEFAULT)
+  (TARGET_CPU_DEFAULT | USERMODE_BIT | TARGET_ENDIAN_DEFAULT)
 
  
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(STREAM,LABELNO)				\
 do									\
   {									\
-    fprintf((STREAM), "\tmov.l\t%cLP%d,r1\n",				\
-            LOCAL_LABEL_PREFIX, (LABELNO));				\
-    fprintf((STREAM), "\tmova\t%cLP%dr,r0\n",				\
-            LOCAL_LABEL_PREFIX, (LABELNO));				\
-    fprintf((STREAM), "\tjmp\t@r1\n");					\
-    fprintf((STREAM), "\tnop\n");					\
-    fprintf((STREAM), "\t.align\t2\n");					\
-    fprintf((STREAM), "%cLP%d:\t.long\t__mcount\n",			\
-            LOCAL_LABEL_PREFIX, (LABELNO));				\
-    fprintf((STREAM), "%cLP%dr:\n", LOCAL_LABEL_PREFIX, (LABELNO));	\
+    if (TARGET_SHMEDIA32)						\
+      {									\
+	/* FIXME */							\
+	abort ();							\
+      }									\
+    else if (TARGET_SHMEDIA64)						\
+      {									\
+	/* FIXME */							\
+	abort ();							\
+      }									\
+    else								\
+      {									\
+        fprintf((STREAM), "\tmov.l\t%cLP%d,r1\n",			\
+                LOCAL_LABEL_PREFIX, (LABELNO));				\
+        fprintf((STREAM), "\tmova\t%cLP%dr,r0\n",			\
+                LOCAL_LABEL_PREFIX, (LABELNO));				\
+        fprintf((STREAM), "\tjmp\t@r1\n");				\
+        fprintf((STREAM), "\tnop\n");					\
+        fprintf((STREAM), "\t.align\t2\n");				\
+        fprintf((STREAM), "%cLP%d:\t.long\t__mcount\n",			\
+                LOCAL_LABEL_PREFIX, (LABELNO));				\
+        fprintf((STREAM), "%cLP%dr:\n", LOCAL_LABEL_PREFIX, (LABELNO));	\
+      }									\
   }									\
 while (0)
Index: config/sh/t-netbsd-sh5
===================================================================
RCS file: config/sh/t-netbsd-sh5
diff -N config/sh/t-netbsd-sh5
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/sh/t-netbsd-sh5	4 Jun 2002 03:58:13 -0000
@@ -0,0 +1,18 @@
+TARGET_LIBGCC2_CFLAGS = -fpic
+
+LIB1ASMFUNCS = \
+  _sdivsi3 _sdivsi3_i4 _udivsi3 _udivsi3_i4 _set_fpscr \
+  _shcompact_call_trampoline _shcompact_return_trampoline \
+  _shcompact_incoming_args _ic_invalidate _nested_trampoline \
+  _push_pop_shmedia_regs
+
+LIB2FUNCS_EXTRA=
+
+EXTRA_MULTILIB_PARTS=
+
+# NetBSD's C library includes a fast software FP library that
+# has support for setting/setting the rounding mode, exception
+# mask, etc.  Therefore, we don't want to include software FP
+# in libgcc.
+FPBIT =
+DPBIT =
Index: config/sh/t-netbsd-sh5-32
===================================================================
RCS file: config/sh/t-netbsd-sh5-32
diff -N config/sh/t-netbsd-sh5-32
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/sh/t-netbsd-sh5-32	4 Jun 2002 03:58:13 -0000
@@ -0,0 +1,3 @@
+MULTILIB_OPTIONS += m5-32media-nofpu/m5-compact/m5-compact-nofpu/m5-64media/m5-64media-nofpu
+MULTILIB_DIRNAMES=
+MULTILIB_MATCHES =
Index: config/sh/t-netbsd-sh5-64
===================================================================
RCS file: config/sh/t-netbsd-sh5-64
diff -N config/sh/t-netbsd-sh5-64
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/sh/t-netbsd-sh5-64	4 Jun 2002 03:58:13 -0000
@@ -0,0 +1,3 @@
+MULTILIB_OPTIONS += m5-64media-nofpu/m5-compact/m5-compact-nofpu/m5-32media/m5-32media-nofpu
+MULTILIB_DIRNAMES=
+MULTILIB_MATCHES =


More information about the Gcc-patches mailing list