Debian Codegraph @

gcc/config/mmix/mmix.h

raw
1 /* Definitions of target machine for GNU compiler, for MMIX.
2 Copyright (C) 2000-2025 Free Software Foundation, Inc.
3 Contributed by Hans-Peter Nilsson ([email protected])
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
9 the Free Software Foundation; either version 3, or (at your option)
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
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #ifndef GCC_MMIX_H
22 #define GCC_MMIX_H
23
24 /* First, some local helper macros. Note that the "default" value of
25 FIXED_REGISTERS, CALL_USED_REGISTERS, REG_ALLOC_ORDER and
26 REG_CLASS_CONTENTS depend on these values. */
27 #define MMIX_RESERVED_GNU_ARG_0_REGNUM 231
28 #define MMIX_FIRST_ARG_REGNUM \
29 (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 16)
30 #define MMIX_FIRST_INCOMING_ARG_REGNUM \
31 (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 0)
32 #define MMIX_MAX_ARGS_IN_REGS 16
33
34 /* FIXME: This one isn't fully implemented yet. Return values larger than
35 one register are passed by reference in MMIX_STRUCT_VALUE_REGNUM by the
36 caller, except for return values of type "complex". */
37 #define MMIX_MAX_REGS_FOR_VALUE 16
38 #define MMIX_RETURN_VALUE_REGNUM \
39 (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 15)
40 #define MMIX_OUTGOING_RETURN_VALUE_REGNUM \
41 (TARGET_ABI_GNU ? MMIX_RESERVED_GNU_ARG_0_REGNUM : 0)
42 #define MMIX_STRUCT_VALUE_REGNUM 251
43 #define MMIX_STATIC_CHAIN_REGNUM 252
44 #define MMIX_FRAME_POINTER_REGNUM 253
45 #define MMIX_STACK_POINTER_REGNUM 254
46 #define MMIX_LAST_GENERAL_REGISTER 255
47 #define MMIX_INCOMING_RETURN_ADDRESS_REGNUM MMIX_rJ_REGNUM
48 #define MMIX_HIMULT_REGNUM 258
49 #define MMIX_REMAINDER_REGNUM MMIX_rR_REGNUM
50 #define MMIX_ARG_POINTER_REGNUM 261
51 #define MMIX_rO_REGNUM 262
52 #define MMIX_LAST_STACK_REGISTER_REGNUM 31
53
54 /* Four registers; "ideally, these registers should be call-clobbered", so
55 just grab a bunch of the common clobbered registers. FIXME: Last
56 registers of return-value should be used, with an error if there's a
57 return-value (that collides in size). */
58 #define MMIX_EH_RETURN_DATA_REGNO_START (MMIX_STRUCT_VALUE_REGNUM - 4)
59
60 /* Try to keep the definitions from running away on their own. */
61 #if (MMIX_EH_RETURN_DATA_REGNO_START \
62 != MMIX_RESERVED_GNU_ARG_0_REGNUM + MMIX_MAX_ARGS_IN_REGS)
63 #error MMIX register definition inconsistency
64 #endif
65
66 #if (MMIX_MAX_REGS_FOR_VALUE + MMIX_MAX_ARGS_IN_REGS > 32)
67 #error MMIX parameters and return values bad, more than 32 registers
68 #endif
69
70 /* This chosen as "a call-clobbered hard register that is otherwise
71 untouched by the epilogue". */
72 #define MMIX_EH_RETURN_STACKADJ_REGNUM MMIX_STATIC_CHAIN_REGNUM
73
74 #define MMIX_FUNCTION_ARG_SIZE(MODE, TYPE) \
75 ((MODE) != BLKmode ? GET_MODE_SIZE (MODE) : int_size_in_bytes (TYPE))
76
77 /* Per-function machine data. This is normally an opaque type just
78 defined and used in the tm.c file, but we need to see the definition in
79 mmix.md too. */
80 struct GTY(()) machine_function
81 {
82 int has_landing_pad;
83 int highest_saved_stack_register;
84 int in_prologue;
85 };
86
87 /* For these target macros, there is no generic documentation here. You
88 should read `Using and Porting GCC' for that. Only comments specific
89 to the MMIX target are here.
90
91 There are however references to the specific texinfo node (comments
92 with "Node:"), so there should be little or nothing amiss. Probably
93 the opposite, since we don't have to care about old littering and
94 soon outdated generic comments. */
95
96 /* Node: Driver */
97
98 /* User symbols are in the same name-space as built-in symbols, but we
99 don't need the built-in symbols, so remove those and instead apply
100 stricter operand checking. Don't warn when expanding insns. */
101 #define ASM_SPEC "-no-predefined-syms -x"
102
103 /* Pass on -mset-program-start=N and -mset-data-start=M to the linker.
104 Provide default program start 0x100 unless -mno-set-program-start.
105 Don't do this if linking relocatably, with -r. For a final link,
106 produce mmo, unless ELF is requested or when linking relocatably. */
107 #define LINK_SPEC \
108 "%{mset-program-start=*:--defsym __.MMIX.start..text=%*}\
109 %{mset-data-start=*:--defsym __.MMIX.start..data=%*}\
110 %{!mset-program-start=*:\
111 %{!mno-set-program-start:\
112 %{!r:--defsym __.MMIX.start..text=0x100}}}\
113 %{!melf:%{!r:-m mmo}}%{melf|r:-m elf64mmix}"
114
115 /* FIXME: There's no provision for profiling here. */
116 #define STARTFILE_SPEC \
117 "crti%O%s crtbegin%O%s"
118
119 #define ENDFILE_SPEC "crtend%O%s crtn%O%s"
120
121 /* Node: Run-time Target */
122
123 /* Define __LONG_MAX__, since we're advised not to change glimits.h. */
124 #define TARGET_CPU_CPP_BUILTINS() \
125 do \
126 { \
127 builtin_define ("__mmix__"); \
128 builtin_define ("__MMIX__"); \
129 if (TARGET_ABI_GNU) \
130 builtin_define ("__MMIX_ABI_GNU__"); \
131 else \
132 builtin_define ("__MMIX_ABI_MMIXWARE__"); \
133 } \
134 while (0)
135
136 #define TARGET_DEFAULT \
137 (MASK_BRANCH_PREDICT | MASK_BASE_ADDRESSES | MASK_USE_RETURN_INSN)
138
139
140 /* Node: Per-Function Data */
141 #define INIT_EXPANDERS mmix_init_expanders ()
142
143
144 /* Node: Storage Layout */
145 /* I see no bit-field instructions. Anyway, the common order is from low
146 to high, as the power of two, hence little-endian. */
147 #define BITS_BIG_ENDIAN 0
148 #define BYTES_BIG_ENDIAN 1
149 #define WORDS_BIG_ENDIAN 1
150 #define FLOAT_WORDS_BIG_ENDIAN 1
151 #define UNITS_PER_WORD 8
152
153 /* We need to align everything to 64 bits that can affect the alignment
154 of other types. Since address N is interpreted in MMIX as (N modulo
155 access_size), we must align. */
156 #define PARM_BOUNDARY 64
157 #define STACK_BOUNDARY 64
158 #define FUNCTION_BOUNDARY 32
159 #define BIGGEST_ALIGNMENT 64
160
161 /* This one is only used in the ADA front end. */
162 #define MINIMUM_ATOMIC_ALIGNMENT 8
163
164 /* Copied from elfos.h. */
165 #define MAX_OFILE_ALIGNMENT (32768 * 8)
166
167 #define DATA_ABI_ALIGNMENT(TYPE, BASIC_ALIGN) \
168 mmix_data_alignment (TYPE, BASIC_ALIGN)
169
170 #define LOCAL_ALIGNMENT(TYPE, BASIC_ALIGN) \
171 mmix_local_alignment (TYPE, BASIC_ALIGN)
172
173 /* Following other ports, this seems to most commonly be the word-size,
174 so let's do that here too. */
175 #define EMPTY_FIELD_BOUNDARY 64
176
177 /* We chose to have this low solely for similarity with the alpha. It has
178 nothing to do with passing the tests dg/c99-scope-2 and
179 execute/align-1.c. Nothing. Though the tests seem wrong. Padding of
180 the structure is automatically added to get alignment when needed if we
181 set this to just byte-boundary. */
182 #define STRUCTURE_SIZE_BOUNDARY 8
183
184 /* The lower bits are ignored. */
185 #define STRICT_ALIGNMENT 1
186
187 /* With the default, (64 bits), most things still work, but code for
188 e.g. __int128 will be suboptimal. */
189 #define MAX_FIXED_MODE_SIZE (2 * BITS_PER_WORD)
190
191 /* Node: Type Layout */
192
193 /* It might seem more natural to have 64-bit ints on a 64-bit machine,
194 but then an occasional MMIX programmer needs to know how to put a lot
195 of __attribute__ stuff to get to the 8, 16 and 32-bit modes rather
196 than the "intuitive" char, short and int types. */
197 #define INT_TYPE_SIZE 32
198 #define SHORT_TYPE_SIZE 16
199 #define LONG_LONG_TYPE_SIZE 64
200
201 #define DEFAULT_SIGNED_CHAR 1
202
203
204 /* Node: Register Basics */
205 /* We tell GCC about all 256 general registers, and we also include
206 rD, rE, rH, rJ, rR and rO (in that order) so we can describe what insns
207 clobber them. We use a faked register for the argument pointer. It is
208 always eliminated towards the frame-pointer or the stack-pointer, never
209 output in assembly. Any fixed register would do for this, like $255,
210 but future debugging is easier when using a separate register. It
211 counts as a global register for pseudorandom reasons. */
212 #define FIRST_PSEUDO_REGISTER 263
213
214 /* We treat general registers with no assigned purpose as fixed. The
215 stack pointer, $254, is also fixed. Register $255 is referred to as a
216 temporary register in the MMIX papers, and used as such in mmixal, so
217 it should not be used as a stack pointer. We set it to fixed, and use
218 it "manually" at times of despair. */
219 #define FIXED_REGISTERS \
220 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
222 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
223 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
224 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
225 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
226 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
227 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
228 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
229 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
230 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
231 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
232 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
233 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
234 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
235 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, \
236 1, 1, 0, 0, 0, 1, 1 \
237 }
238
239 /* General registers are fixed and therefore "historically" marked
240 call-used. (FIXME: This has changed). Registers $15..$31 are
241 call-clobbered; we'll put arguments in $16 and up, and we need $15 for
242 the MMIX register-stack "hole". */
243 #define CALL_USED_REGISTERS \
244 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, \
245 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
246 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
247 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
248 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
249 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
250 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
251 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
252 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
253 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
254 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
255 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
256 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
257 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
258 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
259 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, \
260 1, 1, 1, 1, 1, 1, 1 \
261 }
262
263 #define INCOMING_REGNO(OUT) mmix_opposite_regno (OUT, 0)
264
265 #define OUTGOING_REGNO(IN) mmix_opposite_regno (IN, 1)
266
267 /* Defining LOCAL_REGNO is necessary in presence of prologue/epilogue,
268 else GCC will be confused that those registers aren't saved and
269 restored. */
270 #define LOCAL_REGNO(REGNO) mmix_local_regno (REGNO)
271
272 /* Node: Allocation Order */
273
274 /* We should allocate registers from 0 to 31 by increasing number, because
275 I think that's what people expect. Beyond that, just use
276 call-clobbered global registers first, then call-clobbered special
277 registers. Last, the fixed registers. */
278 #define MMIX_MMIXWARE_ABI_REG_ALLOC_ORDER \
279 { 0, 1, 2, 3, 4, 5, 6, 7, \
280 8, 9, 10, 11, 12, 13, 14, 15, \
281 16, 17, 18, 19, 20, 21, 22, 23, \
282 24, 25, 26, 27, 28, 29, 30, 31, \
283 \
284 252, 251, 250, 249, 248, 247, \
285 \
286 253, \
287 \
288 258, 260, 259, \
289 \
290 32, 33, 34, 35, 36, 37, 38, 39, \
291 40, 41, 42, 43, 44, 45, 46, 47, \
292 48, 49, 50, 51, 52, 53, 54, 55, \
293 56, 57, 58, 59, 60, 61, 62, 63, \
294 64, 65, 66, 67, 68, 69, 70, 71, \
295 72, 73, 74, 75, 76, 77, 78, 79, \
296 80, 81, 82, 83, 84, 85, 86, 87, \
297 88, 89, 90, 91, 92, 93, 94, 95, \
298 96, 97, 98, 99, 100, 101, 102, 103, \
299 104, 105, 106, 107, 108, 109, 110, 111, \
300 112, 113, 114, 115, 116, 117, 118, 119, \
301 120, 121, 122, 123, 124, 125, 126, 127, \
302 128, 129, 130, 131, 132, 133, 134, 135, \
303 136, 137, 138, 139, 140, 141, 142, 143, \
304 144, 145, 146, 147, 148, 149, 150, 151, \
305 152, 153, 154, 155, 156, 157, 158, 159, \
306 160, 161, 162, 163, 164, 165, 166, 167, \
307 168, 169, 170, 171, 172, 173, 174, 175, \
308 176, 177, 178, 179, 180, 181, 182, 183, \
309 184, 185, 186, 187, 188, 189, 190, 191, \
310 192, 193, 194, 195, 196, 197, 198, 199, \
311 200, 201, 202, 203, 204, 205, 206, 207, \
312 208, 209, 210, 211, 212, 213, 214, 215, \
313 216, 217, 218, 219, 220, 221, 222, 223, \
314 224, 225, 226, 227, 228, 229, 230, 231, \
315 232, 233, 234, 235, 236, 237, 238, 239, \
316 240, 241, 242, 243, 244, 245, 246, \
317 \
318 254, 255, 256, 257, 261, 262 \
319 }
320
321 /* As a convenience, we put this nearby, for ease of comparison.
322 First, call-clobbered registers in reverse order of assignment as
323 parameters (also the top ones; not because they're parameters, but
324 for continuity).
325
326 Second, saved registers that go on the register-stack.
327
328 Third, special registers rH, rR and rJ. They should not normally be
329 allocated, but since they're call-clobbered, it is cheaper to use one
330 of them than using a call-saved register for a call-clobbered use,
331 assuming it is referenced a very limited number of times. Other global
332 and fixed registers come next; they are never allocated. */
333 #define MMIX_GNU_ABI_REG_ALLOC_ORDER \
334 { 252, 251, 250, 249, 248, 247, 246, \
335 245, 244, 243, 242, 241, 240, 239, 238, \
336 237, 236, 235, 234, 233, 232, 231, \
337 \
338 0, 1, 2, 3, 4, 5, 6, 7, \
339 8, 9, 10, 11, 12, 13, 14, 15, \
340 16, 17, 18, 19, 20, 21, 22, 23, \
341 24, 25, 26, 27, 28, 29, 30, 31, \
342 \
343 253, \
344 \
345 258, 260, 259, \
346 \
347 32, 33, 34, 35, 36, 37, 38, 39, \
348 40, 41, 42, 43, 44, 45, 46, 47, \
349 48, 49, 50, 51, 52, 53, 54, 55, \
350 56, 57, 58, 59, 60, 61, 62, 63, \
351 64, 65, 66, 67, 68, 69, 70, 71, \
352 72, 73, 74, 75, 76, 77, 78, 79, \
353 80, 81, 82, 83, 84, 85, 86, 87, \
354 88, 89, 90, 91, 92, 93, 94, 95, \
355 96, 97, 98, 99, 100, 101, 102, 103, \
356 104, 105, 106, 107, 108, 109, 110, 111, \
357 112, 113, 114, 115, 116, 117, 118, 119, \
358 120, 121, 122, 123, 124, 125, 126, 127, \
359 128, 129, 130, 131, 132, 133, 134, 135, \
360 136, 137, 138, 139, 140, 141, 142, 143, \
361 144, 145, 146, 147, 148, 149, 150, 151, \
362 152, 153, 154, 155, 156, 157, 158, 159, \
363 160, 161, 162, 163, 164, 165, 166, 167, \
364 168, 169, 170, 171, 172, 173, 174, 175, \
365 176, 177, 178, 179, 180, 181, 182, 183, \
366 184, 185, 186, 187, 188, 189, 190, 191, \
367 192, 193, 194, 195, 196, 197, 198, 199, \
368 200, 201, 202, 203, 204, 205, 206, 207, \
369 208, 209, 210, 211, 212, 213, 214, 215, \
370 216, 217, 218, 219, 220, 221, 222, 223, \
371 224, 225, 226, 227, 228, 229, 230, \
372 \
373 254, 255, 256, 257, 261, 262 \
374 }
375
376 /* The default one. */
377 #define REG_ALLOC_ORDER MMIX_MMIXWARE_ABI_REG_ALLOC_ORDER
378
379 /* Node: Leaf Functions */
380 /* (empty) */
381
382
383 /* Node: Register Classes */
384
385 enum reg_class
386 {
387 NO_REGS, GENERAL_REGS, REMAINDER_REG, HIMULT_REG,
388 SYSTEM_REGS, ALL_REGS, LIM_REG_CLASSES
389 };
390
391 #define N_REG_CLASSES (int) LIM_REG_CLASSES
392
393 #define REG_CLASS_NAMES \
394 {"NO_REGS", "GENERAL_REGS", "REMAINDER_REG", "HIMULT_REG", \
395 "SYSTEM_REGS", "ALL_REGS"}
396
397 /* Note that the contents of each item is always 32 bits. */
398 #define REG_CLASS_CONTENTS \
399 {{0, 0, 0, 0, 0, 0, 0, 0, 0}, \
400 {~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 0x20}, \
401 {0, 0, 0, 0, 0, 0, 0, 0, 0x10}, \
402 {0, 0, 0, 0, 0, 0, 0, 0, 4}, \
403 {0, 0, 0, 0, 0, 0, 0, 0, 0x7f}, \
404 {~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 0x7f}}
405
406 #define REGNO_REG_CLASS(REGNO) \
407 ((REGNO) <= MMIX_LAST_GENERAL_REGISTER \
408 || (REGNO) == MMIX_ARG_POINTER_REGNUM \
409 ? GENERAL_REGS \
410 : (REGNO) == MMIX_REMAINDER_REGNUM ? REMAINDER_REG \
411 : (REGNO) == MMIX_HIMULT_REGNUM ? HIMULT_REG : SYSTEM_REGS)
412
413 #define BASE_REG_CLASS GENERAL_REGS
414
415 #define INDEX_REG_CLASS GENERAL_REGS
416
417 #define REGNO_OK_FOR_BASE_P(REGNO) \
418 ((REGNO) <= MMIX_LAST_GENERAL_REGISTER \
419 || (REGNO) == MMIX_ARG_POINTER_REGNUM \
420 || (reg_renumber[REGNO] > 0 \
421 && reg_renumber[REGNO] <= MMIX_LAST_GENERAL_REGISTER))
422
423 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P (REGNO)
424
425 #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
426 mmix_secondary_reload_class (CLASS, MODE, X, 1)
427
428 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
429 mmix_secondary_reload_class (CLASS, MODE, X, 0)
430
431 #define CLASS_MAX_NREGS(CLASS, MODE) targetm.hard_regno_nregs (CLASS, MODE)
432
433
434 /* Node: Frame Layout */
435
436 #define STACK_GROWS_DOWNWARD 1
437 #define FRAME_GROWS_DOWNWARD 1
438
439 #define FIRST_PARM_OFFSET(FUNDECL) 0
440
441 #define DYNAMIC_CHAIN_ADDRESS(FRAMEADDR) \
442 mmix_dynamic_chain_address (FRAMEADDR)
443
444 /* FIXME: It seems RETURN_ADDR_OFFSET is undocumented. */
445
446 #define SETUP_FRAME_ADDRESSES() \
447 mmix_setup_frame_addresses ()
448
449 #define RETURN_ADDR_RTX(COUNT, FRAME) \
450 mmix_return_addr_rtx (COUNT, FRAME)
451
452 /* It's in rJ before we store it somewhere. */
453 #define INCOMING_RETURN_ADDR_RTX \
454 gen_rtx_REG (Pmode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM)
455
456 /* FIXME: This does not seem properly documented or cross-indexed.
457 Nowhere except in the code does it say it *has* to be in the range
458 0..255, or else it will be truncated. That goes for the default too. */
459 #define DWARF_FRAME_RETURN_COLUMN \
460 DWARF_FRAME_REGNUM (MMIX_INCOMING_RETURN_ADDRESS_REGNUM)
461
462 /* No return address is stored there. */
463 #define INCOMING_FRAME_SP_OFFSET 0
464
465 /* Node: Stack Checking */
466 /* (empty) */
467
468
469 /* Node: Exception Handling */
470
471 #define EH_RETURN_DATA_REGNO(N) \
472 mmix_eh_return_data_regno (N)
473
474 #define EH_RETURN_STACKADJ_RTX \
475 mmix_eh_return_stackadj_rtx ()
476
477 #define EH_RETURN_HANDLER_RTX \
478 mmix_eh_return_handler_rtx ()
479
480 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
481 mmix_asm_preferred_eh_data_format (CODE, GLOBAL)
482
483 /* Node: Frame Registers */
484 #define STACK_POINTER_REGNUM MMIX_STACK_POINTER_REGNUM
485
486 /* Perhaps we can use HARD_FRAME_POINTER_REGNUM and decide later on
487 what register we want to use. */
488 #define FRAME_POINTER_REGNUM MMIX_FRAME_POINTER_REGNUM
489 #define ARG_POINTER_REGNUM MMIX_ARG_POINTER_REGNUM
490
491 #define STATIC_CHAIN_REGNUM MMIX_STATIC_CHAIN_REGNUM
492
493
494 /* Node: Elimination */
495
496 /* The frame-pointer is stored in a location that either counts to the
497 offset of incoming parameters, or that counts to the offset of the
498 frame, so we can't use a single offset. We therefore eliminate those
499 two separately. */
500 #define ELIMINABLE_REGS \
501 {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
502 {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
503 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
504
505 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
506 (OFFSET) = mmix_initial_elimination_offset (FROM, TO)
507
508
509 /* Node: Stack Arguments */
510
511 #define ACCUMULATE_OUTGOING_ARGS 1
512
513
514 /* Node: Register Arguments */
515
516 typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
517
518 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
519 ((CUM).regs = 0, (CUM).lib = ((LIBNAME) != 0))
520
521 #define FUNCTION_ARG_REGNO_P(REGNO) \
522 mmix_function_arg_regno_p (REGNO, 0)
523
524
525 /* Node: Caller Saves */
526 /* (empty) */
527
528
529 /* Node: Function Entry */
530
531 /* See mmix.cc for TARGET_ASM_FUNCTION_PROLOGUE and
532 TARGET_ASM_FUNCTION_EPILOGUE. */
533
534 /* We need to say that the epilogue uses the return address, so the
535 initial-value machinery restores it. FIXME: Some targets
536 conditionalize on "reload_completed &&". Investigate difference.
537 FIXME: Not needed if nonlocal_goto_stack_level. */
538 #define EPILOGUE_USES(REGNO) \
539 ((REGNO) == MMIX_INCOMING_RETURN_ADDRESS_REGNUM)
540
541 /* Node: Profiling */
542 #define FUNCTION_PROFILER(FILE, LABELNO) \
543 mmix_function_profiler (FILE, LABELNO)
544
545 /* Node: Trampolines */
546
547 #define TRAMPOLINE_SIZE (4*UNITS_PER_WORD)
548 #define TRAMPOLINE_ALIGNMENT BITS_PER_WORD
549
550 /* Node: Addressing Modes */
551
552 #define CONSTANT_ADDRESS_P(X) \
553 mmix_constant_address_p (X)
554
555 #define MAX_REGS_PER_ADDRESS 2
556
557
558 /* Node: Condition Code */
559
560 #define SELECT_CC_MODE(OP, X, Y) \
561 mmix_select_cc_mode (OP, X, Y)
562
563 /* A definition of CANONICALIZE_COMPARISON that changed LE and GT
564 comparisons with -1 to LT and GE respectively, and LT, LTU, GE or GEU
565 comparisons with 256 to 255 and LE, LEU, GT and GTU has been
566 ineffective; the code path for performing the changes did not trig for
567 neither the GCC testsuite nor ghostscript-6.52 nor Knuth's mmix.tar.gz
568 itself (core GCC functionality supposedly handling it) with sources
569 from 2002-06-06. */
570
571 #define REVERSIBLE_CC_MODE(MODE) \
572 mmix_reversible_cc_mode (MODE)
573
574
575 /* Node: Costs */
576
577 #define SLOW_BYTE_ACCESS 0
578
579 /* A PUSHJ doesn't cost more than a PUSHGO, so don't needlessly create
580 the latter. */
581 #define NO_FUNCTION_CSE 1
582
583 /* Node: Sections */
584
585 /* This must be a constant string, since it's used in crtstuff.c. */
586 #define TEXT_SECTION_ASM_OP \
587 "\t.text ! mmixal:= 9H LOC 8B"
588
589 /* FIXME: Not documented. */
590 #define DATA_SECTION_ASM_OP \
591 mmix_data_section_asm_op ()
592
593 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata"
594
595 /* Node: PIC */
596 /* (empty) */
597
598
599 /* Node: File Framework */
600
601 /* While any other punctuation character but ";" would do, we prefer "%"
602 or "!"; "!" is an unary operator and so will not be mistakenly included
603 in correctly formed expressions. The hash character adds mass; catches
604 the eye. We can't have it as a comment char by itself, since it's a
605 hex-number prefix. */
606 #define ASM_COMMENT_START "!#"
607
608 /* These aren't currently functional. We just keep them as markers. */
609 #define ASM_APP_ON "%APP\n"
610 #define ASM_APP_OFF "%NO_APP\n"
611
612 #define OUTPUT_QUOTED_STRING(STREAM, STRING) \
613 mmix_output_quoted_string (STREAM, STRING, strlen (STRING))
614
615 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
616
617 /* Node: Data Output */
618
619 #define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \
620 mmix_asm_output_ascii (STREAM, PTR, LEN)
621
622 /* Make output more ELF-like, by emitting .hidden for hidden symbols
623 (which don't really matter for mmix-knuth-mmixware). */
624 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
625 default_elf_asm_output_external (FILE, DECL, NAME)
626
627 /* Node: Uninitialized Data */
628
629 #define ASM_OUTPUT_ALIGNED_COMMON(ST, N, S, A) \
630 mmix_asm_output_aligned_common (ST, N, S, A)
631
632 #define ASM_OUTPUT_ALIGNED_LOCAL(ST, N, S, A) \
633 mmix_asm_output_aligned_local (ST, N, S, A)
634
635
636 /* Node: Label Output */
637
638 #define ASM_OUTPUT_LABEL(STREAM, NAME) \
639 mmix_asm_output_label (STREAM, NAME)
640
641 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
642 mmix_asm_output_internal_label (STREAM, NAME)
643
644 #define ASM_DECLARE_REGISTER_GLOBAL(STREAM, DECL, REGNO, NAME) \
645 mmix_asm_declare_register_global (STREAM, DECL, REGNO, NAME)
646
647 #define GLOBAL_ASM_OP "\t.global "
648
649 #define ASM_WEAKEN_LABEL(STREAM, NAME) \
650 mmix_asm_weaken_label (STREAM, NAME)
651
652 #define MAKE_DECL_ONE_ONLY(DECL) \
653 mmix_make_decl_one_only (DECL)
654
655 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
656 mmix_asm_output_labelref (STREAM, NAME)
657
658 /* We insert a ":" to disambiguate against user symbols like L5. */
659 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
660 sprintf (LABEL, "*%s:%ld", PREFIX, (long)(NUM))
661
662 /* Override the default, which looks at NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL.
663 We want the real default "%s.%lu" in dumps and compiler messages, but the
664 actual assembly code format is adjusted to the effect of "%s::%lu". See
665 mmix_asm_output_labelref. */
666 #define ASM_PN_FORMAT "%s.%lu"
667
668 #define ASM_OUTPUT_DEF(STREAM, NAME, VALUE) \
669 mmix_asm_output_def (STREAM, NAME, VALUE)
670
671 /* Node: Macros for Initialization */
672 /* We're compiling to ELF and linking to MMO; fundamental ELF features
673 that GCC depend on are there. */
674
675 /* These must be constant strings, since they're used in crtstuff.c. */
676 #define INIT_SECTION_ASM_OP "\t.section .init,\"ax\" ! mmixal-incompatible"
677
678 #define FINI_SECTION_ASM_OP "\t.section .fini,\"ax\" ! mmixal-incompatible"
679
680 #define OBJECT_FORMAT_ELF
681
682
683 /* Node: Instruction Output */
684
685 /* The non-$ register names must be prefixed with ":", since they're
686 affected by PREFIX. We provide the non-colon names as additional
687 names. */
688 #define REGISTER_NAMES \
689 {"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", \
690 "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", \
691 "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", \
692 "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", \
693 "$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39", \
694 "$40", "$41", "$42", "$43", "$44", "$45", "$46", "$47", \
695 "$48", "$49", "$50", "$51", "$52", "$53", "$54", "$55", \
696 "$56", "$57", "$58", "$59", "$60", "$61", "$62", "$63", \
697 "$64", "$65", "$66", "$67", "$68", "$69", "$70", "$71", \
698 "$72", "$73", "$74", "$75", "$76", "$77", "$78", "$79", \
699 "$80", "$81", "$82", "$83", "$84", "$85", "$86", "$87", \
700 "$88", "$89", "$90", "$91", "$92", "$93", "$94", "$95", \
701 "$96", "$97", "$98", "$99", "$100", "$101", "$102", "$103", \
702 "$104", "$105", "$106", "$107", "$108", "$109", "$110", "$111", \
703 "$112", "$113", "$114", "$115", "$116", "$117", "$118", "$119", \
704 "$120", "$121", "$122", "$123", "$124", "$125", "$126", "$127", \
705 "$128", "$129", "$130", "$131", "$132", "$133", "$134", "$135", \
706 "$136", "$137", "$138", "$139", "$140", "$141", "$142", "$143", \
707 "$144", "$145", "$146", "$147", "$148", "$149", "$150", "$151", \
708 "$152", "$153", "$154", "$155", "$156", "$157", "$158", "$159", \
709 "$160", "$161", "$162", "$163", "$164", "$165", "$166", "$167", \
710 "$168", "$169", "$170", "$171", "$172", "$173", "$174", "$175", \
711 "$176", "$177", "$178", "$179", "$180", "$181", "$182", "$183", \
712 "$184", "$185", "$186", "$187", "$188", "$189", "$190", "$191", \
713 "$192", "$193", "$194", "$195", "$196", "$197", "$198", "$199", \
714 "$200", "$201", "$202", "$203", "$204", "$205", "$206", "$207", \
715 "$208", "$209", "$210", "$211", "$212", "$213", "$214", "$215", \
716 "$216", "$217", "$218", "$219", "$220", "$221", "$222", "$223", \
717 "$224", "$225", "$226", "$227", "$228", "$229", "$230", "$231", \
718 "$232", "$233", "$234", "$235", "$236", "$237", "$238", "$239", \
719 "$240", "$241", "$242", "$243", "$244", "$245", "$246", "$247", \
720 "$248", "$249", "$250", "$251", "$252", "$253", "$254", "$255", \
721 ":rD", ":rE", ":rH", ":rJ", ":rR", "ap_!BAD!", ":rO"}
722
723 #define ADDITIONAL_REGISTER_NAMES \
724 {{"sp", 254}, {":sp", 254}, {"rD", 256}, {"rE", 257}, \
725 {"rH", 258}, {"rJ", MMIX_rJ_REGNUM}, {"rO", MMIX_rO_REGNUM}}
726
727 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
728 mmix_asm_output_reg_push (STREAM, REGNO)
729
730 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
731 mmix_asm_output_reg_pop (STREAM, REGNO)
732
733
734 /* Node: Dispatch Tables */
735
736 /* We define both types, since SImode is the better, but DImode the only
737 possible for mmixal so that's the one actually used. */
738 #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
739 mmix_asm_output_addr_diff_elt (STREAM, BODY, VALUE, REL)
740
741 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
742 mmix_asm_output_addr_vec_elt (STREAM, VALUE)
743
744
745 /* Node: Exception Region Output */
746 /* (empty) */
747
748 /* Node: Alignment Output */
749
750 #define ASM_OUTPUT_SKIP(STREAM, NBYTES) \
751 mmix_asm_output_skip (STREAM, NBYTES)
752
753 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
754 mmix_asm_output_align (STREAM, POWER)
755
756
757 /* Node: All Debuggers */
758
759 #define DEBUGGER_REGNO(REGNO) \
760 mmix_debugger_regno (REGNO)
761
762 /* Node: DWARF */
763 #define DWARF2_DEBUGGING_INFO 1
764 #define DWARF2_ASM_LINE_DEBUG_INFO 1
765
766 /* Node: Misc */
767
768 /* There's no way to get a PC-relative offset into tables for SImode, so
769 for the moment we have absolute entries in DImode.
770 When we're going ELF, these should be SImode and 1. */
771 #define CASE_VECTOR_MODE DImode
772 #define CASE_VECTOR_PC_RELATIVE 0
773
774 #define WORD_REGISTER_OPERATIONS 1
775
776 /* We have a choice, which makes this yet another parameter to tweak. The
777 gut feeling is currently that SIGN_EXTEND wins; "int" is more frequent
778 than "unsigned int", and we have signed characters. FIXME: measure. */
779 #define LOAD_EXTEND_OP(MODE) (TARGET_ZERO_EXTEND ? ZERO_EXTEND : SIGN_EXTEND)
780
781 #define MOVE_MAX 8
782
783 /* ??? MMIX allows a choice of STORE_FLAG_VALUE. Revisit later,
784 we don't have scc expanders yet. */
785
786 #define Pmode DImode
787
788 #define FUNCTION_MODE QImode
789
790 /* mmix-knuth-mmixware target has no support of C99 runtime */
791 #undef TARGET_LIBC_HAS_FUNCTION
792 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
793
794 /* These are checked. */
795 #define DOLLARS_IN_IDENTIFIERS 0
796 #define NO_DOLLAR_IN_LABEL
797 #define NO_DOT_IN_LABEL
798
799 #endif /* GCC_MMIX_H */
800 /*
801 * Local variables:
802 * eval: (c-set-style "gnu")
803 * indent-tabs-mode: t
804 * End:
805 */