From 12a41c224db06c4b858894780d2a26d6ac8e0566 Mon Sep 17 00:00:00 2001
From: Neil Booth <neil@daikokuya.demon.co.uk>
Date: Mon, 13 May 2002 05:57:38 +0000
Subject: [PATCH] Makefile.in (c-common.o, cppinit.o): Update.

	* Makefile.in (c-common.o, cppinit.o): Update.
	* c-common.c: Include except.h.
	(cb_register_builtins): Handle __USING_SJLJ_EXCEPTIONS__.
	Call TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS.
	* cppinit.c (__USING_SJLJ_EXCEPTIONS): Not here.
	* defaults.h (TARGET_OS_CPP_BUILTINS, TARGET_CPU_CPP_BUILTINS,
	CPP_PREDEFINES): Handle here.
config:
	* alpha/alpha-interix.h, alpha/gnu.h, alpha/linux.h,
	alpha/netbsd.h, alpha/openbsd.h, alpha/osf.h, alpha/unicosmk.h,
	alpha/vms.h, alpha/vxworks.h: Remove CPP_PREDEFINES, define
	TARGET_OS_CPP_BUILTINS.
	* alpha/alpha.h (TARGET_CPU_CPP_BUILTINS): Define.
	(CPP_SPEC, EXTRA_SPECS): Update.
	(CPP_AM_BWX_SPEC, CPP_AM_MAX_SPEC, CPP_AM_FIX_SPEC,
	CPP_AM_CIX_SPEC, CPP_IM_EV4_SPEC, CPP_IM_EV5_SPEC,
	CPP_IM_EV6_SPEC, CPP_CPU_EV4_SPEC, CPP_CPU_EV5_SPEC,
	CPP_CPU_EV56_SPEC, CPP_CPU_PCA56_SPEC, CPP_CPU_EV6_SPEC,
	CPP_CPU_EV67_SPEC, CPP_CPU_DEFAULT_SPEC, CPP_CPU_SPEC): Remove.
doc:
	* tm.texi (TARGET_REGISTER_CPP_BUILTINS): Remove.
	(TARGET_OS_CPP_BUILTINS, TARGET_CPU_CPP_BUILTINS): Define.

From-SVN: r53410
---
 gcc/ChangeLog                    |  25 +++++++
 gcc/Makefile.in                  |   4 +-
 gcc/c-common.c                   |  10 ++-
 gcc/config/alpha/alpha-interix.h |  21 +++---
 gcc/config/alpha/alpha.h         | 120 ++++++++++++-------------------
 gcc/config/alpha/gnu.h           |  12 +++-
 gcc/config/alpha/linux.h         |  11 ++-
 gcc/config/alpha/netbsd.h        |  11 +--
 gcc/config/alpha/openbsd.h       |   9 ++-
 gcc/config/alpha/osf.h           |  13 +++-
 gcc/config/alpha/unicosmk.h      |  16 ++++-
 gcc/config/alpha/vms.h           |  10 ++-
 gcc/config/alpha/vxworks.h       |  12 ++--
 gcc/cppinit.c                    |   5 --
 gcc/defaults.h                   |  12 ++++
 gcc/doc/tm.texi                  |  26 +++++--
 gcc/gcc.c                        |   2 +-
 17 files changed, 193 insertions(+), 126 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 443aff9977b0..6381456b8222 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,28 @@
+2002-05-13  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+	* Makefile.in (c-common.o, cppinit.o): Update.
+	* c-common.c: Include except.h.
+	(cb_register_builtins): Handle __USING_SJLJ_EXCEPTIONS__.
+	Call TARGET_CPU_CPP_BUILTINS and TARGET_OS_CPP_BUILTINS.
+	* cppinit.c (__USING_SJLJ_EXCEPTIONS): Not here.
+	* defaults.h (TARGET_OS_CPP_BUILTINS, TARGET_CPU_CPP_BUILTINS,
+	CPP_PREDEFINES): Handle here.
+config:
+	* alpha/alpha-interix.h, alpha/gnu.h, alpha/linux.h,
+	alpha/netbsd.h, alpha/openbsd.h, alpha/osf.h, alpha/unicosmk.h,
+	alpha/vms.h, alpha/vxworks.h: Remove CPP_PREDEFINES, define
+	TARGET_OS_CPP_BUILTINS.
+	* alpha/alpha.h (TARGET_CPU_CPP_BUILTINS): Define.
+	(CPP_SPEC, EXTRA_SPECS): Update.
+	(CPP_AM_BWX_SPEC, CPP_AM_MAX_SPEC, CPP_AM_FIX_SPEC,
+	CPP_AM_CIX_SPEC, CPP_IM_EV4_SPEC, CPP_IM_EV5_SPEC,
+	CPP_IM_EV6_SPEC, CPP_CPU_EV4_SPEC, CPP_CPU_EV5_SPEC,
+	CPP_CPU_EV56_SPEC, CPP_CPU_PCA56_SPEC, CPP_CPU_EV6_SPEC,
+	CPP_CPU_EV67_SPEC, CPP_CPU_DEFAULT_SPEC, CPP_CPU_SPEC): Remove.
+doc:
+	* tm.texi (TARGET_REGISTER_CPP_BUILTINS): Remove.
+	(TARGET_OS_CPP_BUILTINS, TARGET_CPU_CPP_BUILTINS): Define.
+
 2002-05-12  Zack Weinberg  <zack@codesourcery.com>
 
 	* emit-rtl.c (global_rtl): Update comment.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 092f1ea11144..937b6e50d2f8 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1215,7 +1215,7 @@ s-under: $(GCC_PASSES)
 c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \
 	$(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \
 	$(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def $(TARGET_H) \
-	diagnostic.h tree-inline.h
+	diagnostic.h tree-inline.h except.h
 
 # A file used by all variants of C and some other languages.
 
@@ -2011,7 +2011,7 @@ cpplib.o:   cpplib.c   $(CONFIG_H) $(LIBCPP_DEPS)
 cpphash.o:  cpphash.c  $(CONFIG_H) $(LIBCPP_DEPS)
 cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
 cppinit.o:  cppinit.c  $(CONFIG_H) $(LIBCPP_DEPS) cppdefault.h \
-		mkdeps.h prefix.h version.h except.h
+		mkdeps.h prefix.h version.h
 
 cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) cppdefault.h Makefile
 	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 59a0b7f9f93e..8233187b92a8 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cpplib.h"
 #include "target.h"
 #include "langhooks.h"
+#include "except.h"		/* For USING_SJLJ_EXCEPTIONS.  */
 cpp_reader *parse_in;		/* Declared in c-lex.h.  */
 
 #undef WCHAR_TYPE_SIZE
@@ -4325,11 +4326,14 @@ cb_register_builtins (pfile)
 	cpp_define (pfile, "__GXX_WEAK__=0");
     }
 
+  /* libgcc needs to know this.  */
+  if (USING_SJLJ_EXCEPTIONS)
+    cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");
+
   /* 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;
-#endif
+  TARGET_CPU_CPP_BUILTINS ();
+  TARGET_OS_CPP_BUILTINS ();
 }
 
 /* Pass an object-like macro.  If it doesn't lie in the user's
diff --git a/gcc/config/alpha/alpha-interix.h b/gcc/config/alpha/alpha-interix.h
index 4dc21868dd45..e7874b0a0112 100644
--- a/gcc/config/alpha/alpha-interix.h
+++ b/gcc/config/alpha/alpha-interix.h
@@ -25,15 +25,18 @@ Boston, MA 02111-1307, USA.  */
 
 /* cpp handles __STDC__ */
 /* The three "Alpha" defines on the first such line are from the CLAXP spec */
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES " \
-  -D__INTERIX \
-  -D__OPENNT \
-  -D__Alpha_AXP -D_M_ALPHA -D_ALPHA_  \
-  -D__alpha -D__alpha__\
-  -D__stdcall= \
-  -D__cdecl= \
-  -Asystem=unix -Asystem=interix -Acpu=alpha -Amachine=alpha"
+#define TARGET_OS_CPP_BUILTINS()				\
+    do {							\
+	builtin_define ("__INTERIX");				\
+	builtin_define ("__OPENNT");				\
+	builtin_define ("__Alpha_AXP");				\
+	builtin_define ("_M_ALPHA");				\
+	builtin_define ("_ALPHA_");				\
+	builtin_define ("__stdcall=");				\
+	builtin_define ("__cdecl=");				\
+	builtin_assert ("system=unix");				\
+	builtin_assert ("system=interix");			\
+    } while (0)
 
 #undef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC "\
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index 683740d913c0..caab8f60598a 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -20,6 +20,50 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+/* Target CPU builtins.  */
+#define TARGET_CPU_CPP_BUILTINS()			\
+  do							\
+    {							\
+	builtin_define ("__alpha");			\
+	builtin_define ("__alpha__");			\
+	builtin_assert ("cpu=alpha");			\
+	builtin_assert ("machine=alpha");		\
+	if (TARGET_CIX)					\
+	  {						\
+	    builtin_define ("__alpha_cix__");		\
+	    builtin_assert ("cpu=cix");			\
+	  }						\
+	if (TARGET_FIX)					\
+	  {						\
+	    builtin_define ("__alpha_fix__");		\
+	    builtin_assert ("cpu=fix");			\
+	  }						\
+	if (TARGET_BWX)					\
+	  {						\
+	    builtin_define ("__alpha_bwx__");		\
+	    builtin_assert ("cpu=bwx");			\
+	  }						\
+	if (TARGET_MAX)					\
+	  {						\
+	    builtin_define ("__alpha_max__");		\
+	    builtin_assert ("cpu=max");			\
+	  }						\
+	if (TARGET_CPU_EV6)				\
+	  {						\
+	    builtin_define ("__alpha_ev6__");		\
+	    builtin_assert ("cpu=ev6");			\
+	  }						\
+	else if (TARGET_CPU_EV5)			\
+	  {						\
+	    builtin_define ("__alpha_ev5__");		\
+	    builtin_assert ("cpu=ev5");			\
+	  }						\
+	else	/* Presumably ev4.  */			\
+	  {						\
+	    builtin_define ("__alpha_ev4__");		\
+	    builtin_assert ("cpu=ev4");			\
+	  }						\
+    } while (0)
 
 /* For C++ we need to ensure that __LANGUAGE_C_PLUS_PLUS is defined independent
    of the source file extension.  */
@@ -37,7 +81,7 @@ Boston, MA 02111-1307, USA.  */
 %{!.S:%{!.cc:%{!.cxx:%{!.cpp:%{!.cp:%{!.c++:%{!.C:%{!.m:-D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C }}}}}}}}}\
 %{mieee:-D_IEEE_FP }\
 %{mieee-with-inexact:-D_IEEE_FP -D_IEEE_FP_INEXACT }}\
-%(cpp_cpu) %(cpp_subtarget)"
+%(cpp_subtarget)"
 
 #ifndef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC ""
@@ -285,65 +329,6 @@ extern const char *alpha_mlat_string;	/* For -mmemory-latency= */
    N_("Tune expected memory latency")},			\
 }
 
-/* Attempt to describe CPU characteristics to the preprocessor.  */
-
-/* Corresponding to amask...  */
-#define CPP_AM_BWX_SPEC	"-D__alpha_bwx__ -Acpu=bwx"
-#define CPP_AM_MAX_SPEC	"-D__alpha_max__ -Acpu=max"
-#define CPP_AM_FIX_SPEC	"-D__alpha_fix__ -Acpu=fix"
-#define CPP_AM_CIX_SPEC	"-D__alpha_cix__ -Acpu=cix"
-
-/* Corresponding to implver...  */
-#define CPP_IM_EV4_SPEC	"-D__alpha_ev4__ -Acpu=ev4"
-#define CPP_IM_EV5_SPEC	"-D__alpha_ev5__ -Acpu=ev5"
-#define CPP_IM_EV6_SPEC	"-D__alpha_ev6__ -Acpu=ev6"
-
-/* Common combinations.  */
-#define CPP_CPU_EV4_SPEC	"%(cpp_im_ev4)"
-#define CPP_CPU_EV5_SPEC	"%(cpp_im_ev5)"
-#define CPP_CPU_EV56_SPEC	"%(cpp_im_ev5) %(cpp_am_bwx)"
-#define CPP_CPU_PCA56_SPEC	"%(cpp_im_ev5) %(cpp_am_bwx) %(cpp_am_max)"
-#define CPP_CPU_EV6_SPEC \
-  "%(cpp_im_ev6) %(cpp_am_bwx) %(cpp_am_max) %(cpp_am_fix)"
-#define CPP_CPU_EV67_SPEC \
-  "%(cpp_im_ev6) %(cpp_am_bwx) %(cpp_am_max) %(cpp_am_fix) %(cpp_am_cix)"
-
-#ifndef CPP_CPU_DEFAULT_SPEC
-# if TARGET_CPU_DEFAULT & MASK_CPU_EV6
-#  if TARGET_CPU_DEFAULT & MASK_CIX
-#    define CPP_CPU_DEFAULT_SPEC	CPP_CPU_EV67_SPEC
-#  else
-#    define CPP_CPU_DEFAULT_SPEC	CPP_CPU_EV6_SPEC
-#  endif
-# else
-#  if TARGET_CPU_DEFAULT & MASK_CPU_EV5
-#   if TARGET_CPU_DEFAULT & MASK_MAX
-#    define CPP_CPU_DEFAULT_SPEC	CPP_CPU_PCA56_SPEC
-#   else
-#    if TARGET_CPU_DEFAULT & MASK_BWX
-#     define CPP_CPU_DEFAULT_SPEC	CPP_CPU_EV56_SPEC
-#    else
-#     define CPP_CPU_DEFAULT_SPEC	CPP_CPU_EV5_SPEC
-#    endif
-#   endif
-#  else
-#   define CPP_CPU_DEFAULT_SPEC		CPP_CPU_EV4_SPEC
-#  endif
-# endif
-#endif /* CPP_CPU_DEFAULT_SPEC */
-
-#ifndef CPP_CPU_SPEC
-#define CPP_CPU_SPEC "\
-%{!undef:-Acpu=alpha -Amachine=alpha -D__alpha -D__alpha__ \
-%{mcpu=ev4|mcpu=21064:%(cpp_cpu_ev4) }\
-%{mcpu=ev5|mcpu=21164:%(cpp_cpu_ev5) }\
-%{mcpu=ev56|mcpu=21164a:%(cpp_cpu_ev56) }\
-%{mcpu=pca56|mcpu=21164pc|mcpu=21164PC:%(cpp_cpu_pca56) }\
-%{mcpu=ev6|mcpu=21264:%(cpp_cpu_ev6) }\
-%{mcpu=ev67|mcpu=21264a:%(cpp_cpu_ev67) }\
-%{!mcpu*:%(cpp_cpu_default) }}"
-#endif
-
 /* This macro defines names of additional specifications to put in the
    specs that can be used in various specifications like CC1_SPEC.  Its
    definition is an initializer with a subgrouping for each command option.
@@ -359,21 +344,6 @@ extern const char *alpha_mlat_string;	/* For -mmemory-latency= */
 #endif
 
 #define EXTRA_SPECS				\
-  { "cpp_am_bwx", CPP_AM_BWX_SPEC },		\
-  { "cpp_am_max", CPP_AM_MAX_SPEC },		\
-  { "cpp_am_fix", CPP_AM_FIX_SPEC },		\
-  { "cpp_am_cix", CPP_AM_CIX_SPEC },		\
-  { "cpp_im_ev4", CPP_IM_EV4_SPEC },		\
-  { "cpp_im_ev5", CPP_IM_EV5_SPEC },		\
-  { "cpp_im_ev6", CPP_IM_EV6_SPEC },		\
-  { "cpp_cpu_ev4", CPP_CPU_EV4_SPEC },		\
-  { "cpp_cpu_ev5", CPP_CPU_EV5_SPEC },		\
-  { "cpp_cpu_ev56", CPP_CPU_EV56_SPEC },	\
-  { "cpp_cpu_pca56", CPP_CPU_PCA56_SPEC },	\
-  { "cpp_cpu_ev6", CPP_CPU_EV6_SPEC },		\
-  { "cpp_cpu_ev67", CPP_CPU_EV67_SPEC },	\
-  { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC },	\
-  { "cpp_cpu", CPP_CPU_SPEC },			\
   { "cpp_subtarget", CPP_SUBTARGET_SPEC },	\
   SUBTARGET_EXTRA_SPECS
 
diff --git a/gcc/config/alpha/gnu.h b/gcc/config/alpha/gnu.h
index c18796dd0c70..ed72429185e6 100644
--- a/gcc/config/alpha/gnu.h
+++ b/gcc/config/alpha/gnu.h
@@ -3,9 +3,15 @@
 #undef TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Alpha GNU)");
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-"-D__GNU__ -D__gnu_hurd__ -Dunix -Asystem=gnu -D_LONGLONG -D__alpha__ -D__ELF__"
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define ("__GNU__");		\
+	builtin_define ("__ELF__");		\
+	builtin_define ("__gnu_hurd__");	\
+	builtin_define ("_LONGLONG");		\
+	builtin_define_std ("unix");		\
+	builtin_assert ("system=gnu");		\
+    } while (0)
 
 #undef ELF_DYNAMIC_LINKER
 #define ELF_DYNAMIC_LINKER	"/lib/ld.so"
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 21639c5ece0b..d98a34d3d459 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -23,9 +23,14 @@ Boston, MA 02111-1307, USA.  */
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (MASK_FP | MASK_FPREGS | MASK_GAS)
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-  "-D__gnu_linux__ -Dlinux -Dunix -Asystem=linux -D_LONGLONG -D__alpha__"
+#define TARGET_OS_CPP_BUILTINS()				\
+    do {							\
+	builtin_define ("__gnu_linux__");			\
+	builtin_define ("_LONGLONG");				\
+	builtin_define_std ("linux");				\
+	builtin_define_std ("unix");				\
+	builtin_assert ("system=linux");			\
+    } while (0)
 
 /* The GNU C++ standard library requires that these macros be defined.  */
 #undef CPLUSPLUS_CPP_SPEC
diff --git a/gcc/config/alpha/netbsd.h b/gcc/config/alpha/netbsd.h
index 508b71cdf555..9b0c23239723 100644
--- a/gcc/config/alpha/netbsd.h
+++ b/gcc/config/alpha/netbsd.h
@@ -22,10 +22,13 @@ Boston, MA 02111-1307, USA.  */
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (MASK_FP | MASK_FPREGS | MASK_GAS)
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES							\
-  "-D__NetBSD__ -D_LP64 -Asystem=unix -Asystem=NetBSD"
-
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define ("__NetBSD__");		\
+	builtin_define ("_LP64");		\
+	builtin_assert ("system=unix");		\
+	builtin_assert ("system=NetBSD");	\
+    } while (0)
 
 /* Show that we need a GP when profiling.  */
 #undef TARGET_PROFILING_NEEDS_GP
diff --git a/gcc/config/alpha/openbsd.h b/gcc/config/alpha/openbsd.h
index d0247490161e..b82b66df3c8c 100644
--- a/gcc/config/alpha/openbsd.h
+++ b/gcc/config/alpha/openbsd.h
@@ -39,8 +39,13 @@ Boston, MA 02111-1307, USA.  */
   "%{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{assert*}"
 
 /* run-time target specifications */
-#define CPP_PREDEFINES "-D__unix__ -D__ANSI_COMPAT -Asystem=unix \
--D__OpenBSD__ -D__alpha__ -D__alpha"
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define ("__OpenBSD__");		\
+	builtin_define ("__ANSI_COMPAT");	\
+	builtin_define ("__unix__");		\
+	builtin_assert ("system=unix");		\
+    } while (0)
 
 /* Layout of source language data types.  */
 
diff --git a/gcc/config/alpha/osf.h b/gcc/config/alpha/osf.h
index efb0a16d7fd0..cb3b3447eeee 100644
--- a/gcc/config/alpha/osf.h
+++ b/gcc/config/alpha/osf.h
@@ -32,9 +32,16 @@ Boston, MA 02111-1307, USA.  */
 
 /* Names to predefine in the preprocessor for this target machine.  */
 
-#define CPP_PREDEFINES "\
--Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD \
--D_SYSTYPE_BSD -Asystem=unix -Asystem=xpg4"
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define_std ("unix");		\
+	builtin_define_std ("SYSTYPE_BSD");	\
+	builtin_define ("_SYSTYPE_BSD");	\
+	builtin_define ("__osf__");		\
+	builtin_define ("_LONGLONG");		\
+	builtin_assert ("system=unix");		\
+	builtin_assert ("system=xpg4");		\
+    } while (0)
 
 /* Tru64 UNIX V5 requires additional definitions for 16 byte long double
    support.  Empty by default.  */
diff --git a/gcc/config/alpha/unicosmk.h b/gcc/config/alpha/unicosmk.h
index 80492e486b85..8ed0f72d70cc 100644
--- a/gcc/config/alpha/unicosmk.h
+++ b/gcc/config/alpha/unicosmk.h
@@ -32,8 +32,20 @@ Boston, MA 02111-1307, USA.  */
 /* The following defines are necessary for the standard headers to work
    correctly.  */
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__unix=1 -D_UNICOS=205 -D_CRAY=1 -D_CRAYT3E=1 -D_CRAYMPP=1 -D_CRAYIEEE=1 -D_ADDR64=1 -D_LD64=1 -D__UNICOSMK__ -D__INT_MAX__=9223372036854775807 -D__SHRT_MAX__=2147483647"
+#define TARGET_OS_CPP_BUILTINS()				\
+    do {							\
+	builtin_define ("__unix");				\
+	builtin_define ("_UNICOS=205");				\
+	builtin_define ("_CRAY");				\
+	builtin_define ("_CRAYT3E");				\
+	builtin_define ("_CRAYMPP");				\
+	builtin_define ("_CRAYIEEE");				\
+	builtin_define ("_ADDR64");				\
+	builtin_define ("_LD64");				\
+	builtin_define ("__UNICOSMK__");			\
+	builtin_define ("__INT_MAX__=9223372036854775807");	\
+	builtin_define ("__SHRT_MAX__=2147483647")		\
+    } while (0)
 
 #define SHORT_TYPE_SIZE 32
 
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index 12529f4d936d..53f2fbd707a9 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -29,9 +29,13 @@ Boston, MA 02111-1307, USA.  */
 
 #define NO_EXTERNAL_INDIRECT_ADDRESS
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-"-D__ALPHA -Dvms -DVMS -D__vms__ -D__VMS__ -Asystem=vms"
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define_std ("vms");		\
+	builtin_define_std ("VMS");		\
+	builtin_define ("__ALPHA");		\
+	builtin_assert ("system=vms");		\
+    } while (0)
 
 #undef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC "\
diff --git a/gcc/config/alpha/vxworks.h b/gcc/config/alpha/vxworks.h
index 2f711ce26210..a27c6452116f 100644
--- a/gcc/config/alpha/vxworks.h
+++ b/gcc/config/alpha/vxworks.h
@@ -26,10 +26,14 @@ Boston, MA 02111-1307, USA.  */
 %{!mvxsim: %{!mcpu*|mcpu=21064:-DCPU=21064} %{mcpu=21164:-DCPU=21164}} \
 %{posix: -D_POSIX_SOURCE}"
 
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "\
--D__vxworks -D__alpha_vxworks -Asystem=vxworks \
--Asystem=embedded -D_LONGLONG"
+#define TARGET_OS_CPP_BUILTINS()		\
+    do {					\
+	builtin_define ("__vxworks");		\
+	builtin_define ("__alpha_vxworks");	\
+	builtin_define ("_LONGLONG");		\
+	builtin_assert ("system=vxworks");	\
+	builtin_assert ("system=embedded");	\
+    } while (0)
 
 /* VxWorks does all the library stuff itself.  */
 
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index dae4ffe602c8..7042cd279885 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -28,7 +28,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "version.h"
 #include "mkdeps.h"
 #include "cppdefault.h"
-#include "except.h"	/* for USING_SJLJ_EXCEPTIONS */
 
 /* Predefined symbols, built-in macros, and the default include path.  */
 
@@ -663,10 +662,6 @@ static const struct builtin builtin_array[] =
   X("__USER_LABEL_PREFIX__",	ULP),
   C("__REGISTER_PREFIX__",	REGISTER_PREFIX),
   C("__HAVE_BUILTIN_SETJMP__",	"1"),
-#if USING_SJLJ_EXCEPTIONS
-  /* libgcc needs to know this.  */
-  C("__USING_SJLJ_EXCEPTIONS__","1"),
-#endif
 #ifndef NO_BUILTIN_SIZE_TYPE
   C("__SIZE_TYPE__",		SIZE_TYPE),
 #endif
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 69c95e7d9e9d..7a45877f3297 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -35,6 +35,18 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #  define TARGET_ESC 033
 #endif
 
+/* When removal of CPP_PREDEFINES is complete, TARGET_CPU_CPP_BULITINS
+   can also be removed from here.  */
+#ifndef TARGET_OS_CPP_BUILTINS
+# define TARGET_OS_CPP_BUILTINS()
+#endif
+#ifndef TARGET_CPU_CPP_BUILTINS
+# define TARGET_CPU_CPP_BUILTINS()
+#endif
+#ifndef CPP_PREDEFINES
+# define CPP_PREDEFINES ""
+#endif
+
 /* Store in OUTPUT a string (made with alloca) containing
    an assembler-name for a local static variable or function named NAME.
    LABELNO is an integer which is different for each call.  */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f382796937a5..36ccaebcd350 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -623,12 +623,15 @@ The macro @code{STANDARD_STARTFILE_PREFIX}.
 Here are run-time target specifications.
 
 @table @code
-@findex TARGET_REGISTER_CPP_BUILTINS
-@item TARGET_REGISTER_CPP_BUILTINS
-This macro expands to a block of code that defines target-specific
-built-in preprocessor macros and assertions, using the functions
-@code{builtin_macro}, @code{builtin_macro_std} and
-@code{builtin_assert} declared in @file{c-lex.h}.
+@findex TARGET_CPU_CPP_BUILTINS
+@item TARGET_CPU_CPP_BUILTINS()
+This function-like macro expands to a block of code that defines
+built-in preprocessor macros and assertions for the target cpu, using
+the functions @code{builtin_macro}, @code{builtin_macro_std} and
+@code{builtin_assert} declared in @file{c-lex.h}.  When the front end
+calls this macro it provides a trailing semicolon, and since it has
+finished command line option processing your code can use those
+results freely.
 
 @code{builtin_assert} takes a string in the form you pass to the
 command-line option @option{-A}, such as @code{cpu=mips}, and creates
@@ -646,7 +649,16 @@ and possibly @code{unix}; passing @code{_mips} defines @code{__mips},
 @code{__mips__} and possibly @code{_mips}, and passing @code{_ABI64}
 defines only @code{_ABI64}.
 
-This macro obsoletes the @code{CPP_PREDEFINES} target macro.
+With @code{TARGET_OS_CPP_BUILTINS} this macro obsoletes the
+@code{CPP_PREDEFINES} target macro.
+
+@findex TARGET_OS_CPP_BUILTINS
+@item TARGET_OS_CPP_BUILTINS()
+Similarly to @code{TARGET_CPU_CPP_BUILTINS} but this macro is optional
+and is used for the target operating system instead.
+
+With @code{TARGET_CPU_CPP_BUILTINS} this macro obsoletes the
+@code{CPP_PREDEFINES} target macro.
 
 @findex CPP_PREDEFINES
 @item CPP_PREDEFINES
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 3e5a430a3640..1f8fb15dda16 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -694,7 +694,7 @@ static const char *cpp_options =
  %{fshow-column} %{fno-show-column}\
  %{fsigned-char&funsigned-char}\
  %{fleading-underscore} %{fno-leading-underscore}\
- %{fno-operator-names} %{ftabstop=*}";
+ %{fno-operator-names} %{ftabstop=*} %{undef}";
 
 /* NB: This is shared amongst all front-ends.  */
 static const char *cc1_options =
-- 
GitLab