[NDS32] Add new function nds32_cpu_cpp_builtins and use it for TARGET_CPU_CPP_BUILTINS.
authorKito Cheng <kito.cheng@gmail.com>
Sun, 11 Mar 2018 08:42:30 +0000 (08:42 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Sun, 11 Mar 2018 08:42:30 +0000 (08:42 +0000)
gcc/
* config/nds32/nds32-protos.h (nds32_cpu_cpp_builtins): Declare
function.
* config/nds32/nds32.c (nds32_cpu_cpp_builtins): New function.
* config/nds32/nds32.h (TARGET_CPU_CPP_BUILTINS): Modify its
definition.

Co-Authored-By: Chung-Ju Wu <jasonwucj@gmail.com>
From-SVN: r258426

gcc/ChangeLog
gcc/config/nds32/nds32-protos.h
gcc/config/nds32/nds32.c
gcc/config/nds32/nds32.h

index d429cd2883f836fe8d0abadd956748fb5ff989ea..5d2df1d215c0093572e4a5d1ce2874b23884583d 100644 (file)
@@ -1,3 +1,12 @@
+2018-03-11  Kito Cheng  <kito.cheng@gmail.com>
+           Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32-protos.h (nds32_cpu_cpp_builtins): Declare
+       function.
+       * config/nds32/nds32.c (nds32_cpu_cpp_builtins): New function.
+       * config/nds32/nds32.h (TARGET_CPU_CPP_BUILTINS): Modify its
+       definition.
+
 2018-03-11  Kito Cheng  <kito.cheng@gmail.com>
            Chung-Ju Wu  <jasonwucj@gmail.com>
 
index e1522f9e5f4cf624695856ed8ef3d98b7513eaa1..fe2509bbae3996bb0e6602bcc3855af65bb51972 100644 (file)
@@ -156,4 +156,7 @@ extern bool nds32_isr_function_p (tree);
 extern bool nds32_rtx_costs_impl (rtx, machine_mode, int, int, int *, bool);
 extern int nds32_address_cost_impl (rtx, machine_mode, addr_space_t, bool);
 
+/* Auxiliary functions for pre-define marco.  */
+extern void nds32_cpu_cpp_builtins(struct cpp_reader *);
+
 /* ------------------------------------------------------------------------ */
index 085a7b86ade0b88bfe848757980a93b33dd1fee4..f1e64cdc171f0bcaa9340963059f984b14fb75a8 100644 (file)
@@ -47,6 +47,7 @@
 #include "expr.h"
 #include "tm-constrs.h"
 #include "builtins.h"
+#include "cpplib.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -2750,6 +2751,53 @@ nds32_expand_builtin (tree exp,
 
 /* PART 4: Implemet extern function definitions,
            the prototype is in nds32-protos.h.  */
+\f
+/* Run-time Target Specification.  */
+
+void
+nds32_cpu_cpp_builtins(struct cpp_reader *pfile)
+{
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+  builtin_define ("__nds32__");
+  builtin_define ("__NDS32__");
+
+  if (TARGET_ISA_V2)
+    builtin_define ("__NDS32_ISA_V2__");
+  if (TARGET_ISA_V3)
+    builtin_define ("__NDS32_ISA_V3__");
+  if (TARGET_ISA_V3M)
+    builtin_define ("__NDS32_ISA_V3M__");
+
+  if (TARGET_BIG_ENDIAN)
+    builtin_define ("__NDS32_EB__");
+  else
+    builtin_define ("__NDS32_EL__");
+
+  if (TARGET_REDUCED_REGS)
+    builtin_define ("__NDS32_REDUCED_REGS__");
+  if (TARGET_CMOV)
+    builtin_define ("__NDS32_CMOV__");
+  if (TARGET_EXT_PERF)
+    builtin_define ("__NDS32_EXT_PERF__");
+  if (TARGET_EXT_PERF2)
+    builtin_define ("__NDS32_EXT_PERF2__");
+  if (TARGET_EXT_STRING)
+    builtin_define ("__NDS32_EXT_STRING__");
+  if (TARGET_16_BIT)
+    builtin_define ("__NDS32_16_BIT__");
+  if (TARGET_GP_DIRECT)
+    builtin_define ("__NDS32_GP_DIRECT__");
+
+  if (TARGET_BIG_ENDIAN)
+    builtin_define ("__big_endian__");
+
+  builtin_assert ("cpu=nds32");
+  builtin_assert ("machine=nds32");
+#undef builtin_define
+#undef builtin_assert
+}
+
 \f
 /* Defining Data Structures for Per-function Information.  */
 
index 1c812f77579fafbc7a2290fa6d4fc466c74624ca..6846aef5f16d207d734da7a007c7f70f00710545 100644 (file)
@@ -440,38 +440,8 @@ enum nds32_builtins
 \f
 /* Run-time Target Specification.  */
 
-#define TARGET_CPU_CPP_BUILTINS()                     \
-  do                                                  \
-    {                                                 \
-      builtin_define ("__nds32__");                   \
-                                                      \
-      if (TARGET_ISA_V2)                              \
-        builtin_define ("__NDS32_ISA_V2__");          \
-      if (TARGET_ISA_V3)                              \
-        builtin_define ("__NDS32_ISA_V3__");          \
-      if (TARGET_ISA_V3M)                             \
-        builtin_define ("__NDS32_ISA_V3M__");         \
-                                                      \
-      if (TARGET_BIG_ENDIAN)                          \
-        builtin_define ("__big_endian__");            \
-      if (TARGET_REDUCED_REGS)                        \
-        builtin_define ("__NDS32_REDUCED_REGS__");    \
-      if (TARGET_CMOV)                                \
-        builtin_define ("__NDS32_CMOV__");            \
-      if (TARGET_EXT_PERF)                            \
-        builtin_define ("__NDS32_EXT_PERF__");        \
-      if (TARGET_EXT_PERF2)                           \
-        builtin_define ("__NDS32_EXT_PERF2__");       \
-      if (TARGET_EXT_STRING)                          \
-        builtin_define ("__NDS32_EXT_STRING__");      \
-      if (TARGET_16_BIT)                              \
-        builtin_define ("__NDS32_16_BIT__");          \
-      if (TARGET_GP_DIRECT)                           \
-        builtin_define ("__NDS32_GP_DIRECT__");       \
-                                                      \
-      builtin_assert ("cpu=nds32");                   \
-      builtin_assert ("machine=nds32");               \
-    } while (0)
+#define TARGET_CPU_CPP_BUILTINS() \
+  nds32_cpu_cpp_builtins (pfile)
 
 \f
 /* Defining Data Structures for Per-function Information.  */