Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / config / sh / sh-c.c
index 2fdff54..4f3a41a 100644 (file)
@@ -1,6 +1,5 @@
 /* Pragma handling for GCC for Renesas / SuperH SH.
-   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1993-2013 Free Software Foundation, Inc.
    Contributed by Joern Rennecke <joern.rennecke@st.com>.
 
 This file is part of GCC.
@@ -25,6 +24,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "tree.h"
 #include "tm_p.h"
+#include "cpplib.h"
+#include "c-family/c-common.h"
+#include "target.h"
 
 /* Handle machine specific pragmas to be semi-compatible with Renesas
    compiler.  */
@@ -66,3 +68,79 @@ sh_pr_nosave_low_regs (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
 {
   sh_add_function_attribute ("nosave_low_regs");
 }
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+
+/* Implement the TARGET_CPU_CPP_BUILTINS macro  */
+void
+sh_cpu_cpp_builtins (cpp_reader* pfile)
+{
+  builtin_define ("__sh__");
+  builtin_assert ("cpu=sh");
+  builtin_assert ("machine=sh");
+  switch ((int) sh_cpu)
+    {
+    case PROCESSOR_SH1:
+      builtin_define ("__sh1__");
+      builtin_define ("__SH1__");
+      break;
+    case PROCESSOR_SH2:
+      builtin_define ("__sh2__");
+      builtin_define ("__SH2__");
+      break;
+    case PROCESSOR_SH2E:
+      builtin_define ("__SH2E__");
+      break;
+    case PROCESSOR_SH2A:
+      builtin_define ("__SH2A__");
+      if (TARGET_SH2A_DOUBLE)
+       builtin_define (TARGET_FPU_SINGLE
+                       ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__");
+      else
+       builtin_define (TARGET_FPU_ANY
+                       ? "__SH2A_SINGLE_ONLY__" : "__SH2A_NOFPU__");
+      break;
+    case PROCESSOR_SH3:
+      builtin_define ("__sh3__");
+      builtin_define ("__SH3__");
+      if (TARGET_HARD_SH4)
+       builtin_define ("__SH4_NOFPU__");
+      break;
+    case PROCESSOR_SH3E:
+      builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__");
+      break;
+    case PROCESSOR_SH4:
+      builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__");
+      break;
+    case PROCESSOR_SH4A: \
+      builtin_define ("__SH4A__");
+      builtin_define (TARGET_SH4
+                     ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__")
+                     : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__"
+                     : "__SH4_NOFPU__");
+      break;
+    case PROCESSOR_SH5:
+      {
+       builtin_define_with_value ("__SH5__",
+                                  TARGET_SHMEDIA64 ? "64" : "32", 0);
+       builtin_define_with_value ("__SHMEDIA__",
+                                  TARGET_SHMEDIA ? "1" : "0", 0);
+       if (! TARGET_FPU_DOUBLE)
+         builtin_define ("__SH4_NOFPU__");
+      }
+    }
+  if (TARGET_FPU_ANY)
+    builtin_define ("__SH_FPU_ANY__");
+  if (TARGET_FPU_DOUBLE)
+    builtin_define ("__SH_FPU_DOUBLE__");
+  if (TARGET_HITACHI)
+    builtin_define ("__HITACHI__");
+  if (TARGET_FMOVD)
+    builtin_define ("__FMOVD_ENABLED__");
+  builtin_define (TARGET_LITTLE_ENDIAN
+                 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__");
+
+  cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__",
+                       selected_atomic_model ().cdef_name);
+}