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