]>
gcc.gnu.org Git - gcc.git/blob - gcc/config/mep/mep-pragma.c
1 /* Definitions of Toshiba Media Processor
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 Contributed by Red Hat, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 #include "diagnostic-core.h"
27 #include "c-family/c-pragma.h"
29 #include "hard-reg-set.h"
30 #include "output.h" /* for decode_reg_name */
31 #include "mep-protos.h"
38 #define MAX_RECOG_OPERANDS 10
42 enum cw_which
{ CW_AVAILABLE
, CW_CALL_SAVED
};
44 /* This is normally provided by rtl.h but we can't include that file
45 here. It's safe to copy the definition here because we're only
46 using it internally; the value isn't passed to functions outside
48 #ifndef INVALID_REGNUM
49 #define INVALID_REGNUM (~(unsigned int) 0)
53 mep_pragma_lex (tree
*valp
)
55 enum cpp_ttype t
= pragma_lex (valp
);
62 mep_pragma_io_volatile (cpp_reader
*reader ATTRIBUTE_UNUSED
)
69 type
= mep_pragma_lex (&val
);
72 str
= IDENTIFIER_POINTER (val
);
74 type
= mep_pragma_lex (&val
);
75 if (type
!= CPP_PRAGMA_EOL
)
76 warning (0, "junk at end of #pragma io_volatile");
78 if (strcmp (str
, "on") == 0)
80 target_flags
|= MASK_IO_VOLATILE
;
83 if (strcmp (str
, "off") == 0)
85 target_flags
&= ~ MASK_IO_VOLATILE
;
90 error ("#pragma io_volatile takes only on or off");
94 parse_cr_reg (const char * str
)
98 regno
= decode_reg_name (str
);
99 if (regno
>= FIRST_PSEUDO_REGISTER
)
100 return INVALID_REGNUM
;
102 /* Verify that the regno is in CR_REGS. */
103 if (! TEST_HARD_REG_BIT (reg_class_contents
[CR_REGS
], regno
))
104 return INVALID_REGNUM
;
109 parse_cr_set (HARD_REG_SET
* set
)
113 unsigned int last_regno
= INVALID_REGNUM
;
114 bool do_range
= false;
116 CLEAR_HARD_REG_SET (*set
);
118 while ((type
= mep_pragma_lex (&val
)) != CPP_PRAGMA_EOL
)
120 if (type
== CPP_COMMA
)
122 last_regno
= INVALID_REGNUM
;
125 else if (type
== CPP_ELLIPSIS
)
127 if (last_regno
== INVALID_REGNUM
)
129 error ("invalid coprocessor register range");
134 else if (type
== CPP_NAME
|| type
== CPP_STRING
)
137 unsigned int regno
, i
;
139 if (TREE_CODE (val
) == IDENTIFIER_NODE
)
140 str
= IDENTIFIER_POINTER (val
);
141 else if (TREE_CODE (val
) == STRING_CST
)
142 str
= TREE_STRING_POINTER (val
);
146 regno
= parse_cr_reg (str
);
147 if (regno
== INVALID_REGNUM
)
149 error ("invalid coprocessor register %qE", val
);
155 if (last_regno
> regno
)
156 i
= regno
, regno
= last_regno
;
162 last_regno
= i
= regno
;
166 SET_HARD_REG_BIT (*set
, i
);
172 error ("malformed coprocessor register");
180 mep_pragma_coprocessor_which (enum cw_which cw_which
)
184 /* Process the balance of the pragma and turn it into a hard reg set. */
185 if (! parse_cr_set (&set
))
188 /* Process the collected hard reg set. */
194 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
195 if (TEST_HARD_REG_BIT (set
, i
))
203 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
204 if (TEST_HARD_REG_BIT (set
, i
))
205 fixed_regs
[i
] = call_used_regs
[i
] = 0;
213 /* Fix up register class hierarchy. */
214 mep_save_register_info ();
219 init_dummy_function_start ();
221 expand_dummy_function_end ();
230 mep_pragma_coprocessor_width (void)
236 type
= mep_pragma_lex (&val
);
240 if (! tree_fits_uhwi_p (val
))
242 i
= tree_to_uhwi (val
);
243 /* This pragma no longer has any effect. */
246 target_flags
&= ~MASK_64BIT_CR_REGS
;
248 target_flags
|= MASK_64BIT_CR_REGS
;
251 targetm
.init_builtins ();
253 if (i
!= 32 && i
!= 64)
257 type
= mep_pragma_lex (&val
);
258 if (type
!= CPP_PRAGMA_EOL
)
259 warning (0, "junk at end of #pragma GCC coprocessor width");
266 error ("#pragma GCC coprocessor width takes only 32 or 64");
270 mep_pragma_coprocessor_subclass (void)
276 enum reg_class rclass
;
278 type
= mep_pragma_lex (&val
);
279 if (type
!= CPP_CHAR
)
281 class_letter
= tree_to_uhwi (val
);
282 switch (class_letter
)
297 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
300 if (reg_class_size
[rclass
] > 0)
302 error ("#pragma GCC coprocessor subclass '%c' already defined",
307 type
= mep_pragma_lex (&val
);
311 if (! parse_cr_set (&set
))
314 /* Fix up register class hierarchy. */
315 COPY_HARD_REG_SET (reg_class_contents
[rclass
], set
);
320 error ("malformed #pragma GCC coprocessor subclass");
324 mep_pragma_disinterrupt (cpp_reader
*reader ATTRIBUTE_UNUSED
)
332 type
= mep_pragma_lex (&val
);
333 if (type
== CPP_COMMA
)
335 if (type
!= CPP_NAME
)
337 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val
));
340 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
342 error ("malformed #pragma disinterrupt");
348 mep_pragma_coprocessor (cpp_reader
*reader ATTRIBUTE_UNUSED
)
353 type
= mep_pragma_lex (&val
);
354 if (type
!= CPP_NAME
)
356 error ("malformed #pragma GCC coprocessor");
361 error ("coprocessor not enabled");
363 if (strcmp (IDENTIFIER_POINTER (val
), "available") == 0)
364 mep_pragma_coprocessor_which (CW_AVAILABLE
);
365 else if (strcmp (IDENTIFIER_POINTER (val
), "call_saved") == 0)
366 mep_pragma_coprocessor_which (CW_CALL_SAVED
);
367 else if (strcmp (IDENTIFIER_POINTER (val
), "width") == 0)
368 mep_pragma_coprocessor_width ();
369 else if (strcmp (IDENTIFIER_POINTER (val
), "subclass") == 0)
370 mep_pragma_coprocessor_subclass ();
372 error ("unknown #pragma GCC coprocessor %E", val
);
376 mep_pragma_call (cpp_reader
*reader ATTRIBUTE_UNUSED
)
384 type
= mep_pragma_lex (&val
);
385 if (type
== CPP_COMMA
)
387 if (type
!= CPP_NAME
)
389 mep_note_pragma_call (IDENTIFIER_POINTER (val
));
392 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
394 error ("malformed #pragma call");
400 mep_register_pragmas (void)
402 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile
);
403 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor
);
404 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt
);
405 c_register_pragma (0, "call", mep_pragma_call
);
This page took 0.055185 seconds and 5 git commands to generate.