]> gcc.gnu.org Git - gcc.git/blame - gcc/config/i386/i386.h
(PREFERRED_RELOAD_CLASS): Narrow ALL_REGS to GENERAL_REGS.
[gcc.git] / gcc / config / i386 / i386.h
CommitLineData
c98f8742
JVA
1/* Definitions of target machine for GNU compiler for Intel 80386.
2 Copyright (C) 1988, 1992 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21/* The purpose of this file is to define the characteristics of the i386,
b4ac57ab 22 independent of assembler syntax or operating system.
c98f8742
JVA
23
24 Three other files build on this one to describe a specific assembler syntax:
25 bsd386.h, att386.h, and sun386.h.
26
27 The actual tm.h file for a particular system should include
28 this file, and then the file for the appropriate assembler syntax.
29
30 Many macros that specify assembler syntax are omitted entirely from
31 this file because they really belong in the files for particular
32 assemblers. These include AS1, AS2, AS3, RP, IP, LPREFIX, L_SIZE,
33 PUT_OP_SIZE, USE_STAR, ADDR_BEG, ADDR_END, PRINT_IREG, PRINT_SCALE,
34 PRINT_B_I_S, and many that start with ASM_ or end in ASM_OP. */
35
36/* Names to predefine in the preprocessor for this target machine. */
37
38#define I386 1
39
95393dfd
CH
40/* Stubs for half-pic support if not OSF/1 reference platform. */
41
42#ifndef HALF_PIC_P
43#define HALF_PIC_P() 0
44#define HALF_PIC_NUMBER_PTRS 0
45#define HALF_PIC_NUMBER_REFS 0
46#define HALF_PIC_ENCODE(DECL)
47#define HALF_PIC_DECLARE(NAME)
48#define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it.")
49#define HALF_PIC_ADDRESS_P(X) 0
50#define HALF_PIC_PTR(X) X
51#define HALF_PIC_FINISH(STREAM)
52#endif
53
c98f8742
JVA
54/* Run-time compilation parameters selecting different hardware subsets. */
55
56extern int target_flags;
57
58/* Macros used in the machine description to test the flags. */
59
35b528be
RS
60/* configure can arrage to make this 2, to force a 486. */
61#ifndef TARGET_CPU_DEFAULT
62#define TARGET_CPU_DEFAULT 0
63#endif
64
c98f8742
JVA
65/* Compile 80387 insns for floating point (not library calls). */
66#define TARGET_80387 (target_flags & 1)
67/* Compile code for an i486. */
68#define TARGET_486 (target_flags & 2)
69/* Compile using ret insn that pops args.
70 This will not work unless you use prototypes at least
71 for all functions that can take varying numbers of args. */
72#define TARGET_RTD (target_flags & 8)
73/* Compile passing first two args in regs 0 and 1.
74 This exists only to test compiler features that will
75 be needed for RISC chips. It is not usable
76 and is not intended to be usable on this cpu. */
77#define TARGET_REGPARM (target_flags & 020)
78
d7cd15e9
RS
79/* Put uninitialized locals into bss, not data.
80 Meaningful only on svr3. */
81#define TARGET_SVR3_SHLIB (target_flags & 040)
82
c572e5ba
JVA
83/* Use IEEE floating point comparisons. These handle correctly the cases
84 where the result of a comparison is unordered. Normally SIGFPE is
85 generated in such cases, in which case this isn't needed. */
86#define TARGET_IEEE_FP (target_flags & 0100)
87
8c2bf92a
JVA
88/* Functions that return a floating point value may return that value
89 in the 387 FPU or in 386 integer registers. If set, this flag causes
90 the 387 to be used, which is compatible with most calling conventions. */
91#define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & 0200)
92
c98f8742
JVA
93/* Macro to define tables used to set the flags.
94 This is a list in braces of pairs in braces,
95 each pair being { "NAME", VALUE }
96 where VALUE is the bits to set or minus the bits to clear.
97 An empty string NAME is used to identify the default VALUE. */
98
99#define TARGET_SWITCHES \
100 { { "80387", 1}, \
8c2bf92a 101 { "no-80387", -1}, \
c98f8742 102 { "soft-float", -1}, \
8c2bf92a 103 { "no-soft-float", 1}, \
c98f8742 104 { "486", 2}, \
8c2bf92a 105 { "no-486", -2}, \
c98f8742
JVA
106 { "386", -2}, \
107 { "rtd", 8}, \
8c2bf92a 108 { "no-rtd", -8}, \
c98f8742 109 { "regparm", 020}, \
8c2bf92a 110 { "no-regparm", -020}, \
d7cd15e9 111 { "svr3-shlib", 040}, \
8c2bf92a 112 { "no-svr3-shlib", -040}, \
c572e5ba 113 { "ieee-fp", 0100}, \
8c2bf92a
JVA
114 { "no-ieee-fp", -0100}, \
115 { "fp-ret-in-387", 0200}, \
116 { "no-fp-ret-in-387", -0200}, \
95393dfd 117 SUBTARGET_SWITCHES \
35b528be 118 { "", TARGET_DEFAULT | TARGET_CPU_DEFAULT}}
95393dfd
CH
119
120/* This is meant to be redefined in the host dependent files */
121#define SUBTARGET_SWITCHES
122
c98f8742
JVA
123\f
124/* target machine storage layout */
125
126/* Define this if most significant byte of a word is the lowest numbered. */
127/* That is true on the 80386. */
128
129#define BITS_BIG_ENDIAN 0
130
131/* Define this if most significant byte of a word is the lowest numbered. */
132/* That is not true on the 80386. */
133#define BYTES_BIG_ENDIAN 0
134
135/* Define this if most significant word of a multiword number is the lowest
136 numbered. */
137/* Not true for 80386 */
138#define WORDS_BIG_ENDIAN 0
139
b4ac57ab 140/* number of bits in an addressable storage unit */
c98f8742
JVA
141#define BITS_PER_UNIT 8
142
143/* Width in bits of a "word", which is the contents of a machine register.
144 Note that this is not necessarily the width of data type `int';
145 if using 16-bit ints on a 80386, this would still be 32.
146 But on a machine with 16-bit registers, this would be 16. */
147#define BITS_PER_WORD 32
148
149/* Width of a word, in units (bytes). */
150#define UNITS_PER_WORD 4
151
152/* Width in bits of a pointer.
153 See also the macro `Pmode' defined below. */
154#define POINTER_SIZE 32
155
156/* Allocation boundary (in *bits*) for storing arguments in argument list. */
157#define PARM_BOUNDARY 32
158
159/* Boundary (in *bits*) on which stack pointer should be aligned. */
160#define STACK_BOUNDARY 32
161
162/* Allocation boundary (in *bits*) for the code of a function.
163 For i486, we get better performance by aligning to a cache
164 line (i.e. 16 byte) boundary. */
165#define FUNCTION_BOUNDARY (TARGET_486 ? 128 : 32)
166
167/* Alignment of field after `int : 0' in a structure. */
168
169#define EMPTY_FIELD_BOUNDARY 32
170
171/* Minimum size in bits of the largest boundary to which any
172 and all fundamental data types supported by the hardware
173 might need to be aligned. No data type wants to be aligned
174 rounder than this. The i386 supports 64-bit floating point
175 quantities, but these can be aligned on any 32-bit boundary. */
176#define BIGGEST_ALIGNMENT 32
177
b4ac57ab 178/* Set this non-zero if move instructions will actually fail to work
c98f8742 179 when given unaligned data. */
b4ac57ab 180#define STRICT_ALIGNMENT 0
c98f8742
JVA
181
182/* If bit field type is int, don't let it cross an int,
183 and give entire struct the alignment of an int. */
184/* Required on the 386 since it doesn't have bitfield insns. */
185#define PCC_BITFIELD_TYPE_MATTERS 1
186
187/* Align loop starts for optimal branching. */
188#define ASM_OUTPUT_LOOP_ALIGN(FILE) \
189 ASM_OUTPUT_ALIGN (FILE, 2)
190
191/* This is how to align an instruction for optimal branching.
192 On i486 we'll get better performance by aligning on a
193 cache line (i.e. 16 byte) boundary. */
194#define ASM_OUTPUT_ALIGN_CODE(FILE) \
195 ASM_OUTPUT_ALIGN ((FILE), (TARGET_486 ? 4 : 2))
196\f
197/* Standard register usage. */
198
199/* This processor has special stack-like registers. See reg-stack.c
200 for details. */
201
202#define STACK_REGS
203
204/* Number of actual hardware registers.
205 The hardware registers are assigned numbers for the compiler
206 from 0 to just below FIRST_PSEUDO_REGISTER.
207 All registers that the compiler knows about must be given numbers,
208 even those that are not normally considered general registers.
209
210 In the 80386 we give the 8 general purpose registers the numbers 0-7.
211 We number the floating point registers 8-15.
212 Note that registers 0-7 can be accessed as a short or int,
213 while only 0-3 may be used with byte `mov' instructions.
214
215 Reg 16 does not correspond to any hardware register, but instead
216 appears in the RTL as an argument pointer prior to reload, and is
217 eliminated during reloading in favor of either the stack or frame
218 pointer. */
219
220#define FIRST_PSEUDO_REGISTER 17
221
222/* 1 for registers that have pervasive standard uses
223 and are not available for the register allocator.
224 On the 80386, the stack pointer is such, as is the arg pointer. */
225#define FIXED_REGISTERS \
226/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
227{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
228
229/* 1 for registers not available across function calls.
230 These must include the FIXED_REGISTERS and also any
231 registers that can be used without being saved.
232 The latter must include the registers where values are returned
233 and the register where structure-value addresses are passed.
234 Aside from that, you can include as many other registers as you like. */
235
236#define CALL_USED_REGISTERS \
237/*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
238{ 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
239
240/* Macro to conditionally modify fixed_regs/call_used_regs. */
241#define CONDITIONAL_REGISTER_USAGE \
242 { \
243 if (flag_pic) \
244 { \
245 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
246 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
247 } \
8c2bf92a
JVA
248 if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387) \
249 { \
250 int i; \
251 HARD_REG_SET x; \
252 COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]); \
253 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \
254 if (TEST_HARD_REG_BIT (x, i)) \
255 fixed_regs[i] = call_used_regs[i] = 1; \
256 } \
c98f8742
JVA
257 }
258
259/* Return number of consecutive hard regs needed starting at reg REGNO
260 to hold something of mode MODE.
261 This is ordinarily the length in words of a value of mode MODE
262 but can be less for certain modes in special long registers.
263
264 Actually there are no two word move instructions for consecutive
265 registers. And only registers 0-3 may have mov byte instructions
266 applied to them.
267 */
268
269#define HARD_REGNO_NREGS(REGNO, MODE) \
270 (FP_REGNO_P (REGNO) ? 1 \
271 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
272
273/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
274 On the 80386, the first 4 cpu registers can hold any mode
275 while the floating point registers may hold only floating point.
276 Make it clear that the fp regs could not hold a 16-byte float. */
277
278#define HARD_REGNO_MODE_OK(REGNO, MODE) \
1bbe49a6
JVA
279 ((REGNO) < 2 ? 1 \
280 : (REGNO) < 4 ? 1 \
281 : FP_REGNO_P ((REGNO)) \
282 ? ((GET_MODE_CLASS (MODE) == MODE_FLOAT \
283 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
284 && GET_MODE_UNIT_SIZE (MODE) <= 8) \
c98f8742
JVA
285 : (MODE) != QImode)
286
287/* Value is 1 if it is a good idea to tie two pseudo registers
288 when one has mode MODE1 and one has mode MODE2.
289 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
290 for any hard reg, then this must be 0 for correct output. */
291
292#define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2))
293
294/* A C expression returning the cost of moving data from a register of class
295 CLASS1 to one of CLASS2.
296
297 On the i386, copying between floating-point and fixed-point
298 registers is expensive. */
299
300#define REGISTER_MOVE_COST(CLASS1, CLASS2) \
301 ((((CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS) \
302 || ((CLASS2) == FLOAT_REGS && (CLASS1) != FLOAT_REGS)) \
303 ? 10 : 2)
304
305/* Specify the registers used for certain standard purposes.
306 The values of these macros are register numbers. */
307
308/* on the 386 the pc register is %eip, and is not usable as a general
309 register. The ordinary mov instructions won't work */
310/* #define PC_REGNUM */
311
312/* Register to use for pushing function arguments. */
313#define STACK_POINTER_REGNUM 7
314
315/* Base register for access to local variables of the function. */
316#define FRAME_POINTER_REGNUM 6
317
318/* First floating point reg */
319#define FIRST_FLOAT_REG 8
320
321/* First & last stack-like regs */
322#define FIRST_STACK_REG FIRST_FLOAT_REG
323#define LAST_STACK_REG (FIRST_FLOAT_REG + 7)
324
325/* Value should be nonzero if functions must have frame pointers.
326 Zero means the frame pointer need not be set up (and parms
327 may be accessed via the stack pointer) in functions that seem suitable.
328 This is computed in `reload', in reload1.c. */
329#define FRAME_POINTER_REQUIRED 0
330
331/* Base register for access to arguments of the function. */
332#define ARG_POINTER_REGNUM 16
333
334/* Register in which static-chain is passed to a function. */
335#define STATIC_CHAIN_REGNUM 2
336
337/* Register to hold the addressing base for position independent
338 code access to data items. */
339#define PIC_OFFSET_TABLE_REGNUM 3
340
341/* Register in which address to store a structure value
342 arrives in the function. On the 386, the prologue
343 copies this from the stack to register %eax. */
344#define STRUCT_VALUE_INCOMING 0
345
346/* Place in which caller passes the structure value address.
347 0 means push the value on the stack like an argument. */
348#define STRUCT_VALUE 0
349\f
350/* Define the classes of registers for register constraints in the
351 machine description. Also define ranges of constants.
352
353 One of the classes must always be named ALL_REGS and include all hard regs.
354 If there is more than one class, another class must be named NO_REGS
355 and contain no registers.
356
357 The name GENERAL_REGS must be the name of a class (or an alias for
358 another name such as ALL_REGS). This is the class of registers
359 that is allowed by "g" or "r" in a register constraint.
360 Also, registers outside this class are allocated only when
361 instructions express preferences for them.
362
363 The classes must be numbered in nondecreasing order; that is,
364 a larger-numbered class must never be contained completely
365 in a smaller-numbered class.
366
367 For any two classes, it is very desirable that there be another
ab408a86
JVA
368 class that represents their union.
369
370 It might seem that class BREG is unnecessary, since no useful 386
371 opcode needs reg %ebx. But some systems pass args to the OS in ebx,
372 and the "b" register constraint is useful in asms for syscalls. */
c98f8742
JVA
373
374enum reg_class
375{
376 NO_REGS,
ab408a86 377 AREG, DREG, CREG, BREG,
c98f8742
JVA
378 Q_REGS, /* %eax %ebx %ecx %edx */
379 SIREG, DIREG,
380 INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */
381 GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
382 FP_TOP_REG, FP_SECOND_REG, /* %st(0) %st(1) */
383 FLOAT_REGS,
384 ALL_REGS, LIM_REG_CLASSES
385};
386
387#define N_REG_CLASSES (int) LIM_REG_CLASSES
388
389/* Give names of register classes as strings for dump file. */
390
391#define REG_CLASS_NAMES \
392{ "NO_REGS", \
ab408a86 393 "AREG", "DREG", "CREG", "BREG", \
c98f8742
JVA
394 "Q_REGS", \
395 "SIREG", "DIREG", \
396 "INDEX_REGS", \
397 "GENERAL_REGS", \
398 "FP_TOP_REG", "FP_SECOND_REG", \
399 "FLOAT_REGS", \
400 "ALL_REGS" }
401
402/* Define which registers fit in which classes.
403 This is an initializer for a vector of HARD_REG_SET
404 of length N_REG_CLASSES. */
405
406#define REG_CLASS_CONTENTS \
407{ 0, \
ab408a86 408 0x1, 0x2, 0x4, 0x8, /* AREG, DREG, CREG, BREG */ \
c98f8742
JVA
409 0xf, /* Q_REGS */ \
410 0x10, 0x20, /* SIREG, DIREG */ \
411 0x1007f, /* INDEX_REGS */ \
412 0x100ff, /* GENERAL_REGS */ \
413 0x0100, 0x0200, /* FP_TOP_REG, FP_SECOND_REG */ \
414 0xff00, /* FLOAT_REGS */ \
415 0x1ffff }
416
417/* The same information, inverted:
418 Return the class number of the smallest class containing
419 reg number REGNO. This could be a conditional expression
420 or could index an array. */
421
422extern enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
423#define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
424
425/* When defined, the compiler allows registers explicitly used in the
426 rtl to be used as spill registers but prevents the compiler from
427 extending the lifetime of these registers. */
428
429#define SMALL_REGISTER_CLASSES
430
431#define QI_REG_P(X) \
432 (REG_P (X) && REGNO (X) < 4)
433#define NON_QI_REG_P(X) \
434 (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER)
435
436#define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
437#define FP_REGNO_P(n) ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG)
438
439#define STACK_REG_P(xop) (REG_P (xop) && \
440 REGNO (xop) >= FIRST_STACK_REG && \
441 REGNO (xop) <= LAST_STACK_REG)
442
443#define NON_STACK_REG_P(xop) (REG_P (xop) && ! STACK_REG_P (xop))
444
445#define STACK_TOP_P(xop) (REG_P (xop) && REGNO (xop) == FIRST_STACK_REG)
446
447/* Try to maintain the accuracy of the death notes for regs satisfying the
448 following. Important for stack like regs, to know when to pop. */
449
450/* #define PRESERVE_DEATH_INFO_REGNO_P(x) FP_REGNO_P(x) */
451
452/* 1 if register REGNO can magically overlap other regs.
453 Note that nonzero values work only in very special circumstances. */
454
455/* #define OVERLAPPING_REGNO_P(REGNO) FP_REGNO_P (REGNO) */
456
457/* The class value for index registers, and the one for base regs. */
458
459#define INDEX_REG_CLASS INDEX_REGS
460#define BASE_REG_CLASS GENERAL_REGS
461
462/* Get reg_class from a letter such as appears in the machine description. */
463
464#define REG_CLASS_FROM_LETTER(C) \
8c2bf92a
JVA
465 ((C) == 'r' ? GENERAL_REGS : \
466 (C) == 'q' ? Q_REGS : \
467 (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
468 ? FLOAT_REGS \
469 : NO_REGS) : \
470 (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
471 ? FP_TOP_REG \
472 : NO_REGS) : \
473 (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
474 ? FP_SECOND_REG \
475 : NO_REGS) : \
476 (C) == 'a' ? AREG : \
477 (C) == 'b' ? BREG : \
478 (C) == 'c' ? CREG : \
479 (C) == 'd' ? DREG : \
480 (C) == 'D' ? DIREG : \
c98f8742
JVA
481 (C) == 'S' ? SIREG : NO_REGS)
482
483/* The letters I, J, K, L and M in a register constraint string
484 can be used to stand for particular ranges of immediate operands.
485 This macro defines what the ranges are.
486 C is the letter, and VALUE is a constant value.
487 Return 1 if VALUE is in the range specified by C.
488
489 I is for non-DImode shifts.
490 J is for DImode shifts.
491 K and L are for an `andsi' optimization.
492 M is for shifts that can be executed by the "lea" opcode.
493 */
494
495#define CONST_OK_FOR_LETTER_P(VALUE, C) \
496 ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31 : \
497 (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 : \
498 (C) == 'K' ? (VALUE) == 0xff : \
499 (C) == 'L' ? (VALUE) == 0xffff : \
500 (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3 : \
501 0)
502
503/* Similar, but for floating constants, and defining letters G and H.
b4ac57ab
RS
504 Here VALUE is the CONST_DOUBLE rtx itself. We allow constants even if
505 TARGET_387 isn't set, because the stack register converter may need to
506 load 0.0 into the function value register. */
c98f8742
JVA
507
508#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
b4ac57ab 509 ((C) == 'G' ? standard_80387_constant_p (VALUE) : 0)
c98f8742
JVA
510
511/* Place additional restrictions on the register class to use when it
512 is necessary to be able to hold a value of mode @var{mode} in a reload
513 register for which class @var{class} would ordinarily be used. */
514
515#define LIMIT_RELOAD_CLASS(MODE, CLASS) \
516 ((MODE) == QImode && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS) \
517 ? Q_REGS : (CLASS))
518
519/* Given an rtx X being reloaded into a reg required to be
520 in class CLASS, return the class of reg to actually use.
521 In general this is just CLASS; but on some machines
522 in some cases it is preferable to use a more restrictive class.
523 On the 80386 series, we prevent floating constants from being
524 reloaded into floating registers (since no move-insn can do that)
525 and we ensure that QImodes aren't reloaded into the esi or edi reg. */
526
85ff473e 527/* Don't put float CONST_DOUBLE into fp regs.
c98f8742
JVA
528 QImode must go into class Q_REGS.
529 MODE_INT must not go into FLOAT_REGS. */
530
7488be4e 531#define PREFERRED_RELOAD_CLASS(X,CLASS) \
85ff473e
JVA
532 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode ? NO_REGS \
533 : GET_MODE (X) == QImode && ! reg_class_subset_p (CLASS, Q_REGS) ? Q_REGS \
7488be4e
JVA
534 : ((CLASS) == FLOAT_REGS \
535 && (GET_MODE (X) == VOIDmode \
85ff473e
JVA
536 || GET_MODE_CLASS (GET_MODE (X)) == MODE_INT)) ? GENERAL_REGS \
537 : (CLASS) == ALL_REGS ? GENERAL_REGS \
538 : (CLASS))
539
540#define PREFERRED_OUTPUT_RELOAD_CLASS(X,CLASS) \
541 ((CLASS) == ALL_REGS ? GENERAL_REGS \
542 : (CLASS))
543
544/* If we are copying between general and FP registers, we need a memory
545 location. */
546
547#define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
548 (((CLASS1) == FLOAT_REGS && (CLASS2) != FLOAT_REGS) \
549 || ((CLASS2) == FLOAT_REGS && (CLASS1) != FLOAT_REGS))
c98f8742
JVA
550
551/* Return the maximum number of consecutive registers
552 needed to represent mode MODE in a register of class CLASS. */
553/* On the 80386, this is the size of MODE in words,
554 except in the FP regs, where a single reg is always enough. */
555#define CLASS_MAX_NREGS(CLASS, MODE) \
556 ((CLASS) == FLOAT_REGS ? 1 : \
557 (CLASS) == FP_TOP_REG ? 1 : \
558 (CLASS) == FP_SECOND_REG ? 1 : \
559 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
560\f
561/* Stack layout; function entry, exit and calling. */
562
563/* Define this if pushing a word on the stack
564 makes the stack pointer a smaller address. */
565#define STACK_GROWS_DOWNWARD
566
567/* Define this if the nominal address of the stack frame
568 is at the high-address end of the local variables;
569 that is, each additional local variable allocated
570 goes at a more negative offset in the frame. */
571#define FRAME_GROWS_DOWNWARD
572
573/* Offset within stack frame to start allocating local variables at.
574 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
575 first local allocated. Otherwise, it is the offset to the BEGINNING
576 of the first local allocated. */
577#define STARTING_FRAME_OFFSET 0
578
579/* If we generate an insn to push BYTES bytes,
580 this says how many the stack pointer really advances by.
581 On 386 pushw decrements by exactly 2 no matter what the position was.
582 On the 386 there is no pushb; we use pushw instead, and this
583 has the effect of rounding up to 2. */
584
585#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & (-2))
586
587/* Offset of first parameter from the argument pointer register value. */
588#define FIRST_PARM_OFFSET(FNDECL) 0
589
590/* Value is the number of bytes of arguments automatically
591 popped when returning from a subroutine call.
592 FUNTYPE is the data type of the function (as a tree),
593 or for a library call it is an identifier node for the subroutine name.
594 SIZE is the number of bytes of arguments passed on the stack.
595
596 On the 80386, the RTD insn may be used to pop them if the number
597 of args is fixed, but if the number is variable then the caller
598 must pop them all. RTD can't be used for library calls now
599 because the library is compiled with the Unix compiler.
600 Use of RTD is a selectable option, since it is incompatible with
601 standard Unix calling sequences. If the option is not selected,
602 the caller must always pop the args. */
603
604#define RETURN_POPS_ARGS(FUNTYPE,SIZE) \
605 (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE ? 0 \
606 : (TARGET_RTD \
607 && (TYPE_ARG_TYPES (FUNTYPE) == 0 \
608 || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \
609 == void_type_node))) ? (SIZE) \
610 : (aggregate_value_p (FUNTYPE)) ? GET_MODE_SIZE (Pmode) : 0)
611
8c2bf92a
JVA
612/* Define how to find the value returned by a function.
613 VALTYPE is the data type of the value (as a tree).
614 If the precise function being called is known, FUNC is its FUNCTION_DECL;
615 otherwise, FUNC is 0. */
c98f8742
JVA
616#define FUNCTION_VALUE(VALTYPE, FUNC) \
617 gen_rtx (REG, TYPE_MODE (VALTYPE), \
618 VALUE_REGNO (TYPE_MODE (VALTYPE)))
619
620/* Define how to find the value returned by a library function
621 assuming the value has mode MODE. */
622
623#define LIBCALL_VALUE(MODE) \
624 gen_rtx (REG, MODE, VALUE_REGNO (MODE))
625
626/* 1 if N is a possible register number for function argument passing.
627 On the 80386, no registers are used in this way.
628 *NOTE* -mregparm does not work.
629 It exists only to test register calling conventions. */
630
631#define FUNCTION_ARG_REGNO_P(N) 0
632
633/* Define a data type for recording info about an argument list
634 during the scan of that argument list. This data type should
635 hold all necessary information about the function itself
636 and about the args processed so far, enough to enable macros
637 such as FUNCTION_ARG to determine where the next arg should go.
638
639 On the 80386, this is a single integer, which is a number of bytes
640 of arguments scanned so far. */
641
642#define CUMULATIVE_ARGS int
643
644/* Initialize a variable CUM of type CUMULATIVE_ARGS
645 for a call to a function whose data type is FNTYPE.
646 For a library call, FNTYPE is 0.
647
648 On the 80386, the offset starts at 0. */
649
650#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \
651 ((CUM) = 0)
652
653/* Update the data in CUM to advance over an argument
654 of mode MODE and data type TYPE.
655 (TYPE is null for libcalls where that information may not be available.) */
656
657#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
658 ((CUM) += ((MODE) != BLKmode \
659 ? (GET_MODE_SIZE (MODE) + 3) & ~3 \
660 : (int_size_in_bytes (TYPE) + 3) & ~3))
661
662/* Define where to put the arguments to a function.
663 Value is zero to push the argument on the stack,
664 or a hard register in which to store the argument.
665
666 MODE is the argument's machine mode.
667 TYPE is the data type of the argument (as a tree).
668 This is null for libcalls where that information may
669 not be available.
670 CUM is a variable of type CUMULATIVE_ARGS which gives info about
671 the preceding args and about the function being called.
672 NAMED is nonzero if this argument is a named parameter
673 (otherwise it is an extra parameter matching an ellipsis). */
674
675
676/* On the 80386 all args are pushed, except if -mregparm is specified
677 then the first two words of arguments are passed in EAX, EDX.
678 *NOTE* -mregparm does not work.
679 It exists only to test register calling conventions. */
680
681#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
682((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0)
683
684/* For an arg passed partly in registers and partly in memory,
685 this is the number of registers used.
686 For args passed entirely in registers or entirely in memory, zero. */
687
688
689#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
690((TARGET_REGPARM && (CUM) < 8 \
691 && 8 < ((CUM) + ((MODE) == BLKmode \
692 ? int_size_in_bytes (TYPE) \
693 : GET_MODE_SIZE (MODE)))) \
694 ? 2 - (CUM) / 4 : 0)
695
696/* This macro generates the assembly code for function entry.
697 FILE is a stdio stream to output the code to.
698 SIZE is an int: how many units of temporary storage to allocate.
699 Refer to the array `regs_ever_live' to determine which registers
700 to save; `regs_ever_live[I]' is nonzero if register number I
701 is ever used in the function. This macro is responsible for
702 knowing which registers should not be saved even if used. */
703
704#define FUNCTION_PROLOGUE(FILE, SIZE) \
705 function_prologue (FILE, SIZE)
706
707/* Output assembler code to FILE to increment profiler label # LABELNO
708 for profiling a function entry. */
709
710#define FUNCTION_PROFILER(FILE, LABELNO) \
711{ \
712 if (flag_pic) \
713 { \
714 fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \
715 LPREFIX, (LABELNO)); \
716 fprintf (FILE, "\tcall *_mcount@GOT(%%ebx)\n"); \
717 } \
718 else \
719 { \
720 fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
721 fprintf (FILE, "\tcall _mcount\n"); \
722 } \
723}
724
725/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
726 the stack pointer does not matter. The value is tested only in
727 functions that have frame pointers.
728 No definition is equivalent to always zero. */
729/* Note on the 386 it might be more efficient not to define this since
730 we have to restore it ourselves from the frame pointer, in order to
731 use pop */
732
733#define EXIT_IGNORE_STACK 1
734
735/* This macro generates the assembly code for function exit,
736 on machines that need it. If FUNCTION_EPILOGUE is not defined
737 then individual return instructions are generated for each
738 return statement. Args are same as for FUNCTION_PROLOGUE.
739
740 The function epilogue should not depend on the current stack pointer!
741 It should use the frame pointer only. This is mandatory because
742 of alloca; we also take advantage of it to omit stack adjustments
743 before returning.
744
745 If the last non-note insn in the function is a BARRIER, then there
746 is no need to emit a function prologue, because control does not fall
747 off the end. This happens if the function ends in an "exit" call, or
748 if a `return' insn is emitted directly into the function. */
749
750#define FUNCTION_EPILOGUE(FILE, SIZE) \
751do { \
752 rtx last = get_last_insn (); \
753 if (last && GET_CODE (last) == NOTE) \
754 last = prev_nonnote_insn (last); \
755 if (! last || GET_CODE (last) != BARRIER) \
756 function_epilogue (FILE, SIZE); \
757} while (0)
758
759/* Output assembler code for a block containing the constant parts
760 of a trampoline, leaving space for the variable parts. */
761
762/* On the 386, the trampoline contains three instructions:
763 mov #STATIC,ecx
764 mov #FUNCTION,eax
765 jmp @eax */
8c2bf92a
JVA
766#define TRAMPOLINE_TEMPLATE(FILE) \
767{ \
768 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb9)); \
769 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
770 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
771 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb8)); \
772 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
773 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
774 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xff)); \
775 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xe0)); \
c98f8742
JVA
776}
777
778/* Length in units of the trampoline for entering a nested function. */
779
780#define TRAMPOLINE_SIZE 12
781
782/* Emit RTL insns to initialize the variable parts of a trampoline.
783 FNADDR is an RTX for the address of the function's pure code.
784 CXT is an RTX for the static chain value for the function. */
785
786#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
787{ \
788 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 1)), CXT); \
789 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 6)), FNADDR); \
790}
791\f
792/* Definitions for register eliminations.
793
794 This is an array of structures. Each structure initializes one pair
795 of eliminable registers. The "from" register number is given first,
796 followed by "to". Eliminations of the same "from" register are listed
797 in order of preference.
798
799 We have two registers that can be eliminated on the i386. First, the
800 frame pointer register can often be eliminated in favor of the stack
801 pointer register. Secondly, the argument pointer register can always be
802 eliminated; it is replaced with either the stack or frame pointer. */
803
804#define ELIMINABLE_REGS \
805{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
806 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
807 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
808
809/* Given FROM and TO register numbers, say whether this elimination is allowed.
810 Frame pointer elimination is automatically handled.
811
812 For the i386, if frame pointer elimination is being done, we would like to
813 convert ap into sp, not fp.
814
815 All other eliminations are valid. */
816
817#define CAN_ELIMINATE(FROM, TO) \
818 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
819 ? ! frame_pointer_needed \
820 : 1)
821
822/* Define the offset between two registers, one to be eliminated, and the other
823 its replacement, at the start of a routine. */
824
825#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
826{ \
827 if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \
828 (OFFSET) = 8; /* Skip saved PC and previous frame pointer */ \
829 else \
830 { \
831 int regno; \
832 int offset = 0; \
833 \
834 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
835 if ((regs_ever_live[regno] && ! call_used_regs[regno]) \
836 || (current_function_uses_pic_offset_table \
837 && regno == PIC_OFFSET_TABLE_REGNUM)) \
838 offset += 4; \
839 \
840 (OFFSET) = offset + get_frame_size (); \
841 \
842 if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
843 (OFFSET) += 4; /* Skip saved PC */ \
844 } \
845}
846\f
847/* Addressing modes, and classification of registers for them. */
848
849/* #define HAVE_POST_INCREMENT */
850/* #define HAVE_POST_DECREMENT */
851
852/* #define HAVE_PRE_DECREMENT */
853/* #define HAVE_PRE_INCREMENT */
854
855/* Macros to check register numbers against specific register classes. */
856
857/* These assume that REGNO is a hard or pseudo reg number.
858 They give nonzero only if REGNO is a hard reg of the suitable class
859 or a pseudo reg currently allocated to a suitable hard reg.
860 Since they use reg_renumber, they are safe only once reg_renumber
861 has been allocated, which happens in local-alloc.c. */
862
863#define REGNO_OK_FOR_INDEX_P(REGNO) \
864 ((REGNO) < STACK_POINTER_REGNUM \
865 || (unsigned) reg_renumber[REGNO] < STACK_POINTER_REGNUM)
866
867#define REGNO_OK_FOR_BASE_P(REGNO) \
868 ((REGNO) <= STACK_POINTER_REGNUM \
869 || (REGNO) == ARG_POINTER_REGNUM \
870 || (unsigned) reg_renumber[REGNO] <= STACK_POINTER_REGNUM)
871
872#define REGNO_OK_FOR_SIREG_P(REGNO) ((REGNO) == 4 || reg_renumber[REGNO] == 4)
873#define REGNO_OK_FOR_DIREG_P(REGNO) ((REGNO) == 5 || reg_renumber[REGNO] == 5)
874
875/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
876 and check its validity for a certain class.
877 We have two alternate definitions for each of them.
878 The usual definition accepts all pseudo regs; the other rejects
879 them unless they have been allocated suitable hard regs.
880 The symbol REG_OK_STRICT causes the latter definition to be used.
881
882 Most source files want to accept pseudo regs in the hope that
883 they will get allocated to the class that the insn wants them to be in.
884 Source files for reload pass need to be strict.
885 After reload, it makes no difference, since pseudo regs have
886 been eliminated by then. */
887
888#ifndef REG_OK_STRICT
889
890/* Nonzero if X is a hard reg that can be used as an index or if
891 it is a pseudo reg. */
892
893#define REG_OK_FOR_INDEX_P(X) \
894 (REGNO (X) < STACK_POINTER_REGNUM \
895 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
896
897/* Nonzero if X is a hard reg that can be used as a base reg
898 of if it is a pseudo reg. */
899 /* ?wfs */
900
901#define REG_OK_FOR_BASE_P(X) \
902 (REGNO (X) <= STACK_POINTER_REGNUM \
903 || REGNO (X) == ARG_POINTER_REGNUM \
904 || REGNO(X) >= FIRST_PSEUDO_REGISTER)
905
906#define REG_OK_FOR_STRREG_P(X) \
907 (REGNO (X) == 4 || REGNO (X) == 5 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
908
909#else
910
911/* Nonzero if X is a hard reg that can be used as an index. */
912#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
913/* Nonzero if X is a hard reg that can be used as a base reg. */
914#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
915#define REG_OK_FOR_STRREG_P(X) \
916 (REGNO_OK_FOR_DIREG_P (REGNO (X)) || REGNO_OK_FOR_SIREG_P (REGNO (X)))
917
918#endif
919
920/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
921 that is a valid memory address for an instruction.
922 The MODE argument is the machine mode for the MEM expression
923 that wants to use this address.
924
925 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
926 except for CONSTANT_ADDRESS_P which is usually machine-independent.
927
928 See legitimize_pic_address in i386.c for details as to what
929 constitutes a legitimate address when -fpic is used. */
930
931#define MAX_REGS_PER_ADDRESS 2
932
933#define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)
934
935/* Nonzero if the constant value X is a legitimate general operand.
936 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
937
938#define LEGITIMATE_CONSTANT_P(X) 1
939
940#define GO_IF_INDEXABLE_BASE(X, ADDR) \
941 if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR
942
943#define LEGITIMATE_INDEX_REG_P(X) \
944 (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
945
946/* Return 1 if X is an index or an index times a scale. */
947
948#define LEGITIMATE_INDEX_P(X) \
949 (LEGITIMATE_INDEX_REG_P (X) \
950 || (GET_CODE (X) == MULT \
951 && LEGITIMATE_INDEX_REG_P (XEXP (X, 0)) \
952 && GET_CODE (XEXP (X, 1)) == CONST_INT \
953 && (INTVAL (XEXP (X, 1)) == 2 \
954 || INTVAL (XEXP (X, 1)) == 4 \
955 || INTVAL (XEXP (X, 1)) == 8)))
956
957/* Go to ADDR if X is an index term, a base reg, or a sum of those. */
958
959#define GO_IF_INDEXING(X, ADDR) \
960{ if (LEGITIMATE_INDEX_P (X)) goto ADDR; \
961 GO_IF_INDEXABLE_BASE (X, ADDR); \
962 if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0))) \
963 { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); } \
964 if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1))) \
965 { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } }
966
967/* We used to allow this, but it isn't ever used.
968 || ((GET_CODE (X) == POST_DEC || GET_CODE (X) == POST_INC) \
969 && REG_P (XEXP (X, 0)) \
970 && REG_OK_FOR_STRREG_P (XEXP (X, 0))) \
971*/
972
973#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
974{ \
975 if (CONSTANT_ADDRESS_P (X) \
976 && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \
977 goto ADDR; \
978 GO_IF_INDEXING (X, ADDR); \
979 if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
980 { \
981 rtx x0 = XEXP (X, 0); \
982 if (! flag_pic || ! SYMBOLIC_CONST (XEXP (X, 1))) \
983 { GO_IF_INDEXING (x0, ADDR); } \
984 else if (x0 == pic_offset_table_rtx) \
985 goto ADDR; \
986 else if (GET_CODE (x0) == PLUS) \
987 { \
988 if (XEXP (x0, 0) == pic_offset_table_rtx) \
989 { GO_IF_INDEXABLE_BASE (XEXP (x0, 1), ADDR); } \
990 if (XEXP (x0, 1) == pic_offset_table_rtx) \
991 { GO_IF_INDEXABLE_BASE (XEXP (x0, 0), ADDR); } \
992 } \
993 } \
994}
995
996/* Try machine-dependent ways of modifying an illegitimate address
997 to be legitimate. If we find one, return the new, valid address.
998 This macro is used in only one place: `memory_address' in explow.c.
999
1000 OLDX is the address as it was before break_out_memory_refs was called.
1001 In some cases it is useful to look at this to decide what needs to be done.
1002
1003 MODE and WIN are passed so that this macro can use
1004 GO_IF_LEGITIMATE_ADDRESS.
1005
1006 It is always safe for this macro to do nothing. It exists to recognize
1007 opportunities to optimize the output.
1008
1009 For the 80386, we handle X+REG by loading X into a register R and
1010 using R+REG. R will go in a general reg and indexing will be used.
1011 However, if REG is a broken-out memory address or multiplication,
1012 nothing needs to be done because REG can certainly go in a general reg.
1013
1014 When -fpic is used, special handling is needed for symbolic references.
1015 See comments by legitimize_pic_address in i386.c for details. */
1016
1017#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
1018{ extern rtx legitimize_pic_address (); \
1019 int ch = (X) != (OLDX); \
1020 if (flag_pic && SYMBOLIC_CONST (X)) \
1021 { \
1022 (X) = legitimize_pic_address (X, 0); \
1023 if (memory_address_p (MODE, X)) \
1024 goto WIN; \
1025 } \
1026 if (GET_CODE (X) == PLUS) \
1027 { if (GET_CODE (XEXP (X, 0)) == MULT) \
1028 ch = 1, XEXP (X, 0) = force_operand (XEXP (X, 0), 0); \
1029 if (GET_CODE (XEXP (X, 1)) == MULT) \
1030 ch = 1, XEXP (X, 1) = force_operand (XEXP (X, 1), 0); \
1031 if (ch && GET_CODE (XEXP (X, 1)) == REG \
1032 && GET_CODE (XEXP (X, 0)) == REG) \
1033 goto WIN; \
1034 if (flag_pic && SYMBOLIC_CONST (XEXP (X, 1))) \
1035 ch = 1, (X) = legitimize_pic_address (X, 0); \
1036 if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); } \
1037 if (GET_CODE (XEXP (X, 0)) == REG) \
1038 { register rtx temp = gen_reg_rtx (Pmode); \
1039 register rtx val = force_operand (XEXP (X, 1), temp); \
f093cb8f 1040 if (val != temp) emit_move_insn (temp, val); \
c98f8742
JVA
1041 XEXP (X, 1) = temp; \
1042 goto WIN; } \
1043 else if (GET_CODE (XEXP (X, 1)) == REG) \
1044 { register rtx temp = gen_reg_rtx (Pmode); \
1045 register rtx val = force_operand (XEXP (X, 0), temp); \
f093cb8f 1046 if (val != temp) emit_move_insn (temp, val); \
c98f8742
JVA
1047 XEXP (X, 0) = temp; \
1048 goto WIN; }}}
1049
1050/* Nonzero if the constant value X is a legitimate general operand
1051 when generating PIC code. It is given that flag_pic is on and
1052 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1053
1054#define LEGITIMATE_PIC_OPERAND_P(X) \
1055 (! SYMBOLIC_CONST (X) \
1056 || (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X)))
1057
1058#define SYMBOLIC_CONST(X) \
1059(GET_CODE (X) == SYMBOL_REF \
1060 || GET_CODE (X) == LABEL_REF \
1061 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
1062
1063/* Go to LABEL if ADDR (a legitimate address expression)
1064 has an effect that depends on the machine mode it is used for.
1065 On the 80386, only postdecrement and postincrement address depend thus
1066 (the amount of decrement or increment being the length of the operand). */
1067#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1068 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL
1069\f
1070/* Define this macro if references to a symbol must be treated
1071 differently depending on something about the variable or
1072 function named by the symbol (such as what section it is in).
1073
b4ac57ab 1074 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
c98f8742
JVA
1075 so that we may access it directly in the GOT. */
1076
1077#define ENCODE_SECTION_INFO(DECL) \
1078do \
1079 { \
1080 if (flag_pic) \
1081 { \
b4ac57ab
RS
1082 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
1083 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
1084 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
1085 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
1086 || ! TREE_PUBLIC (DECL)); \
c98f8742
JVA
1087 } \
1088 } \
1089while (0)
1090\f
1091/* Specify the machine mode that this machine uses
1092 for the index in the tablejump instruction. */
1093#define CASE_VECTOR_MODE Pmode
1094
1095/* Define this if the tablejump instruction expects the table
1096 to contain offsets from the address of the table.
1097 Do not define this if the table should contain absolute addresses. */
1098/* #define CASE_VECTOR_PC_RELATIVE */
1099
1100/* Specify the tree operation to be used to convert reals to integers.
1101 This should be changed to take advantage of fist --wfs ??
1102 */
1103#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1104
1105/* This is the kind of divide that is easiest to do in the general case. */
1106#define EASY_DIV_EXPR TRUNC_DIV_EXPR
1107
1108/* Define this as 1 if `char' should by default be signed; else as 0. */
1109#define DEFAULT_SIGNED_CHAR 1
1110
1111/* Max number of bytes we can move from memory to memory
1112 in one reasonably fast instruction. */
1113#define MOVE_MAX 4
1114
1115/* MOVE_RATIO is the number of move instructions that is better than a
1116 block move. Make this large on i386, since the block move is very
1117 inefficient with small blocks, and the hard register needs of the
1118 block move require much reload work. */
1119#define MOVE_RATIO 5
1120
1121/* Define this if zero-extension is slow (more than one real instruction). */
1122/* #define SLOW_ZERO_EXTEND */
1123
1124/* Nonzero if access to memory by bytes is slow and undesirable. */
1125#define SLOW_BYTE_ACCESS 0
1126
1127/* Define if shifts truncate the shift count
1128 which implies one can omit a sign-extension or zero-extension
1129 of a shift count. */
1130/* One i386, shifts do truncate the count. But bit opcodes don't. */
1131
1132/* #define SHIFT_COUNT_TRUNCATED */
1133
1134/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1135 is done just by pretending it is already truncated. */
1136#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1137
1138/* We assume that the store-condition-codes instructions store 0 for false
1139 and some other value for true. This is the value stored for true. */
1140
1141#define STORE_FLAG_VALUE 1
1142
1143/* When a prototype says `char' or `short', really pass an `int'.
1144 (The 386 can't easily push less than an int.) */
1145
1146#define PROMOTE_PROTOTYPES
1147
1148/* Specify the machine mode that pointers have.
1149 After generation of rtl, the compiler makes no further distinction
1150 between pointers and any other objects of this machine mode. */
1151#define Pmode SImode
1152
1153/* A function address in a call instruction
1154 is a byte address (for indexing purposes)
1155 so give the MEM rtx a byte's mode. */
1156#define FUNCTION_MODE QImode
1157
1158/* Define this if addresses of constant functions
1159 shouldn't be put through pseudo regs where they can be cse'd.
1160 Desirable on the 386 because a CALL with a constant address is
1161 not much slower than one with a register address. */
1162#define NO_FUNCTION_CSE
1163
1164/* Provide the costs of a rtl expression. This is in the body of a
1165 switch on CODE. */
1166
3bb22aee 1167#define RTX_COSTS(X,CODE,OUTER_CODE) \
c98f8742
JVA
1168 case MULT: \
1169 return COSTS_N_INSNS (10); \
1170 case DIV: \
1171 case UDIV: \
1172 case MOD: \
1173 case UMOD: \
3bb22aee
RS
1174 return COSTS_N_INSNS (40); \
1175 case PLUS: \
078fb2a4
JVA
1176 if (GET_CODE (XEXP (X, 0)) == REG \
1177 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
dce838e1
JVA
1178 return 1; \
1179 break;
c98f8742
JVA
1180
1181
1182/* Compute the cost of computing a constant rtl expression RTX
1183 whose rtx-code is CODE. The body of this macro is a portion
1184 of a switch statement. If the code is computed here,
1185 return it with a return statement. Otherwise, break from the switch. */
1186
3bb22aee 1187#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
c98f8742
JVA
1188 case CONST_INT: \
1189 case CONST: \
1190 case LABEL_REF: \
1191 case SYMBOL_REF: \
1192 return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 0; \
1193 case CONST_DOUBLE: \
1194 { \
7488be4e
JVA
1195 int code; \
1196 if (GET_MODE (RTX) == VOIDmode) \
1197 return 2; \
1198 code = standard_80387_constant_p (RTX); \
c98f8742
JVA
1199 return code == 1 ? 0 : \
1200 code == 2 ? 1 : \
1201 2; \
3bb22aee 1202 }
c98f8742
JVA
1203
1204/* Compute the cost of an address. This is meant to approximate the size
1205 and/or execution delay of an insn using that address. If the cost is
1206 approximated by the RTL complexity, including CONST_COSTS above, as
1207 is usually the case for CISC machines, this macro should not be defined.
1208 For aggressively RISCy machines, only one insn format is allowed, so
1209 this macro should be a constant. The value of this macro only matters
1210 for valid addresses.
1211
1212 For i386, it is better to use a complex address than let gcc copy
1213 the address into a reg and make a new pseudo. But not if the address
1214 requires to two regs - that would mean more pseudos with longer
1215 lifetimes. */
1216
1217#define ADDRESS_COST(RTX) \
1218 ((CONSTANT_P (RTX) \
1219 || (GET_CODE (RTX) == PLUS && CONSTANT_P (XEXP (RTX, 1)) \
1220 && REG_P (XEXP (RTX, 0)))) ? 0 \
1221 : REG_P (RTX) ? 1 \
1222 : 2)
1223\f
c572e5ba
JVA
1224/* Add any extra modes needed to represent the condition code.
1225
1226 For the i386, we need separate modes when floating-point equality
1227 comparisons are being done. */
1228
1229#define EXTRA_CC_MODES CCFPEQmode
1230
1231/* Define the names for the modes specified above. */
1232#define EXTRA_CC_NAMES "CCFPEQ"
1233
1234/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
1235 return the mode to be used for the comparison.
1236
1237 For floating-point equality comparisons, CCFPEQmode should be used.
1238 VOIDmode should be used in all other cases. */
1239
b565a316 1240#define SELECT_CC_MODE(OP,X,Y) \
c572e5ba
JVA
1241 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
1242 && ((OP) == EQ || (OP) == NE) ? CCFPEQmode : CCmode)
1243
1244/* Define the information needed to generate branch and scc insns. This is
1245 stored from the compare operation. Note that we can't use "rtx" here
1246 since it hasn't been defined! */
1247
1248extern struct rtx_def *i386_compare_op0, *i386_compare_op1;
1249extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)();
1250
c98f8742
JVA
1251/* Tell final.c how to eliminate redundant test instructions. */
1252
1253/* Here we define machine-dependent flags and fields in cc_status
1254 (see `conditions.h'). */
1255
1256/* Set if the cc value is actually in the 80387, so a floating point
1257 conditional branch must be output. */
1258#define CC_IN_80387 04000
1259
1260/* Set if the CC value was stored in a nonstandard way, so that
1261 the state of equality is indicated by zero in the carry bit. */
1262#define CC_Z_IN_NOT_C 010000
1263
1264/* Store in cc_status the expressions
1265 that the condition codes will describe
1266 after execution of an instruction whose pattern is EXP.
1267 Do not alter them if the instruction would not alter the cc's. */
1268
1269#define NOTICE_UPDATE_CC(EXP, INSN) \
1270 notice_update_cc((EXP))
1271
1272/* Output a signed jump insn. Use template NORMAL ordinarily, or
1273 FLOAT following a floating point comparison.
1274 Use NO_OV following an arithmetic insn that set the cc's
1275 before a test insn that was deleted.
1276 NO_OV may be zero, meaning final should reinsert the test insn
1277 because the jump cannot be handled properly without it. */
1278
1279#define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
1280{ \
1281 if (cc_prev_status.flags & CC_IN_80387) \
1282 return FLOAT; \
1283 if (cc_prev_status.flags & CC_NO_OVERFLOW) \
1284 return NO_OV; \
1285 return NORMAL; \
1286}
1287\f
1288/* Control the assembler format that we output, to the extent
1289 this does not vary between assemblers. */
1290
1291/* How to refer to registers in assembler output.
1292 This sequence is indexed by compiler's hard-register-number (see above). */
1293
1294/* In order to refer to the first 8 regs as 32 bit regs prefix an "e"
1295 For non floating point regs, the following are the HImode names.
1296
1297 For float regs, the stack top is sometimes referred to as "%st(0)"
9e06e321 1298 instead of just "%st". PRINT_REG handles this with the "y" code. */
c98f8742
JVA
1299
1300#define HI_REGISTER_NAMES \
1301{"ax","dx","cx","bx","si","di","bp","sp", \
1302 "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","" }
1303
1304#define REGISTER_NAMES HI_REGISTER_NAMES
1305
1306/* Table of additional register names to use in user input. */
1307
1308#define ADDITIONAL_REGISTER_NAMES \
1309{ "eax", 0, "edx", 1, "ecx", 2, "ebx", 3, \
1310 "esi", 4, "edi", 5, "ebp", 6, "esp", 7, \
1311 "al", 0, "dl", 1, "cl", 2, "bl", 3, \
1312 "ah", 0, "dh", 1, "ch", 2, "bh", 3 }
1313
1314/* Note we are omitting these since currently I don't know how
1315to get gcc to use these, since they want the same but different
1316number as al, and ax.
1317*/
1318
b4ac57ab 1319/* note the last four are not really qi_registers, but
c98f8742
JVA
1320 the md will have to never output movb into one of them
1321 only a movw . There is no movb into the last four regs */
1322
1323#define QI_REGISTER_NAMES \
1324{"al", "dl", "cl", "bl", "si", "di", "bp", "sp",}
1325
1326/* These parallel the array above, and can be used to access bits 8:15
1327 of regs 0 through 3. */
1328
1329#define QI_HIGH_REGISTER_NAMES \
1330{"ah", "dh", "ch", "bh", }
1331
1332/* How to renumber registers for dbx and gdb. */
1333
1334/* {0,2,1,3,6,7,4,5,12,13,14,15,16,17} */
1335#define DBX_REGISTER_NUMBER(n) \
1336((n) == 0 ? 0 : \
1337 (n) == 1 ? 2 : \
1338 (n) == 2 ? 1 : \
1339 (n) == 3 ? 3 : \
1340 (n) == 4 ? 6 : \
1341 (n) == 5 ? 7 : \
1342 (n) == 6 ? 4 : \
1343 (n) == 7 ? 5 : \
1344 (n) + 4)
1345
1346/* This is how to output the definition of a user-level label named NAME,
1347 such as the label on a static function or variable NAME. */
1348
1349#define ASM_OUTPUT_LABEL(FILE,NAME) \
1350 (assemble_name (FILE, NAME), fputs (":\n", FILE))
1351
1352/* This is how to output an assembler line defining a `double' constant. */
1353
1354#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
1355 fprintf (FILE, "%s %.22e\n", ASM_DOUBLE, (VALUE))
1356
1357
1358/* This is how to output an assembler line defining a `float' constant. */
1359
1360#define ASM_OUTPUT_FLOAT(FILE,VALUE) \
1361do { union { float f; long l;} tem; \
1362 tem.f = (VALUE); \
1363 fprintf((FILE), "%s 0x%x\n", ASM_LONG, tem.l); \
1364 } while (0)
1365
1366
1367/* Store in OUTPUT a string (made with alloca) containing
1368 an assembler-name for a local static variable named NAME.
1369 LABELNO is an integer which is different for each call. */
1370
1371#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
1372( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
1373 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
1374
1375
1376
1377/* This is how to output an assembler line defining an `int' constant. */
1378
1379#define ASM_OUTPUT_INT(FILE,VALUE) \
1380( fprintf (FILE, "%s ", ASM_LONG), \
1381 output_addr_const (FILE,(VALUE)), \
1382 putc('\n',FILE))
1383
1384/* Likewise for `char' and `short' constants. */
1385/* is this supposed to do align too?? */
1386
1387#define ASM_OUTPUT_SHORT(FILE,VALUE) \
1388( fprintf (FILE, "%s ", ASM_SHORT), \
1389 output_addr_const (FILE,(VALUE)), \
1390 putc('\n',FILE))
1391
1392/*
1393#define ASM_OUTPUT_SHORT(FILE,VALUE) \
1394( fprintf (FILE, "%s ", ASM_BYTE_OP), \
1395 output_addr_const (FILE,(VALUE)), \
1396 fputs (",", FILE), \
1397 output_addr_const (FILE,(VALUE)), \
1398 fputs (" >> 8\n",FILE))
1399*/
1400
1401
1402#define ASM_OUTPUT_CHAR(FILE,VALUE) \
1403( fprintf (FILE, "%s ", ASM_BYTE_OP), \
1404 output_addr_const (FILE, (VALUE)), \
1405 putc ('\n', FILE))
1406
1407/* This is how to output an assembler line for a numeric constant byte. */
1408
1409#define ASM_OUTPUT_BYTE(FILE,VALUE) \
1410 fprintf ((FILE), "%s 0x%x\n", ASM_BYTE_OP, (VALUE))
1411
1412/* This is how to output an insn to push a register on the stack.
1413 It need not be very fast code. */
1414
1415#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
1416 fprintf (FILE, "\tpushl e%s\n", reg_names[REGNO])
1417
1418/* This is how to output an insn to pop a register from the stack.
1419 It need not be very fast code. */
1420
1421#define ASM_OUTPUT_REG_POP(FILE,REGNO) \
1422 fprintf (FILE, "\tpopl e%s\n", reg_names[REGNO])
1423
1424/* This is how to output an element of a case-vector that is absolute.
1425 */
1426
1427#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1428 fprintf (FILE, "%s %s%d\n", ASM_LONG, LPREFIX, VALUE)
1429
1430/* This is how to output an element of a case-vector that is relative.
1431 We don't use these on the 386 yet, because the ATT assembler can't do
1432 forward reference the differences.
1433 */
1434
1435#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
1436 fprintf (FILE, "\t.word %s%d-%s%d\n",LPREFIX, VALUE,LPREFIX, REL)
1437
1438/* Define the parentheses used to group arithmetic operations
1439 in assembler code. */
1440
1441#define ASM_OPEN_PAREN ""
1442#define ASM_CLOSE_PAREN ""
1443
1444/* Define results of standard character escape sequences. */
1445#define TARGET_BELL 007
1446#define TARGET_BS 010
1447#define TARGET_TAB 011
1448#define TARGET_NEWLINE 012
1449#define TARGET_VT 013
1450#define TARGET_FF 014
1451#define TARGET_CR 015
74b42c8b 1452\f
c98f8742
JVA
1453/* Print operand X (an rtx) in assembler syntax to file FILE.
1454 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
1455 The CODE z takes the size of operand from the following digit, and
1456 outputs b,w,or l respectively.
1457
1458 On the 80386, we use several such letters:
1459 f -- float insn (print a CONST_DOUBLE as a float rather than in hex).
1460 L,W,B,Q,S -- print the opcode suffix for specified size of operand.
1461 R -- print the prefix for register names.
1462 z -- print the opcode suffix for the size of the current operand.
1463 * -- print a star (in certain assembler syntax)
1464 w -- print the operand as if it's a "word" (HImode) even if it isn't.
1465 b -- print the operand as if it's a byte (QImode) even if it isn't.
1466 c -- don't print special prefixes before constant operands. */
1467
1468#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1469 ((CODE) == '*')
1470
74b42c8b
RS
1471/* Print the name of a register based on its machine mode and number.
1472 If CODE is 'w', pretend the mode is HImode.
1473 If CODE is 'b', pretend the mode is QImode.
1474 If CODE is 'k', pretend the mode is SImode.
1475 If CODE is 'h', pretend the reg is the `high' byte register.
1476 If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op. */
1477
aa3e8d2a
JVA
1478extern char *hi_reg_name[];
1479extern char *qi_reg_name[];
1480extern char *qi_high_reg_name[];
1481
74b42c8b 1482#define PRINT_REG(X, CODE, FILE) \
aa3e8d2a
JVA
1483 do { if (REGNO (X) == ARG_POINTER_REGNUM) \
1484 abort (); \
74b42c8b
RS
1485 fprintf (FILE, "%s", RP); \
1486 switch ((CODE == 'w' ? 2 \
1487 : CODE == 'b' ? 1 \
1488 : CODE == 'k' ? 4 \
1489 : CODE == 'y' ? 3 \
1490 : CODE == 'h' ? 0 \
1491 : GET_MODE_SIZE (GET_MODE (X)))) \
1492 { \
1493 case 3: \
1494 if (STACK_TOP_P (X)) \
aa3e8d2a
JVA
1495 { \
1496 fputs ("st(0)", FILE); \
1497 break; \
1498 } \
1499 case 4: \
1500 case 8: \
9e06e321 1501 if (! FP_REG_P (X)) fputs ("e", FILE); \
74b42c8b
RS
1502 case 2: \
1503 fputs (hi_reg_name[REGNO (X)], FILE); \
1504 break; \
1505 case 1: \
1506 fputs (qi_reg_name[REGNO (X)], FILE); \
1507 break; \
1508 case 0: \
1509 fputs (qi_high_reg_name[REGNO (X)], FILE); \
1510 break; \
1511 } \
1512 } while (0)
1513
c98f8742
JVA
1514#define PRINT_OPERAND(FILE, X, CODE) \
1515 print_operand (FILE, X, CODE)
c98f8742
JVA
1516
1517#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
1518 print_operand_address (FILE, ADDR)
1519
aa3e8d2a
JVA
1520/* Print the name of a register for based on its machine mode and number.
1521 This macro is used to print debugging output.
1522 This macro is different from PRINT_REG in that it may be used in
1523 programs that are not linked with aux-output.o. */
1524
1525#define DEBUG_PRINT_REG(X, CODE, FILE) \
1526 do { static char *hi_name[] = HI_REGISTER_NAMES; \
1527 static char *qi_name[] = QI_REGISTER_NAMES; \
7488be4e 1528 fprintf (FILE, "%d %s", REGNO (X), RP); \
aa3e8d2a
JVA
1529 if (REGNO (X) == ARG_POINTER_REGNUM) \
1530 { fputs ("argp", FILE); break; } \
1531 if (STACK_TOP_P (X)) \
1532 { fputs ("st(0)", FILE); break; } \
1533 switch (GET_MODE_SIZE (GET_MODE (X))) \
1534 { \
1535 case 8: \
1536 case 4: \
1537 if (! FP_REG_P (X)) fputs ("e", FILE); \
1538 case 2: \
1539 fputs (hi_name[REGNO (X)], FILE); \
1540 break; \
1541 case 1: \
1542 fputs (qi_name[REGNO (X)], FILE); \
1543 break; \
1544 } \
1545 } while (0)
1546
c98f8742
JVA
1547/* Output the prefix for an immediate operand, or for an offset operand. */
1548#define PRINT_IMMED_PREFIX(FILE) fputs (IP, (FILE))
1549#define PRINT_OFFSET_PREFIX(FILE) fputs (IP, (FILE))
1550
1551/* Routines in libgcc that return floats must return them in an fp reg,
1552 just as other functions do which return such values.
1553 These macros make that happen. */
1554
1555#define FLOAT_VALUE_TYPE float
1556#define INTIFY(FLOATVAL) FLOATVAL
1557
1558/* Nonzero if INSN magically clobbers register REGNO. */
1559
1560/* #define INSN_CLOBBERS_REGNO_P(INSN, REGNO) \
1561 (FP_REGNO_P (REGNO) \
1562 && (GET_CODE (INSN) == JUMP_INSN || GET_CODE (INSN) == BARRIER))
1563*/
1564
1565/* a letter which is not needed by the normal asm syntax, which
1566 we can use for operand syntax in the extended asm */
1567
1568#define ASM_OPERAND_LETTER '#'
1569\f
1570#define RET return ""
1571#define AT_SP(mode) (gen_rtx (MEM, (mode), stack_pointer_rtx))
1572\f
1573/*
1574Local variables:
1575version-control: t
1576End:
1577*/
This page took 0.27023 seconds and 5 git commands to generate.