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