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