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