[ARC] New CPU C-define handler.
authorClaudiu Zissulescu <claziss@synopsys.com>
Wed, 28 Sep 2016 14:25:21 +0000 (16:25 +0200)
committerClaudiu Zissulescu <claziss@gcc.gnu.org>
Wed, 28 Sep 2016 14:25:21 +0000 (16:25 +0200)
gcc/
2016-09-29  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc-c.c: New file.
* config/arc/arc-c.def: Likewise.
* config/arc/t-arc: Likewise.
* config.gcc: Include arc-c.o as c and cpp object.
* config/arc/arc-protos.h (arc_cpu_cpp_builtins): Add prototype.
* config/arc/arc.h (TARGET_CPU_CPP_BUILTINS): Use
arc_cpu_cpp_builtins.

From-SVN: r240577

gcc/ChangeLog
gcc/config.gcc
gcc/config/arc/arc-c.c [new file with mode: 0644]
gcc/config/arc/arc-c.def [new file with mode: 0644]
gcc/config/arc/arc-protos.h
gcc/config/arc/arc.h
gcc/config/arc/t-arc [new file with mode: 0644]

index 51afcec073755d3aaecc2a0d8416b5ecdab97af1..f69a301d049bdc485461f1b7aff012d07057b5b0 100644 (file)
@@ -1,3 +1,13 @@
+2016-09-29  Claudiu Zissulescu  <claziss@synopsys.com>
+
+       * config/arc/arc-c.c: New file.
+       * config/arc/arc-c.def: Likewise.
+       * config/arc/t-arc: Likewise.
+       * config.gcc: Include arc-c.o as c and cpp object.
+       * config/arc/arc-protos.h (arc_cpu_cpp_builtins): Add prototype.
+       * config/arc/arc.h (TARGET_CPU_CPP_BUILTINS): Use
+       arc_cpu_cpp_builtins.
+
 2016-09-29  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.md (*rotrsi3_cnt1): New pattern.
index 5a9c50c020800c9ceb9d490bb844177aa1ac9869..7d24561ce4f67e13284ae00684e002ccd0b03167 100644 (file)
@@ -316,6 +316,8 @@ am33_2.0-*-linux*)
        ;;
 arc*-*-*)
        cpu_type=arc
+       c_target_objs="arc-c.o"
+       cxx_target_objs="arc-c.o"
        ;;
 arm*-*-*)
        cpu_type=arm
diff --git a/gcc/config/arc/arc-c.c b/gcc/config/arc/arc-c.c
new file mode 100644 (file)
index 0000000..3bf3fd2
--- /dev/null
@@ -0,0 +1,69 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "tm_p.h"
+#include "cpplib.h"
+#include "c-family/c-common.h"
+#include "target.h"
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+
+/* Define or undefine macros based on the current target.  */
+
+static void
+def_or_undef_macro (cpp_reader* pfile, const char *name, bool def_p)
+{
+  if (def_p)
+    cpp_define (pfile, name);
+  else
+    cpp_undef (pfile, name);
+}
+
+/* Helper for TARGET_CPU_CPP_BUILTINS hook.  */
+
+void
+arc_cpu_cpp_builtins (cpp_reader * pfile)
+{
+  builtin_assert ("cpu=arc");
+  builtin_assert ("machine=arc");
+
+  builtin_define ("__arc__");
+
+#undef ARC_C_DEF
+#define ARC_C_DEF(NAME, CONDITION)             \
+  def_or_undef_macro (pfile, NAME, CONDITION);
+
+#include "arc-c.def"
+#undef ARC_C_DEF
+
+  builtin_define_with_int_value ("__ARC_TLS_REGNO__",
+                                arc_tp_regno);
+
+  builtin_define (TARGET_BIG_ENDIAN
+                 ? "__BIG_ENDIAN__" : "__LITTLE_ENDIAN__");
+  if (TARGET_BIG_ENDIAN)
+    builtin_define ("__big_endian__");
+
+}
diff --git a/gcc/config/arc/arc-c.def b/gcc/config/arc/arc-c.def
new file mode 100644 (file)
index 0000000..065e973
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (C) 2016 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.
+*/
+
+ARC_C_DEF ("__ARC600__",       TARGET_ARC600)
+ARC_C_DEF ("__ARC601__",       TARGET_ARC601)
+ARC_C_DEF ("__ARC700__",       TARGET_ARC700)
+ARC_C_DEF ("__ARCEM__",                TARGET_EM)
+ARC_C_DEF ("__ARCHS__",                TARGET_HS)
+ARC_C_DEF ("__ARC_ATOMIC__",   TARGET_ATOMIC)
+ARC_C_DEF ("__ARC_NORM__",     TARGET_NORM)
+ARC_C_DEF ("__ARC_MUL64__",    TARGET_MUL64_SET)
+ARC_C_DEF ("__ARC_MUL32BY16__", TARGET_MULMAC_32BY16_SET)
+ARC_C_DEF ("__ARC_SIMD__",     TARGET_SIMD_SET)
+
+ARC_C_DEF ("__ARC_BARREL_SHIFTER__", TARGET_BARREL_SHIFTER)
+
+ARC_C_DEF ("__ARC_LL64__",   TARGET_LL64)
+ARC_C_DEF ("__ARC_MPY__",    TARGET_MPY)
+ARC_C_DEF ("__ARC_SWAP__",   TARGET_SWAP)
+ARC_C_DEF ("__ARC_EA__",     TARGET_EA_SET)
+ARC_C_DEF ("__ARC_FPX_SP__", (TARGET_SPFP_FAST_SET || TARGET_SPFP_COMPACT_SET))
+ARC_C_DEF ("__ARC_FPX_DP__", (TARGET_DPFP_FAST_SET || TARGET_DPFP_COMPACT_SET))
+ARC_C_DEF ("__ARC_MULT32__", TARGET_MUL64_SET)
+ARC_C_DEF ("__ARC_DIVREM__", TARGET_DIVREM)
+
+ARC_C_DEF ("__ARC_CODE_DENSITY__", TARGET_CODE_DENSITY)
+
+ARC_C_DEF ("__ARC_MPY_WLHX__",   (arc_mpy_option >= 2))
+ARC_C_DEF ("__ARC_MPY_WLH1__",   (arc_mpy_option == 2))
+ARC_C_DEF ("__ARC_MPY_WLH2__",   (arc_mpy_option == 3))
+ARC_C_DEF ("__ARC_MPY_WLH3__",   (arc_mpy_option == 4))
+ARC_C_DEF ("__ARC_MPY_WLH4__",   (arc_mpy_option == 5))
+ARC_C_DEF ("__ARC_MPY_WLH5__",   (arc_mpy_option == 6))
+ARC_C_DEF ("__ARC_MPY_DMPY__",   (arc_mpy_option == 7))
+ARC_C_DEF ("__ARC_MPY_MACD__",   (arc_mpy_option == 8))
+ARC_C_DEF ("__ARC_MPY_QMACW__",  (arc_mpy_option == 9))
+
+ARC_C_DEF ("__ARC_FPU_SP__",     TARGET_FP_SP_BASE)
+ARC_C_DEF ("__ARC_FPU_DP__",     TARGET_FP_DP_BASE)
+ARC_C_DEF ("__ARC_FPU_SP_DIV__", TARGET_FP_SP_SQRT)
+ARC_C_DEF ("__ARC_FPU_DP_DIV__", TARGET_FP_DP_SQRT)
+ARC_C_DEF ("__ARC_FPU_SP_FMA__", TARGET_FP_SP_FUSED)
+ARC_C_DEF ("__ARC_FPU_DP_FMA__", TARGET_FP_DP_FUSED)
+ARC_C_DEF ("__ARC_FPU_ASSIST__", TARGET_FP_DP_AX)
+
+/* To be deprecated.  */
+ARC_C_DEF ("__A6__",     TARGET_ARC600)
+ARC_C_DEF ("__A7__",     TARGET_ARC700)
+ARC_C_DEF ("__EM__",     TARGET_EM)
+ARC_C_DEF ("__HS__",     TARGET_HS)
+ARC_C_DEF ("__Xnorm",    TARGET_NORM)
+ARC_C_DEF ("__Xbarrel_shifter", TARGET_BARREL_SHIFTER)
index 73aacbc72bd9e6a13da7d36fe23159a4f4ce728b..ad5d4d347ec5e6f8a9c5e7d6990c2746d3cc9c0e 100644 (file)
@@ -123,3 +123,4 @@ extern int arc_return_slot_offset (void);
 extern bool arc_legitimize_reload_address (rtx *, machine_mode, int, int);
 extern void arc_secondary_reload_conv (rtx, rtx, rtx, bool);
 extern bool insn_is_tls_gd_dispatch (rtx_insn *);
+extern void arc_cpu_cpp_builtins (cpp_reader *);
index f6b85ea7e51b19501c044b338a17b0d4cf8a03a5..c02e1cd4c77703bcf5f81a8273c86e87885e8845 100644 (file)
@@ -64,61 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 #undef CC1_SPEC
 
 /* Names to predefine in the preprocessor for this target machine.  */
-#define TARGET_CPU_CPP_BUILTINS()      \
- do {                                  \
-    builtin_define ("__arc__");                \
-    if (TARGET_ARC600)                 \
-      {                                        \
-       builtin_define ("__A6__");      \
-       builtin_define ("__ARC600__");  \
-      }                                        \
-    else if (TARGET_ARC601)                    \
-      {                                        \
-       builtin_define ("__ARC601__");  \
-      }                                        \
-    else if (TARGET_ARC700)                    \
-      {                                        \
-       builtin_define ("__A7__");      \
-       builtin_define ("__ARC700__");  \
-      }                                        \
-    else if (TARGET_EM)                        \
-      {                                        \
-       builtin_define ("__EM__");      \
-      }                                        \
-    else if (TARGET_HS)                        \
-      {                                        \
-       builtin_define ("__HS__");      \
-      }                                        \
-    if (TARGET_ATOMIC)                 \
-      {                                        \
-       builtin_define ("__ARC_ATOMIC__");      \
-      }                                        \
-    if (TARGET_NORM)                   \
-      {                                        \
-       builtin_define ("__ARC_NORM__");\
-       builtin_define ("__Xnorm");     \
-      }                                        \
-    if (TARGET_LL64)                   \
-      {                                        \
-       builtin_define ("__ARC_LL64__");\
-      }                                        \
-    if (TARGET_MUL64_SET)              \
-      builtin_define ("__ARC_MUL64__");\
-    if (TARGET_MULMAC_32BY16_SET)      \
-      builtin_define ("__ARC_MUL32BY16__");\
-    if (TARGET_SIMD_SET)               \
-      builtin_define ("__ARC_SIMD__"); \
-    if (TARGET_BARREL_SHIFTER)         \
-      builtin_define ("__Xbarrel_shifter");\
-    builtin_define_with_int_value ("__ARC_TLS_REGNO__", \
-                                  arc_tp_regno);       \
-    builtin_assert ("cpu=arc");                \
-    builtin_assert ("machine=arc");    \
-    builtin_define (TARGET_BIG_ENDIAN  \
-                   ? "__BIG_ENDIAN__" : "__LITTLE_ENDIAN__"); \
-    if (TARGET_BIG_ENDIAN)             \
-      builtin_define ("__big_endian__"); \
-} while(0)
+#define TARGET_CPU_CPP_BUILTINS() arc_cpu_cpp_builtins (pfile)
 
 #if DEFAULT_LIBC == LIBC_UCLIBC
 
diff --git a/gcc/config/arc/t-arc b/gcc/config/arc/t-arc
new file mode 100644 (file)
index 0000000..4252e73
--- /dev/null
@@ -0,0 +1,29 @@
+# GCC Makefile fragment for Synopsys DesignWare ARC.
+#
+# Copyright (C) 2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along
+# with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+TM_H += $(srcdir)/config/arc/arc-c.def
+
+arc-c.o: $(srcdir)/config/arc/arc-c.c $(CONFIG_H) $(SYSTEM_H) \
+$(TREE_H) $(TM_H) $(TM_P_H) coretypes.h
+       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+               $(srcdir)/config/arc/arc-c.c
+
+# Local Variables:
+# mode: Makefile
+# End: