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