[AArch64] Improve scheduling model for X-Gene
[official-gcc.git] / gcc / config / m32c / m32c-pragma.c
blob68aa2287222bf786cdb4763fed51202027743fbb
1 /* M32C Pragma support
2 Copyright (C) 2004-2017 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
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "c-family/c-common.h"
26 #include "c-family/c-pragma.h"
27 #include "m32c-protos.h"
29 /* Implements the "GCC memregs" pragma. This pragma takes only an
30 integer, and is semantically identical to the -memregs= command
31 line option. The only catch is, the programmer should only use
32 this pragma at the beginning of the file (preferably, in some
33 project-wide header) to avoid ABI changes related to changing the
34 list of available "registers". */
35 static void
36 m32c_pragma_memregs (cpp_reader * reader ATTRIBUTE_UNUSED)
38 /* on off */
39 tree val;
40 enum cpp_ttype type;
41 HOST_WIDE_INT i;
43 type = pragma_lex (&val);
44 if (type == CPP_NUMBER)
46 if (tree_fits_uhwi_p (val))
48 i = tree_to_uhwi (val);
50 type = pragma_lex (&val);
51 if (type != CPP_EOF)
52 warning (0, "junk at end of #pragma GCC memregs [0..16]");
54 if (0 <= i && i <= 16)
56 if (!ok_to_change_target_memregs)
58 warning (0,
59 "#pragma GCC memregs must precede any function decls");
60 return;
62 target_memregs = i;
63 m32c_conditional_register_usage ();
65 else
67 warning (0, "#pragma GCC memregs takes a number [0..16]");
70 return;
74 error ("#pragma GCC memregs takes a number [0..16]");
77 /* Implements the "pragma ADDRESS" pragma. This pragma takes a
78 variable name and an address, and arranges for that variable to be
79 "at" that address. The variable is also made volatile. */
80 static void
81 m32c_pragma_address (cpp_reader * reader ATTRIBUTE_UNUSED)
83 /* on off */
84 tree var, addr;
85 enum cpp_ttype type;
87 type = pragma_lex (&var);
88 if (type == CPP_NAME)
90 type = pragma_lex (&addr);
91 if (type == CPP_NUMBER)
93 if (var != error_mark_node)
95 unsigned uaddr = tree_to_uhwi (addr);
96 m32c_note_pragma_address (IDENTIFIER_POINTER (var), uaddr);
99 type = pragma_lex (&var);
100 if (type != CPP_EOF)
102 error ("junk at end of #pragma ADDRESS");
104 return;
107 error ("malformed #pragma ADDRESS variable address");
110 /* Implements REGISTER_TARGET_PRAGMAS. */
111 void
112 m32c_register_pragmas (void)
114 c_register_pragma ("GCC", "memregs", m32c_pragma_memregs);
115 c_register_pragma (NULL, "ADDRESS", m32c_pragma_address);
116 c_register_pragma (NULL, "address", m32c_pragma_address);
118 /* R8C and M16C have 16-bit pointers in a 20-bit address zpace.
119 M32C has 24-bit pointers in a 24-bit address space, so does not
120 need far pointers, but we accept the qualifier anyway, as a
121 no-op. */
122 if (TARGET_A16)
123 c_register_addr_space ("__far", ADDR_SPACE_FAR);
124 else
125 c_register_addr_space ("__far", ADDR_SPACE_GENERIC);