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