[PATCH] Cleanup MIPS NetBSD CPP built-ins

Jason R Thorpe thorpej@wasabisystems.com
Wed May 29 18:38:00 GMT 2002


It needs a lot more work, mostly because of icky warts in how CPP
is handled in general in the MIPS code.  But incremental improvement
is good :-)

Committed to trunk.

        * config/mips/netbsd.h (TARGET_OS_CPP_BUILTINS): Define.
        (CPP_PREDEFINES): Make sure this is undefined.
        (CPP_SPEC): Place -D__mips=1 at the beginning of the spec,
        since it is no longer in CPP_PREDEFINES.  Don't -U__MIPSEL__
        or -U__MIPSEB__ before defining one or the other.  Instead, 
        use %(subtarget_endian_default) if neither -EB nor -EL are
        specified.  
        (SUBTARGET_EXTRA_SPECS): Define.
        (SUBTARGET_CPP_SPEC): Remove __LONG64 handling.  Use
        %(netbsd_cpp_spec).

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: config/mips/netbsd.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/netbsd.h,v
retrieving revision 1.17
diff -u -r1.17 netbsd.h
--- config/mips/netbsd.h	15 May 2002 05:29:56 -0000	1.17
+++ config/mips/netbsd.h	30 May 2002 01:22:53 -0000
@@ -36,6 +36,19 @@
 
 #define TARGET_DEFAULT (MASK_GAS|MASK_ABICALLS)
 
+#define TARGET_OS_CPP_BUILTINS()			\
+  do							\
+    {							\
+      NETBSD_OS_CPP_BUILTINS_ELF();			\
+      builtin_define ("__NO_LEADING_UNDERSCORES__");	\
+      builtin_define ("__mips__");			\
+      builtin_define ("__GP_SUPPORT__");		\
+      builtin_assert ("machine=mips");			\
+      if (TARGET_LONG64)				\
+	builtin_define ("__LONG64");			\
+    }							\
+  while (0)
+
 
 /* XXX Don't use DWARF-2 debugging info, for now.  */
 #undef DBX_DEBUGGING_INFO
@@ -54,6 +67,7 @@
 #undef US_SOFTWARE_GOFAST
 #undef INIT_SUBTARGET_OPTABS
 #define INIT_SUBTARGET_OPTABS
+#undef CPP_PREDEFINES
 
 
 /* Get generic NetBSD definitions.  */
@@ -64,30 +78,21 @@
 #include <netbsd-elf.h>
 
 
-/* Provide CPP predefines appropriate for NetBSD.  We default to
-   MIPS-I.  */
-
-#undef CPP_PREDEFINES
-#if TARGET_ENDIAN_DEFAULT != 0 
-#define CPP_PREDEFINES							\
-  "-D__NetBSD__ -D__ELF__ -D__mips__ -D__mips=1 -D__MIPSEB__		\
-   -D__NO_LEADING_UNDERSCORES__	-D__GP_SUPPORT__			\
-   -Asystem=unix -Asystem=NetBSD -Amachine=mips"
-#else
-#define CPP_PREDEFINES							\
-  "-D__NetBSD__ -D__ELF__ -D__mips__ -D__mips=1 -D__MIPSEL__		\
-   -D__NO_LEADING_UNDERSCORES__	-D__GP_SUPPORT__			\
-   -Asystem=unix -Asystem=NetBSD -Amachine=mips"
-#endif
+/* Provide a CPP_SPEC appropriate for NetBSD.  This is a simplified
+   CPP_SPEC from <mips/mips.h>.  We (mostly) use the SUBTARGET_CPP_SPEC
+   to deal with NetBSD-specific CPP options.
 
+   We default to MIPS-I at the very beginning of the spec, and let the
+   value get overridden later, as necessary.  We also set up a default
+   endian spec.
 
-/* Provide a CPP_SPEC appropriate for NetBSD.  This is a simplified
-   CPP_SPEC from <mips/mips.h>.  We use the SUBTARGET_CPP_SPEC to
-   deal with NetBSD-specific CPP options.  */
+   This will get cleaned up once the MIPS target uses
+   TARGET_CPU_CPP_BUILTINS().  */
 
 #undef CPP_SPEC
 #define CPP_SPEC							\
-  "%(subtarget_cpp_size_spec)						\
+  "-D__mips=1								\
+   %(subtarget_cpp_size_spec)						\
    %{mips3:-U__mips -D__mips=3 -D__mips64}				\
    %{mips4:-U__mips -D__mips=4 -D__mips64}				\
    %{mips32:-U__mips -D__mips=32}					\
@@ -105,18 +110,26 @@
    %{msoft-float:-D__mips_soft_float}					\
    %{mabi=eabi:-D__mips_eabi}						\
    %{mips16:%{!mno-mips16:-D__mips16}}					\
-   %{EB:-U__MIPSEL__ -D__MIPSEB__}					\
-   %{EL:-U__MIPSEB__ -D__MIPSEL__}					\
+   %{EB:-D__MIPSEB__} %{EL:-D__MIPSEL__}				\
+   %{!EB:%{!EL:%(subtarget_endian_default)}}				\
    %(subtarget_cpp_spec) "
 
-/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  Currently,
-   we just deal with the GCC option '-posix', and define __LONG64
-   as appropriate for <machine/ansi.h>.  */
+/* Extra specs we need.  */
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS						\
+  { "subtarget_endian_default",	SUBTARGET_ENDIAN_DEFAULT_SPEC },	\
+  { "netbsd_cpp_spec",		NETBSD_CPP_SPEC },
+
+#if TARGET_ENDIAN_DEFAULT != 0
+#define SUBTARGET_ENDIAN_DEFAULT_SPEC "-D__MIPSEB__"
+#else
+#define SUBTARGET_ENDIAN_DEFAULT_SPEC "-D__MIPSEL__"
+#endif
+
+/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD.  */
 
 #undef SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE}    \
-   %{mlong64:%{!mips1:%{!mips2:%{!mips32:-D__LONG64}}}} \
-   %{!mlong64:-U__LONG64}"
+#define SUBTARGET_CPP_SPEC "%(netbsd_cpp_spec)"
 
 /* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
    This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for


More information about the Gcc-patches mailing list