]>
Commit | Line | Data |
---|---|---|
e101acea | 1 | /* v850 specific, C compiler specific functions. |
d353bf18 | 2 | Copyright (C) 2000-2015 Free Software Foundation, Inc. |
e101acea | 3 | Contributed by Jeff Law (law@cygnus.com). |
4 | ||
b5b835e5 | 5 | This file is part of GCC. |
e101acea | 6 | |
b5b835e5 | 7 | GCC is free software; you can redistribute it and/or modify |
e101acea | 8 | it under the terms of the GNU General Public License as published by |
038d1e19 | 9 | the Free Software Foundation; either version 3, or (at your option) |
e101acea | 10 | any later version. |
11 | ||
b5b835e5 | 12 | GCC is distributed in the hope that it will be useful, |
e101acea | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
038d1e19 | 18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
e101acea | 20 | |
21 | #include "config.h" | |
22 | #include "system.h" | |
805e22b2 | 23 | #include "coretypes.h" |
24 | #include "tm.h" | |
e101acea | 25 | #include "cpplib.h" |
b20a8bb4 | 26 | #include "hash-set.h" |
b20a8bb4 | 27 | #include "vec.h" |
b20a8bb4 | 28 | #include "input.h" |
29 | #include "alias.h" | |
30 | #include "symtab.h" | |
b20a8bb4 | 31 | #include "inchash.h" |
e101acea | 32 | #include "tree.h" |
9ed99284 | 33 | #include "stringpool.h" |
34 | #include "attribs.h" | |
7bedc3a0 | 35 | #include "c-family/c-pragma.h" |
0b205f4c | 36 | #include "diagnostic-core.h" |
e101acea | 37 | #include "ggc.h" |
38 | #include "tm_p.h" | |
39 | ||
40 | #ifndef streq | |
41 | #define streq(a,b) (strcmp (a, b) == 0) | |
42 | #endif | |
43 | \f | |
39031315 | 44 | static int pop_data_area (v850_data_area); |
45 | static int push_data_area (v850_data_area); | |
46 | static void mark_current_function_as_interrupt (void); | |
e101acea | 47 | \f |
48 | /* Push a data area onto the stack. */ | |
49 | ||
50 | static int | |
39031315 | 51 | push_data_area (v850_data_area data_area) |
e101acea | 52 | { |
53 | data_area_stack_element * elem; | |
54 | ||
55 | elem = (data_area_stack_element *) xmalloc (sizeof (* elem)); | |
56 | ||
57 | if (elem == NULL) | |
58 | return 0; | |
59 | ||
60 | elem->prev = data_area_stack; | |
61 | elem->data_area = data_area; | |
62 | ||
63 | data_area_stack = elem; | |
64 | ||
65 | return 1; | |
66 | } | |
67 | ||
68 | /* Remove a data area from the stack. */ | |
69 | ||
70 | static int | |
39031315 | 71 | pop_data_area (v850_data_area data_area) |
e101acea | 72 | { |
73 | if (data_area_stack == NULL) | |
e8d0745d | 74 | warning (OPT_Wpragmas, "#pragma GHS endXXXX found without " |
75 | "previous startXXX"); | |
e101acea | 76 | else if (data_area != data_area_stack->data_area) |
e8d0745d | 77 | warning (OPT_Wpragmas, "#pragma GHS endXXX does not match " |
78 | "previous startXXX"); | |
e101acea | 79 | else |
80 | { | |
81 | data_area_stack_element * elem; | |
82 | ||
83 | elem = data_area_stack; | |
84 | data_area_stack = data_area_stack->prev; | |
85 | ||
86 | free (elem); | |
87 | ||
88 | return 1; | |
89 | } | |
90 | ||
91 | return 0; | |
92 | } | |
93 | ||
94 | /* Set the machine specific 'interrupt' attribute on the current function. */ | |
95 | ||
e3c541f0 | 96 | static void |
39031315 | 97 | mark_current_function_as_interrupt (void) |
e101acea | 98 | { |
99 | tree name; | |
100 | ||
101 | if (current_function_decl == NULL_TREE) | |
102 | { | |
c3ceba8e | 103 | warning (0, "cannot set interrupt attribute: no current function"); |
feb9af9f | 104 | return; |
e101acea | 105 | } |
106 | ||
107 | name = get_identifier ("interrupt"); | |
108 | ||
109 | if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE) | |
110 | { | |
c3ceba8e | 111 | warning (0, "cannot set interrupt attribute: no such identifier"); |
feb9af9f | 112 | return; |
e101acea | 113 | } |
114 | ||
e3c541f0 | 115 | decl_attributes (¤t_function_decl, |
116 | tree_cons (name, NULL_TREE, NULL_TREE), 0); | |
e101acea | 117 | } |
118 | ||
119 | \f | |
120 | /* Support for GHS pragmata. */ | |
121 | ||
122 | void | |
39031315 | 123 | ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 124 | { |
ef51d1e3 | 125 | int repeat = 0; |
e101acea | 126 | |
127 | /* #pragma ghs section [name = alias [, name = alias [, ...]]] */ | |
128 | do | |
129 | { | |
130 | tree x; | |
131 | enum cpp_ttype type; | |
67a779df | 132 | tree sect_ident; |
e101acea | 133 | const char *sect, *alias; |
134 | enum GHS_section_kind kind; | |
135 | ||
b5d533bb | 136 | type = pragma_lex (&x); |
e101acea | 137 | |
138 | if (type == CPP_EOF && !repeat) | |
139 | goto reset; | |
140 | else if (type == CPP_NAME) | |
67a779df | 141 | { |
142 | sect_ident = x; | |
143 | sect = IDENTIFIER_POINTER (sect_ident); | |
144 | } | |
e101acea | 145 | else |
146 | goto bad; | |
147 | repeat = 0; | |
148 | ||
b5d533bb | 149 | if (pragma_lex (&x) != CPP_EQ) |
e101acea | 150 | goto bad; |
b5d533bb | 151 | if (pragma_lex (&x) != CPP_NAME) |
e101acea | 152 | goto bad; |
153 | ||
154 | alias = IDENTIFIER_POINTER (x); | |
155 | ||
b5d533bb | 156 | type = pragma_lex (&x); |
e101acea | 157 | if (type == CPP_COMMA) |
158 | repeat = 1; | |
159 | else if (type != CPP_EOF) | |
e8d0745d | 160 | warning (OPT_Wpragmas, "junk at end of #pragma ghs section"); |
e101acea | 161 | |
162 | if (streq (sect, "data")) kind = GHS_SECTION_KIND_DATA; | |
163 | else if (streq (sect, "text")) kind = GHS_SECTION_KIND_TEXT; | |
164 | else if (streq (sect, "rodata")) kind = GHS_SECTION_KIND_RODATA; | |
165 | else if (streq (sect, "const")) kind = GHS_SECTION_KIND_RODATA; | |
166 | else if (streq (sect, "rosdata")) kind = GHS_SECTION_KIND_ROSDATA; | |
167 | else if (streq (sect, "rozdata")) kind = GHS_SECTION_KIND_ROZDATA; | |
168 | else if (streq (sect, "sdata")) kind = GHS_SECTION_KIND_SDATA; | |
169 | else if (streq (sect, "tdata")) kind = GHS_SECTION_KIND_TDATA; | |
170 | else if (streq (sect, "zdata")) kind = GHS_SECTION_KIND_ZDATA; | |
171 | /* According to GHS beta documentation, the following should not be | |
172 | allowed! */ | |
173 | else if (streq (sect, "bss")) kind = GHS_SECTION_KIND_BSS; | |
174 | else if (streq (sect, "zbss")) kind = GHS_SECTION_KIND_ZDATA; | |
175 | else | |
176 | { | |
67a779df | 177 | warning (0, "unrecognized section name %qE", sect_ident); |
e101acea | 178 | return; |
179 | } | |
180 | ||
181 | if (streq (alias, "default")) | |
182 | GHS_current_section_names [kind] = NULL; | |
183 | else | |
d88fa80d | 184 | GHS_current_section_names [kind] = alias; |
e101acea | 185 | } |
186 | while (repeat); | |
187 | ||
188 | return; | |
189 | ||
190 | bad: | |
e8d0745d | 191 | warning (OPT_Wpragmas, "malformed #pragma ghs section"); |
e101acea | 192 | return; |
193 | ||
194 | reset: | |
195 | /* #pragma ghs section \n: Reset all section names back to their defaults. */ | |
196 | { | |
197 | int i; | |
198 | ||
199 | for (i = COUNT_OF_GHS_SECTION_KINDS; i--;) | |
200 | GHS_current_section_names [i] = NULL; | |
201 | } | |
202 | } | |
203 | ||
204 | void | |
39031315 | 205 | ghs_pragma_interrupt (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 206 | { |
207 | tree x; | |
208 | ||
b5d533bb | 209 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 210 | warning (OPT_Wpragmas, "junk at end of #pragma ghs interrupt"); |
e101acea | 211 | |
212 | mark_current_function_as_interrupt (); | |
213 | } | |
214 | ||
215 | void | |
39031315 | 216 | ghs_pragma_starttda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 217 | { |
218 | tree x; | |
219 | ||
b5d533bb | 220 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 221 | warning (OPT_Wpragmas, "junk at end of #pragma ghs starttda"); |
e101acea | 222 | |
223 | push_data_area (DATA_AREA_TDA); | |
224 | } | |
225 | ||
226 | void | |
39031315 | 227 | ghs_pragma_startsda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 228 | { |
229 | tree x; | |
230 | ||
b5d533bb | 231 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 232 | warning (OPT_Wpragmas, "junk at end of #pragma ghs startsda"); |
e101acea | 233 | |
234 | push_data_area (DATA_AREA_SDA); | |
235 | } | |
236 | ||
237 | void | |
39031315 | 238 | ghs_pragma_startzda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 239 | { |
240 | tree x; | |
241 | ||
b5d533bb | 242 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 243 | warning (OPT_Wpragmas, "junk at end of #pragma ghs startzda"); |
e101acea | 244 | |
245 | push_data_area (DATA_AREA_ZDA); | |
246 | } | |
247 | ||
248 | void | |
39031315 | 249 | ghs_pragma_endtda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 250 | { |
251 | tree x; | |
252 | ||
b5d533bb | 253 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 254 | warning (OPT_Wpragmas, "junk at end of #pragma ghs endtda"); |
e101acea | 255 | |
256 | pop_data_area (DATA_AREA_TDA); | |
257 | } | |
258 | ||
259 | void | |
39031315 | 260 | ghs_pragma_endsda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 261 | { |
262 | tree x; | |
263 | ||
b5d533bb | 264 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 265 | warning (OPT_Wpragmas, "junk at end of #pragma ghs endsda"); |
e101acea | 266 | |
267 | pop_data_area (DATA_AREA_SDA); | |
268 | } | |
269 | ||
270 | void | |
39031315 | 271 | ghs_pragma_endzda (cpp_reader * pfile ATTRIBUTE_UNUSED) |
e101acea | 272 | { |
273 | tree x; | |
274 | ||
b5d533bb | 275 | if (pragma_lex (&x) != CPP_EOF) |
e8d0745d | 276 | warning (OPT_Wpragmas, "junk at end of #pragma ghs endzda"); |
e101acea | 277 | |
278 | pop_data_area (DATA_AREA_ZDA); | |
279 | } |