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)
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, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "coretypes.h"
34 #define streq(a,b) (strcmp (a, b) == 0)
37 static int pop_data_area PARAMS ((v850_data_area));
38 static int push_data_area PARAMS ((v850_data_area));
39 static void mark_current_function_as_interrupt PARAMS ((void));
41 /* Push a data area onto the stack. */
44 push_data_area (data_area)
45 v850_data_area data_area;
47 data_area_stack_element * elem;
49 elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
54 elem->prev = data_area_stack;
55 elem->data_area = data_area;
57 data_area_stack = elem;
62 /* Remove a data area from the stack. */
65 pop_data_area (data_area)
66 v850_data_area data_area;
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");
74 data_area_stack_element * elem;
76 elem = data_area_stack;
77 data_area_stack = data_area_stack->prev;
87 /* Set the machine specific 'interrupt' attribute on the current function. */
90 mark_current_function_as_interrupt ()
94 if (current_function_decl == NULL_TREE)
96 warning ("cannot set interrupt attribute: no current function");
100 name = get_identifier ("interrupt");
102 if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
104 warning ("cannot set interrupt attribute: no such identifier");
108 decl_attributes (¤t_function_decl,
109 tree_cons (name, NULL_TREE, NULL_TREE), 0);
113 /* Support for GHS pragmata. */
116 ghs_pragma_section (pfile)
117 cpp_reader *pfile ATTRIBUTE_UNUSED;
121 /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
126 const char *sect, *alias;
127 enum GHS_section_kind kind;
131 if (type == CPP_EOF && !repeat)
133 else if (type == CPP_NAME)
134 sect = IDENTIFIER_POINTER (x);
139 if (c_lex (&x) != CPP_EQ)
141 if (c_lex (&x) != CPP_NAME)
144 alias = IDENTIFIER_POINTER (x);
147 if (type == CPP_COMMA)
149 else if (type != CPP_EOF)
150 warning ("junk at end of #pragma ghs section");
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
163 else if (streq (sect, "bss")) kind = GHS_SECTION_KIND_BSS;
164 else if (streq (sect, "zbss")) kind = GHS_SECTION_KIND_ZDATA;
167 warning ("unrecognized section name \"%s\"", sect);
171 if (streq (alias, "default"))
172 GHS_current_section_names [kind] = NULL;
174 GHS_current_section_names [kind] =
175 build_string (strlen (alias) + 1, alias);
182 warning ("malformed #pragma ghs section");
186 /* #pragma ghs section \n: Reset all section names back to their defaults. */
190 for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
191 GHS_current_section_names [i] = NULL;
196 ghs_pragma_interrupt (pfile)
197 cpp_reader *pfile ATTRIBUTE_UNUSED;
201 if (c_lex (&x) != CPP_EOF)
202 warning ("junk at end of #pragma ghs interrupt");
204 mark_current_function_as_interrupt ();
208 ghs_pragma_starttda (pfile)
209 cpp_reader *pfile ATTRIBUTE_UNUSED;
213 if (c_lex (&x) != CPP_EOF)
214 warning ("junk at end of #pragma ghs starttda");
216 push_data_area (DATA_AREA_TDA);
220 ghs_pragma_startsda (pfile)
221 cpp_reader *pfile ATTRIBUTE_UNUSED;
225 if (c_lex (&x) != CPP_EOF)
226 warning ("junk at end of #pragma ghs startsda");
228 push_data_area (DATA_AREA_SDA);
232 ghs_pragma_startzda (pfile)
233 cpp_reader *pfile ATTRIBUTE_UNUSED;
237 if (c_lex (&x) != CPP_EOF)
238 warning ("junk at end of #pragma ghs startzda");
240 push_data_area (DATA_AREA_ZDA);
244 ghs_pragma_endtda (pfile)
245 cpp_reader *pfile ATTRIBUTE_UNUSED;
249 if (c_lex (&x) != CPP_EOF)
250 warning ("junk at end of #pragma ghs endtda");
252 pop_data_area (DATA_AREA_TDA);
256 ghs_pragma_endsda (pfile)
257 cpp_reader *pfile ATTRIBUTE_UNUSED;
261 if (c_lex (&x) != CPP_EOF)
262 warning ("junk at end of #pragma ghs endsda");
264 pop_data_area (DATA_AREA_SDA);
268 ghs_pragma_endzda (pfile)
269 cpp_reader *pfile ATTRIBUTE_UNUSED;
273 if (c_lex (&x) != CPP_EOF)
274 warning ("junk at end of #pragma ghs endzda");
276 pop_data_area (DATA_AREA_ZDA);