]> gcc.gnu.org Git - gcc.git/blob - gcc/config/m68k/m68k.h
(EXTRA_CONSTRAINT): New macro.
[gcc.git] / gcc / config / m68k / m68k.h
1 /* Definitions of target machine for GNU compiler. Sun 68000/68020 version.
2 Copyright (C) 1987, 88, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21
22 /* Note that some other tm.h files include this one and then override
23 many of the definitions that relate to assembler syntax. */
24
25
26 /* Names to predefine in the preprocessor for this target machine. */
27
28 /* See sun3.h, sun2.h, isi.h for different CPP_PREDEFINES. */
29
30 /* Print subsidiary information on the compiler version in use. */
31 #ifdef MOTOROLA
32 #define TARGET_VERSION fprintf (stderr, " (68k, Motorola syntax)");
33 #else
34 #define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)");
35 #endif
36
37 /* Define SUPPORT_SUN_FPA to include support for generating code for
38 the Sun Floating Point Accelerator, an optional product for Sun 3
39 machines. By default, it is not defined. Avoid defining it unless
40 you need to output code for the Sun3+FPA architecture, as it has the
41 effect of slowing down the register set operations in hard-reg-set.h
42 (total number of registers will exceed number of bits in a long,
43 if defined, causing the set operations to expand to loops).
44 SUPPORT_SUN_FPA is typically defined in sun3.h. */
45
46 /* Run-time compilation parameters selecting different hardware subsets. */
47
48 extern int target_flags;
49
50 /* Macros used in the machine description to test the flags. */
51
52 /* Compile for a 68020 (not a 68000 or 68010). */
53 #define MASK_68020 1
54 #define TARGET_68020 (target_flags & MASK_68020)
55
56 /* Compile 68881 insns for floating point (not library calls). */
57 #define MASK_68881 2
58 #define TARGET_68881 (target_flags & MASK_68881)
59
60 /* Compile using 68020 bitfield insns. */
61 #define MASK_BITFIELD 4
62 #define TARGET_BITFIELD (target_flags & MASK_BITFIELD)
63
64 /* Compile using rtd insn calling sequence.
65 This will not work unless you use prototypes at least
66 for all functions that can take varying numbers of args. */
67 #define MASK_RTD 8
68 #define TARGET_RTD (target_flags & MASK_RTD)
69
70 /* Compile passing first two args in regs 0 and 1.
71 This exists only to test compiler features that will
72 be needed for RISC chips. It is not usable
73 and is not intended to be usable on this cpu. */
74 #define MASK_REGPARM 16
75 #define TARGET_REGPARM (target_flags & MASK_REGPARM)
76
77 /* Compile with 16-bit `int'. */
78 #define MASK_SHORT 32
79 #define TARGET_SHORT (target_flags & MASK_SHORT)
80
81 /* Compile with special insns for Sun FPA. */
82 #define MASK_FPA 64
83 #define TARGET_FPA (target_flags & MASK_FPA)
84
85 /* Compile (actually, link) for Sun SKY board. */
86 #define MASK_SKY 128
87 #define TARGET_SKY (target_flags & MASK_SKY)
88
89 /* Optimize for 68040, but still allow execution on 68020
90 (-m68020-40 or -m68040).
91 The 68040 will execute all 68030 and 68881/2 instructions, but some
92 of them must be emulated in software by the OS. When TARGET_68040 is
93 turned on, these instructions won't be used. This code will still
94 run on a 68030 and 68881/2. */
95 #define MASK_68040 256
96 #define TARGET_68040 (target_flags & MASK_68040)
97
98 /* Use the 68040-only fp instructions (-m68040 or -m68060). */
99 #define MASK_68040_ONLY 512
100 #define TARGET_68040_ONLY (target_flags & MASK_68040_ONLY)
101
102 /* Optimize for 68060, but still allow execution on 68020
103 (-m68020-60 or -m68060).
104 The 68060 will execute all 68030 and 68881/2 instructions, but some
105 of them must be emulated in software by the OS. When TARGET_68060 is
106 turned on, these instructions won't be used. This code will still
107 run on a 68030 and 68881/2. */
108 #define MASK_68060 1024
109 #define TARGET_68060 (target_flags & MASK_68060)
110
111 /* Compile for mcf5200 */
112 #define MASK_5200 2048
113 #define TARGET_5200 (target_flags & MASK_5200)
114
115 /* Align ints to a word boundary. This breaks compatibility with the
116 published ABI's for structures containing ints, but produces faster
117 code on cpus with 32 bit busses (020, 030, 040, 060, CPU32+, coldfire).
118 It's required for coldfire cpus without a misalignment module. */
119 #define MASK_ALIGN_INT 4096
120 #define TARGET_ALIGN_INT (target_flags & MASK_ALIGN_INT)
121
122 /* Compile for a CPU32 */
123 /* A 68020 without bitfields is a good heuristic for a CPU32 */
124 #define TARGET_CPU32 (TARGET_68020 && !TARGET_BITFIELD)
125
126 /* Macro to define tables used to set the flags.
127 This is a list in braces of pairs in braces,
128 each pair being { "NAME", VALUE }
129 where VALUE is the bits to set or minus the bits to clear.
130 An empty string NAME is used to identify the default VALUE. */
131
132 #define TARGET_SWITCHES \
133 { { "68020", - (MASK_5200|MASK_68060|MASK_68040|MASK_68040_ONLY)}, \
134 { "c68020", - (MASK_5200|MASK_68060|MASK_68040|MASK_68040_ONLY)}, \
135 { "68020", (MASK_68020|MASK_BITFIELD)}, \
136 { "c68020", (MASK_68020|MASK_BITFIELD)}, \
137 { "68000", - (MASK_5200|MASK_68060|MASK_68040|MASK_68040_ONLY \
138 |MASK_68020|MASK_BITFIELD)}, \
139 { "c68000", - (MASK_5200|MASK_68060|MASK_68040|MASK_68040_ONLY \
140 |MASK_68020|MASK_BITFIELD)}, \
141 { "bitfield", MASK_BITFIELD}, \
142 { "nobitfield", - MASK_BITFIELD}, \
143 { "rtd", MASK_RTD}, \
144 { "nortd", - MASK_RTD}, \
145 { "short", MASK_SHORT}, \
146 { "noshort", - MASK_SHORT}, \
147 { "fpa", -(MASK_SKY|MASK_68040_ONLY|MASK_68881)}, \
148 { "fpa", MASK_FPA}, \
149 { "nofpa", - MASK_FPA}, \
150 { "sky", -(MASK_FPA|MASK_68040_ONLY|MASK_68881)}, \
151 { "sky", MASK_SKY}, \
152 { "nosky", - MASK_SKY}, \
153 { "68881" - (MASK_FPA|MASK_SKY)}, \
154 { "68881", MASK_68881}, \
155 { "soft-float", - (MASK_FPA|MASK_SKY|MASK_68040_ONLY|MASK_68881)}, \
156 { "68020-40", -(MASK_5200|MASK_68060)}, \
157 { "68020-40", (MASK_BITFIELD|MASK_68881|MASK_68020|MASK_68040)}, \
158 { "68020-60", -(MASK_5200|MASK_68040)}, \
159 { "68020-60", (MASK_BITFIELD|MASK_68881|MASK_68020|MASK_68060)}, \
160 { "68030", - (MASK_5200|MASK_68060|MASK_68040|MASK_68040_ONLY)}, \
161 { "68030", (MASK_68020|MASK_BITFIELD)}, \
162 { "68040", - (MASK_5200|MASK_68060)}, \
163 { "68040", (MASK_68020|MASK_68881|MASK_BITFIELD \
164 |MASK_68040_ONLY|MASK_68040)}, \
165 { "68060", - (MASK_5200|MASK_68040)}, \
166 { "68060", (MASK_68020|MASK_68881|MASK_BITFIELD \
167 |MASK_68040_ONLY|MASK_68060)}, \
168 { "5200", - (MASK_68060|MASK_68040|MASK_68020|MASK_BITFIELD|MASK_68881)}, \
169 { "5200", (MASK_5200)}, \
170 { "68851", 0}, \
171 { "no-68851", 0}, \
172 { "68302", - (MASK_5200|MASK_68060|MASK_68040|MASK_68020|MASK_BITFIELD)}, \
173 { "68332", - (MASK_5200|MASK_68060|MASK_68040|MASK_BITFIELD)}, \
174 { "68332", MASK_68020}, \
175 { "align-int", MASK_ALIGN_INT }, \
176 { "no-align-int", -MASK_ALIGN_INT }, \
177 SUBTARGET_SWITCHES \
178 { "", TARGET_DEFAULT}}
179 /* TARGET_DEFAULT is defined in sun*.h and isi.h, etc. */
180
181 /* This macro is similar to `TARGET_SWITCHES' but defines names of
182 command options that have values. Its definition is an
183 initializer with a subgrouping for each command option.
184
185 Each subgrouping contains a string constant, that defines the
186 fixed part of the option name, and the address of a variable. The
187 variable, type `char *', is set to the variable part of the given
188 option if the fixed part matches. The actual option name is made
189 by appending `-m' to the specified name. */
190 #define TARGET_OPTIONS \
191 { { "align-loops=", &m68k_align_loops_string }, \
192 { "align-jumps=", &m68k_align_jumps_string }, \
193 { "align-functions=", &m68k_align_funcs_string }, \
194 SUBTARGET_OPTIONS \
195 }
196
197 /* Sometimes certain combinations of command options do not make
198 sense on a particular target machine. You can define a macro
199 `OVERRIDE_OPTIONS' to take account of this. This macro, if
200 defined, is executed once just after all the command options have
201 been parsed.
202
203 Don't use this macro to turn on various extra optimizations for
204 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
205
206 #define OVERRIDE_OPTIONS \
207 { \
208 override_options(); \
209 if (! TARGET_68020 && flag_pic == 2) \
210 error("-fPIC is not currently supported on the 68000 or 68010\n"); \
211 SUBTARGET_OVERRIDE_OPTIONS; \
212 }
213
214 /* These are meant to be redefined in the host dependent files */
215 #define SUBTARGET_SWITCHES
216 #define SUBTARGET_OPTIONS
217 #define SUBTARGET_OVERRIDE_OPTIONS
218 \f
219 /* target machine storage layout */
220
221 /* Define for XFmode extended real floating point support.
222 This will automatically cause REAL_ARITHMETIC to be defined. */
223 #define LONG_DOUBLE_TYPE_SIZE 96
224
225 /* Define if you don't want extended real, but do want to use the
226 software floating point emulator for REAL_ARITHMETIC and
227 decimal <-> binary conversion. */
228 /* #define REAL_ARITHMETIC */
229
230 /* Define this if most significant bit is lowest numbered
231 in instructions that operate on numbered bit-fields.
232 This is true for 68020 insns such as bfins and bfexts.
233 We make it true always by avoiding using the single-bit insns
234 except in special cases with constant bit numbers. */
235 #define BITS_BIG_ENDIAN 1
236
237 /* Define this if most significant byte of a word is the lowest numbered. */
238 /* That is true on the 68000. */
239 #define BYTES_BIG_ENDIAN 1
240
241 /* Define this if most significant word of a multiword number is the lowest
242 numbered. */
243 /* For 68000 we can decide arbitrarily
244 since there are no machine instructions for them.
245 So let's be consistent. */
246 #define WORDS_BIG_ENDIAN 1
247
248 /* number of bits in an addressable storage unit */
249 #define BITS_PER_UNIT 8
250
251 /* Width in bits of a "word", which is the contents of a machine register.
252 Note that this is not necessarily the width of data type `int';
253 if using 16-bit ints on a 68000, this would still be 32.
254 But on a machine with 16-bit registers, this would be 16. */
255 #define BITS_PER_WORD 32
256
257 /* Width of a word, in units (bytes). */
258 #define UNITS_PER_WORD 4
259
260 /* Width in bits of a pointer.
261 See also the macro `Pmode' defined below. */
262 #define POINTER_SIZE 32
263
264 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
265 #define PARM_BOUNDARY (TARGET_SHORT ? 16 : 32)
266
267 /* Boundary (in *bits*) on which stack pointer should be aligned. */
268 #define STACK_BOUNDARY 16
269
270 /* Allocation boundary (in *bits*) for the code of a function. */
271 #define FUNCTION_BOUNDARY (1 << (m68k_align_funcs + 3))
272
273 /* Alignment of field after `int : 0' in a structure. */
274 #define EMPTY_FIELD_BOUNDARY 16
275
276 /* No data type wants to be aligned rounder than this.
277 Most published ABIs say that ints should be aligned on 16 bit
278 boundries, but cpus with 32 bit busses get better performance
279 aligned on 32 bit boundries. Coldfires without a misalignment
280 module require 32 bit alignment. */
281 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_INT ? 32 : 16)
282
283 /* Set this nonzero if move instructions will actually fail to work
284 when given unaligned data. */
285 #define STRICT_ALIGNMENT 1
286
287 /* Maximum power of 2 that code can be aligned to. */
288 #define MAX_CODE_ALIGN 2 /* 4 byte alignment */
289
290 /* Align loop starts for optimal branching. */
291 #define ASM_OUTPUT_LOOP_ALIGN(FILE) ASM_OUTPUT_ALIGN ((FILE), m68k_align_loops)
292
293 /* This is how to align an instruction for optimal branching. */
294 #define ASM_OUTPUT_ALIGN_CODE(FILE) ASM_OUTPUT_ALIGN ((FILE), m68k_align_jumps)
295
296 #define SELECT_RTX_SECTION(MODE, X) \
297 { \
298 if (!flag_pic) \
299 readonly_data_section(); \
300 else if (LEGITIMATE_PIC_OPERAND_P (X)) \
301 readonly_data_section(); \
302 else \
303 data_section(); \
304 }
305
306 /* Define number of bits in most basic integer type.
307 (If undefined, default is BITS_PER_WORD). */
308
309 #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32)
310
311 /* Define these to avoid dependence on meaning of `int'.
312 Note that WCHAR_TYPE_SIZE is used in cexp.y,
313 where TARGET_SHORT is not available. */
314
315 #define WCHAR_TYPE "long int"
316 #define WCHAR_TYPE_SIZE 32
317 \f
318 /* Standard register usage. */
319
320 /* Number of actual hardware registers.
321 The hardware registers are assigned numbers for the compiler
322 from 0 to just below FIRST_PSEUDO_REGISTER.
323 All registers that the compiler knows about must be given numbers,
324 even those that are not normally considered general registers.
325 For the 68000, we give the data registers numbers 0-7,
326 the address registers numbers 010-017,
327 and the 68881 floating point registers numbers 020-027. */
328 #ifndef SUPPORT_SUN_FPA
329 #define FIRST_PSEUDO_REGISTER 24
330 #else
331 #define FIRST_PSEUDO_REGISTER 56
332 #endif
333
334 /* This defines the register which is used to hold the offset table for PIC. */
335 #define PIC_OFFSET_TABLE_REGNUM 13
336
337 /* Used to output a (use pic_offset_table_rtx) so that we
338 always save/restore a5 in functions that use PIC relocation
339 at *any* time during the compilation process. */
340 #define FINALIZE_PIC finalize_pic()
341
342 #ifndef SUPPORT_SUN_FPA
343
344 /* 1 for registers that have pervasive standard uses
345 and are not available for the register allocator.
346 On the 68000, only the stack pointer is such. */
347
348 #define FIXED_REGISTERS \
349 {/* Data registers. */ \
350 0, 0, 0, 0, 0, 0, 0, 0, \
351 \
352 /* Address registers. */ \
353 0, 0, 0, 0, 0, 0, 0, 1, \
354 \
355 /* Floating point registers \
356 (if available). */ \
357 0, 0, 0, 0, 0, 0, 0, 0 }
358
359 /* 1 for registers not available across function calls.
360 These must include the FIXED_REGISTERS and also any
361 registers that can be used without being saved.
362 The latter must include the registers where values are returned
363 and the register where structure-value addresses are passed.
364 Aside from that, you can include as many other registers as you like. */
365 #define CALL_USED_REGISTERS \
366 {1, 1, 0, 0, 0, 0, 0, 0, \
367 1, 1, 0, 0, 0, 0, 0, 1, \
368 1, 1, 0, 0, 0, 0, 0, 0 }
369
370 #else /* SUPPORT_SUN_FPA */
371
372 /* 1 for registers that have pervasive standard uses
373 and are not available for the register allocator.
374 On the 68000, only the stack pointer is such. */
375
376 /* fpa0 is also reserved so that it can be used to move shit back and
377 forth between high fpa regs and everything else. */
378
379 #define FIXED_REGISTERS \
380 {/* Data registers. */ \
381 0, 0, 0, 0, 0, 0, 0, 0, \
382 \
383 /* Address registers. */ \
384 0, 0, 0, 0, 0, 0, 0, 1, \
385 \
386 /* Floating point registers \
387 (if available). */ \
388 0, 0, 0, 0, 0, 0, 0, 0, \
389 \
390 /* Sun3 FPA registers. */ \
391 1, 0, 0, 0, 0, 0, 0, 0, \
392 0, 0, 0, 0, 0, 0, 0, 0, \
393 0, 0, 0, 0, 0, 0, 0, 0, \
394 0, 0, 0, 0, 0, 0, 0, 0 }
395
396 /* 1 for registers not available across function calls.
397 These must include the FIXED_REGISTERS and also any
398 registers that can be used without being saved.
399 The latter must include the registers where values are returned
400 and the register where structure-value addresses are passed.
401 Aside from that, you can include as many other registers as you like. */
402 #define CALL_USED_REGISTERS \
403 {1, 1, 0, 0, 0, 0, 0, 0, \
404 1, 1, 0, 0, 0, 0, 0, 1, \
405 1, 1, 0, 0, 0, 0, 0, 0, \
406 /* FPA registers. */ \
407 1, 1, 1, 1, 0, 0, 0, 0, \
408 0, 0, 0, 0, 0, 0, 0, 0, \
409 0, 0, 0, 0, 0, 0, 0, 0, \
410 0, 0, 0, 0, 0, 0, 0, 0 }
411
412 #endif /* defined SUPPORT_SUN_FPA */
413
414
415 /* Make sure everything's fine if we *don't* have a given processor.
416 This assumes that putting a register in fixed_regs will keep the
417 compiler's mitts completely off it. We don't bother to zero it out
418 of register classes. If neither TARGET_FPA or TARGET_68881 is set,
419 the compiler won't touch since no instructions that use these
420 registers will be valid. */
421
422 #ifdef SUPPORT_SUN_FPA
423
424 #define CONDITIONAL_REGISTER_USAGE \
425 { \
426 int i; \
427 HARD_REG_SET x; \
428 if (!TARGET_FPA) \
429 { \
430 COPY_HARD_REG_SET (x, reg_class_contents[(int)FPA_REGS]); \
431 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \
432 if (TEST_HARD_REG_BIT (x, i)) \
433 fixed_regs[i] = call_used_regs[i] = 1; \
434 } \
435 if (TARGET_FPA) \
436 { \
437 COPY_HARD_REG_SET (x, reg_class_contents[(int)FP_REGS]); \
438 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \
439 if (TEST_HARD_REG_BIT (x, i)) \
440 fixed_regs[i] = call_used_regs[i] = 1; \
441 } \
442 }
443
444 #endif /* defined SUPPORT_SUN_FPA */
445
446 /* Return number of consecutive hard regs needed starting at reg REGNO
447 to hold something of mode MODE.
448 This is ordinarily the length in words of a value of mode MODE
449 but can be less for certain modes in special long registers.
450
451 On the 68000, ordinary registers hold 32 bits worth;
452 for the 68881 registers, a single register is always enough for
453 anything that can be stored in them at all. */
454 #define HARD_REGNO_NREGS(REGNO, MODE) \
455 ((REGNO) >= 16 ? GET_MODE_NUNITS (MODE) \
456 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
457
458 #ifndef SUPPORT_SUN_FPA
459
460 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
461 On the 68000, the cpu registers can hold any mode but the 68881 registers
462 can hold only SFmode or DFmode. The 68881 registers can't hold anything
463 if 68881 use is disabled. */
464
465 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
466 (((REGNO) < 16 \
467 && !((REGNO) < 8 && (REGNO) + GET_MODE_SIZE ((MODE)) / 4 > 8)) \
468 || ((REGNO) < 24 \
469 && TARGET_68881 \
470 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
471 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)))
472
473 #else /* defined SUPPORT_SUN_FPA */
474
475 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
476 On the 68000, the cpu registers can hold any mode but the 68881 registers
477 can hold only SFmode or DFmode. And the 68881 registers can't hold anything
478 if 68881 use is disabled. However, the Sun FPA register can
479 (apparently) hold whatever you feel like putting in them.
480 If using the fpa, don't put a double in d7/a0. */
481
482 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
483 (((REGNO) < 16 \
484 && !(TARGET_FPA \
485 && GET_MODE_CLASS ((MODE)) != MODE_INT \
486 && GET_MODE_UNIT_SIZE ((MODE)) > 4 \
487 && (REGNO) < 8 && (REGNO) + GET_MODE_SIZE ((MODE)) / 4 > 8 \
488 && (REGNO) % (GET_MODE_UNIT_SIZE ((MODE)) / 4) != 0)) \
489 || ((REGNO) < 24 \
490 ? TARGET_68881 && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
491 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
492 : ((REGNO) < 56 ? TARGET_FPA : 0)))
493
494 #endif /* defined SUPPORT_SUN_FPA */
495
496 /* Value is 1 if it is a good idea to tie two pseudo registers
497 when one has mode MODE1 and one has mode MODE2.
498 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
499 for any hard reg, then this must be 0 for correct output. */
500 #define MODES_TIEABLE_P(MODE1, MODE2) \
501 (! TARGET_68881 \
502 || ((GET_MODE_CLASS (MODE1) == MODE_FLOAT \
503 || GET_MODE_CLASS (MODE1) == MODE_COMPLEX_FLOAT) \
504 == (GET_MODE_CLASS (MODE2) == MODE_FLOAT \
505 || GET_MODE_CLASS (MODE2) == MODE_COMPLEX_FLOAT)))
506
507 /* Specify the registers used for certain standard purposes.
508 The values of these macros are register numbers. */
509
510 /* m68000 pc isn't overloaded on a register. */
511 /* #define PC_REGNUM */
512
513 /* Register to use for pushing function arguments. */
514 #define STACK_POINTER_REGNUM 15
515
516 /* Base register for access to local variables of the function. */
517 #define FRAME_POINTER_REGNUM 14
518
519 /* Value should be nonzero if functions must have frame pointers.
520 Zero means the frame pointer need not be set up (and parms
521 may be accessed via the stack pointer) in functions that seem suitable.
522 This is computed in `reload', in reload1.c. */
523 #define FRAME_POINTER_REQUIRED 0
524
525 /* Base register for access to arguments of the function. */
526 #define ARG_POINTER_REGNUM 14
527
528 /* Register in which static-chain is passed to a function. */
529 #define STATIC_CHAIN_REGNUM 8
530
531 /* Register in which address to store a structure value
532 is passed to a function. */
533 #define STRUCT_VALUE_REGNUM 9
534 \f
535 /* Define the classes of registers for register constraints in the
536 machine description. Also define ranges of constants.
537
538 One of the classes must always be named ALL_REGS and include all hard regs.
539 If there is more than one class, another class must be named NO_REGS
540 and contain no registers.
541
542 The name GENERAL_REGS must be the name of a class (or an alias for
543 another name such as ALL_REGS). This is the class of registers
544 that is allowed by "g" or "r" in a register constraint.
545 Also, registers outside this class are allocated only when
546 instructions express preferences for them.
547
548 The classes must be numbered in nondecreasing order; that is,
549 a larger-numbered class must never be contained completely
550 in a smaller-numbered class.
551
552 For any two classes, it is very desirable that there be another
553 class that represents their union. */
554
555 /* The 68000 has three kinds of registers, so eight classes would be
556 a complete set. One of them is not needed. */
557
558 #ifndef SUPPORT_SUN_FPA
559
560 enum reg_class {
561 NO_REGS, DATA_REGS,
562 ADDR_REGS, FP_REGS,
563 GENERAL_REGS, DATA_OR_FP_REGS,
564 ADDR_OR_FP_REGS, ALL_REGS,
565 LIM_REG_CLASSES };
566
567 #define N_REG_CLASSES (int) LIM_REG_CLASSES
568
569 /* Give names of register classes as strings for dump file. */
570
571 #define REG_CLASS_NAMES \
572 { "NO_REGS", "DATA_REGS", \
573 "ADDR_REGS", "FP_REGS", \
574 "GENERAL_REGS", "DATA_OR_FP_REGS", \
575 "ADDR_OR_FP_REGS", "ALL_REGS" }
576
577 /* Define which registers fit in which classes.
578 This is an initializer for a vector of HARD_REG_SET
579 of length N_REG_CLASSES. */
580
581 #define REG_CLASS_CONTENTS \
582 { \
583 0x00000000, /* NO_REGS */ \
584 0x000000ff, /* DATA_REGS */ \
585 0x0000ff00, /* ADDR_REGS */ \
586 0x00ff0000, /* FP_REGS */ \
587 0x0000ffff, /* GENERAL_REGS */ \
588 0x00ff00ff, /* DATA_OR_FP_REGS */ \
589 0x00ffff00, /* ADDR_OR_FP_REGS */ \
590 0x00ffffff, /* ALL_REGS */ \
591 }
592
593 /* The same information, inverted:
594 Return the class number of the smallest class containing
595 reg number REGNO. This could be a conditional expression
596 or could index an array. */
597
598 #define REGNO_REG_CLASS(REGNO) (((REGNO)>>3)+1)
599
600 #else /* defined SUPPORT_SUN_FPA */
601
602 /*
603 * Notes on final choices:
604 *
605 * 1) Didn't feel any need to union-ize LOW_FPA_REGS with anything
606 * else.
607 * 2) Removed all unions that involve address registers with
608 * floating point registers (left in unions of address and data with
609 * floating point).
610 * 3) Defined GENERAL_REGS as ADDR_OR_DATA_REGS.
611 * 4) Defined ALL_REGS as FPA_OR_FP_OR_GENERAL_REGS.
612 * 4) Left in everything else.
613 */
614 enum reg_class { NO_REGS, LO_FPA_REGS, FPA_REGS, FP_REGS,
615 FP_OR_FPA_REGS, DATA_REGS, DATA_OR_FPA_REGS, DATA_OR_FP_REGS,
616 DATA_OR_FP_OR_FPA_REGS, ADDR_REGS, GENERAL_REGS,
617 GENERAL_OR_FPA_REGS, GENERAL_OR_FP_REGS, ALL_REGS,
618 LIM_REG_CLASSES };
619
620 #define N_REG_CLASSES (int) LIM_REG_CLASSES
621
622 /* Give names of register classes as strings for dump file. */
623
624 #define REG_CLASS_NAMES \
625 { "NO_REGS", "LO_FPA_REGS", "FPA_REGS", "FP_REGS", \
626 "FP_OR_FPA_REGS", "DATA_REGS", "DATA_OR_FPA_REGS", "DATA_OR_FP_REGS", \
627 "DATA_OR_FP_OR_FPA_REGS", "ADDR_REGS", "GENERAL_REGS", \
628 "GENERAL_OR_FPA_REGS", "GENERAL_OR_FP_REGS", "ALL_REGS" }
629
630 /* Define which registers fit in which classes.
631 This is an initializer for a vector of HARD_REG_SET
632 of length N_REG_CLASSES. */
633
634 #define REG_CLASS_CONTENTS \
635 { \
636 {0, 0}, /* NO_REGS */ \
637 {0xff000000, 0x000000ff}, /* LO_FPA_REGS */ \
638 {0xff000000, 0x00ffffff}, /* FPA_REGS */ \
639 {0x00ff0000, 0x00000000}, /* FP_REGS */ \
640 {0xffff0000, 0x00ffffff}, /* FP_OR_FPA_REGS */ \
641 {0x000000ff, 0x00000000}, /* DATA_REGS */ \
642 {0xff0000ff, 0x00ffffff}, /* DATA_OR_FPA_REGS */ \
643 {0x00ff00ff, 0x00000000}, /* DATA_OR_FP_REGS */ \
644 {0xffff00ff, 0x00ffffff}, /* DATA_OR_FP_OR_FPA_REGS */\
645 {0x0000ff00, 0x00000000}, /* ADDR_REGS */ \
646 {0x0000ffff, 0x00000000}, /* GENERAL_REGS */ \
647 {0xff00ffff, 0x00ffffff}, /* GENERAL_OR_FPA_REGS */\
648 {0x00ffffff, 0x00000000}, /* GENERAL_OR_FP_REGS */\
649 {0xffffffff, 0x00ffffff}, /* ALL_REGS */ \
650 }
651
652 /* The same information, inverted:
653 Return the class number of the smallest class containing
654 reg number REGNO. This could be a conditional expression
655 or could index an array. */
656
657 extern enum reg_class regno_reg_class[];
658 #define REGNO_REG_CLASS(REGNO) (regno_reg_class[(REGNO)>>3])
659
660 #endif /* SUPPORT_SUN_FPA */
661
662 /* The class value for index registers, and the one for base regs. */
663
664 #define INDEX_REG_CLASS GENERAL_REGS
665 #define BASE_REG_CLASS ADDR_REGS
666
667 /* Get reg_class from a letter such as appears in the machine description.
668 We do a trick here to modify the effective constraints on the
669 machine description; we zorch the constraint letters that aren't
670 appropriate for a specific target. This allows us to guarantee
671 that a specific kind of register will not be used for a given target
672 without fiddling with the register classes above. */
673
674 #ifndef SUPPORT_SUN_FPA
675
676 #define REG_CLASS_FROM_LETTER(C) \
677 ((C) == 'a' ? ADDR_REGS : \
678 ((C) == 'd' ? DATA_REGS : \
679 ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \
680 NO_REGS) : \
681 NO_REGS)))
682
683 #else /* defined SUPPORT_SUN_FPA */
684
685 #define REG_CLASS_FROM_LETTER(C) \
686 ((C) == 'a' ? ADDR_REGS : \
687 ((C) == 'd' ? DATA_REGS : \
688 ((C) == 'f' ? (TARGET_68881 ? FP_REGS : \
689 NO_REGS) : \
690 ((C) == 'x' ? (TARGET_FPA ? FPA_REGS : \
691 NO_REGS) : \
692 ((C) == 'y' ? (TARGET_FPA ? LO_FPA_REGS : \
693 NO_REGS) : \
694 NO_REGS)))))
695
696 #endif /* defined SUPPORT_SUN_FPA */
697
698 /* The letters I, J, K, L and M in a register constraint string
699 can be used to stand for particular ranges of immediate operands.
700 This macro defines what the ranges are.
701 C is the letter, and VALUE is a constant value.
702 Return 1 if VALUE is in the range specified by C.
703
704 For the 68000, `I' is used for the range 1 to 8
705 allowed as immediate shift counts and in addq.
706 `J' is used for the range of signed numbers that fit in 16 bits.
707 `K' is for numbers that moveq can't handle.
708 `L' is for range -8 to -1, range of values that can be added with subq.
709 `M' is for numbers that moveq+notb can't handle.
710 'N' is for range 24 to 31, rotatert:SI 8 to 1 expressed as rotate.
711 'O' is for 16 (for rotate using swap).
712 'P' is for range 8 to 15, rotatert:HI 8 to 1 expressed as rotate. */
713
714 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
715 ((C) == 'I' ? (VALUE) > 0 && (VALUE) <= 8 : \
716 (C) == 'J' ? (VALUE) >= -0x8000 && (VALUE) <= 0x7FFF : \
717 (C) == 'K' ? (VALUE) < -0x80 || (VALUE) >= 0x80 : \
718 (C) == 'L' ? (VALUE) < 0 && (VALUE) >= -8 : \
719 (C) == 'M' ? (VALUE) < -0x100 && (VALUE) >= 0x100 : \
720 (C) == 'N' ? (VALUE) >= 24 && (VALUE) <= 31 : \
721 (C) == 'O' ? (VALUE) == 16 : \
722 (C) == 'P' ? (VALUE) >= 8 && (VALUE) <= 15 : 0)
723
724 /*
725 * A small bit of explanation:
726 * "G" defines all of the floating constants that are *NOT* 68881
727 * constants. this is so 68881 constants get reloaded and the
728 * fpmovecr is used. "H" defines *only* the class of constants that
729 * the fpa can use, because these can be gotten at in any fpa
730 * instruction and there is no need to force reloads.
731 */
732 #ifndef SUPPORT_SUN_FPA
733 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
734 ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : 0 )
735 #else /* defined SUPPORT_SUN_FPA */
736 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
737 ((C) == 'G' ? ! (TARGET_68881 && standard_68881_constant_p (VALUE)) : \
738 (C) == 'H' ? (TARGET_FPA && standard_sun_fpa_constant_p (VALUE)) : 0)
739 #endif /* defined SUPPORT_SUN_FPA */
740
741 /* A C expression that defines the optional machine-dependent constraint
742 letters that can be used to segregate specific types of operands,
743 usually memory references, for the target machine. It should return 1 if
744 VALUE corresponds to the operand type represented by the constraint letter
745 C. If C is not defined as an extra constraint, the value returned should
746 be 0 regardless of VALUE. */
747
748 /* For the m68k, `Q' means address register indirect addressing mode. */
749
750 #define EXTRA_CONSTRAINT(OP, C) \
751 ((C) == 'Q' ? (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG) : \
752 0 )
753
754 /* Given an rtx X being reloaded into a reg required to be
755 in class CLASS, return the class of reg to actually use.
756 In general this is just CLASS; but on some machines
757 in some cases it is preferable to use a more restrictive class.
758 On the 68000 series, use a data reg if possible when the
759 value is a constant in the range where moveq could be used
760 and we ensure that QImodes are reloaded into data regs.
761 Also, if a floating constant needs reloading, put it in memory.
762 Don't do this for !G constants, since all patterns in the md file
763 expect them to be loaded into a register via fpmovecr. See above. */
764
765 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
766 ((GET_CODE (X) == CONST_INT \
767 && (unsigned) (INTVAL (X) + 0x80) < 0x100 \
768 && (CLASS) != ADDR_REGS) \
769 ? DATA_REGS \
770 : (GET_MODE (X) == QImode && (CLASS) != ADDR_REGS) \
771 ? DATA_REGS \
772 : (GET_CODE (X) == CONST_DOUBLE \
773 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
774 ? (! CONST_DOUBLE_OK_FOR_LETTER_P (X, 'G') \
775 && (CLASS == FP_REGS || CLASS == DATA_OR_FP_REGS) \
776 ? FP_REGS : NO_REGS) \
777 : (CLASS))
778
779 /* Return the maximum number of consecutive registers
780 needed to represent mode MODE in a register of class CLASS. */
781 /* On the 68000, this is the size of MODE in words,
782 except in the FP regs, where a single reg is always enough. */
783 #ifndef SUPPORT_SUN_FPA
784
785 #define CLASS_MAX_NREGS(CLASS, MODE) \
786 ((CLASS) == FP_REGS ? 1 \
787 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
788
789 /* Moves between fp regs and other regs are two insns. */
790 #define REGISTER_MOVE_COST(CLASS1, CLASS2) \
791 (((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \
792 || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \
793 ? 4 : 2)
794
795 #else /* defined SUPPORT_SUN_FPA */
796
797 #define CLASS_MAX_NREGS(CLASS, MODE) \
798 ((CLASS) == FP_REGS || (CLASS) == FPA_REGS || (CLASS) == LO_FPA_REGS ? 1 \
799 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
800
801 /* Moves between fp regs and other regs are two insns. */
802 /* Likewise for high fpa regs and other regs. */
803 #define REGISTER_MOVE_COST(CLASS1, CLASS2) \
804 ((((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \
805 || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS) \
806 || ((CLASS1) == FPA_REGS && (CLASS2) != FPA_REGS) \
807 || ((CLASS2) == FPA_REGS && (CLASS1) != FPA_REGS)) \
808 ? 4 : 2)
809
810 #endif /* define SUPPORT_SUN_FPA */
811 \f
812 /* Stack layout; function entry, exit and calling. */
813
814 /* Define this if pushing a word on the stack
815 makes the stack pointer a smaller address. */
816 #define STACK_GROWS_DOWNWARD
817
818 /* Nonzero if we need to generate stack-probe insns.
819 On most systems they are not needed.
820 When they are needed, define this as the stack offset to probe at. */
821 #define NEED_PROBE 0
822
823 /* Define this if the nominal address of the stack frame
824 is at the high-address end of the local variables;
825 that is, each additional local variable allocated
826 goes at a more negative offset in the frame. */
827 #define FRAME_GROWS_DOWNWARD
828
829 /* Offset within stack frame to start allocating local variables at.
830 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
831 first local allocated. Otherwise, it is the offset to the BEGINNING
832 of the first local allocated. */
833 #define STARTING_FRAME_OFFSET 0
834
835 /* If we generate an insn to push BYTES bytes,
836 this says how many the stack pointer really advances by.
837 On the 68000, sp@- in a byte insn really pushes a word. */
838 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
839
840 /* Offset of first parameter from the argument pointer register value. */
841 #define FIRST_PARM_OFFSET(FNDECL) 8
842
843 /* Value is the number of byte of arguments automatically
844 popped when returning from a subroutine call.
845 FUNDECL is the declaration node of the function (as a tree),
846 FUNTYPE is the data type of the function (as a tree),
847 or for a library call it is an identifier node for the subroutine name.
848 SIZE is the number of bytes of arguments passed on the stack.
849
850 On the 68000, the RTS insn cannot pop anything.
851 On the 68010, the RTD insn may be used to pop them if the number
852 of args is fixed, but if the number is variable then the caller
853 must pop them all. RTD can't be used for library calls now
854 because the library is compiled with the Unix compiler.
855 Use of RTD is a selectable option, since it is incompatible with
856 standard Unix calling sequences. If the option is not selected,
857 the caller must always pop the args. */
858
859 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
860 ((TARGET_RTD && (!(FUNDECL) || TREE_CODE (FUNDECL) != IDENTIFIER_NODE) \
861 && (TYPE_ARG_TYPES (FUNTYPE) == 0 \
862 || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \
863 == void_type_node))) \
864 ? (SIZE) : 0)
865
866 /* Define how to find the value returned by a function.
867 VALTYPE is the data type of the value (as a tree).
868 If the precise function being called is known, FUNC is its FUNCTION_DECL;
869 otherwise, FUNC is 0. */
870
871 /* On the 68000 the return value is in D0 regardless. */
872
873 #define FUNCTION_VALUE(VALTYPE, FUNC) \
874 gen_rtx (REG, TYPE_MODE (VALTYPE), 0)
875
876 /* Define how to find the value returned by a library function
877 assuming the value has mode MODE. */
878
879 /* On the 68000 the return value is in D0 regardless. */
880
881 #define LIBCALL_VALUE(MODE) gen_rtx (REG, MODE, 0)
882
883 /* 1 if N is a possible register number for a function value.
884 On the 68000, d0 is the only register thus used. */
885
886 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0)
887
888 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for
889 more than one register. */
890
891 #define NEEDS_UNTYPED_CALL 0
892
893 /* Define this if PCC uses the nonreentrant convention for returning
894 structure and union values. */
895
896 #define PCC_STATIC_STRUCT_RETURN
897
898 /* 1 if N is a possible register number for function argument passing.
899 On the 68000, no registers are used in this way. */
900
901 #define FUNCTION_ARG_REGNO_P(N) 0
902 \f
903 /* Define a data type for recording info about an argument list
904 during the scan of that argument list. This data type should
905 hold all necessary information about the function itself
906 and about the args processed so far, enough to enable macros
907 such as FUNCTION_ARG to determine where the next arg should go.
908
909 On the m68k, this is a single integer, which is a number of bytes
910 of arguments scanned so far. */
911
912 #define CUMULATIVE_ARGS int
913
914 /* Initialize a variable CUM of type CUMULATIVE_ARGS
915 for a call to a function whose data type is FNTYPE.
916 For a library call, FNTYPE is 0.
917
918 On the m68k, the offset starts at 0. */
919
920 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
921 ((CUM) = 0)
922
923 /* Update the data in CUM to advance over an argument
924 of mode MODE and data type TYPE.
925 (TYPE is null for libcalls where that information may not be available.) */
926
927 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
928 ((CUM) += ((MODE) != BLKmode \
929 ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
930 : (int_size_in_bytes (TYPE) + 3) & ~3))
931
932 /* Define where to put the arguments to a function.
933 Value is zero to push the argument on the stack,
934 or a hard register in which to store the argument.
935
936 MODE is the argument's machine mode.
937 TYPE is the data type of the argument (as a tree).
938 This is null for libcalls where that information may
939 not be available.
940 CUM is a variable of type CUMULATIVE_ARGS which gives info about
941 the preceding args and about the function being called.
942 NAMED is nonzero if this argument is a named parameter
943 (otherwise it is an extra parameter matching an ellipsis). */
944
945 /* On the 68000 all args are pushed, except if -mregparm is specified
946 then the first two words of arguments are passed in d0, d1.
947 *NOTE* -mregparm does not work.
948 It exists only to test register calling conventions. */
949
950 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
951 ((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0)
952
953 /* For an arg passed partly in registers and partly in memory,
954 this is the number of registers used.
955 For args passed entirely in registers or entirely in memory, zero. */
956
957 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
958 ((TARGET_REGPARM && (CUM) < 8 \
959 && 8 < ((CUM) + ((MODE) == BLKmode \
960 ? int_size_in_bytes (TYPE) \
961 : GET_MODE_SIZE (MODE)))) \
962 ? 2 - (CUM) / 4 : 0)
963
964 /* Generate the assembly code for function entry. */
965 #define FUNCTION_PROLOGUE(FILE, SIZE) output_function_prologue(FILE, SIZE)
966
967 /* Output assembler code to FILE to increment profiler label # LABELNO
968 for profiling a function entry. */
969
970 #define FUNCTION_PROFILER(FILE, LABELNO) \
971 asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO))
972
973 /* Output assembler code to FILE to initialize this source file's
974 basic block profiling info, if that has not already been done. */
975
976 #define FUNCTION_BLOCK_PROFILER(FILE, BLOCK_OR_LABEL) \
977 do \
978 { \
979 switch (profile_block_flag) \
980 { \
981 case 2: \
982 asm_fprintf (FILE, "\tpea %d\n\tpea %LLPBX0\n\tjsr %U__bb_init_trace_func\n\taddql %I8,%Rsp\n", \
983 (BLOCK_OR_LABEL)); \
984 break; \
985 \
986 default: \
987 asm_fprintf (FILE, "\ttstl %LLPBX0\n\tbne %LLPI%d\n\tpea %LLPBX0\n\tjsr %U__bb_init_func\n\taddql %I4,%Rsp\n%LLPI%d:\n", \
988 (BLOCK_OR_LABEL), (BLOCK_OR_LABEL)); \
989 break; \
990 } \
991 } \
992 while(0)
993
994 /* Output assembler code to FILE to increment the counter for
995 the BLOCKNO'th basic block in this source file. */
996
997 #define BLOCK_PROFILER(FILE, BLOCKNO) \
998 do \
999 { \
1000 switch (profile_block_flag) \
1001 { \
1002 case 2: \
1003 asm_fprintf (FILE, "\tmovel %Ra1,%Rsp@-\n\tlea ___bb,%Ra1\n\tmovel %I%d,%Ra1@(0)\n\tmovel %I%LLPBX0,%Ra1@(4)\n\tmovel %Rsp@+,%Ra1\n\tjsr %U__bb_trace_func\n", \
1004 BLOCKNO); \
1005 break; \
1006 \
1007 default: \
1008 asm_fprintf (FILE, "\taddql %I1,%LLPBX2+%d\n", 4 * BLOCKNO); \
1009 break; \
1010 } \
1011 } \
1012 while(0)
1013
1014 /* Output assembler code to FILE to indicate return from
1015 a function during basic block profiling. */
1016
1017 #define FUNCTION_BLOCK_PROFILER_EXIT(FILE) \
1018 asm_fprintf (FILE, "\tjsr %U__bb_trace_ret\n");
1019
1020 /* Save all registers which may be clobbered by a function call. */
1021
1022 #ifdef MOTOROLA
1023 #define MACHINE_STATE_SAVE(id) \
1024 if (TARGET_5200) \
1025 { \
1026 asm ("sub.l 20,%sp"); \
1027 asm ("movm.l &0x0303,4(%sp)"); \
1028 asm ("move.w %ccr,%d0"); \
1029 asm ("movm.l &0x0001,(%sp)"); \
1030 } \
1031 else \
1032 { \
1033 asm ("move.w %ccr,-(%sp)"); \
1034 asm ("movm.l &0xc0c0,-(%sp)"); \
1035 }
1036 #else
1037 #define MACHINE_STATE_SAVE(id) \
1038 if (TARGET_5200) \
1039 { \
1040 asm ("subl 20,sp"); \
1041 asm ("movml d0/d1/a0/a1,sp@(4)"); \
1042 asm ("movew cc,d0"); \
1043 asm ("movml d0,sp@"); \
1044 } \
1045 else \
1046 { \
1047 asm ("movew cc,sp@-"); \
1048 asm ("moveml d0/d1/a0/a1,sp@-"); \
1049 }
1050 #endif
1051
1052 /* Restore all registers saved by MACHINE_STATE_SAVE. */
1053
1054 #ifdef MOTOROLA
1055 #define MACHINE_STATE_RESTORE(id) \
1056 if (TARGET_5200) \
1057 { \
1058 asm ("movm.l (%sp),&0x0001"); \
1059 asm ("move.w %d0,%ccr"); \
1060 asm ("movm.l 4(%sp),&0x0303"); \
1061 asm ("add.l 20,%sp"); \
1062 } \
1063 else \
1064 { \
1065 asm ("movm.l (%sp)+,&0x0303"); \
1066 asm ("move.w (%sp)+,%ccr"); \
1067 }
1068 #else
1069 #define MACHINE_STATE_RESTORE(id) \
1070 if (TARGET_5200) \
1071 { \
1072 asm ("movml sp@,d0"); \
1073 asm ("movew d0,cc"); \
1074 asm ("movml sp@(4),d0/d1/a0/a1"); \
1075 asm ("addl 20,sp"); \
1076 } \
1077 else \
1078 { \
1079 asm ("moveml sp@+,d0/d1/a0/a1"); \
1080 asm ("movew sp@+,cc"); \
1081 }
1082 #endif
1083
1084 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1085 the stack pointer does not matter. The value is tested only in
1086 functions that have frame pointers.
1087 No definition is equivalent to always zero. */
1088
1089 #define EXIT_IGNORE_STACK 1
1090
1091 /* Generate the assembly code for function exit. */
1092 #define FUNCTION_EPILOGUE(FILE, SIZE) output_function_epilogue (FILE, SIZE)
1093
1094 /* This is a hook for other tm files to change. */
1095 /* #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE) */
1096
1097 /* Determine if the epilogue should be output as RTL.
1098 You should override this if you define FUNCTION_EXTRA_EPILOGUE. */
1099 #define USE_RETURN_INSN use_return_insn ()
1100
1101 /* Store in the variable DEPTH the initial difference between the
1102 frame pointer reg contents and the stack pointer reg contents,
1103 as of the start of the function body. This depends on the layout
1104 of the fixed parts of the stack frame and on how registers are saved.
1105
1106 On the 68k, if we have a frame, we must add one word to its length
1107 to allow for the place that a6 is stored when we do have a frame pointer.
1108 Otherwise, we would need to compute the offset from the frame pointer
1109 of a local variable as a function of frame_pointer_needed, which
1110 is hard. */
1111
1112 #define INITIAL_FRAME_POINTER_OFFSET(DEPTH) \
1113 { int regno; \
1114 int offset = -4; \
1115 for (regno = 16; regno < FIRST_PSEUDO_REGISTER; regno++) \
1116 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1117 offset += 12; \
1118 for (regno = 0; regno < 16; regno++) \
1119 if (regs_ever_live[regno] && ! call_used_regs[regno]) \
1120 offset += 4; \
1121 (DEPTH) = (offset + ((get_frame_size () + 3) & -4) \
1122 + (get_frame_size () == 0 ? 0 : 4)); \
1123 }
1124
1125 /* Output assembler code for a block containing the constant parts
1126 of a trampoline, leaving space for the variable parts. */
1127
1128 /* On the 68k, the trampoline looks like this:
1129 movl #STATIC,a0
1130 jmp FUNCTION
1131
1132 WARNING: Targets that may run on 68040+ cpus must arrange for
1133 the instruction cache to be flushed. Previous incarnations of
1134 the m68k trampoline code attempted to get around this by either
1135 using an out-of-line transfer function or pc-relative data, but
1136 the fact remains that the code to jump to the transfer function
1137 or the code to load the pc-relative data needs to be flushed
1138 just as much as the "variable" portion of the trampoline.
1139 Recognizing that a cache flush is going to be required anyway,
1140 dispense with such notions and build a smaller trampoline. */
1141
1142 /* Since more instructions are required to move a template into
1143 place than to create it on the spot, don't use a template. */
1144
1145 /* Length in units of the trampoline for entering a nested function. */
1146
1147 #define TRAMPOLINE_SIZE 12
1148
1149 /* Alignment required for a trampoline in bits. */
1150
1151 #define TRAMPOLINE_ALIGNMENT 16
1152
1153 /* Targets redefine this to invoke code to either flush the cache,
1154 or enable stack execution (or both). */
1155
1156 #ifndef FINALIZE_TRAMPOLINE
1157 #define FINALIZE_TRAMPOLINE(TRAMP)
1158 #endif
1159
1160 /* Emit RTL insns to initialize the variable parts of a trampoline.
1161 FNADDR is an RTX for the address of the function's pure code.
1162 CXT is an RTX for the static chain value for the function. */
1163
1164 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1165 { \
1166 emit_move_insn (gen_rtx (MEM, HImode, TRAMP), GEN_INT(0x207C)); \
1167 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 2)), CXT); \
1168 emit_move_insn (gen_rtx (MEM, HImode, plus_constant (TRAMP, 6)), \
1169 GEN_INT(0x4EF9)); \
1170 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 8)), FNADDR); \
1171 FINALIZE_TRAMPOLINE(TRAMP); \
1172 }
1173
1174 /* This is the library routine that is used
1175 to transfer control from the trampoline
1176 to the actual nested function.
1177 It is defined for backward compatibility,
1178 for linking with object code that used the old
1179 trampoline definition. */
1180
1181 /* A colon is used with no explicit operands
1182 to cause the template string to be scanned for %-constructs. */
1183 /* The function name __transfer_from_trampoline is not actually used.
1184 The function definition just permits use of "asm with operands"
1185 (though the operand list is empty). */
1186 #define TRANSFER_FROM_TRAMPOLINE \
1187 void \
1188 __transfer_from_trampoline () \
1189 { \
1190 register char *a0 asm ("%a0"); \
1191 asm (GLOBAL_ASM_OP " ___trampoline"); \
1192 asm ("___trampoline:"); \
1193 asm volatile ("move%.l %0,%@" : : "m" (a0[22])); \
1194 asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18])); \
1195 asm ("rts":); \
1196 }
1197 \f
1198 /* Addressing modes, and classification of registers for them. */
1199
1200 #define HAVE_POST_INCREMENT
1201 /* #define HAVE_POST_DECREMENT */
1202
1203 #define HAVE_PRE_DECREMENT
1204 /* #define HAVE_PRE_INCREMENT */
1205
1206 /* Macros to check register numbers against specific register classes. */
1207
1208 /* These assume that REGNO is a hard or pseudo reg number.
1209 They give nonzero only if REGNO is a hard reg of the suitable class
1210 or a pseudo reg currently allocated to a suitable hard reg.
1211 Since they use reg_renumber, they are safe only once reg_renumber
1212 has been allocated, which happens in local-alloc.c. */
1213
1214 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1215 ((REGNO) < 16 || (unsigned) reg_renumber[REGNO] < 16)
1216 #define REGNO_OK_FOR_BASE_P(REGNO) \
1217 (((REGNO) ^ 010) < 8 || (unsigned) (reg_renumber[REGNO] ^ 010) < 8)
1218 #define REGNO_OK_FOR_DATA_P(REGNO) \
1219 ((REGNO) < 8 || (unsigned) reg_renumber[REGNO] < 8)
1220 #define REGNO_OK_FOR_FP_P(REGNO) \
1221 (((REGNO) ^ 020) < 8 || (unsigned) (reg_renumber[REGNO] ^ 020) < 8)
1222 #ifdef SUPPORT_SUN_FPA
1223 #define REGNO_OK_FOR_FPA_P(REGNO) \
1224 (((REGNO) >= 24 && (REGNO) < 56) || (reg_renumber[REGNO] >= 24 && reg_renumber[REGNO] < 56))
1225 #endif
1226
1227 /* Now macros that check whether X is a register and also,
1228 strictly, whether it is in a specified class.
1229
1230 These macros are specific to the 68000, and may be used only
1231 in code for printing assembler insns and in conditions for
1232 define_optimization. */
1233
1234 /* 1 if X is a data register. */
1235
1236 #define DATA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_DATA_P (REGNO (X)))
1237
1238 /* 1 if X is an fp register. */
1239
1240 #define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
1241
1242 /* 1 if X is an address register */
1243
1244 #define ADDRESS_REG_P(X) (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X)))
1245
1246 #ifdef SUPPORT_SUN_FPA
1247 /* 1 if X is a register in the Sun FPA. */
1248 #define FPA_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FPA_P (REGNO (X)))
1249 #else
1250 /* Answer must be no if we don't have an FPA. */
1251 #define FPA_REG_P(X) 0
1252 #endif
1253 \f
1254 /* Maximum number of registers that can appear in a valid memory address. */
1255
1256 #define MAX_REGS_PER_ADDRESS 2
1257
1258 /* Recognize any constant value that is a valid address. */
1259
1260 #define CONSTANT_ADDRESS_P(X) \
1261 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
1262 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
1263 || GET_CODE (X) == HIGH)
1264
1265 /* Nonzero if the constant value X is a legitimate general operand.
1266 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1267
1268 #define LEGITIMATE_CONSTANT_P(X) 1
1269
1270 /* Nonzero if the constant value X is a legitimate general operand
1271 when generating PIC code. It is given that flag_pic is on and
1272 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1273
1274 #define LEGITIMATE_PIC_OPERAND_P(X) \
1275 ((! symbolic_operand (X, VOIDmode) \
1276 && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X) \
1277 && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM \
1278 && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0), \
1279 VOIDmode))) \
1280 || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
1281
1282 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1283 and check its validity for a certain class.
1284 We have two alternate definitions for each of them.
1285 The usual definition accepts all pseudo regs; the other rejects
1286 them unless they have been allocated suitable hard regs.
1287 The symbol REG_OK_STRICT causes the latter definition to be used.
1288
1289 Most source files want to accept pseudo regs in the hope that
1290 they will get allocated to the class that the insn wants them to be in.
1291 Source files for reload pass need to be strict.
1292 After reload, it makes no difference, since pseudo regs have
1293 been eliminated by then. */
1294
1295 #ifndef REG_OK_STRICT
1296
1297 /* Nonzero if X is a hard reg that can be used as an index
1298 or if it is a pseudo reg. */
1299 #define REG_OK_FOR_INDEX_P(X) ((REGNO (X) ^ 020) >= 8)
1300 /* Nonzero if X is a hard reg that can be used as a base reg
1301 or if it is a pseudo reg. */
1302 #define REG_OK_FOR_BASE_P(X) ((REGNO (X) & ~027) != 0)
1303
1304 #else
1305
1306 /* Nonzero if X is a hard reg that can be used as an index. */
1307 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1308 /* Nonzero if X is a hard reg that can be used as a base reg. */
1309 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1310
1311 #endif
1312 \f
1313 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1314 that is a valid memory address for an instruction.
1315 The MODE argument is the machine mode for the MEM expression
1316 that wants to use this address.
1317
1318 When generating PIC, an address involving a SYMBOL_REF is legitimate
1319 if and only if it is the sum of pic_offset_table_rtx and the SYMBOL_REF.
1320 We use LEGITIMATE_PIC_OPERAND_P to throw out the illegitimate addresses,
1321 and we explicitly check for the sum of pic_offset_table_rtx and a SYMBOL_REF.
1322
1323 Likewise for a LABEL_REF when generating PIC.
1324
1325 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
1326
1327 /* Allow SUBREG everywhere we allow REG. This results in better code. It
1328 also makes function inlining work when inline functions are called with
1329 arguments that are SUBREGs. */
1330
1331 #define LEGITIMATE_BASE_REG_P(X) \
1332 ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
1333 || (GET_CODE (X) == SUBREG \
1334 && GET_CODE (SUBREG_REG (X)) == REG \
1335 && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
1336
1337 #define INDIRECTABLE_1_ADDRESS_P(X) \
1338 ((CONSTANT_ADDRESS_P (X) && (!flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \
1339 || LEGITIMATE_BASE_REG_P (X) \
1340 || ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == POST_INC) \
1341 && LEGITIMATE_BASE_REG_P (XEXP (X, 0))) \
1342 || (GET_CODE (X) == PLUS \
1343 && LEGITIMATE_BASE_REG_P (XEXP (X, 0)) \
1344 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1345 && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000) \
1346 || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \
1347 && flag_pic && GET_CODE (XEXP (X, 1)) == SYMBOL_REF) \
1348 || (GET_CODE (X) == PLUS && XEXP (X, 0) == pic_offset_table_rtx \
1349 && flag_pic && GET_CODE (XEXP (X, 1)) == LABEL_REF)) \
1350
1351 #if 0
1352 /* This should replace the last two (non-pic) lines
1353 except that Sun's assembler does not seem to handle such operands. */
1354 && (TARGET_68020 ? CONSTANT_ADDRESS_P (XEXP (X, 1)) \
1355 : (GET_CODE (XEXP (X, 1)) == CONST_INT \
1356 && ((unsigned) INTVAL (XEXP (X, 1)) + 0x8000) < 0x10000))))
1357 #endif
1358
1359
1360 #define GO_IF_NONINDEXED_ADDRESS(X, ADDR) \
1361 { if (INDIRECTABLE_1_ADDRESS_P (X)) goto ADDR; }
1362
1363 /* Only labels on dispatch tables are valid for indexing from. */
1364 #define GO_IF_INDEXABLE_BASE(X, ADDR) \
1365 { rtx temp; \
1366 if (GET_CODE (X) == LABEL_REF \
1367 && (temp = next_nonnote_insn (XEXP (X, 0))) != 0 \
1368 && GET_CODE (temp) == JUMP_INSN \
1369 && (GET_CODE (PATTERN (temp)) == ADDR_VEC \
1370 || GET_CODE (PATTERN (temp)) == ADDR_DIFF_VEC)) \
1371 goto ADDR; \
1372 if (LEGITIMATE_BASE_REG_P (X)) goto ADDR; }
1373
1374 #define GO_IF_INDEXING(X, ADDR) \
1375 { if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0))) \
1376 { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); } \
1377 if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1))) \
1378 { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } }
1379
1380 #define GO_IF_INDEXED_ADDRESS(X, ADDR) \
1381 { GO_IF_INDEXING (X, ADDR); \
1382 if (GET_CODE (X) == PLUS) \
1383 { if (GET_CODE (XEXP (X, 1)) == CONST_INT \
1384 && (unsigned) INTVAL (XEXP (X, 1)) + 0x80 < 0x100) \
1385 { rtx go_temp = XEXP (X, 0); GO_IF_INDEXING (go_temp, ADDR); } \
1386 if (GET_CODE (XEXP (X, 0)) == CONST_INT \
1387 && (unsigned) INTVAL (XEXP (X, 0)) + 0x80 < 0x100) \
1388 { rtx go_temp = XEXP (X, 1); GO_IF_INDEXING (go_temp, ADDR); } } }
1389
1390 #define LEGITIMATE_INDEX_REG_P(X) \
1391 ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
1392 || (GET_CODE (X) == SIGN_EXTEND \
1393 && GET_CODE (XEXP (X, 0)) == REG \
1394 && GET_MODE (XEXP (X, 0)) == HImode \
1395 && REG_OK_FOR_INDEX_P (XEXP (X, 0))) \
1396 || (GET_CODE (X) == SUBREG \
1397 && GET_CODE (SUBREG_REG (X)) == REG \
1398 && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
1399
1400 #define LEGITIMATE_INDEX_P(X) \
1401 (LEGITIMATE_INDEX_REG_P (X) \
1402 || ((TARGET_68020 || TARGET_5200) && GET_CODE (X) == MULT \
1403 && LEGITIMATE_INDEX_REG_P (XEXP (X, 0)) \
1404 && GET_CODE (XEXP (X, 1)) == CONST_INT \
1405 && (INTVAL (XEXP (X, 1)) == 2 \
1406 || INTVAL (XEXP (X, 1)) == 4 \
1407 || (INTVAL (XEXP (X, 1)) == 8 && !TARGET_5200))))
1408
1409 /* If pic, we accept INDEX+LABEL, which is what do_tablejump makes. */
1410 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1411 { GO_IF_NONINDEXED_ADDRESS (X, ADDR); \
1412 GO_IF_INDEXED_ADDRESS (X, ADDR); \
1413 if (flag_pic && MODE == CASE_VECTOR_MODE && GET_CODE (X) == PLUS \
1414 && LEGITIMATE_INDEX_P (XEXP (X, 0)) \
1415 && GET_CODE (XEXP (X, 1)) == LABEL_REF) \
1416 goto ADDR; }
1417
1418 /* Don't call memory_address_noforce for the address to fetch
1419 the switch offset. This address is ok as it stands (see above),
1420 but memory_address_noforce would alter it. */
1421 #define PIC_CASE_VECTOR_ADDRESS(index) index
1422 \f
1423 /* Try machine-dependent ways of modifying an illegitimate address
1424 to be legitimate. If we find one, return the new, valid address.
1425 This macro is used in only one place: `memory_address' in explow.c.
1426
1427 OLDX is the address as it was before break_out_memory_refs was called.
1428 In some cases it is useful to look at this to decide what needs to be done.
1429
1430 MODE and WIN are passed so that this macro can use
1431 GO_IF_LEGITIMATE_ADDRESS.
1432
1433 It is always safe for this macro to do nothing. It exists to recognize
1434 opportunities to optimize the output.
1435
1436 For the 68000, we handle X+REG by loading X into a register R and
1437 using R+REG. R will go in an address reg and indexing will be used.
1438 However, if REG is a broken-out memory address or multiplication,
1439 nothing needs to be done because REG can certainly go in an address reg. */
1440
1441 #define COPY_ONCE(Y) if (!copied) { Y = copy_rtx (Y); copied = ch = 1; }
1442 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1443 { register int ch = (X) != (OLDX); \
1444 if (GET_CODE (X) == PLUS) \
1445 { int copied = 0; \
1446 if (GET_CODE (XEXP (X, 0)) == MULT) \
1447 { COPY_ONCE (X); XEXP (X, 0) = force_operand (XEXP (X, 0), 0);} \
1448 if (GET_CODE (XEXP (X, 1)) == MULT) \
1449 { COPY_ONCE (X); XEXP (X, 1) = force_operand (XEXP (X, 1), 0);} \
1450 if (ch && GET_CODE (XEXP (X, 1)) == REG \
1451 && GET_CODE (XEXP (X, 0)) == REG) \
1452 goto WIN; \
1453 if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); } \
1454 if (GET_CODE (XEXP (X, 0)) == REG \
1455 || (GET_CODE (XEXP (X, 0)) == SIGN_EXTEND \
1456 && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \
1457 && GET_MODE (XEXP (XEXP (X, 0), 0)) == HImode)) \
1458 { register rtx temp = gen_reg_rtx (Pmode); \
1459 register rtx val = force_operand (XEXP (X, 1), 0); \
1460 emit_move_insn (temp, val); \
1461 COPY_ONCE (X); \
1462 XEXP (X, 1) = temp; \
1463 goto WIN; } \
1464 else if (GET_CODE (XEXP (X, 1)) == REG \
1465 || (GET_CODE (XEXP (X, 1)) == SIGN_EXTEND \
1466 && GET_CODE (XEXP (XEXP (X, 1), 0)) == REG \
1467 && GET_MODE (XEXP (XEXP (X, 1), 0)) == HImode)) \
1468 { register rtx temp = gen_reg_rtx (Pmode); \
1469 register rtx val = force_operand (XEXP (X, 0), 0); \
1470 emit_move_insn (temp, val); \
1471 COPY_ONCE (X); \
1472 XEXP (X, 0) = temp; \
1473 goto WIN; }}}
1474
1475 /* Go to LABEL if ADDR (a legitimate address expression)
1476 has an effect that depends on the machine mode it is used for.
1477 On the 68000, only predecrement and postincrement address depend thus
1478 (the amount of decrement or increment being the length of the operand). */
1479
1480 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1481 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC) goto LABEL
1482 \f
1483 /* Specify the machine mode that this machine uses
1484 for the index in the tablejump instruction. */
1485 #define CASE_VECTOR_MODE HImode
1486
1487 /* Define this if the tablejump instruction expects the table
1488 to contain offsets from the address of the table.
1489 Do not define this if the table should contain absolute addresses. */
1490 #define CASE_VECTOR_PC_RELATIVE
1491
1492 /* Specify the tree operation to be used to convert reals to integers. */
1493 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1494
1495 /* This is the kind of divide that is easiest to do in the general case. */
1496 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1497
1498 /* Define this as 1 if `char' should by default be signed; else as 0. */
1499 #define DEFAULT_SIGNED_CHAR 1
1500
1501 /* Don't cse the address of the function being compiled. */
1502 #define NO_RECURSIVE_FUNCTION_CSE
1503
1504 /* Max number of bytes we can move from memory to memory
1505 in one reasonably fast instruction. */
1506 #define MOVE_MAX 4
1507
1508 /* Define this if zero-extension is slow (more than one real instruction). */
1509 #define SLOW_ZERO_EXTEND
1510
1511 /* Nonzero if access to memory by bytes is slow and undesirable. */
1512 #define SLOW_BYTE_ACCESS 0
1513
1514 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1515 is done just by pretending it is already truncated. */
1516 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1517
1518 /* We assume that the store-condition-codes instructions store 0 for false
1519 and some other value for true. This is the value stored for true. */
1520
1521 #define STORE_FLAG_VALUE -1
1522
1523 /* When a prototype says `char' or `short', really pass an `int'. */
1524 #define PROMOTE_PROTOTYPES
1525
1526 /* Specify the machine mode that pointers have.
1527 After generation of rtl, the compiler makes no further distinction
1528 between pointers and any other objects of this machine mode. */
1529 #define Pmode SImode
1530
1531 /* A function address in a call instruction
1532 is a byte address (for indexing purposes)
1533 so give the MEM rtx a byte's mode. */
1534 #define FUNCTION_MODE QImode
1535
1536 /* Compute the cost of computing a constant rtl expression RTX
1537 whose rtx-code is CODE. The body of this macro is a portion
1538 of a switch statement. If the code is computed here,
1539 return it with a return statement. Otherwise, break from the switch. */
1540
1541 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1542 case CONST_INT: \
1543 /* Constant zero is super cheap due to clr instruction. */ \
1544 if (RTX == const0_rtx) return 0; \
1545 /* if ((OUTER_CODE) == SET) */ \
1546 return const_int_cost(RTX); \
1547 case CONST: \
1548 case LABEL_REF: \
1549 case SYMBOL_REF: \
1550 return 3; \
1551 case CONST_DOUBLE: \
1552 return 5;
1553
1554 /* Compute the cost of various arithmetic operations.
1555 These are vaguely right for a 68020. */
1556 /* The costs for long multiply have been adjusted to
1557 work properly in synth_mult on the 68020,
1558 relative to an average of the time for add and the time for shift,
1559 taking away a little more because sometimes move insns are needed. */
1560 /* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms. */
1561 #define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : 13)
1562 #define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : 5)
1563 #define DIVW_COST (TARGET_68020 ? 27 : 12)
1564
1565 #define RTX_COSTS(X,CODE,OUTER_CODE) \
1566 case PLUS: \
1567 /* An lea costs about three times as much as a simple add. */ \
1568 if (GET_MODE (X) == SImode \
1569 && GET_CODE (XEXP (X, 1)) == REG \
1570 && GET_CODE (XEXP (X, 0)) == MULT \
1571 && GET_CODE (XEXP (XEXP (X, 0), 0)) == REG \
1572 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT \
1573 && (INTVAL (XEXP (XEXP (X, 0), 1)) == 2 \
1574 || INTVAL (XEXP (XEXP (X, 0), 1)) == 4 \
1575 || INTVAL (XEXP (XEXP (X, 0), 1)) == 8)) \
1576 return COSTS_N_INSNS (3); /* lea an@(dx:l:i),am */ \
1577 break; \
1578 case ASHIFT: \
1579 case ASHIFTRT: \
1580 case LSHIFTRT: \
1581 if (TARGET_68060) \
1582 return COSTS_N_INSNS(1); \
1583 if (! TARGET_68020) \
1584 { \
1585 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
1586 { \
1587 if (INTVAL (XEXP (X, 1)) < 16) \
1588 return COSTS_N_INSNS (2) + INTVAL (XEXP (X, 1)) / 2; \
1589 else \
1590 /* We're using clrw + swap for these cases. */ \
1591 return COSTS_N_INSNS (4) + (INTVAL (XEXP (X, 1)) - 16) / 2; \
1592 } \
1593 return COSTS_N_INSNS (10); /* worst case */ \
1594 } \
1595 /* A shift by a big integer takes an extra instruction. */ \
1596 if (GET_CODE (XEXP (X, 1)) == CONST_INT \
1597 && (INTVAL (XEXP (X, 1)) == 16)) \
1598 return COSTS_N_INSNS (2); /* clrw;swap */ \
1599 if (GET_CODE (XEXP (X, 1)) == CONST_INT \
1600 && !(INTVAL (XEXP (X, 1)) > 0 \
1601 && INTVAL (XEXP (X, 1)) <= 8)) \
1602 return COSTS_N_INSNS (3); /* lsr #i,dn */ \
1603 break; \
1604 case MULT: \
1605 if ((GET_CODE (XEXP (X, 0)) == ZERO_EXTEND \
1606 || GET_CODE (XEXP (X, 0)) == SIGN_EXTEND) \
1607 && GET_MODE (X) == SImode) \
1608 return COSTS_N_INSNS (MULW_COST); \
1609 if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \
1610 return COSTS_N_INSNS (MULW_COST); \
1611 else \
1612 return COSTS_N_INSNS (MULL_COST); \
1613 case DIV: \
1614 case UDIV: \
1615 case MOD: \
1616 case UMOD: \
1617 if (GET_MODE (X) == QImode || GET_MODE (X) == HImode) \
1618 return COSTS_N_INSNS (DIVW_COST); /* div.w */ \
1619 return COSTS_N_INSNS (43); /* div.l */
1620 \f
1621 /* Tell final.c how to eliminate redundant test instructions. */
1622
1623 /* Here we define machine-dependent flags and fields in cc_status
1624 (see `conditions.h'). */
1625
1626 /* Set if the cc value is actually in the 68881, so a floating point
1627 conditional branch must be output. */
1628 #define CC_IN_68881 04000
1629
1630 /* Store in cc_status the expressions that the condition codes will
1631 describe after execution of an instruction whose pattern is EXP.
1632 Do not alter them if the instruction would not alter the cc's. */
1633
1634 /* On the 68000, all the insns to store in an address register fail to
1635 set the cc's. However, in some cases these instructions can make it
1636 possibly invalid to use the saved cc's. In those cases we clear out
1637 some or all of the saved cc's so they won't be used. */
1638
1639 #define NOTICE_UPDATE_CC(EXP,INSN) notice_update_cc (EXP, INSN)
1640
1641 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
1642 { if (cc_prev_status.flags & CC_IN_68881) \
1643 return FLOAT; \
1644 if (cc_prev_status.flags & CC_NO_OVERFLOW) \
1645 return NO_OV; \
1646 return NORMAL; }
1647 \f
1648 /* Control the assembler format that we output. */
1649
1650 /* Output at beginning of assembler file. */
1651
1652 #define ASM_FILE_START(FILE) \
1653 fprintf (FILE, "#NO_APP\n");
1654
1655 /* Output to assembler file text saying following lines
1656 may contain character constants, extra white space, comments, etc. */
1657
1658 #define ASM_APP_ON "#APP\n"
1659
1660 /* Output to assembler file text saying following lines
1661 no longer contain unusual constructs. */
1662
1663 #define ASM_APP_OFF "#NO_APP\n"
1664
1665 /* Output before read-only data. */
1666
1667 #define TEXT_SECTION_ASM_OP ".text"
1668
1669 /* Output before writable data. */
1670
1671 #define DATA_SECTION_ASM_OP ".data"
1672
1673 /* Here are four prefixes that are used by asm_fprintf to
1674 facilitate customization for alternate assembler syntaxes.
1675 Machines with no likelihood of an alternate syntax need not
1676 define these and need not use asm_fprintf. */
1677
1678 /* The prefix for register names. Note that REGISTER_NAMES
1679 is supposed to include this prefix. */
1680
1681 #define REGISTER_PREFIX ""
1682
1683 /* The prefix for local labels. You should be able to define this as
1684 an empty string, or any arbitrary string (such as ".", ".L%", etc)
1685 without having to make any other changes to account for the specific
1686 definition. Note it is a string literal, not interpreted by printf
1687 and friends. */
1688
1689 #define LOCAL_LABEL_PREFIX ""
1690
1691 /* The prefix to add to user-visible assembler symbols. */
1692
1693 #define USER_LABEL_PREFIX "_"
1694
1695 /* The prefix for immediate operands. */
1696
1697 #define IMMEDIATE_PREFIX "#"
1698
1699 /* How to refer to registers in assembler output.
1700 This sequence is indexed by compiler's hard-register-number (see above). */
1701
1702 #ifndef SUPPORT_SUN_FPA
1703
1704 #define REGISTER_NAMES \
1705 {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
1706 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \
1707 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7" }
1708
1709 #else /* SUPPORTED_SUN_FPA */
1710
1711 #define REGISTER_NAMES \
1712 {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
1713 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp", \
1714 "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \
1715 "fpa0", "fpa1", "fpa2", "fpa3", "fpa4", "fpa5", "fpa6", "fpa7", \
1716 "fpa8", "fpa9", "fpa10", "fpa11", "fpa12", "fpa13", "fpa14", "fpa15", \
1717 "fpa16", "fpa17", "fpa18", "fpa19", "fpa20", "fpa21", "fpa22", "fpa23", \
1718 "fpa24", "fpa25", "fpa26", "fpa27", "fpa28", "fpa29", "fpa30", "fpa31" }
1719
1720 #endif /* defined SUPPORT_SUN_FPA */
1721
1722 /* How to renumber registers for dbx and gdb.
1723 On the Sun-3, the floating point registers have numbers
1724 18 to 25, not 16 to 23 as they do in the compiler. */
1725
1726 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
1727
1728 /* This is how to output the definition of a user-level label named NAME,
1729 such as the label on a static function or variable NAME. */
1730
1731 #define ASM_OUTPUT_LABEL(FILE,NAME) \
1732 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
1733
1734 /* This is how to output a command to make the user-level label named NAME
1735 defined for reference from other files. */
1736
1737 #define GLOBAL_ASM_OP ".globl"
1738 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
1739 do { fprintf (FILE, "%s ", GLOBAL_ASM_OP); \
1740 assemble_name (FILE, NAME); \
1741 fputs ("\n", FILE);} while (0)
1742
1743 /* This is how to output a reference to a user-level label named NAME.
1744 `assemble_name' uses this. */
1745
1746 #define ASM_OUTPUT_LABELREF(FILE,NAME) \
1747 asm_fprintf (FILE, "%0U%s", NAME)
1748
1749 /* This is how to output an internal numbered label where
1750 PREFIX is the class of label and NUM is the number within the class. */
1751
1752 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
1753 asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM)
1754
1755 /* This is how to store into the string LABEL
1756 the symbol_ref name of an internal numbered label where
1757 PREFIX is the class of label and NUM is the number within the class.
1758 This is suitable for output with `assemble_name'. */
1759
1760 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
1761 sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM)
1762
1763 /* This is how to output a `long double' extended real constant. */
1764
1765 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
1766 do { long l[3]; \
1767 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
1768 if (sizeof (int) == sizeof (long)) \
1769 fprintf (FILE, "\t.long 0x%x,0x%x,0x%x\n", l[0], l[1], l[2]); \
1770 else \
1771 fprintf (FILE, "\t.long 0x%lx,0x%lx,0x%lx\n", l[0], l[1], l[2]); \
1772 } while (0)
1773
1774 /* This is how to output an assembler line defining a `double' constant. */
1775
1776 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1777 do { char dstr[30]; \
1778 REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \
1779 fprintf (FILE, "\t.double 0r%s\n", dstr); \
1780 } while (0)
1781
1782 /* This is how to output an assembler line defining a `float' constant. */
1783
1784 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1785 do { long l; \
1786 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
1787 if (sizeof (int) == sizeof (long)) \
1788 fprintf (FILE, "\t.long 0x%x\n", l); \
1789 else \
1790 fprintf (FILE, "\t.long 0x%lx\n", l); \
1791 } while (0)
1792
1793 /* This is how to output an assembler line defining an `int' constant. */
1794
1795 #define ASM_OUTPUT_INT(FILE,VALUE) \
1796 ( fprintf (FILE, "\t.long "), \
1797 output_addr_const (FILE, (VALUE)), \
1798 fprintf (FILE, "\n"))
1799
1800 /* Likewise for `char' and `short' constants. */
1801
1802 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
1803 ( fprintf (FILE, "\t.word "), \
1804 output_addr_const (FILE, (VALUE)), \
1805 fprintf (FILE, "\n"))
1806
1807 #define ASM_OUTPUT_CHAR(FILE,VALUE) \
1808 ( fprintf (FILE, "\t.byte "), \
1809 output_addr_const (FILE, (VALUE)), \
1810 fprintf (FILE, "\n"))
1811
1812 /* This is how to output an assembler line for a numeric constant byte. */
1813
1814 #define ASM_OUTPUT_BYTE(FILE,VALUE) \
1815 fprintf (FILE, "\t.byte 0x%x\n", (VALUE))
1816
1817 /* This is how to output an insn to push a register on the stack.
1818 It need not be very fast code. */
1819
1820 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
1821 asm_fprintf (FILE, "\tmovel %s,%Rsp@-\n", reg_names[REGNO])
1822
1823 /* This is how to output an insn to pop a register from the stack.
1824 It need not be very fast code. */
1825
1826 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
1827 asm_fprintf (FILE, "\tmovel %Rsp@+,%s\n", reg_names[REGNO])
1828
1829 /* This is how to output an element of a case-vector that is absolute.
1830 (The 68000 does not use such vectors,
1831 but we must define this macro anyway.) */
1832
1833 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1834 asm_fprintf (FILE, "\t.long %LL%d\n", VALUE)
1835
1836 /* This is how to output an element of a case-vector that is relative. */
1837
1838 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1839 asm_fprintf (FILE, "\t.word %LL%d-%LL%d\n", VALUE, REL)
1840
1841 /* This is how to output an assembler line
1842 that says to advance the location counter
1843 to a multiple of 2**LOG bytes. */
1844
1845 /* We don't have a way to align to more than a two-byte boundary, so do the
1846 best we can and don't complain. */
1847 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
1848 if ((LOG) >= 1) \
1849 fprintf (FILE, "\t.even\n");
1850
1851 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
1852 fprintf (FILE, "\t.skip %u\n", (SIZE))
1853
1854 /* This says how to output an assembler line
1855 to define a global common symbol. */
1856
1857 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
1858 ( fputs (".comm ", (FILE)), \
1859 assemble_name ((FILE), (NAME)), \
1860 fprintf ((FILE), ",%u\n", (ROUNDED)))
1861
1862 /* This says how to output an assembler line
1863 to define a local common symbol. */
1864
1865 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
1866 ( fputs (".lcomm ", (FILE)), \
1867 assemble_name ((FILE), (NAME)), \
1868 fprintf ((FILE), ",%u\n", (ROUNDED)))
1869
1870 /* Store in OUTPUT a string (made with alloca) containing
1871 an assembler-name for a local static variable named NAME.
1872 LABELNO is an integer which is different for each call. */
1873
1874 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1875 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1876 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1877
1878 /* Define the parentheses used to group arithmetic operations
1879 in assembler code. */
1880
1881 #define ASM_OPEN_PAREN "("
1882 #define ASM_CLOSE_PAREN ")"
1883
1884 /* Define results of standard character escape sequences. */
1885 #define TARGET_BELL 007
1886 #define TARGET_BS 010
1887 #define TARGET_TAB 011
1888 #define TARGET_NEWLINE 012
1889 #define TARGET_VT 013
1890 #define TARGET_FF 014
1891 #define TARGET_CR 015
1892
1893 /* Output a float value (represented as a C double) as an immediate operand.
1894 This macro is a 68k-specific macro. */
1895
1896 #define ASM_OUTPUT_FLOAT_OPERAND(CODE,FILE,VALUE) \
1897 do { \
1898 if (CODE == 'f') \
1899 { \
1900 char dstr[30]; \
1901 REAL_VALUE_TO_DECIMAL (VALUE, "%.9g", dstr); \
1902 asm_fprintf ((FILE), "%I0r%s", dstr); \
1903 } \
1904 else \
1905 { \
1906 long l; \
1907 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
1908 if (sizeof (int) == sizeof (long)) \
1909 asm_fprintf ((FILE), "%I0x%x", l); \
1910 else \
1911 asm_fprintf ((FILE), "%I0x%lx", l); \
1912 } \
1913 } while (0)
1914
1915 /* Output a double value (represented as a C double) as an immediate operand.
1916 This macro is a 68k-specific macro. */
1917 #define ASM_OUTPUT_DOUBLE_OPERAND(FILE,VALUE) \
1918 do { char dstr[30]; \
1919 REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \
1920 asm_fprintf (FILE, "%I0r%s", dstr); \
1921 } while (0)
1922
1923 /* Note, long double immediate operands are not actually
1924 generated by m68k.md. */
1925 #define ASM_OUTPUT_LONG_DOUBLE_OPERAND(FILE,VALUE) \
1926 do { char dstr[30]; \
1927 REAL_VALUE_TO_DECIMAL (VALUE, "%.20g", dstr); \
1928 asm_fprintf (FILE, "%I0r%s", dstr); \
1929 } while (0)
1930
1931 /* Print operand X (an rtx) in assembler syntax to file FILE.
1932 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1933 For `%' followed by punctuation, CODE is the punctuation and X is null.
1934
1935 On the 68000, we use several CODE characters:
1936 '.' for dot needed in Motorola-style opcode names.
1937 '-' for an operand pushing on the stack:
1938 sp@-, -(sp) or -(%sp) depending on the style of syntax.
1939 '+' for an operand pushing on the stack:
1940 sp@+, (sp)+ or (%sp)+ depending on the style of syntax.
1941 '@' for a reference to the top word on the stack:
1942 sp@, (sp) or (%sp) depending on the style of syntax.
1943 '#' for an immediate operand prefix (# in MIT and Motorola syntax
1944 but & in SGS syntax).
1945 '!' for the fpcr register (used in some float-to-fixed conversions).
1946 '$' for the letter `s' in an op code, but only on the 68040.
1947 '&' for the letter `d' in an op code, but only on the 68040.
1948 '/' for register prefix needed by longlong.h.
1949
1950 'b' for byte insn (no effect, on the Sun; this is for the ISI).
1951 'd' to force memory addressing to be absolute, not relative.
1952 'f' for float insn (print a CONST_DOUBLE as a float rather than in hex)
1953 'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather
1954 than directly). Second part of 'y' below.
1955 'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
1956 or print pair of registers as rx:ry.
1957 'y' for a FPA insn (print pair of registers as rx:ry). This also outputs
1958 CONST_DOUBLE's as SunFPA constant RAM registers if
1959 possible, so it should not be used except for the SunFPA. */
1960
1961 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1962 ((CODE) == '.' || (CODE) == '#' || (CODE) == '-' \
1963 || (CODE) == '+' || (CODE) == '@' || (CODE) == '!' \
1964 || (CODE) == '$' || (CODE) == '&' || (CODE) == '/')
1965
1966 /* A C compound statement to output to stdio stream STREAM the
1967 assembler syntax for an instruction operand X. X is an RTL
1968 expression.
1969
1970 CODE is a value that can be used to specify one of several ways
1971 of printing the operand. It is used when identical operands
1972 must be printed differently depending on the context. CODE
1973 comes from the `%' specification that was used to request
1974 printing of the operand. If the specification was just `%DIGIT'
1975 then CODE is 0; if the specification was `%LTR DIGIT' then CODE
1976 is the ASCII code for LTR.
1977
1978 If X is a register, this macro should print the register's name.
1979 The names can be found in an array `reg_names' whose type is
1980 `char *[]'. `reg_names' is initialized from `REGISTER_NAMES'.
1981
1982 When the machine description has a specification `%PUNCT' (a `%'
1983 followed by a punctuation character), this macro is called with
1984 a null pointer for X and the punctuation character for CODE.
1985
1986 See m68k.c for the m68k specific codes. */
1987
1988 #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
1989
1990 /* A C compound statement to output to stdio stream STREAM the
1991 assembler syntax for an instruction operand that is a memory
1992 reference whose address is ADDR. ADDR is an RTL expression.
1993
1994 On some machines, the syntax for a symbolic address depends on
1995 the section that the address refers to. On these machines,
1996 define the macro `ENCODE_SECTION_INFO' to store the information
1997 into the `symbol_ref', and then check for it here. */
1998
1999 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
2000
2001
2002 /* Definitions for generating bytecode */
2003
2004 /* Just so it's known this target is supported by the bytecode generator.
2005 If this define isn't found anywhere in the target config files, then
2006 dummy stubs are supplied by bytecode.h, and any attempt to use
2007 -fbytecode will result in an error message. */
2008
2009 #define TARGET_SUPPORTS_BYTECODE
2010
2011 /* Minimal segment alignment within sections is 8 units. */
2012 #define MACHINE_SEG_ALIGN 3
2013
2014 /* Integer alignment is two units. */
2015 #define INT_ALIGN 2
2016
2017 /* Pointer alignment is eight units. */
2018 #define PTR_ALIGN 3
2019
2020 /* Global symbols begin with `_' */
2021 #define NAMES_HAVE_UNDERSCORES
2022
2023 /* BC_xxx below are similar to their ASM_xxx counterparts above. */
2024 #define BC_GLOBALIZE_LABEL(FP, NAME) bc_globalize_label(NAME)
2025
2026 #define BC_OUTPUT_COMMON(FP, NAME, SIZE, ROUNDED) \
2027 do { bc_emit_common(NAME, ROUNDED); bc_globalize_label(NAME); } while (0)
2028
2029 #define BC_OUTPUT_BSS(FP, NAME, SIZE, ROUNDED) \
2030 do { bc_data (); bc_emit_labeldef(NAME); bc_emit_skip (SIZE); } while (0)
2031
2032 #define BC_OUTPUT_LOCAL(FP, NAME, SIZE, ROUNDED) \
2033 bc_emit_common(NAME, ROUNDED)
2034
2035 #define BC_OUTPUT_ALIGN(FP, ALIGN) bc_align(ALIGN)
2036
2037 #define BC_OUTPUT_LABEL(FP, NAME) bc_emit_labeldef(NAME)
2038
2039 #define BC_OUTPUT_SKIP(FP, SIZE) bc_emit_skip(SIZE)
2040
2041 #define BC_OUTPUT_LABELREF(FP, NAME) \
2042 do { \
2043 char *foo = (char *) xmalloc(strlen(NAME) + 2); \
2044 strcpy(foo, "_"); \
2045 strcat(foo, NAME); \
2046 bc_emit_labelref (foo); \
2047 free (foo); \
2048 } while (0)
2049
2050 #define BC_OUTPUT_FLOAT(FP, VAL) \
2051 do { \
2052 float F = VAL; \
2053 bc_emit ((char *) &F, sizeof F); \
2054 } while (0)
2055
2056 #define BC_OUTPUT_DOUBLE(FP, VAL) \
2057 do { \
2058 double D = VAL; \
2059 bc_emit ((char *) &D, sizeof D); \
2060 } while (0)
2061
2062 #define BC_OUTPUT_BYTE(FP, VAL) \
2063 do { \
2064 char C = VAL; \
2065 bc_emit (&C, 1); \
2066 } while (0)
2067
2068
2069 #define BC_OUTPUT_FILE ASM_OUTPUT_FILE
2070 #define BC_OUTPUT_ASCII ASM_OUTPUT_ASCII
2071 #define BC_OUTPUT_IDENT ASM_OUTPUT_IDENT
2072
2073 /* Same as XSTR, but for bytecode */
2074 #define BCXSTR(RTX) ((RTX)->bc_label)
2075
2076
2077 /* Flush bytecode buffer onto file */
2078 #define BC_WRITE_FILE(FP) \
2079 { \
2080 fprintf (FP, ".text\n"); \
2081 bc_seg_write (bc_text_seg, FP); \
2082 fprintf(FP, "\n.data\n"); \
2083 bc_seg_write (bc_data_seg, FP); \
2084 bc_sym_write (FP); /* do .globl, .bss, etc. */ \
2085 }
2086
2087 /* Write one symbol */
2088 #define BC_WRITE_SEGSYM(SEGSYM, FP) \
2089 { \
2090 prsym (FP, (SEGSYM)->sym->name); \
2091 fprintf (FP, ":\n"); \
2092 }
2093
2094
2095 /* Write one reloc entry */
2096 #define BC_WRITE_RELOC_ENTRY(SEGRELOC, FP, OFFSET) \
2097 { \
2098 fprintf (FP, "\t.long "); \
2099 prsym (FP, (SEGRELOC)->sym->name); \
2100 fprintf (FP, " + %d\n", OFFSET); \
2101 }
2102
2103 /* Start new line of bytecodes */
2104 #define BC_START_BYTECODE_LINE(FP) \
2105 { \
2106 fprintf (FP, "\t.byte"); \
2107 }
2108
2109 /* Write one bytecode */
2110 #define BC_WRITE_BYTECODE(SEP, VAL, FP) \
2111 { \
2112 fprintf (FP, "%c0x%02X", (SEP), (VAL) & 0xff); \
2113 }
2114
2115 /* Write one bytecode RTL entry */
2116 #define BC_WRITE_RTL(R, FP) \
2117 { \
2118 fprintf (FP, "%s+%d/0x%08X\n", (R)->label, (R)->offset, (R)->bc_label); \
2119 }
2120
2121
2122 /* Emit function entry trampoline */
2123 #define BC_EMIT_TRAMPOLINE(TRAMPSEG, CALLINFO) \
2124 { \
2125 short insn; \
2126 \
2127 /* Push a reference to the callinfo structure. */ \
2128 insn = 0x4879; /* pea xxx.L */ \
2129 seg_data (TRAMPSEG, (char *) &insn, sizeof insn); \
2130 seg_refsym (TRAMPSEG, CALLINFO, 0); \
2131 \
2132 /* Call __interp, pop arguments, and return. */ \
2133 insn = 0x4eb9; /* jsr xxx.L */ \
2134 seg_data (TRAMPSEG, (char *) &insn, sizeof insn); \
2135 seg_refsym (TRAMPSEG, "__callint", 0); \
2136 insn = 0x588f; /* addql #4, sp */ \
2137 seg_data (TRAMPSEG, (char *) &insn, sizeof insn); \
2138 insn = 0x4e75; /* rts */ \
2139 seg_data (TRAMPSEG, (char *) &insn, sizeof insn); \
2140 }
2141
2142
2143
2144 #if 0
2145 #define VALIDATE_STACK() if (stack_depth < 0) abort ();
2146 #else
2147 #if 0
2148 #define VALIDATE_STACK() \
2149 fprintf (stderr, " %%%d%%", stack_depth);
2150 #endif
2151 #endif
2152
2153 /* Define functions defined in aux-output.c and used in templates. */
2154
2155 extern char *output_move_const_into_data_reg ();
2156 extern char *output_move_simode_const ();
2157 extern char *output_move_simode ();
2158 extern char *output_move_himode ();
2159 extern char *output_move_qimode ();
2160 extern char *output_move_stricthi ();
2161 extern char *output_move_strictqi ();
2162 extern char *output_move_double ();
2163 extern char *output_move_const_single ();
2164 extern char *output_move_const_double ();
2165 extern char *output_btst ();
2166 extern char *output_scc_di ();
2167 extern char *output_addsi3 ();
2168
2169 /* Variables in m68k.c */
2170 extern char *m68k_align_loops_string;
2171 extern char *m68k_align_jumps_string;
2172 extern char *m68k_align_funcs_string;
2173 extern int m68k_align_loops;
2174 extern int m68k_align_jumps;
2175 extern int m68k_align_funcs;
2176 extern int m68k_last_compare_had_fp_operands;
2177
2178 \f
2179 /*
2180 Local variables:
2181 version-control: t
2182 End:
2183 */
This page took 0.147525 seconds and 6 git commands to generate.