2 Copyright (C) 2004, 2007 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)
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/>. */
24 #include "coretypes.h"
27 #include "diagnostic-core.h"
29 #include "c-family/c-pragma.h"
31 #include "hard-reg-set.h"
33 #include "m32c-protos.h"
35 #define MAX_RECOG_OPERANDS 10
39 /* Implements the "GCC memregs" pragma. This pragma takes only an
40 integer, and is semantically identical to the -memregs= command
41 line option. The only catch is, the programmer should only use
42 this pragma at the beginning of the file (preferably, in some
43 project-wide header) to avoid ABI changes related to changing the
44 list of available "registers". */
46 m32c_pragma_memregs (cpp_reader
* reader ATTRIBUTE_UNUSED
)
52 static char new_number
[3];
54 type
= pragma_lex (&val
);
55 if (type
== CPP_NUMBER
)
57 if (host_integerp (val
, 1))
59 i
= tree_low_cst (val
, 1);
61 type
= pragma_lex (&val
);
63 warning (0, "junk at end of #pragma GCC memregs [0..16]");
65 if (0 <= i
&& i
<= 16)
67 if (!ok_to_change_target_memregs
)
70 "#pragma GCC memregs must precede any function decls");
73 new_number
[0] = (i
/ 10) + '0';
74 new_number
[1] = (i
% 10) + '0';
76 target_memregs
= new_number
;
77 m32c_conditional_register_usage ();
81 warning (0, "#pragma GCC memregs takes a number [0..16]");
88 error ("#pragma GCC memregs takes a number [0..16]");
91 /* Implements the "pragma ADDRESS" pragma. This pragma takes a
92 variable name and an address, and arranges for that variable to be
93 "at" that address. The variable is also made volatile. */
95 m32c_pragma_address (cpp_reader
* reader ATTRIBUTE_UNUSED
)
102 type
= pragma_lex (&var
);
103 if (type
== CPP_NAME
)
105 var_str
= IDENTIFIER_POINTER (var
);
107 type
= pragma_lex (&addr
);
108 if (type
== CPP_NUMBER
)
110 if (var
!= error_mark_node
)
112 unsigned uaddr
= tree_low_cst (addr
, 1);
113 m32c_note_pragma_address (IDENTIFIER_POINTER (var
), uaddr
);
116 type
= pragma_lex (&var
);
119 error ("junk at end of #pragma ADDRESS");
124 error ("malformed #pragma ADDRESS variable address");
127 /* Implements REGISTER_TARGET_PRAGMAS. */
129 m32c_register_pragmas (void)
131 c_register_pragma ("GCC", "memregs", m32c_pragma_memregs
);
132 c_register_pragma (NULL
, "ADDRESS", m32c_pragma_address
);
133 c_register_pragma (NULL
, "address", m32c_pragma_address
);