]>
git.ipfire.org Git - thirdparty/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"
28 #include "diagnostic-core.h"
29 #include "c-family/c-pragma.h"
31 #include "hard-reg-set.h"
32 #include "output.h" /* for decode_reg_name */
33 #include "mep-protos.h"
35 #define MAX_RECOG_OPERANDS 10
39 enum cw_which
{ CW_AVAILABLE
, CW_CALL_SAVED
};
41 /* This is normally provided by rtl.h but we can't include that file
42 here. It's safe to copy the definition here because we're only
43 using it internally; the value isn't passed to functions outside
45 #ifndef INVALID_REGNUM
46 #define INVALID_REGNUM (~(unsigned int) 0)
50 mep_pragma_lex (tree
*valp
)
52 enum cpp_ttype t
= pragma_lex (valp
);
59 mep_pragma_io_volatile (cpp_reader
*reader ATTRIBUTE_UNUSED
)
66 type
= mep_pragma_lex (&val
);
69 str
= IDENTIFIER_POINTER (val
);
71 type
= mep_pragma_lex (&val
);
72 if (type
!= CPP_PRAGMA_EOL
)
73 warning (0, "junk at end of #pragma io_volatile");
75 if (strcmp (str
, "on") == 0)
77 target_flags
|= MASK_IO_VOLATILE
;
80 if (strcmp (str
, "off") == 0)
82 target_flags
&= ~ MASK_IO_VOLATILE
;
87 error ("#pragma io_volatile takes only on or off");
91 parse_cr_reg (const char * str
)
95 regno
= decode_reg_name (str
);
96 if (regno
>= FIRST_PSEUDO_REGISTER
)
97 return INVALID_REGNUM
;
99 /* Verify that the regno is in CR_REGS. */
100 if (! TEST_HARD_REG_BIT (reg_class_contents
[CR_REGS
], regno
))
101 return INVALID_REGNUM
;
106 parse_cr_set (HARD_REG_SET
* set
)
110 unsigned int last_regno
= INVALID_REGNUM
;
111 bool do_range
= false;
113 CLEAR_HARD_REG_SET (*set
);
115 while ((type
= mep_pragma_lex (&val
)) != CPP_PRAGMA_EOL
)
117 if (type
== CPP_COMMA
)
119 last_regno
= INVALID_REGNUM
;
122 else if (type
== CPP_ELLIPSIS
)
124 if (last_regno
== INVALID_REGNUM
)
126 error ("invalid coprocessor register range");
131 else if (type
== CPP_NAME
|| type
== CPP_STRING
)
134 unsigned int regno
, i
;
136 if (TREE_CODE (val
) == IDENTIFIER_NODE
)
137 str
= IDENTIFIER_POINTER (val
);
138 else if (TREE_CODE (val
) == STRING_CST
)
139 str
= TREE_STRING_POINTER (val
);
143 regno
= parse_cr_reg (str
);
144 if (regno
== INVALID_REGNUM
)
146 error ("invalid coprocessor register %qE", val
);
152 if (last_regno
> regno
)
153 i
= regno
, regno
= last_regno
;
159 last_regno
= i
= regno
;
163 SET_HARD_REG_BIT (*set
, i
);
169 error ("malformed coprocessor register");
177 mep_pragma_coprocessor_which (enum cw_which cw_which
)
181 /* Process the balance of the pragma and turn it into a hard reg set. */
182 if (! parse_cr_set (&set
))
185 /* Process the collected hard reg set. */
191 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
192 if (TEST_HARD_REG_BIT (set
, i
))
200 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
201 if (TEST_HARD_REG_BIT (set
, i
))
202 fixed_regs
[i
] = call_used_regs
[i
] = 0;
210 /* Fix up register class hierarchy. */
211 mep_save_register_info ();
216 init_dummy_function_start ();
218 expand_dummy_function_end ();
227 mep_pragma_coprocessor_width (void)
233 type
= mep_pragma_lex (&val
);
237 if (! tree_fits_uhwi_p (val
))
239 i
= tree_to_uhwi (val
);
240 /* This pragma no longer has any effect. */
243 target_flags
&= ~MASK_64BIT_CR_REGS
;
245 target_flags
|= MASK_64BIT_CR_REGS
;
248 targetm
.init_builtins ();
250 if (i
!= 32 && i
!= 64)
254 type
= mep_pragma_lex (&val
);
255 if (type
!= CPP_PRAGMA_EOL
)
256 warning (0, "junk at end of #pragma GCC coprocessor width");
263 error ("#pragma GCC coprocessor width takes only 32 or 64");
267 mep_pragma_coprocessor_subclass (void)
273 enum reg_class rclass
;
275 type
= mep_pragma_lex (&val
);
276 if (type
!= CPP_CHAR
)
278 class_letter
= tree_to_uhwi (val
);
279 switch (class_letter
)
294 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
297 if (reg_class_size
[rclass
] > 0)
299 error ("#pragma GCC coprocessor subclass '%c' already defined",
304 type
= mep_pragma_lex (&val
);
308 if (! parse_cr_set (&set
))
311 /* Fix up register class hierarchy. */
312 COPY_HARD_REG_SET (reg_class_contents
[rclass
], set
);
317 error ("malformed #pragma GCC coprocessor subclass");
321 mep_pragma_disinterrupt (cpp_reader
*reader ATTRIBUTE_UNUSED
)
329 type
= mep_pragma_lex (&val
);
330 if (type
== CPP_COMMA
)
332 if (type
!= CPP_NAME
)
334 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val
));
337 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
339 error ("malformed #pragma disinterrupt");
345 mep_pragma_coprocessor (cpp_reader
*reader ATTRIBUTE_UNUSED
)
350 type
= mep_pragma_lex (&val
);
351 if (type
!= CPP_NAME
)
353 error ("malformed #pragma GCC coprocessor");
358 error ("coprocessor not enabled");
360 if (strcmp (IDENTIFIER_POINTER (val
), "available") == 0)
361 mep_pragma_coprocessor_which (CW_AVAILABLE
);
362 else if (strcmp (IDENTIFIER_POINTER (val
), "call_saved") == 0)
363 mep_pragma_coprocessor_which (CW_CALL_SAVED
);
364 else if (strcmp (IDENTIFIER_POINTER (val
), "width") == 0)
365 mep_pragma_coprocessor_width ();
366 else if (strcmp (IDENTIFIER_POINTER (val
), "subclass") == 0)
367 mep_pragma_coprocessor_subclass ();
369 error ("unknown #pragma GCC coprocessor %E", val
);
373 mep_pragma_call (cpp_reader
*reader ATTRIBUTE_UNUSED
)
381 type
= mep_pragma_lex (&val
);
382 if (type
== CPP_COMMA
)
384 if (type
!= CPP_NAME
)
386 mep_note_pragma_call (IDENTIFIER_POINTER (val
));
389 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
391 error ("malformed #pragma call");
397 mep_register_pragmas (void)
399 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile
);
400 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor
);
401 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt
);
402 c_register_pragma (0, "call", mep_pragma_call
);