]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/mep/mep-pragma.c
7bda2973b11c9eee8bb54f56cc8a9ff51bb74dea
1 /* Definitions of Toshiba Media Processor
2 Copyright (C) 2001-2014 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"
33 #define MAX_RECOG_OPERANDS 10
37 enum cw_which
{ CW_AVAILABLE
, CW_CALL_SAVED
};
39 /* This is normally provided by rtl.h but we can't include that file
40 here. It's safe to copy the definition here because we're only
41 using it internally; the value isn't passed to functions outside
43 #ifndef INVALID_REGNUM
44 #define INVALID_REGNUM (~(unsigned int) 0)
48 mep_pragma_lex (tree
*valp
)
50 enum cpp_ttype t
= pragma_lex (valp
);
57 mep_pragma_io_volatile (cpp_reader
*reader ATTRIBUTE_UNUSED
)
64 type
= mep_pragma_lex (&val
);
67 str
= IDENTIFIER_POINTER (val
);
69 type
= mep_pragma_lex (&val
);
70 if (type
!= CPP_PRAGMA_EOL
)
71 warning (0, "junk at end of #pragma io_volatile");
73 if (strcmp (str
, "on") == 0)
75 target_flags
|= MASK_IO_VOLATILE
;
78 if (strcmp (str
, "off") == 0)
80 target_flags
&= ~ MASK_IO_VOLATILE
;
85 error ("#pragma io_volatile takes only on or off");
89 parse_cr_reg (const char * str
)
93 regno
= decode_reg_name (str
);
94 if (regno
>= FIRST_PSEUDO_REGISTER
)
95 return INVALID_REGNUM
;
97 /* Verify that the regno is in CR_REGS. */
98 if (! TEST_HARD_REG_BIT (reg_class_contents
[CR_REGS
], regno
))
99 return INVALID_REGNUM
;
104 parse_cr_set (HARD_REG_SET
* set
)
108 unsigned int last_regno
= INVALID_REGNUM
;
109 bool do_range
= false;
111 CLEAR_HARD_REG_SET (*set
);
113 while ((type
= mep_pragma_lex (&val
)) != CPP_PRAGMA_EOL
)
115 if (type
== CPP_COMMA
)
117 last_regno
= INVALID_REGNUM
;
120 else if (type
== CPP_ELLIPSIS
)
122 if (last_regno
== INVALID_REGNUM
)
124 error ("invalid coprocessor register range");
129 else if (type
== CPP_NAME
|| type
== CPP_STRING
)
132 unsigned int regno
, i
;
134 if (TREE_CODE (val
) == IDENTIFIER_NODE
)
135 str
= IDENTIFIER_POINTER (val
);
136 else if (TREE_CODE (val
) == STRING_CST
)
137 str
= TREE_STRING_POINTER (val
);
141 regno
= parse_cr_reg (str
);
142 if (regno
== INVALID_REGNUM
)
144 error ("invalid coprocessor register %qE", val
);
150 if (last_regno
> regno
)
151 i
= regno
, regno
= last_regno
;
157 last_regno
= i
= regno
;
161 SET_HARD_REG_BIT (*set
, i
);
167 error ("malformed coprocessor register");
175 mep_pragma_coprocessor_which (enum cw_which cw_which
)
179 /* Process the balance of the pragma and turn it into a hard reg set. */
180 if (! parse_cr_set (&set
))
183 /* Process the collected hard reg set. */
189 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
190 if (TEST_HARD_REG_BIT (set
, i
))
198 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
199 if (TEST_HARD_REG_BIT (set
, i
))
200 fixed_regs
[i
] = call_used_regs
[i
] = 0;
208 /* Fix up register class hierarchy. */
209 mep_save_register_info ();
214 init_dummy_function_start ();
216 expand_dummy_function_end ();
225 mep_pragma_coprocessor_width (void)
231 type
= mep_pragma_lex (&val
);
235 if (! tree_fits_uhwi_p (val
))
237 i
= tree_to_uhwi (val
);
238 /* This pragma no longer has any effect. */
241 target_flags
&= ~MASK_64BIT_CR_REGS
;
243 target_flags
|= MASK_64BIT_CR_REGS
;
246 targetm
.init_builtins ();
248 if (i
!= 32 && i
!= 64)
252 type
= mep_pragma_lex (&val
);
253 if (type
!= CPP_PRAGMA_EOL
)
254 warning (0, "junk at end of #pragma GCC coprocessor width");
261 error ("#pragma GCC coprocessor width takes only 32 or 64");
265 mep_pragma_coprocessor_subclass (void)
271 enum reg_class rclass
;
273 type
= mep_pragma_lex (&val
);
274 if (type
!= CPP_CHAR
)
276 class_letter
= tree_to_uhwi (val
);
277 switch (class_letter
)
292 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
295 if (reg_class_size
[rclass
] > 0)
297 error ("#pragma GCC coprocessor subclass '%c' already defined",
302 type
= mep_pragma_lex (&val
);
306 if (! parse_cr_set (&set
))
309 /* Fix up register class hierarchy. */
310 COPY_HARD_REG_SET (reg_class_contents
[rclass
], set
);
315 error ("malformed #pragma GCC coprocessor subclass");
319 mep_pragma_disinterrupt (cpp_reader
*reader ATTRIBUTE_UNUSED
)
327 type
= mep_pragma_lex (&val
);
328 if (type
== CPP_COMMA
)
330 if (type
!= CPP_NAME
)
332 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val
));
335 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
337 error ("malformed #pragma disinterrupt");
343 mep_pragma_coprocessor (cpp_reader
*reader ATTRIBUTE_UNUSED
)
348 type
= mep_pragma_lex (&val
);
349 if (type
!= CPP_NAME
)
351 error ("malformed #pragma GCC coprocessor");
356 error ("coprocessor not enabled");
358 if (strcmp (IDENTIFIER_POINTER (val
), "available") == 0)
359 mep_pragma_coprocessor_which (CW_AVAILABLE
);
360 else if (strcmp (IDENTIFIER_POINTER (val
), "call_saved") == 0)
361 mep_pragma_coprocessor_which (CW_CALL_SAVED
);
362 else if (strcmp (IDENTIFIER_POINTER (val
), "width") == 0)
363 mep_pragma_coprocessor_width ();
364 else if (strcmp (IDENTIFIER_POINTER (val
), "subclass") == 0)
365 mep_pragma_coprocessor_subclass ();
367 error ("unknown #pragma GCC coprocessor %E", val
);
371 mep_pragma_call (cpp_reader
*reader ATTRIBUTE_UNUSED
)
379 type
= mep_pragma_lex (&val
);
380 if (type
== CPP_COMMA
)
382 if (type
!= CPP_NAME
)
384 mep_note_pragma_call (IDENTIFIER_POINTER (val
));
387 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
389 error ("malformed #pragma call");
395 mep_register_pragmas (void)
397 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile
);
398 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor
);
399 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt
);
400 c_register_pragma (0, "call", mep_pragma_call
);