]>
Commit | Line | Data |
---|---|---|
bcf684c7 | 1 | /* Definitions of target machine for GNU compiler, for MMIX. |
a9ba5098 | 2 | Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc. |
bcf684c7 HPN |
3 | Contributed by Hans-Peter Nilsson (hp@bitrange.com) |
4 | ||
c583c5c3 | 5 | This file is part of GCC. |
bcf684c7 | 6 | |
c583c5c3 | 7 | GCC is free software; you can redistribute it and/or modify |
bcf684c7 HPN |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
c583c5c3 | 12 | GCC is distributed in the hope that it will be useful, |
bcf684c7 HPN |
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 | |
c583c5c3 | 18 | along with GCC; see the file COPYING. If not, write to |
bcf684c7 HPN |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #ifndef GCC_MMIX_H | |
23 | #define GCC_MMIX_H | |
24 | ||
25 | /* First, some local helper macros. Note that the "default" value of | |
26 | FIXED_REGISTERS, CALL_USED_REGISTERS, REG_ALLOC_ORDER and | |
27 | REG_CLASS_CONTENTS depend on these values. */ | |
28 | #define MMIX_RESERVED_GNU_ARG_0_REGNUM 231 | |
29 | #define MMIX_FIRST_ARG_REGNUM \ | |
30 | (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 16) | |
31 | #define MMIX_FIRST_INCOMING_ARG_REGNUM \ | |
32 | (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 0) | |
33 | #define MMIX_MAX_ARGS_IN_REGS 16 | |
34 | ||
35 | /* FIXME: This one isn't fully implemented yet. Return values larger than | |
36 | one register are passed by reference in MMIX_STRUCT_VALUE_REGNUM by the | |
37 | caller, except for return values of type "complex". */ | |
38 | #define MMIX_MAX_REGS_FOR_VALUE 16 | |
39 | #define MMIX_RETURN_VALUE_REGNUM \ | |
40 | (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 15) | |
41 | #define MMIX_OUTGOING_RETURN_VALUE_REGNUM \ | |
42 | (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 0) | |
43 | #define MMIX_STRUCT_VALUE_REGNUM 251 | |
44 | #define MMIX_STATIC_CHAIN_REGNUM 252 | |
45 | #define MMIX_FRAME_POINTER_REGNUM 253 | |
46 | #define MMIX_STACK_POINTER_REGNUM 254 | |
47 | #define MMIX_LAST_GENERAL_REGISTER 255 | |
91312b81 | 48 | #define MMIX_INCOMING_RETURN_ADDRESS_REGNUM MMIX_rJ_REGNUM |
bcf684c7 | 49 | #define MMIX_HIMULT_REGNUM 258 |
34116c2a | 50 | #define MMIX_REMAINDER_REGNUM MMIX_rR_REGNUM |
bcf684c7 | 51 | #define MMIX_ARG_POINTER_REGNUM 261 |
957ec0f9 | 52 | #define MMIX_rO_REGNUM 262 |
1f2641b6 | 53 | #define MMIX_LAST_STACK_REGISTER_REGNUM 31 |
bcf684c7 HPN |
54 | |
55 | /* Four registers; "ideally, these registers should be call-clobbered", so | |
56 | just grab a bunch of the common clobbered registers. FIXME: Last | |
57 | registers of return-value should be used, with an error if there's a | |
58 | return-value (that collides in size). */ | |
59 | #define MMIX_EH_RETURN_DATA_REGNO_START (MMIX_STRUCT_VALUE_REGNUM - 4) | |
60 | ||
61 | /* Try to keep the definitions from running away on their own. */ | |
62 | #if (MMIX_EH_RETURN_DATA_REGNO_START \ | |
63 | != MMIX_RESERVED_GNU_ARG_0_REGNUM + MMIX_MAX_ARGS_IN_REGS) | |
64 | #error MMIX register definition inconsistency | |
65 | #endif | |
66 | ||
67 | #if (MMIX_MAX_REGS_FOR_VALUE + MMIX_MAX_ARGS_IN_REGS > 32) | |
68 | #error MMIX parameters and return values bad, more than 32 registers | |
69 | #endif | |
70 | ||
71 | /* This chosen as "a call-clobbered hard register that is otherwise | |
72 | untouched by the epilogue". */ | |
73 | #define MMIX_EH_RETURN_STACKADJ_REGNUM MMIX_STATIC_CHAIN_REGNUM | |
74 | ||
75 | #ifdef REG_OK_STRICT | |
76 | # define MMIX_REG_OK_STRICT 1 | |
77 | #else | |
78 | # define MMIX_REG_OK_STRICT 0 | |
79 | #endif | |
80 | ||
81 | #define MMIX_FUNCTION_ARG_SIZE(MODE, TYPE) \ | |
82 | ((MODE) != BLKmode ? GET_MODE_SIZE (MODE) : int_size_in_bytes (TYPE)) | |
83 | ||
84 | /* Declarations for helper variables that are not tied to a particular | |
85 | target macro. */ | |
e2500fed GK |
86 | extern GTY(()) rtx mmix_compare_op0; |
87 | extern GTY(()) rtx mmix_compare_op1; | |
bcf684c7 HPN |
88 | |
89 | /* Per-function machine data. This is normally an opaque type just | |
90 | defined and used in the tm.c file, but we need to see the definition in | |
91 | mmix.md too. */ | |
e2500fed | 92 | struct machine_function GTY(()) |
bcf684c7 | 93 | { |
bcf684c7 | 94 | int has_landing_pad; |
1f2641b6 | 95 | int highest_saved_stack_register; |
957ec0f9 | 96 | int in_prologue; |
bcf684c7 HPN |
97 | }; |
98 | ||
99 | /* For these target macros, there is no generic documentation here. You | |
100 | should read `Using and Porting GCC' for that. Only comments specific | |
101 | to the MMIX target are here. | |
102 | ||
103 | There are however references to the specific texinfo node (comments | |
104 | with "Node:"), so there should be little or nothing amiss. Probably | |
105 | the opposite, since we don't have to care about old littering and | |
106 | soon outdated generic comments. */ | |
107 | ||
108 | /* Node: Driver */ | |
109 | ||
bcf684c7 HPN |
110 | /* User symbols are in the same name-space as built-in symbols, but we |
111 | don't need the built-in symbols, so remove those and instead apply | |
112 | stricter operand checking. Don't warn when expanding insns. */ | |
113 | #define ASM_SPEC "-no-predefined-syms -x" | |
114 | ||
115 | /* Pass on -mset-program-start=N and -mset-data-start=M to the linker. | |
116 | Provide default program start 0x100 unless -mno-set-program-start. | |
4f1aac42 HPN |
117 | Don't do this if linking relocatably, with -r. For a final link, |
118 | produce mmo, unless ELF is requested or when linking relocatably. */ | |
bcf684c7 HPN |
119 | #define LINK_SPEC \ |
120 | "%{mset-program-start=*:--defsym __.MMIX.start..text=%*}\ | |
121 | %{mset-data-start=*:--defsym __.MMIX.start..data=%*}\ | |
122 | %{!mset-program-start=*:\ | |
4f1aac42 HPN |
123 | %{!mno-set-program-start:\ |
124 | %{!r:--defsym __.MMIX.start..text=0x100}}}\ | |
125 | %{!melf:%{!r:-m mmo}}%{melf|r:-m elf64mmix}" | |
bcf684c7 HPN |
126 | |
127 | /* Put unused option values here. */ | |
75540760 | 128 | extern const char *mmix_cc1_ignored_option; |
bcf684c7 HPN |
129 | |
130 | #define TARGET_OPTIONS \ | |
131 | {{"set-program-start=", &mmix_cc1_ignored_option, \ | |
c409ea0d | 132 | N_("Set start-address of the program"), 0}, \ |
bcf684c7 | 133 | {"set-data-start=", &mmix_cc1_ignored_option, \ |
c409ea0d | 134 | N_("Set start-address of data"), 0} } |
bcf684c7 HPN |
135 | |
136 | /* FIXME: There's no provision for profiling here. */ | |
137 | #define STARTFILE_SPEC \ | |
138 | "crti%O%s crtbegin%O%s" | |
139 | ||
140 | #define ENDFILE_SPEC "crtend%O%s crtn%O%s" | |
141 | ||
142 | /* Node: Run-time Target */ | |
143 | ||
144 | /* Define __LONG_MAX__, since we're advised not to change glimits.h. */ | |
38e18619 HPN |
145 | #define TARGET_CPU_CPP_BUILTINS() \ |
146 | do \ | |
147 | { \ | |
148 | builtin_define ("__mmix__"); \ | |
149 | builtin_define ("__MMIX__"); \ | |
38e18619 HPN |
150 | if (TARGET_ABI_GNU) \ |
151 | builtin_define ("__MMIX_ABI_GNU__"); \ | |
152 | else \ | |
153 | builtin_define ("__MMIX_ABI_MMIXWARE__"); \ | |
154 | } \ | |
155 | while (0) | |
bcf684c7 HPN |
156 | |
157 | extern int target_flags; | |
158 | ||
159 | #define TARGET_MASK_LIBFUNCS 1 | |
160 | #define TARGET_MASK_ABI_GNU 2 | |
161 | #define TARGET_MASK_FCMP_EPSILON 4 | |
162 | #define TARGET_MASK_ZERO_EXTEND 8 | |
163 | #define TARGET_MASK_KNUTH_DIVISION 16 | |
164 | #define TARGET_MASK_TOPLEVEL_SYMBOLS 32 | |
91312b81 | 165 | #define TARGET_MASK_BRANCH_PREDICT 64 |
66b8c57f | 166 | #define TARGET_MASK_USE_RETURN_INSN 128 |
bcf684c7 | 167 | |
a824924d HPN |
168 | /* We use the term "base address" since that's what Knuth uses. The base |
169 | address goes in a global register. When addressing, it's more like | |
170 | "base address plus offset", with the offset being 0..255 from the base, | |
171 | which itself can be a symbol plus an offset. The effect is like having | |
2a43945f | 172 | a constant pool in global registers, code offsetting from those |
a824924d HPN |
173 | registers (automatically causing a request for a suitable constant base |
174 | address register) without having to know the specific register or the | |
38e18619 HPN |
175 | specific offset. The setback is that there's a limited number of |
176 | registers, and you'll not find out until link time whether you | |
59b9a953 | 177 | should have compiled with -mno-base-addresses. */ |
a824924d HPN |
178 | #define TARGET_MASK_BASE_ADDRESSES 128 |
179 | ||
bcf684c7 HPN |
180 | /* FIXME: Get rid of this one. */ |
181 | #define TARGET_LIBFUNC (target_flags & TARGET_MASK_LIBFUNCS) | |
182 | #define TARGET_ABI_GNU (target_flags & TARGET_MASK_ABI_GNU) | |
183 | #define TARGET_FCMP_EPSILON (target_flags & TARGET_MASK_FCMP_EPSILON) | |
184 | #define TARGET_ZERO_EXTEND (target_flags & TARGET_MASK_ZERO_EXTEND) | |
185 | #define TARGET_KNUTH_DIVISION (target_flags & TARGET_MASK_KNUTH_DIVISION) | |
186 | #define TARGET_TOPLEVEL_SYMBOLS (target_flags & TARGET_MASK_TOPLEVEL_SYMBOLS) | |
91312b81 | 187 | #define TARGET_BRANCH_PREDICT (target_flags & TARGET_MASK_BRANCH_PREDICT) |
a824924d | 188 | #define TARGET_BASE_ADDRESSES (target_flags & TARGET_MASK_BASE_ADDRESSES) |
66b8c57f | 189 | #define TARGET_USE_RETURN_INSN (target_flags & TARGET_MASK_USE_RETURN_INSN) |
bcf684c7 | 190 | |
3e0f61ac | 191 | #define TARGET_DEFAULT \ |
66b8c57f HPN |
192 | (TARGET_MASK_BRANCH_PREDICT | TARGET_MASK_BASE_ADDRESSES \ |
193 | | TARGET_MASK_USE_RETURN_INSN) | |
bcf684c7 | 194 | |
91312b81 | 195 | /* FIXME: Provide a way to *load* the epsilon register. */ |
bcf684c7 HPN |
196 | #define TARGET_SWITCHES \ |
197 | {{"libfuncs", TARGET_MASK_LIBFUNCS, \ | |
198 | N_("For intrinsics library: pass all parameters in registers")}, \ | |
199 | {"no-libfuncs", -TARGET_MASK_LIBFUNCS, ""}, \ | |
200 | {"abi=mmixware", -TARGET_MASK_ABI_GNU, \ | |
201 | N_("Use register stack for parameters and return value")}, \ | |
202 | {"abi=gnu", TARGET_MASK_ABI_GNU, \ | |
203 | N_("Use call-clobbered registers for parameters and return value")}, \ | |
204 | {"epsilon", TARGET_MASK_FCMP_EPSILON, \ | |
205 | N_("Use epsilon-respecting floating point compare instructions")}, \ | |
206 | {"no-epsilon", -TARGET_MASK_FCMP_EPSILON, ""}, \ | |
207 | {"zero-extend", TARGET_MASK_ZERO_EXTEND, \ | |
208 | N_("Use zero-extending memory loads, not sign-extending ones")}, \ | |
209 | {"no-zero-extend", -TARGET_MASK_ZERO_EXTEND, ""}, \ | |
210 | {"knuthdiv", TARGET_MASK_KNUTH_DIVISION, \ | |
211 | N_("Generate divide results with reminder having the same sign as the\ | |
c725bd79 | 212 | divisor (not the dividend)")}, \ |
bcf684c7 HPN |
213 | {"no-knuthdiv", -TARGET_MASK_KNUTH_DIVISION, ""}, \ |
214 | {"toplevel-symbols", TARGET_MASK_TOPLEVEL_SYMBOLS, \ | |
215 | N_("Prepend global symbols with \":\" (for use with PREFIX)")}, \ | |
91312b81 | 216 | {"no-toplevel-symbols", -TARGET_MASK_TOPLEVEL_SYMBOLS, \ |
bcf684c7 HPN |
217 | N_("Do not provide a default start-address 0x100 of the program")}, \ |
218 | {"elf", 0, \ | |
219 | N_("Link to emit program in ELF format (rather than mmo)")}, \ | |
91312b81 HPN |
220 | {"branch-predict", TARGET_MASK_BRANCH_PREDICT, \ |
221 | N_("Use P-mnemonics for branches statically predicted as taken")}, \ | |
222 | {"no-branch-predict", -TARGET_MASK_BRANCH_PREDICT, \ | |
223 | N_("Don't use P-mnemonics for branches")}, \ | |
a824924d HPN |
224 | {"base-addresses", TARGET_MASK_BASE_ADDRESSES, \ |
225 | N_("Use addresses that allocate global registers")}, \ | |
226 | {"no-base-addresses", -TARGET_MASK_BASE_ADDRESSES, \ | |
227 | N_("Do not use addresses that allocate global registers")}, \ | |
66b8c57f HPN |
228 | {"single-exit", -TARGET_MASK_USE_RETURN_INSN, \ |
229 | N_("Generate a single exit point for each function")}, \ | |
230 | {"no-single-exit", TARGET_MASK_USE_RETURN_INSN, \ | |
231 | N_("Do not generate a single exit point for each function")}, \ | |
bcf684c7 HPN |
232 | {"", TARGET_DEFAULT, ""}} |
233 | ||
234 | /* Unfortunately, this must not reference anything in "mmix.c". */ | |
235 | #define TARGET_VERSION \ | |
91312b81 | 236 | fprintf (stderr, " (MMIX)") |
bcf684c7 HPN |
237 | |
238 | #define OVERRIDE_OPTIONS mmix_override_options () | |
239 | ||
240 | #define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \ | |
241 | do \ | |
242 | { \ | |
243 | if (LEVEL >= 1) \ | |
244 | flag_regmove = TRUE; \ | |
245 | \ | |
246 | if (SIZE || LEVEL > 1) \ | |
247 | { \ | |
248 | flag_omit_frame_pointer = TRUE; \ | |
249 | flag_strength_reduce = FALSE; \ | |
250 | } \ | |
251 | } \ | |
252 | while (0) | |
253 | ||
254 | /* This one will have to wait a little bit; right now we can't debug | |
255 | neither with or without a frame-pointer. */ | |
256 | /* #define CAN_DEBUG_WITHOUT_FP */ | |
257 | ||
258 | ||
259 | /* Node: Per-Function Data */ | |
260 | #define INIT_EXPANDERS mmix_init_expanders () | |
261 | ||
262 | ||
263 | /* Node: Storage Layout */ | |
43a88a8c | 264 | /* I see no bit-field instructions. Anyway, the common order is from low |
bcf684c7 HPN |
265 | to high, as the power of two, hence little-endian. */ |
266 | #define BITS_BIG_ENDIAN 0 | |
267 | #define BYTES_BIG_ENDIAN 1 | |
268 | #define WORDS_BIG_ENDIAN 1 | |
269 | #define FLOAT_WORDS_BIG_ENDIAN 1 | |
bcf684c7 | 270 | #define UNITS_PER_WORD 8 |
bcf684c7 HPN |
271 | |
272 | /* FIXME: This macro is correlated to MAX_FIXED_MODE_SIZE in that | |
273 | e.g. this macro must not be 8 (default, UNITS_PER_WORD) when | |
274 | MAX_FIXED_MODE_SIZE is 64 (default, DImode), or really: this must be | |
275 | set manually if MAX_FIXED_MODE_SIZE is not at least twice the register | |
276 | size. By setting it to 4, we don't have to worry about TImode things | |
277 | yet. Revisit, perhaps get TImode going or get some solution that does | |
278 | not mandate TImode or lie in other ways. */ | |
279 | #define MIN_UNITS_PER_WORD 4 | |
280 | ||
281 | /* FIXME: Promotion of modes currently generates slow code, extending | |
282 | before every operation. */ | |
d4453b7a PB |
283 | /* I'm a little bit undecided about this one. It might be beneficial to |
284 | promote all operations. */ | |
bcf684c7 | 285 | |
d4453b7a | 286 | #define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ |
bcf684c7 HPN |
287 | do { \ |
288 | if (GET_MODE_CLASS (MODE) == MODE_INT \ | |
289 | && GET_MODE_SIZE (MODE) < 8) \ | |
290 | { \ | |
291 | (MODE) = DImode; \ | |
292 | /* Do the following some time later, \ | |
293 | scrutinizing differences. */ \ | |
294 | if (0) (UNSIGNEDP) = 0; \ | |
295 | } \ | |
296 | } while (0) | |
297 | ||
bcf684c7 HPN |
298 | /* We need to align everything to 64 bits that can affect the alignment |
299 | of other types. Since address N is interpreted in MMIX as (N modulo | |
300 | access_size), we must align. */ | |
301 | #define PARM_BOUNDARY 64 | |
302 | #define STACK_BOUNDARY 64 | |
303 | #define FUNCTION_BOUNDARY 32 | |
304 | #define BIGGEST_ALIGNMENT 64 | |
305 | ||
306 | /* This one is only used in the ADA front end. */ | |
307 | #define MINIMUM_ATOMIC_ALIGNMENT 8 | |
308 | ||
309 | /* Copied from elfos.h. */ | |
310 | #define MAX_OFILE_ALIGNMENT (32768 * 8) | |
311 | ||
312 | #define DATA_ALIGNMENT(TYPE, BASIC_ALIGN) \ | |
313 | mmix_data_alignment (TYPE, BASIC_ALIGN) | |
314 | ||
315 | #define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \ | |
316 | mmix_constant_alignment (CONSTANT, BASIC_ALIGN) | |
317 | ||
318 | #define LOCAL_ALIGNMENT(TYPE, BASIC_ALIGN) \ | |
319 | mmix_local_alignment (TYPE, BASIC_ALIGN) | |
320 | ||
321 | /* Following other ports, this seems to most commonly be the word-size, | |
322 | so let's do that here too. */ | |
323 | #define EMPTY_FIELD_BOUNDARY 64 | |
324 | ||
325 | /* We chose to have this low solely for similarity with the alpha. It has | |
326 | nothing to do with passing the tests dg/c99-scope-2 and | |
327 | execute/align-1.c. Nothing. Though the tests seem wrong. Padding of | |
328 | the structure is automatically added to get alignment when needed if we | |
329 | set this to just byte-boundary. */ | |
330 | #define STRUCTURE_SIZE_BOUNDARY 8 | |
331 | ||
332 | /* The lower bits are ignored. */ | |
333 | #define STRICT_ALIGNMENT 1 | |
334 | ||
335 | ||
336 | /* Node: Type Layout */ | |
337 | ||
338 | /* It might seem more natural to have 64-bit ints on a 64-bit machine, | |
339 | but then an occasional MMIX programmer needs to know how to put a lot | |
340 | of __attribute__ stuff to get to the 8, 16 and 32-bit modes rather | |
341 | than the "intuitive" char, short and int types. */ | |
342 | #define INT_TYPE_SIZE 32 | |
343 | #define SHORT_TYPE_SIZE 16 | |
344 | #define LONG_LONG_TYPE_SIZE 64 | |
345 | ||
346 | #define FLOAT_TYPE_SIZE 32 | |
347 | #define DOUBLE_TYPE_SIZE 64 | |
348 | #define LONG_DOUBLE_TYPE_SIZE 64 | |
349 | ||
350 | #define DEFAULT_SIGNED_CHAR 1 | |
351 | ||
bcf684c7 HPN |
352 | |
353 | /* Node: Register Basics */ | |
354 | /* We tell GCC about all 256 general registers, and we also include | |
957ec0f9 | 355 | rD, rE, rH, rJ, rR and rO (in that order) so we can describe what insns |
bcf684c7 HPN |
356 | clobber them. We use a faked register for the argument pointer. It is |
357 | always eliminated towards the frame-pointer or the stack-pointer, never | |
358 | output in assembly. Any fixed register would do for this, like $255, | |
359 | but future debugging is easier when using a separate register. It | |
360 | counts as a global register for pseudorandom reasons. */ | |
957ec0f9 | 361 | #define FIRST_PSEUDO_REGISTER 263 |
bcf684c7 HPN |
362 | |
363 | /* We treat general registers with no assigned purpose as fixed. The | |
364 | stack pointer, $254, is also fixed. Register $255 is referred to as a | |
365 | temporary register in the MMIX papers, and used as such in mmixal, so | |
366 | it should not be used as a stack pointer. We set it to fixed, and use | |
367 | it "manually" at times of despair. */ | |
368 | #define FIXED_REGISTERS \ | |
369 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
370 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ | |
371 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
372 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
373 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
374 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
375 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
376 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
377 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
378 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
379 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
380 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
381 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
382 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
a824924d HPN |
383 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ |
384 | 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, \ | |
957ec0f9 | 385 | 1, 1, 0, 0, 0, 1, 1 \ |
bcf684c7 HPN |
386 | } |
387 | ||
388 | /* General registers are fixed and therefore "historically" marked | |
389 | call-used. (FIXME: This has changed). Registers $15..$31 are | |
390 | call-clobbered; we'll put arguments in $16 and up, and we need $15 for | |
391 | the MMIX register-stack "hole". */ | |
392 | #define CALL_USED_REGISTERS \ | |
393 | { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, \ | |
394 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
395 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
396 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
397 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
398 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
399 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
400 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
401 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
402 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
403 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
404 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
405 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
406 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
407 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ | |
408 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, \ | |
957ec0f9 | 409 | 1, 1, 1, 1, 1, 1, 1 \ |
bcf684c7 HPN |
410 | } |
411 | ||
412 | #define CONDITIONAL_REGISTER_USAGE mmix_conditional_register_usage () | |
413 | ||
957ec0f9 HPN |
414 | /* No INCOMING_REGNO or OUTGOING_REGNO, since those macros are not usable |
415 | for MMIX: it doesn't have a fixed register window size. FIXME: Perhaps | |
416 | we should say something about $0..$15 may sometimes be the incoming | |
417 | $16..$31. Those macros need better documentation; it looks like | |
418 | they're just bogus and that FUNCTION_INCOMING_ARG_REGNO_P and | |
419 | FUNCTION_OUTGOING_VALUE should be used where they're used. For the | |
bcf684c7 HPN |
420 | moment, do nothing; things seem to work anyway. */ |
421 | ||
957ec0f9 HPN |
422 | /* Defining LOCAL_REGNO is necessary in presence of prologue/epilogue, |
423 | else GCC will be confused that those registers aren't saved and | |
424 | restored. */ | |
425 | #define LOCAL_REGNO(REGNO) mmix_local_regno (REGNO) | |
bcf684c7 HPN |
426 | |
427 | /* Node: Allocation Order */ | |
428 | ||
429 | /* We should allocate registers from 0 to 31 by increasing number, because | |
430 | I think that's what people expect. Beyond that, just use | |
431 | call-clobbered global registers first, then call-clobbered special | |
432 | registers. Last, the fixed registers. */ | |
433 | #define MMIX_MMIXWARE_ABI_REG_ALLOC_ORDER \ | |
434 | { 0, 1, 2, 3, 4, 5, 6, 7, \ | |
435 | 8, 9, 10, 11, 12, 13, 14, 15, \ | |
436 | 16, 17, 18, 19, 20, 21, 22, 23, \ | |
437 | 24, 25, 26, 27, 28, 29, 30, 31, \ | |
438 | \ | |
439 | 252, 251, 250, 249, 248, 247, \ | |
bcf684c7 HPN |
440 | \ |
441 | 253, \ | |
442 | \ | |
443 | 258, 260, 259, \ | |
444 | \ | |
445 | 32, 33, 34, 35, 36, 37, 38, 39, \ | |
446 | 40, 41, 42, 43, 44, 45, 46, 47, \ | |
447 | 48, 49, 50, 51, 52, 53, 54, 55, \ | |
448 | 56, 57, 58, 59, 60, 61, 62, 63, \ | |
449 | 64, 65, 66, 67, 68, 69, 70, 71, \ | |
450 | 72, 73, 74, 75, 76, 77, 78, 79, \ | |
451 | 80, 81, 82, 83, 84, 85, 86, 87, \ | |
452 | 88, 89, 90, 91, 92, 93, 94, 95, \ | |
453 | 96, 97, 98, 99, 100, 101, 102, 103, \ | |
454 | 104, 105, 106, 107, 108, 109, 110, 111, \ | |
455 | 112, 113, 114, 115, 116, 117, 118, 119, \ | |
456 | 120, 121, 122, 123, 124, 125, 126, 127, \ | |
457 | 128, 129, 130, 131, 132, 133, 134, 135, \ | |
458 | 136, 137, 138, 139, 140, 141, 142, 143, \ | |
459 | 144, 145, 146, 147, 148, 149, 150, 151, \ | |
460 | 152, 153, 154, 155, 156, 157, 158, 159, \ | |
461 | 160, 161, 162, 163, 164, 165, 166, 167, \ | |
462 | 168, 169, 170, 171, 172, 173, 174, 175, \ | |
463 | 176, 177, 178, 179, 180, 181, 182, 183, \ | |
464 | 184, 185, 186, 187, 188, 189, 190, 191, \ | |
465 | 192, 193, 194, 195, 196, 197, 198, 199, \ | |
466 | 200, 201, 202, 203, 204, 205, 206, 207, \ | |
467 | 208, 209, 210, 211, 212, 213, 214, 215, \ | |
468 | 216, 217, 218, 219, 220, 221, 222, 223, \ | |
469 | 224, 225, 226, 227, 228, 229, 230, 231, \ | |
a824924d HPN |
470 | 232, 233, 234, 235, 236, 237, 238, 239, \ |
471 | 240, 241, 242, 243, 244, 245, 246, \ | |
472 | \ | |
957ec0f9 | 473 | 254, 255, 256, 257, 261, 262 \ |
bcf684c7 HPN |
474 | } |
475 | ||
476 | /* As a convenience, we put this nearby, for ease of comparison. | |
477 | First, call-clobbered registers in reverse order of assignment as | |
478 | parameters (also the top ones; not because they're parameters, but | |
479 | for continuity). | |
480 | ||
481 | Second, saved registers that go on the register-stack. | |
482 | ||
483 | Third, special registers rH, rR and rJ. They should not normally be | |
484 | allocated, but since they're call-clobbered, it is cheaper to use one | |
485 | of them than using a call-saved register for a call-clobbered use, | |
486 | assuming it is referenced a very limited number of times. Other global | |
487 | and fixed registers come next; they are never allocated. */ | |
488 | #define MMIX_GNU_ABI_REG_ALLOC_ORDER \ | |
3ec1b4cb | 489 | { 252, 251, 250, 249, 248, 247, 246, \ |
bcf684c7 | 490 | 245, 244, 243, 242, 241, 240, 239, 238, \ |
a824924d | 491 | 237, 236, 235, 234, 233, 232, 231, \ |
bcf684c7 HPN |
492 | \ |
493 | 0, 1, 2, 3, 4, 5, 6, 7, \ | |
494 | 8, 9, 10, 11, 12, 13, 14, 15, \ | |
495 | 16, 17, 18, 19, 20, 21, 22, 23, \ | |
496 | 24, 25, 26, 27, 28, 29, 30, 31, \ | |
497 | \ | |
498 | 253, \ | |
499 | \ | |
500 | 258, 260, 259, \ | |
501 | \ | |
502 | 32, 33, 34, 35, 36, 37, 38, 39, \ | |
503 | 40, 41, 42, 43, 44, 45, 46, 47, \ | |
504 | 48, 49, 50, 51, 52, 53, 54, 55, \ | |
505 | 56, 57, 58, 59, 60, 61, 62, 63, \ | |
506 | 64, 65, 66, 67, 68, 69, 70, 71, \ | |
507 | 72, 73, 74, 75, 76, 77, 78, 79, \ | |
508 | 80, 81, 82, 83, 84, 85, 86, 87, \ | |
509 | 88, 89, 90, 91, 92, 93, 94, 95, \ | |
510 | 96, 97, 98, 99, 100, 101, 102, 103, \ | |
511 | 104, 105, 106, 107, 108, 109, 110, 111, \ | |
512 | 112, 113, 114, 115, 116, 117, 118, 119, \ | |
513 | 120, 121, 122, 123, 124, 125, 126, 127, \ | |
514 | 128, 129, 130, 131, 132, 133, 134, 135, \ | |
515 | 136, 137, 138, 139, 140, 141, 142, 143, \ | |
516 | 144, 145, 146, 147, 148, 149, 150, 151, \ | |
517 | 152, 153, 154, 155, 156, 157, 158, 159, \ | |
518 | 160, 161, 162, 163, 164, 165, 166, 167, \ | |
519 | 168, 169, 170, 171, 172, 173, 174, 175, \ | |
520 | 176, 177, 178, 179, 180, 181, 182, 183, \ | |
521 | 184, 185, 186, 187, 188, 189, 190, 191, \ | |
522 | 192, 193, 194, 195, 196, 197, 198, 199, \ | |
523 | 200, 201, 202, 203, 204, 205, 206, 207, \ | |
524 | 208, 209, 210, 211, 212, 213, 214, 215, \ | |
525 | 216, 217, 218, 219, 220, 221, 222, 223, \ | |
a824924d HPN |
526 | 224, 225, 226, 227, 228, 229, 230, \ |
527 | \ | |
957ec0f9 | 528 | 254, 255, 256, 257, 261, 262 \ |
bcf684c7 HPN |
529 | } |
530 | ||
531 | /* The default one. */ | |
532 | #define REG_ALLOC_ORDER MMIX_MMIXWARE_ABI_REG_ALLOC_ORDER | |
533 | ||
534 | /* Node: Values in Registers */ | |
535 | ||
536 | #define HARD_REGNO_NREGS(REGNO, MODE) \ | |
537 | ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) \ | |
538 | / UNITS_PER_WORD) | |
539 | ||
540 | #define HARD_REGNO_MODE_OK(REGNO, MODE) 1 | |
541 | ||
542 | /* Note that no register can really be accessed in single-float mode, so | |
543 | we *can* say 1 here. FIXME: Will TRT happen for single-float, or do | |
544 | we have to punt to libgcc1.asm? */ | |
545 | #define MODES_TIEABLE_P(MODE1, MODE2) 1 | |
546 | ||
547 | ||
548 | /* Node: Leaf Functions */ | |
549 | /* (empty) */ | |
550 | ||
551 | ||
552 | /* Node: Register Classes */ | |
553 | ||
554 | enum reg_class | |
3ec1b4cb HPN |
555 | { |
556 | NO_REGS, GENERAL_REGS, REMAINDER_REG, HIMULT_REG, | |
557 | SYSTEM_REGS, ALL_REGS, LIM_REG_CLASSES | |
558 | }; | |
bcf684c7 HPN |
559 | |
560 | #define N_REG_CLASSES (int) LIM_REG_CLASSES | |
561 | ||
562 | #define REG_CLASS_NAMES \ | |
563 | {"NO_REGS", "GENERAL_REGS", "REMAINDER_REG", "HIMULT_REG", \ | |
564 | "SYSTEM_REGS", "ALL_REGS"} | |
565 | ||
566 | /* Note that the contents of each item is always 32 bits. */ | |
567 | #define REG_CLASS_CONTENTS \ | |
568 | {{0, 0, 0, 0, 0, 0, 0, 0, 0}, \ | |
569 | {~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 0x20}, \ | |
570 | {0, 0, 0, 0, 0, 0, 0, 0, 0x10}, \ | |
571 | {0, 0, 0, 0, 0, 0, 0, 0, 4}, \ | |
957ec0f9 HPN |
572 | {0, 0, 0, 0, 0, 0, 0, 0, 0x7f}, \ |
573 | {~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 0x7f}} | |
bcf684c7 HPN |
574 | |
575 | #define REGNO_REG_CLASS(REGNO) \ | |
576 | ((REGNO) <= MMIX_LAST_GENERAL_REGISTER \ | |
577 | || (REGNO) == MMIX_ARG_POINTER_REGNUM \ | |
578 | ? GENERAL_REGS \ | |
579 | : (REGNO) == MMIX_REMAINDER_REGNUM ? REMAINDER_REG \ | |
580 | : (REGNO) == MMIX_HIMULT_REGNUM ? HIMULT_REG : SYSTEM_REGS) | |
581 | ||
582 | #define BASE_REG_CLASS GENERAL_REGS | |
583 | ||
584 | #define INDEX_REG_CLASS GENERAL_REGS | |
585 | ||
586 | #define REG_CLASS_FROM_LETTER(CHAR) \ | |
587 | ((CHAR) == 'x' ? SYSTEM_REGS \ | |
588 | : (CHAR) == 'y' ? REMAINDER_REG \ | |
589 | : (CHAR) == 'z' ? HIMULT_REG : NO_REGS) | |
590 | ||
591 | #define REGNO_OK_FOR_BASE_P(REGNO) \ | |
592 | ((REGNO) <= MMIX_LAST_GENERAL_REGISTER \ | |
593 | || (REGNO) == MMIX_ARG_POINTER_REGNUM \ | |
594 | || (reg_renumber[REGNO] > 0 \ | |
595 | && reg_renumber[REGNO] <= MMIX_LAST_GENERAL_REGISTER)) | |
596 | ||
597 | #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P (REGNO) | |
598 | ||
599 | #define PREFERRED_RELOAD_CLASS(X, CLASS) \ | |
600 | mmix_preferred_reload_class (X, CLASS) | |
601 | ||
602 | #define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \ | |
603 | mmix_preferred_output_reload_class (X, CLASS) | |
604 | ||
605 | #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \ | |
606 | mmix_secondary_reload_class (CLASS, MODE, X, 1) | |
607 | ||
608 | #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \ | |
609 | mmix_secondary_reload_class (CLASS, MODE, X, 0) | |
610 | ||
611 | #define CLASS_MAX_NREGS(CLASS, MODE) HARD_REGNO_NREGS (CLASS, MODE) | |
612 | ||
613 | #define CONST_OK_FOR_LETTER_P(VALUE, C) \ | |
614 | mmix_const_ok_for_letter_p (VALUE, C) | |
615 | ||
616 | #define EXTRA_CONSTRAINT(VALUE, C) \ | |
e9fef64c | 617 | mmix_extra_constraint (VALUE, C, MMIX_REG_OK_STRICT) |
bcf684c7 HPN |
618 | |
619 | /* Do we need anything serious here? Yes, any FLOT constant. */ | |
620 | #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ | |
621 | mmix_const_double_ok_for_letter_p (VALUE, C) | |
622 | ||
623 | ||
624 | /* Node: Frame Layout */ | |
625 | ||
626 | #define STACK_GROWS_DOWNWARD | |
627 | #define FRAME_GROWS_DOWNWARD | |
628 | ||
629 | #define STARTING_FRAME_OFFSET \ | |
630 | mmix_starting_frame_offset () | |
631 | ||
3ec1b4cb | 632 | #define FIRST_PARM_OFFSET(FUNDECL) 0 |
bcf684c7 HPN |
633 | |
634 | #define DYNAMIC_CHAIN_ADDRESS(FRAMEADDR) \ | |
635 | mmix_dynamic_chain_address (FRAMEADDR) | |
636 | ||
637 | /* FIXME: It seems RETURN_ADDR_OFFSET is undocumented. */ | |
638 | ||
639 | #define SETUP_FRAME_ADDRESSES() \ | |
640 | mmix_setup_frame_addresses () | |
641 | ||
642 | #define RETURN_ADDR_RTX(COUNT, FRAME) \ | |
643 | mmix_return_addr_rtx (COUNT, FRAME) | |
644 | ||
645 | /* It's in rJ before we store it somewhere. */ | |
646 | #define INCOMING_RETURN_ADDR_RTX \ | |
647 | gen_rtx_REG (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM) | |
648 | ||
649 | /* FIXME: This does not seem properly documented or cross-indexed. | |
650 | Nowhere except in the code does it say it *has* to be in the range | |
651 | 0..255, or else it will be truncated. That goes for the default too. */ | |
652 | #define DWARF_FRAME_RETURN_COLUMN \ | |
653 | DWARF_FRAME_REGNUM (MMIX_INCOMING_RETURN_ADDRESS_REGNUM) | |
654 | ||
655 | /* No return address is stored there. */ | |
656 | #define INCOMING_FRAME_SP_OFFSET 0 | |
657 | ||
658 | /* Node: Stack Checking */ | |
659 | /* (empty) */ | |
660 | ||
661 | ||
662 | /* Node: Exception Handling */ | |
663 | ||
664 | #define EH_RETURN_DATA_REGNO(N) \ | |
665 | mmix_eh_return_data_regno (N) | |
666 | ||
667 | #define EH_RETURN_STACKADJ_RTX \ | |
668 | mmix_eh_return_stackadj_rtx () | |
669 | ||
670 | #define EH_RETURN_HANDLER_RTX \ | |
671 | mmix_eh_return_handler_rtx () | |
672 | ||
673 | #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ | |
674 | mmix_asm_preferred_eh_data_format (CODE, GLOBAL) | |
675 | ||
676 | /* Node: Frame Registers */ | |
677 | #define STACK_POINTER_REGNUM MMIX_STACK_POINTER_REGNUM | |
678 | ||
679 | /* Perhaps we can use HARD_FRAME_POINTER_REGNUM and decide later on | |
680 | what register we want to use. */ | |
681 | #define FRAME_POINTER_REGNUM MMIX_FRAME_POINTER_REGNUM | |
682 | #define ARG_POINTER_REGNUM MMIX_ARG_POINTER_REGNUM | |
683 | ||
684 | #define STATIC_CHAIN_REGNUM MMIX_STATIC_CHAIN_REGNUM | |
685 | ||
686 | ||
687 | /* Node: Elimination */ | |
688 | /* FIXME: Is this requirement built-in? Anyway, we should try to get rid | |
689 | of it; we can deduce the value. */ | |
690 | #define FRAME_POINTER_REQUIRED (nonlocal_goto_stack_level != NULL_RTX) | |
691 | ||
692 | /* The frame-pointer is stored in a location that either counts to the | |
693 | offset of incoming parameters, or that counts to the offset of the | |
694 | frame, so we can't use a single offset. We therefore eliminate those | |
695 | two separately. */ | |
696 | #define ELIMINABLE_REGS \ | |
697 | {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ | |
698 | {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ | |
699 | {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}} | |
700 | ||
701 | /* We need not worry about when the frame-pointer is required for other | |
702 | reasons; GCC takes care of those cases. */ | |
703 | #define CAN_ELIMINATE(FROM, TO) 1 | |
704 | ||
705 | #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ | |
392fc5b0 | 706 | (OFFSET) = mmix_initial_elimination_offset (FROM, TO) |
bcf684c7 HPN |
707 | |
708 | ||
709 | /* Node: Stack Arguments */ | |
710 | ||
711 | #define ACCUMULATE_OUTGOING_ARGS 1 | |
712 | ||
713 | #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACKSIZE) 0 | |
714 | ||
715 | ||
716 | /* Node: Register Arguments */ | |
717 | #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ | |
718 | mmix_function_arg (&(CUM), MODE, TYPE, NAMED, 0) | |
719 | ||
720 | #define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \ | |
721 | mmix_function_arg (&(CUM), MODE, TYPE, NAMED, 1) | |
722 | ||
723 | #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \ | |
724 | mmix_function_arg_pass_by_reference (&(CUM), MODE, TYPE, NAMED) | |
725 | ||
726 | /* This *sounds* good, but does not seem to be implemented correctly to | |
727 | be a win; at least it wasn't in 2.7.2. FIXME: Check and perhaps | |
e9986d3a HPN |
728 | replace with a big comment. |
729 | The definition needs to match or be a subset of | |
730 | FUNCTION_ARG_PASS_BY_REFERENCE, since not all callers check that before | |
109b748d | 731 | usage. Watch lots of C++ testcases fail if set to 1, for example |
e9986d3a HPN |
732 | g++.dg/init/byval1.C. */ |
733 | #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \ | |
734 | mmix_function_arg_pass_by_reference (&(CUM), MODE, TYPE, NAMED) | |
bcf684c7 | 735 | |
6c535c69 | 736 | typedef struct { int regs; int lib; } CUMULATIVE_ARGS; |
bcf684c7 | 737 | |
0f6937fe | 738 | #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \ |
6c535c69 | 739 | ((CUM).regs = 0, (CUM).lib = ((LIBNAME) != 0)) |
bcf684c7 HPN |
740 | |
741 | #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ | |
742 | ((CUM).regs \ | |
743 | = ((MUST_PASS_IN_STACK (MODE, TYPE)) \ | |
744 | || (MMIX_FUNCTION_ARG_SIZE (MODE, TYPE) > 8 \ | |
745 | && !TARGET_LIBFUNC && !(CUM).lib)) \ | |
746 | ? (MMIX_MAX_ARGS_IN_REGS) + 1 \ | |
747 | : (CUM).regs + (7 + (MMIX_FUNCTION_ARG_SIZE (MODE, TYPE))) / 8) | |
748 | ||
749 | #define FUNCTION_ARG_REGNO_P(REGNO) \ | |
750 | mmix_function_arg_regno_p (REGNO, 0) | |
751 | ||
752 | #define FUNCTION_INCOMING_ARG_REGNO_P(REGNO) \ | |
753 | mmix_function_arg_regno_p (REGNO, 1) | |
754 | ||
755 | ||
756 | /* Node: Register Arguments */ | |
757 | ||
758 | #define FUNCTION_VALUE(VALTYPE, FUNC) \ | |
759 | gen_rtx_REG (TYPE_MODE (VALTYPE), MMIX_RETURN_VALUE_REGNUM) | |
760 | ||
761 | /* This needs to take care of the register hole for complex return values. */ | |
762 | #define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \ | |
763 | mmix_function_outgoing_value (VALTYPE, FUNC) | |
764 | ||
765 | #define LIBCALL_VALUE(MODE) \ | |
4b32269b | 766 | gen_rtx_REG (MODE, MMIX_RETURN_VALUE_REGNUM) |
bcf684c7 HPN |
767 | |
768 | #define FUNCTION_VALUE_REGNO_P(REGNO) \ | |
4b32269b | 769 | mmix_function_value_regno_p (REGNO) |
bcf684c7 HPN |
770 | |
771 | ||
bcf684c7 HPN |
772 | /* Node: Caller Saves */ |
773 | /* (empty) */ | |
774 | ||
775 | ||
776 | /* Node: Function Entry */ | |
777 | ||
778 | /* See mmix.c for TARGET_ASM_FUNCTION_PROLOGUE and | |
779 | TARGET_ASM_FUNCTION_EPILOGUE. */ | |
780 | ||
781 | /* We need to say that the epilogue uses the return address, so the | |
782 | initial-value machinery restores it. FIXME: Some targets | |
783 | conditionalize on "reload_completed &&". Investigate difference. | |
784 | FIXME: Not needed if nonlocal_goto_stack_level. */ | |
785 | #define EPILOGUE_USES(REGNO) \ | |
786 | ((REGNO) == MMIX_INCOMING_RETURN_ADDRESS_REGNUM) | |
787 | ||
bcf684c7 HPN |
788 | /* Node: Profiling */ |
789 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
790 | mmix_function_profiler (FILE, LABELNO) | |
791 | ||
bcf684c7 HPN |
792 | /* Node: Varargs */ |
793 | ||
bcf684c7 HPN |
794 | /* FIXME: This and other EXPAND_BUILTIN_VA_... target macros are not |
795 | documented, although used by several targets. */ | |
796 | #define EXPAND_BUILTIN_VA_ARG(VALIST, TYPE) \ | |
797 | mmix_expand_builtin_va_arg (VALIST, TYPE) | |
798 | ||
799 | /* Node: Trampolines */ | |
800 | ||
801 | #define TRAMPOLINE_TEMPLATE(FILE) \ | |
802 | mmix_trampoline_template (FILE) | |
803 | ||
804 | #define TRAMPOLINE_SIZE mmix_trampoline_size | |
805 | #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \ | |
806 | mmix_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN) | |
807 | ||
808 | ||
bcf684c7 HPN |
809 | /* Node: Addressing Modes */ |
810 | ||
811 | #define CONSTANT_ADDRESS_P(X) \ | |
812 | mmix_constant_address_p (X) | |
813 | ||
814 | #define MAX_REGS_PER_ADDRESS 2 | |
815 | ||
816 | #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \ | |
817 | if (mmix_legitimate_address (MODE, X, MMIX_REG_OK_STRICT)) \ | |
818 | goto LABEL | |
819 | ||
820 | #ifndef REG_OK_STRICT | |
821 | # define REG_OK_FOR_BASE_P(X) \ | |
822 | (REGNO (X) <= MMIX_LAST_GENERAL_REGISTER \ | |
823 | || REGNO (X) == MMIX_ARG_POINTER_REGNUM \ | |
824 | || REGNO (X) >= FIRST_PSEUDO_REGISTER) | |
825 | #else | |
826 | # define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) | |
827 | #endif /* REG_OK_STRICT */ | |
828 | ||
829 | #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X) | |
830 | ||
bcf684c7 HPN |
831 | #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) |
832 | ||
833 | #define LEGITIMATE_CONSTANT_P(X) \ | |
834 | mmix_legitimate_constant_p (X) | |
835 | ||
836 | ||
837 | /* Node: Condition Code */ | |
838 | ||
bcf684c7 HPN |
839 | #define SELECT_CC_MODE(OP, X, Y) \ |
840 | mmix_select_cc_mode (OP, X, Y) | |
841 | ||
38e18619 HPN |
842 | /* A definition of CANONICALIZE_COMPARISON that changed LE and GT |
843 | comparisons with -1 to LT and GE respectively, and LT, LTU, GE or GEU | |
844 | comparisons with 256 to 255 and LE, LEU, GT and GTU has been | |
845 | ineffective; the code path for performing the changes did not trig for | |
109b748d | 846 | neither the GCC testsuite nor ghostscript-6.52 nor Knuth's mmix.tar.gz |
38e18619 HPN |
847 | itself (core GCC functionality supposedly handling it) with sources |
848 | from 2002-06-06. */ | |
bcf684c7 HPN |
849 | |
850 | #define REVERSIBLE_CC_MODE(MODE) \ | |
851 | mmix_reversible_cc_mode (MODE) | |
852 | ||
853 | ||
854 | /* Node: Costs */ | |
855 | ||
bcf684c7 HPN |
856 | /* The special registers can only move to and from general regs, and we |
857 | need to check that their constraints match, so say 3 for them. */ | |
858 | /* WARNING: gcc-2.7.2.2 i686-pc-linux-gnulibc1 (as shipped with RH 4.2) | |
859 | miscompiles reload1.c:reload_cse_simplify_set; a call to | |
860 | reload_cse_regno_equal_p is missing when checking if a substitution of | |
861 | a register setting is valid if this is defined to just the expression | |
862 | in mmix_register_move_cost. | |
863 | ||
864 | Symptom: a (all?) register setting is optimized away for e.g. | |
865 | "char *p1(char *p) { return p+1; }" and the value of register zero ($0) | |
866 | is returned. | |
867 | ||
868 | We can workaround by making this a function call - unknown if this | |
869 | causes dire speed effects. */ | |
870 | #define REGISTER_MOVE_COST(MODE, FROM, TO) \ | |
871 | mmix_register_move_cost (MODE, FROM, TO) | |
872 | ||
873 | #define SLOW_BYTE_ACCESS 0 | |
874 | ||
875 | ||
876 | /* Node: Sections */ | |
877 | ||
878 | /* This must be a constant string, since it's used in crtstuff.c. */ | |
879 | #define TEXT_SECTION_ASM_OP \ | |
880 | "\t.text ! mmixal:= 9H LOC 8B" | |
881 | ||
882 | /* FIXME: Not documented. */ | |
883 | #define DATA_SECTION_ASM_OP \ | |
884 | mmix_data_section_asm_op () | |
885 | ||
d48bc59a | 886 | #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata" |
bcf684c7 | 887 | |
bcf684c7 HPN |
888 | /* Node: PIC */ |
889 | /* (empty) */ | |
890 | ||
891 | ||
892 | /* Node: File Framework */ | |
893 | ||
bcf684c7 HPN |
894 | /* While any other punctuation character but ";" would do, we prefer "%" |
895 | or "!"; "!" is an unary operator and so will not be mistakenly included | |
896 | in correctly formed expressions. The hash character adds mass; catches | |
897 | the eye. We can't have it as a comment char by itself, since it's a | |
898 | hex-number prefix. */ | |
899 | #define ASM_COMMENT_START "!#" | |
900 | ||
901 | /* These aren't currently functional. We just keep them as markers. */ | |
902 | #define ASM_APP_ON "%APP\n" | |
903 | #define ASM_APP_OFF "%NO_APP\n" | |
904 | ||
905 | #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME) \ | |
906 | mmix_asm_output_source_filename (STREAM, NAME) | |
907 | ||
908 | #define OUTPUT_QUOTED_STRING(STREAM, STRING) \ | |
909 | mmix_output_quoted_string (STREAM, STRING, strlen (STRING)) | |
910 | ||
a8d0467e | 911 | #define ASM_OUTPUT_SOURCE_LINE(STREAM, LINE, COUNTER) \ |
bcf684c7 HPN |
912 | mmix_asm_output_source_line (STREAM, LINE) |
913 | ||
914 | #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section | |
915 | ||
916 | ||
917 | /* Node: Data Output */ | |
918 | ||
bcf684c7 HPN |
919 | #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \ |
920 | mmix_asm_output_ascii (STREAM, PTR, LEN) | |
921 | ||
bcf684c7 HPN |
922 | /* Node: Uninitialized Data */ |
923 | ||
924 | #define ASM_OUTPUT_ALIGNED_COMMON(ST, N, S, A) \ | |
925 | mmix_asm_output_aligned_common (ST, N, S, A) | |
926 | ||
927 | #define ASM_OUTPUT_ALIGNED_LOCAL(ST, N, S, A) \ | |
928 | mmix_asm_output_aligned_local (ST, N, S, A) | |
929 | ||
930 | ||
931 | /* Node: Label Output */ | |
932 | ||
933 | #define ASM_OUTPUT_LABEL(STREAM, NAME) \ | |
934 | mmix_asm_output_label (STREAM, NAME) | |
935 | ||
936 | #define ASM_DECLARE_REGISTER_GLOBAL(STREAM, DECL, REGNO, NAME) \ | |
937 | mmix_asm_declare_register_global (STREAM, DECL, REGNO, NAME) | |
938 | ||
5eb99654 | 939 | #define GLOBAL_ASM_OP "\t.global " |
bcf684c7 HPN |
940 | |
941 | #define ASM_WEAKEN_LABEL(STREAM, NAME) \ | |
942 | mmix_asm_weaken_label (STREAM, NAME) | |
943 | ||
944 | #define MAKE_DECL_ONE_ONLY(DECL) \ | |
945 | mmix_make_decl_one_only (DECL) | |
946 | ||
947 | #define ASM_OUTPUT_LABELREF(STREAM, NAME) \ | |
948 | mmix_asm_output_labelref (STREAM, NAME) | |
949 | ||
bcf684c7 HPN |
950 | /* We insert a ":" to disambiguate against user symbols like L5. */ |
951 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ | |
75540760 | 952 | sprintf (LABEL, "*%s:%ld", PREFIX, (long)(NUM)) |
bcf684c7 HPN |
953 | |
954 | /* Insert "::"; these are rarer than internal labels. FIXME: Make sure no | |
955 | ":" is seen in the object file; we don't really want that mmixal | |
956 | feature visible there. We don't want the default, which uses a dot; | |
957 | that'd be incompatible with mmixal. */ | |
4977bab6 | 958 | #define ASM_PN_FORMAT "%s::%lu" |
bcf684c7 HPN |
959 | |
960 | #define ASM_OUTPUT_DEF(STREAM, NAME, VALUE) \ | |
961 | mmix_asm_output_def (STREAM, NAME, VALUE) | |
962 | ||
bcf684c7 | 963 | /* Node: Macros for Initialization */ |
38e18619 HPN |
964 | /* We're compiling to ELF and linking to MMO; fundamental ELF features |
965 | that GCC depend on are there. */ | |
bcf684c7 HPN |
966 | |
967 | /* These must be constant strings, since they're used in crtstuff.c. */ | |
968 | #define INIT_SECTION_ASM_OP "\t.section .init,\"ax\" ! mmixal-incompatible" | |
969 | ||
970 | #define FINI_SECTION_ASM_OP "\t.section .fini,\"ax\" ! mmixal-incompatible" | |
971 | ||
972 | #define OBJECT_FORMAT_ELF | |
973 | ||
974 | ||
975 | /* Node: Instruction Output */ | |
976 | ||
977 | /* The non-$ register names must be prefixed with ":", since they're | |
978 | affected by PREFIX. We provide the non-colon names as additional | |
979 | names. */ | |
980 | #define REGISTER_NAMES \ | |
981 | {"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", \ | |
982 | "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", \ | |
983 | "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", \ | |
984 | "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", \ | |
985 | "$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39", \ | |
986 | "$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47", \ | |
987 | "$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55", \ | |
988 | "$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63", \ | |
989 | "$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71", \ | |
990 | "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", \ | |
991 | "$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87", \ | |
992 | "$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95", \ | |
993 | "$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103", \ | |
994 | "$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111", \ | |
995 | "$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119", \ | |
996 | "$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127", \ | |
997 | "$128", "$129", "$130", "$131", "$132", "$133", "$134", "$135", \ | |
998 | "$136", "$137", "$138", "$139", "$140", "$141", "$142", "$143", \ | |
999 | "$144", "$145", "$146", "$147", "$148", "$149", "$150", "$151", \ | |
1000 | "$152", "$153", "$154", "$155", "$156", "$157", "$158", "$159", \ | |
1001 | "$160", "$161", "$162", "$163", "$164", "$165", "$166", "$167", \ | |
1002 | "$168", "$169", "$170", "$171", "$172", "$173", "$174", "$175", \ | |
1003 | "$176", "$177", "$178", "$179", "$180", "$181", "$182", "$183", \ | |
1004 | "$184", "$185", "$186", "$187", "$188", "$189", "$190", "$191", \ | |
1005 | "$192", "$193", "$194", "$195", "$196", "$197", "$198", "$199", \ | |
1006 | "$200", "$201", "$202", "$203", "$204", "$205", "$206", "$207", \ | |
1007 | "$208", "$209", "$210", "$211", "$212", "$213", "$214", "$215", \ | |
1008 | "$216", "$217", "$218", "$219", "$220", "$221", "$222", "$223", \ | |
1009 | "$224", "$225", "$226", "$227", "$228", "$229", "$230", "$231", \ | |
1010 | "$232", "$233", "$234", "$235", "$236", "$237", "$238", "$239", \ | |
1011 | "$240", "$241", "$242", "$243", "$244", "$245", "$246", "$247", \ | |
1012 | "$248", "$249", "$250", "$251", "$252", "$253", "$254", "$255", \ | |
957ec0f9 | 1013 | ":rD", ":rE", ":rH", ":rJ", ":rR", "ap_!BAD!", ":rO"} |
bcf684c7 HPN |
1014 | |
1015 | #define ADDITIONAL_REGISTER_NAMES \ | |
1016 | {{"sp", 254}, {":sp", 254}, {"rD", 256}, {"rE", 257}, \ | |
957ec0f9 | 1017 | {"rH", 258}, {"rJ", MMIX_rJ_REGNUM}, {"rO", MMIX_rO_REGNUM}} |
bcf684c7 HPN |
1018 | |
1019 | #define PRINT_OPERAND(STREAM, X, CODE) \ | |
1020 | mmix_print_operand (STREAM, X, CODE) | |
1021 | ||
1022 | #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ | |
1023 | mmix_print_operand_punct_valid_p (CODE) | |
1024 | ||
1025 | #define PRINT_OPERAND_ADDRESS(STREAM, X) \ | |
1026 | mmix_print_operand_address (STREAM, X) | |
1027 | ||
bcf684c7 HPN |
1028 | #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \ |
1029 | mmix_asm_output_reg_push (STREAM, REGNO) | |
1030 | ||
1031 | #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \ | |
1032 | mmix_asm_output_reg_pop (STREAM, REGNO) | |
1033 | ||
1034 | ||
1035 | /* Node: Dispatch Tables */ | |
1036 | ||
1037 | /* We define both types, since SImode is the better, but DImode the only | |
1038 | possible for mmixal so that's the one actually used. */ | |
1039 | #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \ | |
1040 | mmix_asm_output_addr_diff_elt (STREAM, BODY, VALUE, REL) | |
1041 | ||
1042 | #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \ | |
1043 | mmix_asm_output_addr_vec_elt (STREAM, VALUE) | |
1044 | ||
1045 | ||
bcf684c7 HPN |
1046 | /* Node: Exception Region Output */ |
1047 | /* (empty) */ | |
1048 | ||
1049 | /* Node: Alignment Output */ | |
1050 | ||
1051 | #define ASM_OUTPUT_SKIP(STREAM, NBYTES) \ | |
1052 | mmix_asm_output_skip (STREAM, NBYTES) | |
1053 | ||
1054 | #define ASM_OUTPUT_ALIGN(STREAM, POWER) \ | |
1055 | mmix_asm_output_align (STREAM, POWER) | |
1056 | ||
1057 | ||
1058 | /* Node: All Debuggers */ | |
1059 | ||
1060 | #define DBX_REGISTER_NUMBER(REGNO) \ | |
1061 | mmix_dbx_register_number (REGNO) | |
1062 | ||
1063 | ||
1064 | /* Node: DBX Options */ | |
1065 | /* (empty) */ | |
1066 | /* Node: DBX Hooks */ | |
1067 | /* (empty) */ | |
1068 | /* Node: File Names and DBX */ | |
1069 | /* (empty) */ | |
1070 | ||
1071 | ||
1072 | /* Node: SDB and DWARF */ | |
23532de9 | 1073 | #define DWARF2_DEBUGGING_INFO 1 |
bcf684c7 HPN |
1074 | #define DWARF2_ASM_LINE_DEBUG_INFO 1 |
1075 | ||
bcf684c7 HPN |
1076 | /* Node: Misc */ |
1077 | ||
1078 | #define PREDICATE_CODES \ | |
1079 | {"mmix_reg_cc_operand", {SUBREG, REG}}, \ | |
1080 | {"mmix_foldable_comparison_operator", \ | |
1081 | {NE, EQ, GE, GT, LE, LT}}, \ | |
1082 | /* All '<', actually. */ \ | |
1083 | {"mmix_comparison_operator", \ | |
1084 | {NE, EQ, GE, GT, LE, LT, GEU, GTU, LEU, \ | |
1085 | LTU, UNORDERED, ORDERED, UNEQ, UNGE, UNLE, \ | |
1086 | UNLT, LTGT}}, \ | |
1087 | {"mmix_symbolic_or_address_operand", \ | |
1088 | {SYMBOL_REF, LABEL_REF, CONST, \ | |
1089 | SUBREG, REG, PLUS}}, \ | |
1090 | {"mmix_reg_or_constant_operand", \ | |
1091 | {CONST_INT, CONST_DOUBLE, SUBREG, REG}}, \ | |
bcf684c7 HPN |
1092 | {"mmix_reg_or_8bit_operand", \ |
1093 | {CONST_INT, CONST_DOUBLE, SUBREG, REG}}, \ | |
1094 | {"mmix_reg_or_0_operand", \ | |
1095 | {CONST_INT, CONST_DOUBLE, SUBREG, REG}}, | |
1096 | ||
1097 | #define SPECIAL_MODE_PREDICATES "mmix_symbolic_or_address_operand", | |
1098 | ||
1099 | /* There's no way to get a PC-relative offset into tables for SImode, so | |
1100 | for the moment we have absolute entries in DImode. | |
1101 | When we're going ELF, these should be SImode and 1. */ | |
1102 | #define CASE_VECTOR_MODE DImode | |
1103 | #define CASE_VECTOR_PC_RELATIVE 0 | |
1104 | ||
1105 | #define WORD_REGISTER_OPERATIONS | |
1106 | ||
1107 | /* We have a choice, which makes this yet another parameter to tweak. The | |
1108 | gut feeling is currently that SIGN_EXTEND wins; "int" is more frequent | |
1109 | than "unsigned int", and we have signed characters. FIXME: measure. */ | |
1110 | #define LOAD_EXTEND_OP(MODE) (TARGET_ZERO_EXTEND ? ZERO_EXTEND : SIGN_EXTEND) | |
1111 | ||
bcf684c7 HPN |
1112 | #define MOVE_MAX 8 |
1113 | ||
1114 | #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 | |
1115 | ||
06f31100 RS |
1116 | /* ??? MMIX allows a choice of STORE_FLAG_VALUE. Revisit later, |
1117 | we don't have scc expanders yet. */ | |
bcf684c7 HPN |
1118 | |
1119 | #define Pmode DImode | |
1120 | ||
1121 | #define FUNCTION_MODE QImode | |
1122 | ||
bcf684c7 HPN |
1123 | #define NO_IMPLICIT_EXTERN_C |
1124 | ||
32f0ffb3 | 1125 | #define HANDLE_SYSV_PRAGMA 1 |
bcf684c7 HPN |
1126 | |
1127 | /* These are checked. */ | |
1128 | #define DOLLARS_IN_IDENTIFIERS 0 | |
1129 | #define NO_DOLLAR_IN_LABEL | |
1130 | #define NO_DOT_IN_LABEL | |
1131 | ||
1132 | #endif /* GCC_MMIX_H */ | |
1133 | /* | |
1134 | * Local variables: | |
1135 | * eval: (c-set-style "gnu") | |
1136 | * indent-tabs-mode: t | |
1137 | * End: | |
1138 | */ |