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