]>
Commit | Line | Data |
---|---|---|
38b2d076 | 1 | /* M32C Pragma support |
5624e564 | 2 | Copyright (C) 2004-2015 Free Software Foundation, Inc. |
38b2d076 DD |
3 | Contributed by Red Hat, Inc. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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 | |
2f83c7d6 | 9 | the Free Software Foundation; either version 3, or (at your option) |
38b2d076 DD |
10 | any later version. |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
2f83c7d6 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
38b2d076 | 20 | |
38b2d076 DD |
21 | #include "config.h" |
22 | #include "system.h" | |
23 | #include "coretypes.h" | |
24 | #include "tm.h" | |
40e23961 | 25 | #include "alias.h" |
38b2d076 | 26 | #include "tree.h" |
444d6efe JR |
27 | #include "c-family/c-pragma.h" |
28 | #include "c-family/c-common.h" | |
718f9c0f | 29 | #include "diagnostic-core.h" |
38b2d076 | 30 | #include "cpplib.h" |
38b2d076 | 31 | #include "m32c-protos.h" |
38b2d076 DD |
32 | |
33 | /* Implements the "GCC memregs" pragma. This pragma takes only an | |
34 | integer, and is semantically identical to the -memregs= command | |
35 | line option. The only catch is, the programmer should only use | |
36 | this pragma at the beginning of the file (preferably, in some | |
37 | project-wide header) to avoid ABI changes related to changing the | |
38 | list of available "registers". */ | |
39 | static void | |
40 | m32c_pragma_memregs (cpp_reader * reader ATTRIBUTE_UNUSED) | |
41 | { | |
42 | /* on off */ | |
43 | tree val; | |
44 | enum cpp_ttype type; | |
45 | HOST_WIDE_INT i; | |
38b2d076 | 46 | |
75ce3d48 | 47 | type = pragma_lex (&val); |
38b2d076 DD |
48 | if (type == CPP_NUMBER) |
49 | { | |
cc269bb6 | 50 | if (tree_fits_uhwi_p (val)) |
38b2d076 | 51 | { |
ae7e9ddd | 52 | i = tree_to_uhwi (val); |
38b2d076 | 53 | |
75ce3d48 | 54 | type = pragma_lex (&val); |
38b2d076 DD |
55 | if (type != CPP_EOF) |
56 | warning (0, "junk at end of #pragma GCC memregs [0..16]"); | |
57 | ||
58 | if (0 <= i && i <= 16) | |
59 | { | |
60 | if (!ok_to_change_target_memregs) | |
61 | { | |
62 | warning (0, | |
63 | "#pragma GCC memregs must precede any function decls"); | |
64 | return; | |
65 | } | |
444d6efe | 66 | target_memregs = i; |
38b2d076 DD |
67 | m32c_conditional_register_usage (); |
68 | } | |
69 | else | |
70 | { | |
71 | warning (0, "#pragma GCC memregs takes a number [0..16]"); | |
72 | } | |
73 | ||
74 | return; | |
75 | } | |
76 | } | |
77 | ||
78 | error ("#pragma GCC memregs takes a number [0..16]"); | |
79 | } | |
80 | ||
f6052f86 DD |
81 | /* Implements the "pragma ADDRESS" pragma. This pragma takes a |
82 | variable name and an address, and arranges for that variable to be | |
83 | "at" that address. The variable is also made volatile. */ | |
84 | static void | |
85 | m32c_pragma_address (cpp_reader * reader ATTRIBUTE_UNUSED) | |
86 | { | |
87 | /* on off */ | |
88 | tree var, addr; | |
89 | enum cpp_ttype type; | |
f6052f86 DD |
90 | |
91 | type = pragma_lex (&var); | |
92 | if (type == CPP_NAME) | |
93 | { | |
f6052f86 DD |
94 | type = pragma_lex (&addr); |
95 | if (type == CPP_NUMBER) | |
96 | { | |
97 | if (var != error_mark_node) | |
98 | { | |
ae7e9ddd | 99 | unsigned uaddr = tree_to_uhwi (addr); |
f6052f86 DD |
100 | m32c_note_pragma_address (IDENTIFIER_POINTER (var), uaddr); |
101 | } | |
102 | ||
103 | type = pragma_lex (&var); | |
104 | if (type != CPP_EOF) | |
105 | { | |
106 | error ("junk at end of #pragma ADDRESS"); | |
107 | } | |
108 | return; | |
109 | } | |
110 | } | |
111 | error ("malformed #pragma ADDRESS variable address"); | |
112 | } | |
113 | ||
38b2d076 DD |
114 | /* Implements REGISTER_TARGET_PRAGMAS. */ |
115 | void | |
116 | m32c_register_pragmas (void) | |
117 | { | |
118 | c_register_pragma ("GCC", "memregs", m32c_pragma_memregs); | |
f6052f86 DD |
119 | c_register_pragma (NULL, "ADDRESS", m32c_pragma_address); |
120 | c_register_pragma (NULL, "address", m32c_pragma_address); | |
5fd5d713 DD |
121 | |
122 | /* R8C and M16C have 16-bit pointers in a 20-bit address zpace. | |
123 | M32C has 24-bit pointers in a 24-bit address space, so does not | |
124 | need far pointers, but we accept the qualifier anyway, as a | |
125 | no-op. */ | |
126 | if (TARGET_A16) | |
127 | c_register_addr_space ("__far", ADDR_SPACE_FAR); | |
128 | else | |
129 | c_register_addr_space ("__far", ADDR_SPACE_GENERIC); | |
38b2d076 | 130 | } |