[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 d429cd2..5d2df1d 100644 (file)
@@ -1,6 +1,15 @@
 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>
+
        * config/nds32/nds32-memory-manipulation.c (nds32_expand_strlen): New
        function.
        * config/nds32/nds32-multiple.md (strlensi): New pattern.
index e1522f9..fe2509b 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 085a7b8..f1e64cd 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"
@@ -2751,6 +2752,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.  */
 
 void
index 1c812f7..6846aef 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.  */