This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Convert a29k to new target CPP builtins


With this patch for an a29k-foo-bsd cross compiler:

$ echo "" | ./xgcc -B./ -E -dD - 
# 1 "<stdin>"
# 1 "<built-in>"
#define __VERSION__ "3.2 20020509 (experimental)"
#define __USER_LABEL_PREFIX__ _
#define __REGISTER_PREFIX__ 
#define __HAVE_BUILTIN_SETJMP__ 1
#define __USING_SJLJ_EXCEPTIONS__ 1
#define __SIZE_TYPE__ unsigned int
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__ char
#define __WINT_TYPE__ unsigned int
#define __STDC__ 1
#define __CHAR_UNSIGNED__ 1
#define _AM29K 1
#define _AM29000 1
#define _EPI 1
#define __am29k 1
#define am29k 1
#define __am29k__ 1
#define __a29k 1
#define a29k 1
#define __a29k__ 1
#define __am29000 1
#define am29000 1
#define __am29000__ 1
[...]

and for the ISO case:

$ echo "" | ./xgcc -B./ -E -dD - -std=c89
# 1 "<stdin>"
# 1 "<built-in>"
#define __VERSION__ "3.2 20020509 (experimental)"
#define __USER_LABEL_PREFIX__ _
#define __REGISTER_PREFIX__ 
#define __HAVE_BUILTIN_SETJMP__ 1
#define __USING_SJLJ_EXCEPTIONS__ 1
#define __SIZE_TYPE__ unsigned int
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__ char
#define __WINT_TYPE__ unsigned int
#define __STDC__ 1
#define __CHAR_UNSIGNED__ 1
#define __STRICT_ANSI__ 1
#define _AM29K 1
#define _AM29000 1
#define _EPI 1
#define __am29k 1
#define __am29k__ 1
#define __a29k 1
#define __a29k__ 1
#define __am29000 1
#define __am29000__ 1
[...]

I think rather than TARGET_REGISTER_CPP_BUILTINS, it's best to have
two subcategories (maybe a third?) of TARGET_OS_CPP_BUILTINS and
TARGET_CPU_CPP_BUILTINS.  This should allow us to get rid of some or
all of the #undef tangle in the headers (as this patch does for a29k).
See below patch for an example.

When all of config/ is converted, the #ifndef TARGET_CPU_CPP_BUILTINS
could be removed (all targets should define it) and CPP_PREDEFINES
would be dead.

Thoughts?

Neil.

============================================================
Index: gcc/c-common.c
--- gcc/c-common.c	9 May 2002 22:48:32 -0000	1.320
+++ gcc/c-common.c	10 May 2002 06:50:20 -0000
@@ -4327,9 +4327,14 @@ cb_register_builtins (pfile)
 
   /* A straightforward target hook doesn't work, because of problems
      linking that hook's body when part of non-C front ends.  */
-#ifdef TARGET_REGISTER_CPP_BUILTINS
-  TARGET_REGISTER_CPP_BUILTINS;
+#ifndef TARGET_OS_CPP_BUILTINS
+# define TARGET_OS_CPP_BUILTINS
 #endif
+#ifndef TARGET_CPU_CPP_BUILTINS
+# define TARGET_CPU_CPP_BUILTINS
+#endif
+  TARGET_CPU_CPP_BUILTINS
+  TARGET_OS_CPP_BUILTINS
 }
 
 /* Pass an object-like macro.  If it doesn't lie in the user's
============================================================
Index: gcc/gcc.c
--- gcc/gcc.c	9 May 2002 22:48:33 -0000	1.313
+++ gcc/gcc.c	10 May 2002 06:50:35 -0000
@@ -641,6 +641,10 @@ proper position among the other output f
 # endif
 #endif
 
+#ifndef CPP_PREDEFINES
+# define CPP_PREDEFINES ""
+#endif
+
 static const char *asm_debug = ASM_DEBUG_SPEC;
 static const char *cpp_spec = CPP_SPEC;
 static const char *cpp_predefines = CPP_PREDEFINES;
============================================================
Index: gcc/config/a29k/a29k.h
--- gcc/config/a29k/a29k.h	12 Mar 2002 05:27:44 -0000	1.34
+++ gcc/config/a29k/a29k.h	10 May 2002 06:50:40 -0000
@@ -23,7 +23,12 @@ Boston, MA 02111-1307, USA.  */
 
 /* Names to predefine in the preprocessor for this target machine.  */
 
-#define CPP_PREDEFINES "-D_AM29K -D_AM29000 -D_EPI -Acpu=a29k -Amachine=a29k"
+#define TARGET_CPU_CPP_BUILTINS		\
+	builtin_define ("_AM29K");	\
+	builtin_define ("_AM29000");	\
+	builtin_define ("_EPI");	\
+	builtin_assert ("cpu=29k");	\
+	builtin_assert ("macine=a29k");
 
 /* Print subsidiary information on the compiler version in use.  */
 #define TARGET_VERSION
============================================================
Index: gcc/config/a29k/rtems.h
--- gcc/config/a29k/rtems.h	12 Apr 2002 13:34:46 -0000	1.4
+++ gcc/config/a29k/rtems.h	10 May 2002 06:50:40 -0000
@@ -21,6 +21,6 @@ Boston, MA 02111-1307, USA.  */
 
 /* Specify predefined symbols in preprocessor.  */
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D_AM29K -D_AM29000 -D_EPI -D__rtems__ \
-  -Asystem=rtems -Acpu=a29k -Amachine=a29k"
+#define TARGET_OS_CPP_BUILTINS		\
+	builtin_define ("__rtems__");	\
+	builtin_assert ("system=rtems");
============================================================
Index: gcc/config/a29k/unix.h
--- gcc/config/a29k/unix.h	19 Nov 2001 18:29:59 -0000	1.4
+++ gcc/config/a29k/unix.h	10 May 2002 06:50:40 -0000
@@ -28,8 +28,11 @@ Boston, MA 02111-1307, USA.  */
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (1+2+16+128)
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dam29k -Da29k -Dam29000 -Asystem=unix -Acpu=a29k -Amachine=a29k"
+#define TARGET_OS_CPP_BUILTINS		\
+	builtin_define_std ("am29k");	\
+	builtin_define_std ("a29k");	\
+	builtin_define_std ("am29000");	\
+	builtin_assert ("system=unix");
 
 #undef CPP_SPEC
 #define CPP_SPEC "%{!m29000:-Dam29050 -D__am29050__}"
============================================================
Index: gcc/config/a29k/vx29k.h
--- gcc/config/a29k/vx29k.h	2 Nov 2000 23:29:07 -0000	1.3
+++ gcc/config/a29k/vx29k.h	10 May 2002 06:50:40 -0000
@@ -22,8 +22,9 @@ Boston, MA 02111-1307, USA.  */
 
 /* Names to predefine in the preprocessor for this target machine.  */
 
-#undef  CPP_PREDEFINES
-#define CPP_PREDEFINES "-D_AM29K -D_AM29000 -Acpu=a29k -Amachine=a29k -D__vxworks -D__vxworks_5"
+#define TARGET_OS_CPP_BUILTINS		\
+	builtin_define ("__vxworks");	\
+	builtin_define ("__vxworks_5");
 
 /* Vxworks header files require that the macro CPU be set.
    We could define it in CPP_PREDEFINES, but the value is (or will be)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]