]>
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"
27 #include "diagnostic-core.h"
28 #include "c-family/c-pragma.h"
30 #include "hard-reg-set.h"
31 #include "output.h" /* for decode_reg_name */
32 #include "mep-protos.h"
34 #define MAX_RECOG_OPERANDS 10
38 enum cw_which
{ CW_AVAILABLE
, CW_CALL_SAVED
};
40 /* This is normally provided by rtl.h but we can't include that file
41 here. It's safe to copy the definition here because we're only
42 using it internally; the value isn't passed to functions outside
44 #ifndef INVALID_REGNUM
45 #define INVALID_REGNUM (~(unsigned int) 0)
49 mep_pragma_lex (tree
*valp
)
51 enum cpp_ttype t
= pragma_lex (valp
);
58 mep_pragma_io_volatile (cpp_reader
*reader ATTRIBUTE_UNUSED
)
65 type
= mep_pragma_lex (&val
);
68 str
= IDENTIFIER_POINTER (val
);
70 type
= mep_pragma_lex (&val
);
71 if (type
!= CPP_PRAGMA_EOL
)
72 warning (0, "junk at end of #pragma io_volatile");
74 if (strcmp (str
, "on") == 0)
76 target_flags
|= MASK_IO_VOLATILE
;
79 if (strcmp (str
, "off") == 0)
81 target_flags
&= ~ MASK_IO_VOLATILE
;
86 error ("#pragma io_volatile takes only on or off");
90 parse_cr_reg (const char * str
)
94 regno
= decode_reg_name (str
);
95 if (regno
>= FIRST_PSEUDO_REGISTER
)
96 return INVALID_REGNUM
;
98 /* Verify that the regno is in CR_REGS. */
99 if (! TEST_HARD_REG_BIT (reg_class_contents
[CR_REGS
], regno
))
100 return INVALID_REGNUM
;
105 parse_cr_set (HARD_REG_SET
* set
)
109 unsigned int last_regno
= INVALID_REGNUM
;
110 bool do_range
= false;
112 CLEAR_HARD_REG_SET (*set
);
114 while ((type
= mep_pragma_lex (&val
)) != CPP_PRAGMA_EOL
)
116 if (type
== CPP_COMMA
)
118 last_regno
= INVALID_REGNUM
;
121 else if (type
== CPP_ELLIPSIS
)
123 if (last_regno
== INVALID_REGNUM
)
125 error ("invalid coprocessor register range");
130 else if (type
== CPP_NAME
|| type
== CPP_STRING
)
133 unsigned int regno
, i
;
135 if (TREE_CODE (val
) == IDENTIFIER_NODE
)
136 str
= IDENTIFIER_POINTER (val
);
137 else if (TREE_CODE (val
) == STRING_CST
)
138 str
= TREE_STRING_POINTER (val
);
142 regno
= parse_cr_reg (str
);
143 if (regno
== INVALID_REGNUM
)
145 error ("invalid coprocessor register %qE", val
);
151 if (last_regno
> regno
)
152 i
= regno
, regno
= last_regno
;
158 last_regno
= i
= regno
;
162 SET_HARD_REG_BIT (*set
, i
);
168 error ("malformed coprocessor register");
176 mep_pragma_coprocessor_which (enum cw_which cw_which
)
180 /* Process the balance of the pragma and turn it into a hard reg set. */
181 if (! parse_cr_set (&set
))
184 /* Process the collected hard reg set. */
190 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
191 if (TEST_HARD_REG_BIT (set
, i
))
199 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; ++i
)
200 if (TEST_HARD_REG_BIT (set
, i
))
201 fixed_regs
[i
] = call_used_regs
[i
] = 0;
209 /* Fix up register class hierarchy. */
210 mep_save_register_info ();
215 init_dummy_function_start ();
217 expand_dummy_function_end ();
226 mep_pragma_coprocessor_width (void)
232 type
= mep_pragma_lex (&val
);
236 if (! tree_fits_uhwi_p (val
))
238 i
= tree_to_uhwi (val
);
239 /* This pragma no longer has any effect. */
242 target_flags
&= ~MASK_64BIT_CR_REGS
;
244 target_flags
|= MASK_64BIT_CR_REGS
;
247 targetm
.init_builtins ();
249 if (i
!= 32 && i
!= 64)
253 type
= mep_pragma_lex (&val
);
254 if (type
!= CPP_PRAGMA_EOL
)
255 warning (0, "junk at end of #pragma GCC coprocessor width");
262 error ("#pragma GCC coprocessor width takes only 32 or 64");
266 mep_pragma_coprocessor_subclass (void)
272 enum reg_class rclass
;
274 type
= mep_pragma_lex (&val
);
275 if (type
!= CPP_CHAR
)
277 class_letter
= tree_to_uhwi (val
);
278 switch (class_letter
)
293 error ("#pragma GCC coprocessor subclass letter must be in [ABCD]");
296 if (reg_class_size
[rclass
] > 0)
298 error ("#pragma GCC coprocessor subclass '%c' already defined",
303 type
= mep_pragma_lex (&val
);
307 if (! parse_cr_set (&set
))
310 /* Fix up register class hierarchy. */
311 COPY_HARD_REG_SET (reg_class_contents
[rclass
], set
);
316 error ("malformed #pragma GCC coprocessor subclass");
320 mep_pragma_disinterrupt (cpp_reader
*reader ATTRIBUTE_UNUSED
)
328 type
= mep_pragma_lex (&val
);
329 if (type
== CPP_COMMA
)
331 if (type
!= CPP_NAME
)
333 mep_note_pragma_disinterrupt (IDENTIFIER_POINTER (val
));
336 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
338 error ("malformed #pragma disinterrupt");
344 mep_pragma_coprocessor (cpp_reader
*reader ATTRIBUTE_UNUSED
)
349 type
= mep_pragma_lex (&val
);
350 if (type
!= CPP_NAME
)
352 error ("malformed #pragma GCC coprocessor");
357 error ("coprocessor not enabled");
359 if (strcmp (IDENTIFIER_POINTER (val
), "available") == 0)
360 mep_pragma_coprocessor_which (CW_AVAILABLE
);
361 else if (strcmp (IDENTIFIER_POINTER (val
), "call_saved") == 0)
362 mep_pragma_coprocessor_which (CW_CALL_SAVED
);
363 else if (strcmp (IDENTIFIER_POINTER (val
), "width") == 0)
364 mep_pragma_coprocessor_width ();
365 else if (strcmp (IDENTIFIER_POINTER (val
), "subclass") == 0)
366 mep_pragma_coprocessor_subclass ();
368 error ("unknown #pragma GCC coprocessor %E", val
);
372 mep_pragma_call (cpp_reader
*reader ATTRIBUTE_UNUSED
)
380 type
= mep_pragma_lex (&val
);
381 if (type
== CPP_COMMA
)
383 if (type
!= CPP_NAME
)
385 mep_note_pragma_call (IDENTIFIER_POINTER (val
));
388 if (!saw_one
|| type
!= CPP_PRAGMA_EOL
)
390 error ("malformed #pragma call");
396 mep_register_pragmas (void)
398 c_register_pragma ("custom", "io_volatile", mep_pragma_io_volatile
);
399 c_register_pragma ("GCC", "coprocessor", mep_pragma_coprocessor
);
400 c_register_pragma (0, "disinterrupt", mep_pragma_disinterrupt
);
401 c_register_pragma (0, "call", mep_pragma_call
);