]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sh/sh-c.c
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / gcc / config / sh / sh-c.c
1 /* Pragma handling for GCC for Renesas / SuperH SH.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 2003, 2004, 2005, 2006, 2007, 2012 Free Software Foundation, Inc.
4 Contributed by Joern Rennecke <joern.rennecke@st.com>.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
21
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "tm_p.h"
28 #include "cpplib.h"
29 #include "c-family/c-common.h"
30 #include "target.h"
31
32 /* Handle machine specific pragmas to be semi-compatible with Renesas
33 compiler. */
34
35 /* Add ATTR to the attributes of the current function. If there is no
36 such function, save it to be added to the attributes of the next
37 function. */
38 static void
39 sh_add_function_attribute (const char *attr)
40 {
41 tree id = get_identifier (attr);
42
43 if (current_function_decl)
44 decl_attributes (&current_function_decl,
45 tree_cons (id, NULL_TREE, NULL_TREE), 0);
46 else
47 {
48 *sh_deferred_function_attributes_tail
49 = tree_cons (id, NULL_TREE, *sh_deferred_function_attributes_tail);
50 sh_deferred_function_attributes_tail
51 = &TREE_CHAIN (*sh_deferred_function_attributes_tail);
52 }
53 }
54
55 void
56 sh_pr_interrupt (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
57 {
58 sh_add_function_attribute ("interrupt_handler");
59 }
60
61 void
62 sh_pr_trapa (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
63 {
64 sh_add_function_attribute ("trapa_handler");
65 }
66
67 void
68 sh_pr_nosave_low_regs (struct cpp_reader *pfile ATTRIBUTE_UNUSED)
69 {
70 sh_add_function_attribute ("nosave_low_regs");
71 }
72
73 #define builtin_define(TXT) cpp_define (pfile, TXT)
74 #define builtin_assert(TXT) cpp_assert (pfile, TXT)
75
76 /* Implement the TARGET_CPU_CPP_BUILTINS macro */
77 void
78 sh_cpu_cpp_builtins (cpp_reader* pfile)
79 {
80 builtin_define ("__sh__");
81 builtin_assert ("cpu=sh");
82 builtin_assert ("machine=sh");
83 switch ((int) sh_cpu)
84 {
85 case PROCESSOR_SH1:
86 builtin_define ("__sh1__");
87 builtin_define ("__SH1__");
88 break;
89 case PROCESSOR_SH2:
90 builtin_define ("__sh2__");
91 builtin_define ("__SH2__");
92 break;
93 case PROCESSOR_SH2E:
94 builtin_define ("__SH2E__");
95 break;
96 case PROCESSOR_SH2A:
97 builtin_define ("__SH2A__");
98 if (TARGET_SH2A_DOUBLE)
99 builtin_define (TARGET_FPU_SINGLE
100 ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__");
101 else
102 builtin_define (TARGET_FPU_ANY
103 ? "__SH2A_SINGLE_ONLY__" : "__SH2A_NOFPU__");
104 break;
105 case PROCESSOR_SH3:
106 builtin_define ("__sh3__");
107 builtin_define ("__SH3__");
108 if (TARGET_HARD_SH4)
109 builtin_define ("__SH4_NOFPU__");
110 break;
111 case PROCESSOR_SH3E:
112 builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__");
113 break;
114 case PROCESSOR_SH4:
115 builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__");
116 break;
117 case PROCESSOR_SH4A: \
118 builtin_define ("__SH4A__");
119 builtin_define (TARGET_SH4
120 ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__")
121 : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__"
122 : "__SH4_NOFPU__");
123 break;
124 case PROCESSOR_SH5:
125 {
126 builtin_define_with_value ("__SH5__",
127 TARGET_SHMEDIA64 ? "64" : "32", 0);
128 builtin_define_with_value ("__SHMEDIA__",
129 TARGET_SHMEDIA ? "1" : "0", 0);
130 if (! TARGET_FPU_DOUBLE)
131 builtin_define ("__SH4_NOFPU__");
132 }
133 }
134 if (TARGET_FPU_ANY)
135 builtin_define ("__SH_FPU_ANY__");
136 if (TARGET_FPU_DOUBLE)
137 builtin_define ("__SH_FPU_DOUBLE__");
138 if (TARGET_HITACHI)
139 builtin_define ("__HITACHI__");
140 if (TARGET_FMOVD)
141 builtin_define ("__FMOVD_ENABLED__");
142 builtin_define (TARGET_LITTLE_ENDIAN
143 ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__");
144
145 cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__",
146 selected_atomic_model ().cdef_name);
147 }