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