Dead
[official-gcc.git] / gomp-20050608-branch / gcc / config / v850 / v850-c.c
blob0dbeb2eb55018d350d07b169116aab25d03d8428
1 /* v850 specific, C compiler specific functions.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3 Contributed by Jeff Law (law@cygnus.com).
5 This file is part of GCC.
7 GCC 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.
12 GCC 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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tm.h"
26 #include "cpplib.h"
27 #include "tree.h"
28 #include "c-pragma.h"
29 #include "toplev.h"
30 #include "ggc.h"
31 #include "tm_p.h"
33 #ifndef streq
34 #define streq(a,b) (strcmp (a, b) == 0)
35 #endif
37 static int pop_data_area (v850_data_area);
38 static int push_data_area (v850_data_area);
39 static void mark_current_function_as_interrupt (void);
41 /* Push a data area onto the stack. */
43 static int
44 push_data_area (v850_data_area data_area)
46 data_area_stack_element * elem;
48 elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
50 if (elem == NULL)
51 return 0;
53 elem->prev = data_area_stack;
54 elem->data_area = data_area;
56 data_area_stack = elem;
58 return 1;
61 /* Remove a data area from the stack. */
63 static int
64 pop_data_area (v850_data_area data_area)
66 if (data_area_stack == NULL)
67 warning (OPT_Wpragmas, "#pragma GHS endXXXX found without "
68 "previous startXXX");
69 else if (data_area != data_area_stack->data_area)
70 warning (OPT_Wpragmas, "#pragma GHS endXXX does not match "
71 "previous startXXX");
72 else
74 data_area_stack_element * elem;
76 elem = data_area_stack;
77 data_area_stack = data_area_stack->prev;
79 free (elem);
81 return 1;
84 return 0;
87 /* Set the machine specific 'interrupt' attribute on the current function. */
89 static void
90 mark_current_function_as_interrupt (void)
92 tree name;
94 if (current_function_decl == NULL_TREE)
96 warning (0, "cannot set interrupt attribute: no current function");
97 return;
100 name = get_identifier ("interrupt");
102 if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
104 warning (0, "cannot set interrupt attribute: no such identifier");
105 return;
108 decl_attributes (&current_function_decl,
109 tree_cons (name, NULL_TREE, NULL_TREE), 0);
113 /* Support for GHS pragmata. */
115 void
116 ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED)
118 int repeat;
120 /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
123 tree x;
124 enum cpp_ttype type;
125 const char *sect, *alias;
126 enum GHS_section_kind kind;
128 type = pragma_lex (&x);
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;
138 if (pragma_lex (&x) != CPP_EQ)
139 goto bad;
140 if (pragma_lex (&x) != CPP_NAME)
141 goto bad;
143 alias = IDENTIFIER_POINTER (x);
145 type = pragma_lex (&x);
146 if (type == CPP_COMMA)
147 repeat = 1;
148 else if (type != CPP_EOF)
149 warning (OPT_Wpragmas, "junk at end of #pragma ghs section");
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
166 warning (0, "unrecognized section name \"%s\"", sect);
167 return;
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);
176 while (repeat);
178 return;
180 bad:
181 warning (OPT_Wpragmas, "malformed #pragma ghs section");
182 return;
184 reset:
185 /* #pragma ghs section \n: Reset all section names back to their defaults. */
187 int i;
189 for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
190 GHS_current_section_names [i] = NULL;
194 void
195 ghs_pragma_interrupt (cpp_reader * pfile ATTRIBUTE_UNUSED)
197 tree x;
199 if (pragma_lex (&x) != CPP_EOF)
200 warning (OPT_Wpragmas, "junk at end of #pragma ghs interrupt");
202 mark_current_function_as_interrupt ();
205 void
206 ghs_pragma_starttda (cpp_reader * pfile ATTRIBUTE_UNUSED)
208 tree x;
210 if (pragma_lex (&x) != CPP_EOF)
211 warning (OPT_Wpragmas, "junk at end of #pragma ghs starttda");
213 push_data_area (DATA_AREA_TDA);
216 void
217 ghs_pragma_startsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
219 tree x;
221 if (pragma_lex (&x) != CPP_EOF)
222 warning (OPT_Wpragmas, "junk at end of #pragma ghs startsda");
224 push_data_area (DATA_AREA_SDA);
227 void
228 ghs_pragma_startzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
230 tree x;
232 if (pragma_lex (&x) != CPP_EOF)
233 warning (OPT_Wpragmas, "junk at end of #pragma ghs startzda");
235 push_data_area (DATA_AREA_ZDA);
238 void
239 ghs_pragma_endtda (cpp_reader * pfile ATTRIBUTE_UNUSED)
241 tree x;
243 if (pragma_lex (&x) != CPP_EOF)
244 warning (OPT_Wpragmas, "junk at end of #pragma ghs endtda");
246 pop_data_area (DATA_AREA_TDA);
249 void
250 ghs_pragma_endsda (cpp_reader * pfile ATTRIBUTE_UNUSED)
252 tree x;
254 if (pragma_lex (&x) != CPP_EOF)
255 warning (OPT_Wpragmas, "junk at end of #pragma ghs endsda");
257 pop_data_area (DATA_AREA_SDA);
260 void
261 ghs_pragma_endzda (cpp_reader * pfile ATTRIBUTE_UNUSED)
263 tree x;
265 if (pragma_lex (&x) != CPP_EOF)
266 warning (OPT_Wpragmas, "junk at end of #pragma ghs endzda");
268 pop_data_area (DATA_AREA_ZDA);