1 /* Definitions of Toshiba Media Processor
2 Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2009 Free
3 Software Foundation, Inc. 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/>. */
24 #include "coretypes.h"
31 #include "hard-reg-set.h"
33 #include "mep-protos.h"
35 #define MAX_RECOG_OPERANDS 10
39 enum cw_which { CW_AVAILABLE, CW_CALL_SAVED };
42 mep_pragma_lex (tree *valp)
44 enum cpp_ttype t = pragma_lex (valp);
51 mep_pragma_io_volatile (cpp_reader *reader ATTRIBUTE_UNUSED)
58 type = mep_pragma_lex (&val);
61 str = IDENTIFIER_POINTER (val);
63 type = mep_pragma_lex (&val);
64 if (type != CPP_PRAGMA_EOL)
65 warning (0, "junk at end of #pragma io_volatile");
67 if (strcmp (str, "on") == 0)
69 target_flags |= MASK_IO_VOLATILE;
72 if (strcmp (str, "off") == 0)
74 target_flags &= ~ MASK_IO_VOLATILE;
79 error ("#pragma io_volatile takes only on or off");
83 parse_cr_reg (const char * str)
87 regno = decode_reg_name (str);
88 if (regno >= FIRST_PSEUDO_REGISTER)
89 return INVALID_REGNUM;
91 /* Verify that the regno is in CR_REGS. */
92 if (! TEST_HARD_REG_BIT (reg_class_contents[CR_REGS], regno))
93 return INVALID_REGNUM;
98 parse_cr_set (HARD_REG_SET * set)
102 unsigned int last_regno = INVALID_REGNUM;
103 bool do_range = false;
105 CLEAR_HARD_REG_SET (*set);
107 while ((type = mep_pragma_lex (&val)) != CPP_PRAGMA_EOL)
109 if (type == CPP_COMMA)
111 last_regno = INVALID_REGNUM;
114 else if (type == CPP_ELLIPSIS)
116 if (last_regno == INVALID_REGNUM)
118 error ("invalid coprocessor register range");
123 else if (type == CPP_NAME || type == CPP_STRING)
126 unsigned int regno, i;
128 if (TREE_CODE (val) == IDENTIFIER_NODE)
129 str = IDENTIFIER_POINTER (val);
130 else if (TREE_CODE (val) == STRING_CST)
131 str = TREE_STRING_POINTER (val);
135 regno = parse_cr_reg (str);
136 if (regno == INVALID_REGNUM)
138 error ("invalid coprocessor register %qE", val);
144 if (last_regno > regno)
145 i = regno, regno = last_regno;
151 last_regno = i = regno;
155 SET_HARD_REG_BIT (*set, i);
161 error ("malformed coprocessor register");
169 mep_pragma_coprocessor_which (enum cw_which cw_which)
173 /* Process the balance of the pragma and turn it into a hard reg set. */
174 if (! parse_cr_set (&set))
177 /* Process the collected hard reg set. */
183 for (i = 0; i < FIRST_PSEUDO_REGISTER; ++i)
184 if (TEST_HARD_REG_BIT (set, i))
192 for (i = 0; i < FIRST_PSEUDO_REGISTER; ++i)
193 if (TEST_HARD_REG_BIT (set, i))
194 fixed_regs[i] = call_used_regs[i] = 0;
202 /* Fix up register class hierarchy. */
203 save_register_info ();
208 init_dummy_function_start ();
210 expand_dummy_function_end ();
219 mep_pragma_coprocessor_width (void)
225 type = mep_pragma_lex (&val);
229 if (! host_integerp (val, 1))
231 i = tree_low_cst (val, 1);
232 /* This pragma no longer has any effect. */
235 target_flags &= ~MASK_64BIT_CR_REGS;
237 target_flags |= MASK_64BIT_CR_REGS;
240 targetm.init_builtins ();
242 if (i != 32 && i != 64)
246 type = mep_pragma_lex (&val);
247 if (type != CPP_PRAGMA_EOL)
248 warning (0, "junk at end of #pragma GCC coprocessor width");
255 error ("#pragma GCC coprocessor width takes only 32 or 64");
259 mep_pragma_coprocessor_subclass (void)
265 enum reg_class class;
267 type = mep_pragma_lex (&val);
268 if (type != CPP_CHAR)
270 class_letter = tree_low_cst (val, 1);
271 if (class_letter >= 'A' && class_letter <= 'D')
272 class = class_letter - 'A' + USER0_REGS;
275 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
278 if (reg_class_size[class] > 0)
280 error ("#pragma GCC coprocessor subclass '%c' already defined",
285 type = mep_pragma_lex (&val);
289 if (! parse_cr_set (&set))
292 /* Fix up register class hierarchy. */
293 COPY_HARD_REG_SET (reg_class_contents[class], set);
298 error ("malformed #pragma GCC coprocessor subclass");
302 mep_pragma_disinterrupt (cpp_reader *reader ATTRIBUTE_UNUSED)
310 type = mep_pragma_lex (&val);
311 if (type == CPP_COMMA)
313 if (type != CPP_NAME)
315 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val));
318 if (!saw_one || type != CPP_PRAGMA_EOL)
320 error ("malformed #pragma disinterrupt");
326 mep_pragma_coprocessor (cpp_reader *reader ATTRIBUTE_UNUSED)
331 type = mep_pragma_lex (&val);
332 if (type != CPP_NAME)
334 error ("malformed #pragma GCC coprocessor");
339 error ("coprocessor not enabled");
341 if (strcmp (IDENTIFIER_POINTER (val), "available") == 0)
342 mep_pragma_coprocessor_which (CW_AVAILABLE);
343 else if (strcmp (IDENTIFIER_POINTER (val), "call_saved") == 0)
344 mep_pragma_coprocessor_which (CW_CALL_SAVED);
345 else if (strcmp (IDENTIFIER_POINTER (val), "width") == 0)
346 mep_pragma_coprocessor_width ();
347 else if (strcmp (IDENTIFIER_POINTER (val), "subclass") == 0)
348 mep_pragma_coprocessor_subclass ();
350 error ("unknown #pragma GCC coprocessor %E", val);
354 mep_pragma_call (cpp_reader *reader ATTRIBUTE_UNUSED)
362 type = mep_pragma_lex (&val);
363 if (type == CPP_COMMA)
365 if (type != CPP_NAME)
367 mep_note_pragma_call (IDENTIFIER_POINTER (val));
370 if (!saw_one || type != CPP_PRAGMA_EOL)
372 error ("malformed #pragma call");
378 mep_register_pragmas (void)
380 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile);
381 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor);
382 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt);
383 c_register_pragma (0, "call", mep_pragma_call);