1 /* Definitions of Toshiba Media Processor
2 Copyright (C) 2001-2013 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 (! host_integerp (val
, 1))
237 i
= tree_low_cst (val
, 1);
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_low_cst (val
, 1);
277 if (class_letter
>= 'A' && class_letter
<= 'D')
278 switch (class_letter
)
295 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
298 if (reg_class_size
[rclass
] > 0)
300 error ("#pragma GCC coprocessor subclass '%c' already defined",
305 type
= mep_pragma_lex (&val
);
309 if (! parse_cr_set (&set
))
312 /* Fix up register class hierarchy. */
313 COPY_HARD_REG_SET (reg_class_contents
[rclass
], set
);
318 error ("malformed #pragma GCC coprocessor subclass");
322 mep_pragma_disinterrupt (cpp_reader
*reader ATTRIBUTE_UNUSED
)
330 type
= mep_pragma_lex (&val
);
331 if (type
== CPP_COMMA
)
333 if (type
!= CPP_NAME
)
335 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val
));
338 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
340 error ("malformed #pragma disinterrupt");
346 mep_pragma_coprocessor (cpp_reader
*reader ATTRIBUTE_UNUSED
)
351 type
= mep_pragma_lex (&val
);
352 if (type
!= CPP_NAME
)
354 error ("malformed #pragma GCC coprocessor");
359 error ("coprocessor not enabled");
361 if (strcmp (IDENTIFIER_POINTER (val
), "available") == 0)
362 mep_pragma_coprocessor_which (CW_AVAILABLE
);
363 else if (strcmp (IDENTIFIER_POINTER (val
), "call_saved") == 0)
364 mep_pragma_coprocessor_which (CW_CALL_SAVED
);
365 else if (strcmp (IDENTIFIER_POINTER (val
), "width") == 0)
366 mep_pragma_coprocessor_width ();
367 else if (strcmp (IDENTIFIER_POINTER (val
), "subclass") == 0)
368 mep_pragma_coprocessor_subclass ();
370 error ("unknown #pragma GCC coprocessor %E", val
);
374 mep_pragma_call (cpp_reader
*reader ATTRIBUTE_UNUSED
)
382 type
= mep_pragma_lex (&val
);
383 if (type
== CPP_COMMA
)
385 if (type
!= CPP_NAME
)
387 mep_note_pragma_call (IDENTIFIER_POINTER (val
));
390 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
392 error ("malformed #pragma call");
398 mep_register_pragmas (void)
400 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile
);
401 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor
);
402 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt
);
403 c_register_pragma (0, "call", mep_pragma_call
);