]> gcc.gnu.org Git - gcc.git/blob - gcc/config/i386/i386.h
a28c503cdafa885b0fa1ce8afc55492cd3d5c8ed
[gcc.git] / gcc / config / i386 / i386.h
1 /* Definitions of target machine for GNU compiler for Intel X86
2 (386, 486, Pentium).
3 Copyright (C) 1988, 1992, 1994, 1995, 1996 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* The purpose of this file is to define the characteristics of the i386,
23 independent of assembler syntax or operating system.
24
25 Three other files build on this one to describe a specific assembler syntax:
26 bsd386.h, att386.h, and sun386.h.
27
28 The actual tm.h file for a particular system should include
29 this file, and then the file for the appropriate assembler syntax.
30
31 Many macros that specify assembler syntax are omitted entirely from
32 this file because they really belong in the files for particular
33 assemblers. These include AS1, AS2, AS3, RP, IP, LPREFIX, L_SIZE,
34 PUT_OP_SIZE, USE_STAR, ADDR_BEG, ADDR_END, PRINT_IREG, PRINT_SCALE,
35 PRINT_B_I_S, and many that start with ASM_ or end in ASM_OP. */
36
37 /* Names to predefine in the preprocessor for this target machine. */
38
39 #define I386 1
40
41 /* Stubs for half-pic support if not OSF/1 reference platform. */
42
43 #ifndef HALF_PIC_P
44 #define HALF_PIC_P() 0
45 #define HALF_PIC_NUMBER_PTRS 0
46 #define HALF_PIC_NUMBER_REFS 0
47 #define HALF_PIC_ENCODE(DECL)
48 #define HALF_PIC_DECLARE(NAME)
49 #define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it.")
50 #define HALF_PIC_ADDRESS_P(X) 0
51 #define HALF_PIC_PTR(X) X
52 #define HALF_PIC_FINISH(STREAM)
53 #endif
54
55 /* Define the specific costs for a given cpu */
56
57 struct processor_costs {
58 int add; /* cost of an add instruction */
59 int lea; /* cost of a lea instruction */
60 int shift_var; /* variable shift costs */
61 int shift_const; /* constant shift costs */
62 int mult_init; /* cost of starting a multiply */
63 int mult_bit; /* cost of multiply per each bit set */
64 int divide; /* cost of a divide/mod */
65 };
66
67 extern struct processor_costs *ix86_cost;
68
69 /* Run-time compilation parameters selecting different hardware subsets. */
70
71 extern int target_flags;
72
73 /* Macros used in the machine description to test the flags. */
74
75 /* configure can arrange to make this 2, to force a 486. */
76 #ifndef TARGET_CPU_DEFAULT
77 #define TARGET_CPU_DEFAULT 0
78 #endif
79
80 /* Masks for the -m switches */
81 #define MASK_80387 000000000001 /* Hardware floating point */
82 #define MASK_486 000000000002 /* 80486 specific */
83 #define MASK_NOTUSED1 000000000004 /* bit not currently used */
84 #define MASK_RTD 000000000010 /* Use ret that pops args */
85 #define MASK_ALIGN_DOUBLE 000000000020 /* align doubles to 2 word boundary */
86 #define MASK_SVR3_SHLIB 000000000040 /* Uninit locals into bss */
87 #define MASK_IEEE_FP 000000000100 /* IEEE fp comparisons */
88 #define MASK_FLOAT_RETURNS 000000000200 /* Return float in st(0) */
89 #define MASK_NO_FANCY_MATH_387 000000000400 /* Disable sin, cos, sqrt */
90 #define MASK_OMIT_LEAF_FRAME_POINTER 0x00000800 /* omit leaf frame pointers */
91 /* Temporary codegen switches */
92 #define MASK_DEBUG_ADDR 000001000000 /* Debug GO_IF_LEGITIMATE_ADDRESS */
93 #define MASK_NO_WIDE_MULTIPLY 000002000000 /* Disable 32x32->64 multiplies */
94 #define MASK_NO_MOVE 000004000000 /* Don't generate mem->mem */
95 #define MASK_NO_PSEUDO 000010000000 /* Move op's args -> pseudos */
96 #define MASK_DEBUG_ARG 000020000000 /* Debug function_arg */
97 #define MASK_SCHEDULE_PROLOGUE 000040000000 /* Emit prologue as rtl */
98 #define MASK_STACK_PROBE 000100000000 /* Enable stack probing */
99
100 /* Use the floating point instructions */
101 #define TARGET_80387 (target_flags & MASK_80387)
102
103 /* Compile using ret insn that pops args.
104 This will not work unless you use prototypes at least
105 for all functions that can take varying numbers of args. */
106 #define TARGET_RTD (target_flags & MASK_RTD)
107
108 /* Align doubles to a two word boundary. This breaks compatibility with
109 the published ABI's for structures containing doubles, but produces
110 faster code on the pentium. */
111 #define TARGET_ALIGN_DOUBLE (target_flags & MASK_ALIGN_DOUBLE)
112
113 /* Put uninitialized locals into bss, not data.
114 Meaningful only on svr3. */
115 #define TARGET_SVR3_SHLIB (target_flags & MASK_SVR3_SHLIB)
116
117 /* Use IEEE floating point comparisons. These handle correctly the cases
118 where the result of a comparison is unordered. Normally SIGFPE is
119 generated in such cases, in which case this isn't needed. */
120 #define TARGET_IEEE_FP (target_flags & MASK_IEEE_FP)
121
122 /* Functions that return a floating point value may return that value
123 in the 387 FPU or in 386 integer registers. If set, this flag causes
124 the 387 to be used, which is compatible with most calling conventions. */
125 #define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & MASK_FLOAT_RETURNS)
126
127 /* Disable generation of FP sin, cos and sqrt operations for 387.
128 This is because FreeBSD lacks these in the math-emulator-code */
129 #define TARGET_NO_FANCY_MATH_387 (target_flags & MASK_NO_FANCY_MATH_387)
130
131 /* Don't create frame pointers for leaf functions */
132 #define TARGET_OMIT_LEAF_FRAME_POINTER (target_flags & MASK_OMIT_LEAF_FRAME_POINTER)
133
134 /* Temporary switches for tuning code generation */
135
136 /* Disable 32x32->64 bit multiplies that are used for long long multiplies
137 and division by constants, but sometimes cause reload problems. */
138 #define TARGET_NO_WIDE_MULTIPLY (target_flags & MASK_NO_WIDE_MULTIPLY)
139 #define TARGET_WIDE_MULTIPLY (!TARGET_NO_WIDE_MULTIPLY)
140
141 /* Emit/Don't emit prologue as rtl */
142 #define TARGET_SCHEDULE_PROLOGUE (target_flags & MASK_SCHEDULE_PROLOGUE)
143
144 /* Debug GO_IF_LEGITIMATE_ADDRESS */
145 #define TARGET_DEBUG_ADDR (target_flags & MASK_DEBUG_ADDR)
146
147 /* Debug FUNCTION_ARG macros */
148 #define TARGET_DEBUG_ARG (target_flags & MASK_DEBUG_ARG)
149
150 /* Hack macros for tuning code generation */
151 #define TARGET_MOVE ((target_flags & MASK_NO_MOVE) == 0) /* Don't generate memory->memory */
152 #define TARGET_PSEUDO ((target_flags & MASK_NO_PSEUDO) == 0) /* Move op's args into pseudos */
153
154 #define TARGET_386 (ix86_cpu == PROCESSOR_I386)
155 #define TARGET_486 (ix86_cpu == PROCESSOR_I486)
156 #define TARGET_PENTIUM (ix86_cpu == PROCESSOR_PENTIUM)
157 #define TARGET_PENTIUMPRO (ix86_cpu == PROCESSOR_PENTIUMPRO)
158 #define TARGET_USE_LEAVE (ix86_cpu == PROCESSOR_I386)
159 #define TARGET_PUSH_MEMORY (ix86_cpu == PROCESSOR_I386)
160 #define TARGET_ZERO_EXTEND_WITH_AND (ix86_cpu != PROCESSOR_I386)
161 #define TARGET_DOUBLE_WITH_ADD (ix86_cpu != PROCESSOR_I386)
162 #define TARGET_USE_BIT_TEST (ix86_cpu == PROCESSOR_I386)
163 #define TARGET_UNROLL_STRLEN (ix86_cpu != PROCESSOR_I386)
164 #define TARGET_USE_Q_REG (ix86_cpu == PROCESSOR_PENTIUM \
165 || ix86_cpu == PROCESSOR_PENTIUMPRO)
166 #define TARGET_USE_ANY_REG (ix86_cpu == PROCESSOR_I486)
167 #define TARGET_CMOVE (ix86_arch == PROCESSOR_PENTIUMPRO)
168 #define TARGET_DEEP_BRANCH_PREDICTION (ix86_cpu == PROCESSOR_PENTIUMPRO)
169 #define TARGET_STACK_PROBE (target_flags & MASK_STACK_PROBE)
170
171 #define TARGET_SWITCHES \
172 { { "80387", MASK_80387 }, \
173 { "no-80387", -MASK_80387 }, \
174 { "hard-float", MASK_80387 }, \
175 { "soft-float", -MASK_80387 }, \
176 { "no-soft-float", MASK_80387 }, \
177 { "386", 0 }, \
178 { "no-386", 0 }, \
179 { "486", 0 }, \
180 { "no-486", 0 }, \
181 { "pentium", 0 }, \
182 { "pentiumpro", 0 }, \
183 { "rtd", MASK_RTD }, \
184 { "no-rtd", -MASK_RTD }, \
185 { "align-double", MASK_ALIGN_DOUBLE }, \
186 { "no-align-double", -MASK_ALIGN_DOUBLE }, \
187 { "svr3-shlib", MASK_SVR3_SHLIB }, \
188 { "no-svr3-shlib", -MASK_SVR3_SHLIB }, \
189 { "ieee-fp", MASK_IEEE_FP }, \
190 { "no-ieee-fp", -MASK_IEEE_FP }, \
191 { "fp-ret-in-387", MASK_FLOAT_RETURNS }, \
192 { "no-fp-ret-in-387", -MASK_FLOAT_RETURNS }, \
193 { "no-fancy-math-387", MASK_NO_FANCY_MATH_387 }, \
194 { "fancy-math-387", -MASK_NO_FANCY_MATH_387 }, \
195 { "omit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER }, \
196 { "no-omit-leaf-frame-pointer",-MASK_OMIT_LEAF_FRAME_POINTER }, \
197 { "no-wide-multiply", MASK_NO_WIDE_MULTIPLY }, \
198 { "wide-multiply", -MASK_NO_WIDE_MULTIPLY }, \
199 { "schedule-prologue", MASK_SCHEDULE_PROLOGUE }, \
200 { "no-schedule-prologue", -MASK_SCHEDULE_PROLOGUE }, \
201 { "debug-addr", MASK_DEBUG_ADDR }, \
202 { "no-debug-addr", -MASK_DEBUG_ADDR }, \
203 { "move", -MASK_NO_MOVE }, \
204 { "no-move", MASK_NO_MOVE }, \
205 { "debug-arg", MASK_DEBUG_ARG }, \
206 { "no-debug-arg", -MASK_DEBUG_ARG }, \
207 { "stack-arg-probe", MASK_STACK_PROBE }, \
208 { "no-stack-arg-probe", -MASK_STACK_PROBE }, \
209 SUBTARGET_SWITCHES \
210 { "", MASK_SCHEDULE_PROLOGUE | TARGET_DEFAULT}}
211
212 /* Which processor to schedule for. The cpu attribute defines a list that
213 mirrors this list, so changes to i386.md must be made at the same time. */
214
215 enum processor_type
216 {PROCESSOR_I386, /* 80386 */
217 PROCESSOR_I486, /* 80486DX, 80486SX, 80486DX[24] */
218 PROCESSOR_PENTIUM,
219 PROCESSOR_PENTIUMPRO};
220
221 #define PROCESSOR_I386_STRING "i386"
222 #define PROCESSOR_I486_STRING "i486"
223 #define PROCESSOR_I586_STRING "i586"
224 #define PROCESSOR_PENTIUM_STRING "pentium"
225 #define PROCESSOR_I686_STRING "i686"
226 #define PROCESSOR_PENTIUMPRO_STRING "pentiumpro"
227
228 extern enum processor_type ix86_cpu;
229
230 extern int ix86_arch;
231
232 /* Define the default processor. This is overridden by other tm.h files. */
233 #define PROCESSOR_DEFAULT \
234 ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_I486) \
235 ? PROCESSOR_I486 \
236 : ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_PENTIUM) \
237 ? PROCESSOR_PENTIUM \
238 : ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_PENTIUMPRO) \
239 ? PROCESSOR_PENTIUMPRO \
240 : PROCESSOR_I386
241 #define PROCESSOR_DEFAULT_STRING \
242 ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_I486) \
243 ? PROCESSOR_I486_STRING \
244 : ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_PENTIUM) \
245 ? PROCESSOR_PENTIUM_STRING \
246 : ((enum processor_type) TARGET_CPU_DEFAULT == PROCESSOR_PENTIUMPRO) \
247 ? PROCESSOR_PENTIUMPRO_STRING \
248 : PROCESSOR_I386_STRING
249
250 /* This macro is similar to `TARGET_SWITCHES' but defines names of
251 command options that have values. Its definition is an
252 initializer with a subgrouping for each command option.
253
254 Each subgrouping contains a string constant, that defines the
255 fixed part of the option name, and the address of a variable. The
256 variable, type `char *', is set to the variable part of the given
257 option if the fixed part matches. The actual option name is made
258 by appending `-m' to the specified name. */
259 #define TARGET_OPTIONS \
260 { { "cpu=", &ix86_cpu_string}, \
261 { "arch=", &ix86_arch_string}, \
262 { "reg-alloc=", &i386_reg_alloc_order }, \
263 { "regparm=", &i386_regparm_string }, \
264 { "align-loops=", &i386_align_loops_string }, \
265 { "align-jumps=", &i386_align_jumps_string }, \
266 { "align-functions=", &i386_align_funcs_string }, \
267 { "branch-cost=", &i386_branch_cost_string }, \
268 SUBTARGET_OPTIONS \
269 }
270
271 /* Sometimes certain combinations of command options do not make
272 sense on a particular target machine. You can define a macro
273 `OVERRIDE_OPTIONS' to take account of this. This macro, if
274 defined, is executed once just after all the command options have
275 been parsed.
276
277 Don't use this macro to turn on various extra optimizations for
278 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
279
280 #define OVERRIDE_OPTIONS override_options ()
281
282 /* These are meant to be redefined in the host dependent files */
283 #define SUBTARGET_SWITCHES
284 #define SUBTARGET_OPTIONS
285
286 /* Define this to change the optimizations performed by default. */
287 #define OPTIMIZATION_OPTIONS(LEVEL) optimization_options(LEVEL)
288
289 /* Specs for the compiler proper */
290
291 #ifndef CC1_SPEC
292 #define CC1_SPEC "\
293 %{!mcpu*: \
294 %{m386:-mcpu=i386 -march=i386} \
295 %{mno-486:-mcpu=i386 -march=i386} \
296 %{m486:-mcpu=i486 -march=i486} \
297 %{mno-386:-mcpu=i486 -march=i486} \
298 %{mno-pentium:-mcpu=i486 -march=i486} \
299 %{mpentium:-mcpu=pentium} \
300 %{mno-pentiumpro:-mcpu=pentium} \
301 %{mpentiumpro:-mcpu=pentiumpro}}"
302 #endif
303 \f
304 #ifndef CPP_CPU_SPEC
305 #define CPP_CPU_SPEC "\
306 -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) \
307 %{mcpu=i486:-Di486} %{m486:-Di486} \
308 %{mpentium:-Dpentium -Di586} %{mcpu=pentium:-Dpentium -Di586} \
309 %{mpentiumpro:-Dpentiumpro -Di686} %{mcpu=pentiumpro:-Dpentiumpro -Di686}"
310 #endif
311
312 /* This macro defines names of additional specifications to put in the specs
313 that can be used in various specifications like CC1_SPEC. Its definition
314 is an initializer with a subgrouping for each command option.
315
316 Each subgrouping contains a string constant, that defines the
317 specification name, and a string constant that used by the GNU CC driver
318 program.
319
320 Do not define this macro if it does not need to do anything. */
321
322 #ifndef SUBTARGET_EXTRA_SPECS
323 #define SUBTARGET_EXTRA_SPECS
324 #endif
325
326 #define EXTRA_SPECS \
327 { "cpp_cpu", CPP_CPU_SPEC }, \
328 SUBTARGET_EXTRA_SPECS
329 \f
330 /* target machine storage layout */
331
332 /* Define for XFmode extended real floating point support.
333 This will automatically cause REAL_ARITHMETIC to be defined. */
334 #define LONG_DOUBLE_TYPE_SIZE 96
335
336 /* Define if you don't want extended real, but do want to use the
337 software floating point emulator for REAL_ARITHMETIC and
338 decimal <-> binary conversion. */
339 /* #define REAL_ARITHMETIC */
340
341 /* Define this if most significant byte of a word is the lowest numbered. */
342 /* That is true on the 80386. */
343
344 #define BITS_BIG_ENDIAN 0
345
346 /* Define this if most significant byte of a word is the lowest numbered. */
347 /* That is not true on the 80386. */
348 #define BYTES_BIG_ENDIAN 0
349
350 /* Define this if most significant word of a multiword number is the lowest
351 numbered. */
352 /* Not true for 80386 */
353 #define WORDS_BIG_ENDIAN 0
354
355 /* number of bits in an addressable storage unit */
356 #define BITS_PER_UNIT 8
357
358 /* Width in bits of a "word", which is the contents of a machine register.
359 Note that this is not necessarily the width of data type `int';
360 if using 16-bit ints on a 80386, this would still be 32.
361 But on a machine with 16-bit registers, this would be 16. */
362 #define BITS_PER_WORD 32
363
364 /* Width of a word, in units (bytes). */
365 #define UNITS_PER_WORD 4
366
367 /* Width in bits of a pointer.
368 See also the macro `Pmode' defined below. */
369 #define POINTER_SIZE 32
370
371 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
372 #define PARM_BOUNDARY 32
373
374 /* Boundary (in *bits*) on which stack pointer should be aligned. */
375 #define STACK_BOUNDARY 32
376
377 /* Allocation boundary (in *bits*) for the code of a function.
378 For i486, we get better performance by aligning to a cache
379 line (i.e. 16 byte) boundary. */
380 #define FUNCTION_BOUNDARY (1 << (i386_align_funcs + 3))
381
382 /* Alignment of field after `int : 0' in a structure. */
383
384 #define EMPTY_FIELD_BOUNDARY 32
385
386 /* Minimum size in bits of the largest boundary to which any
387 and all fundamental data types supported by the hardware
388 might need to be aligned. No data type wants to be aligned
389 rounder than this. The i386 supports 64-bit floating point
390 quantities, but these can be aligned on any 32-bit boundary.
391 The published ABIs say that doubles should be aligned on word
392 boundaries, but the Pentium gets better performance with them
393 aligned on 64 bit boundaries. */
394 #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
395
396 /* align DFmode constants and nonaggregates */
397 #define ALIGN_DFmode (!TARGET_386)
398
399 /* Set this non-zero if move instructions will actually fail to work
400 when given unaligned data. */
401 #define STRICT_ALIGNMENT 0
402
403 /* If bit field type is int, don't let it cross an int,
404 and give entire struct the alignment of an int. */
405 /* Required on the 386 since it doesn't have bitfield insns. */
406 #define PCC_BITFIELD_TYPE_MATTERS 1
407
408 /* Maximum power of 2 that code can be aligned to. */
409 #define MAX_CODE_ALIGN 6 /* 64 byte alignment */
410
411 /* Align loop starts for optimal branching. */
412 #define ASM_OUTPUT_LOOP_ALIGN(FILE) ASM_OUTPUT_ALIGN (FILE, i386_align_loops)
413
414 /* This is how to align an instruction for optimal branching.
415 On i486 we'll get better performance by aligning on a
416 cache line (i.e. 16 byte) boundary. */
417 #define ASM_OUTPUT_ALIGN_CODE(FILE) ASM_OUTPUT_ALIGN ((FILE), i386_align_jumps)
418
419 \f
420 /* Standard register usage. */
421
422 /* This processor has special stack-like registers. See reg-stack.c
423 for details. */
424
425 #define STACK_REGS
426 #define IS_STACK_MODE(mode) (mode==DFmode || mode==SFmode || mode==XFmode)
427
428 /* Number of actual hardware registers.
429 The hardware registers are assigned numbers for the compiler
430 from 0 to just below FIRST_PSEUDO_REGISTER.
431 All registers that the compiler knows about must be given numbers,
432 even those that are not normally considered general registers.
433
434 In the 80386 we give the 8 general purpose registers the numbers 0-7.
435 We number the floating point registers 8-15.
436 Note that registers 0-7 can be accessed as a short or int,
437 while only 0-3 may be used with byte `mov' instructions.
438
439 Reg 16 does not correspond to any hardware register, but instead
440 appears in the RTL as an argument pointer prior to reload, and is
441 eliminated during reloading in favor of either the stack or frame
442 pointer. */
443
444 #define FIRST_PSEUDO_REGISTER 17
445
446 /* 1 for registers that have pervasive standard uses
447 and are not available for the register allocator.
448 On the 80386, the stack pointer is such, as is the arg pointer. */
449 #define FIXED_REGISTERS \
450 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
451 { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
452
453 /* 1 for registers not available across function calls.
454 These must include the FIXED_REGISTERS and also any
455 registers that can be used without being saved.
456 The latter must include the registers where values are returned
457 and the register where structure-value addresses are passed.
458 Aside from that, you can include as many other registers as you like. */
459
460 #define CALL_USED_REGISTERS \
461 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
462 { 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
463
464 /* Order in which to allocate registers. Each register must be
465 listed once, even those in FIXED_REGISTERS. List frame pointer
466 late and fixed registers last. Note that, in general, we prefer
467 registers listed in CALL_USED_REGISTERS, keeping the others
468 available for storage of persistent values.
469
470 Three different versions of REG_ALLOC_ORDER have been tried:
471
472 If the order is edx, ecx, eax, ... it produces a slightly faster compiler,
473 but slower code on simple functions returning values in eax.
474
475 If the order is eax, ecx, edx, ... it causes reload to abort when compiling
476 perl 4.036 due to not being able to create a DImode register (to hold a 2
477 word union).
478
479 If the order is eax, edx, ecx, ... it produces better code for simple
480 functions, and a slightly slower compiler. Users complained about the code
481 generated by allocating edx first, so restore the 'natural' order of things. */
482
483 #define REG_ALLOC_ORDER \
484 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \
485 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
486
487 /* A C statement (sans semicolon) to choose the order in which to
488 allocate hard registers for pseudo-registers local to a basic
489 block.
490
491 Store the desired register order in the array `reg_alloc_order'.
492 Element 0 should be the register to allocate first; element 1, the
493 next register; and so on.
494
495 The macro body should not assume anything about the contents of
496 `reg_alloc_order' before execution of the macro.
497
498 On most machines, it is not necessary to define this macro. */
499
500 #define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
501
502 /* Macro to conditionally modify fixed_regs/call_used_regs. */
503 #define CONDITIONAL_REGISTER_USAGE \
504 { \
505 if (flag_pic) \
506 { \
507 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
508 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
509 } \
510 if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387) \
511 { \
512 int i; \
513 HARD_REG_SET x; \
514 COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]); \
515 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \
516 if (TEST_HARD_REG_BIT (x, i)) \
517 fixed_regs[i] = call_used_regs[i] = 1; \
518 } \
519 }
520
521 /* Return number of consecutive hard regs needed starting at reg REGNO
522 to hold something of mode MODE.
523 This is ordinarily the length in words of a value of mode MODE
524 but can be less for certain modes in special long registers.
525
526 Actually there are no two word move instructions for consecutive
527 registers. And only registers 0-3 may have mov byte instructions
528 applied to them.
529 */
530
531 #define HARD_REGNO_NREGS(REGNO, MODE) \
532 (FP_REGNO_P (REGNO) ? 1 \
533 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
534
535 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
536 On the 80386, the first 4 cpu registers can hold any mode
537 while the floating point registers may hold only floating point.
538 Make it clear that the fp regs could not hold a 16-byte float. */
539
540 /* The casts to int placate a compiler on a microvax,
541 for cross-compiler testing. */
542
543 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
544 ((REGNO) < 2 ? 1 \
545 : (REGNO) < 4 ? 1 \
546 : FP_REGNO_P (REGNO) \
547 ? (((int) GET_MODE_CLASS (MODE) == (int) MODE_FLOAT \
548 || (int) GET_MODE_CLASS (MODE) == (int) MODE_COMPLEX_FLOAT) \
549 && GET_MODE_UNIT_SIZE (MODE) <= (LONG_DOUBLE_TYPE_SIZE == 96 ? 12 : 8))\
550 : (int) (MODE) != (int) QImode ? 1 \
551 : (reload_in_progress | reload_completed) == 1)
552
553 /* Value is 1 if it is a good idea to tie two pseudo registers
554 when one has mode MODE1 and one has mode MODE2.
555 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
556 for any hard reg, then this must be 0 for correct output. */
557
558 #define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2))
559
560 /* Specify the registers used for certain standard purposes.
561 The values of these macros are register numbers. */
562
563 /* on the 386 the pc register is %eip, and is not usable as a general
564 register. The ordinary mov instructions won't work */
565 /* #define PC_REGNUM */
566
567 /* Register to use for pushing function arguments. */
568 #define STACK_POINTER_REGNUM 7
569
570 /* Base register for access to local variables of the function. */
571 #define FRAME_POINTER_REGNUM 6
572
573 /* First floating point reg */
574 #define FIRST_FLOAT_REG 8
575
576 /* First & last stack-like regs */
577 #define FIRST_STACK_REG FIRST_FLOAT_REG
578 #define LAST_STACK_REG (FIRST_FLOAT_REG + 7)
579
580 /* Value should be nonzero if functions must have frame pointers.
581 Zero means the frame pointer need not be set up (and parms
582 may be accessed via the stack pointer) in functions that seem suitable.
583 This is computed in `reload', in reload1.c. */
584 #define FRAME_POINTER_REQUIRED (TARGET_OMIT_LEAF_FRAME_POINTER && !leaf_function_p ())
585
586 /* Base register for access to arguments of the function. */
587 #define ARG_POINTER_REGNUM 16
588
589 /* Register in which static-chain is passed to a function. */
590 #define STATIC_CHAIN_REGNUM 2
591
592 /* Register to hold the addressing base for position independent
593 code access to data items. */
594 #define PIC_OFFSET_TABLE_REGNUM 3
595
596 /* Register in which address to store a structure value
597 arrives in the function. On the 386, the prologue
598 copies this from the stack to register %eax. */
599 #define STRUCT_VALUE_INCOMING 0
600
601 /* Place in which caller passes the structure value address.
602 0 means push the value on the stack like an argument. */
603 #define STRUCT_VALUE 0
604
605 /* A C expression which can inhibit the returning of certain function
606 values in registers, based on the type of value. A nonzero value
607 says to return the function value in memory, just as large
608 structures are always returned. Here TYPE will be a C expression
609 of type `tree', representing the data type of the value.
610
611 Note that values of mode `BLKmode' must be explicitly handled by
612 this macro. Also, the option `-fpcc-struct-return' takes effect
613 regardless of this macro. On most systems, it is possible to
614 leave the macro undefined; this causes a default definition to be
615 used, whose value is the constant 1 for `BLKmode' values, and 0
616 otherwise.
617
618 Do not use this macro to indicate that structures and unions
619 should always be returned in memory. You should instead use
620 `DEFAULT_PCC_STRUCT_RETURN' to indicate this. */
621
622 #define RETURN_IN_MEMORY(TYPE) \
623 ((TYPE_MODE (TYPE) == BLKmode) || int_size_in_bytes (TYPE) > 12)
624
625 \f
626 /* Define the classes of registers for register constraints in the
627 machine description. Also define ranges of constants.
628
629 One of the classes must always be named ALL_REGS and include all hard regs.
630 If there is more than one class, another class must be named NO_REGS
631 and contain no registers.
632
633 The name GENERAL_REGS must be the name of a class (or an alias for
634 another name such as ALL_REGS). This is the class of registers
635 that is allowed by "g" or "r" in a register constraint.
636 Also, registers outside this class are allocated only when
637 instructions express preferences for them.
638
639 The classes must be numbered in nondecreasing order; that is,
640 a larger-numbered class must never be contained completely
641 in a smaller-numbered class.
642
643 For any two classes, it is very desirable that there be another
644 class that represents their union.
645
646 It might seem that class BREG is unnecessary, since no useful 386
647 opcode needs reg %ebx. But some systems pass args to the OS in ebx,
648 and the "b" register constraint is useful in asms for syscalls. */
649
650 enum reg_class
651 {
652 NO_REGS,
653 AREG, DREG, CREG, BREG,
654 AD_REGS, /* %eax/%edx for DImode */
655 Q_REGS, /* %eax %ebx %ecx %edx */
656 SIREG, DIREG,
657 INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */
658 GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
659 FP_TOP_REG, FP_SECOND_REG, /* %st(0) %st(1) */
660 FLOAT_REGS,
661 ALL_REGS, LIM_REG_CLASSES
662 };
663
664 #define N_REG_CLASSES (int) LIM_REG_CLASSES
665
666 #define FLOAT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, FLOAT_REGS))
667
668 /* Give names of register classes as strings for dump file. */
669
670 #define REG_CLASS_NAMES \
671 { "NO_REGS", \
672 "AREG", "DREG", "CREG", "BREG", \
673 "AD_REGS", \
674 "Q_REGS", \
675 "SIREG", "DIREG", \
676 "INDEX_REGS", \
677 "GENERAL_REGS", \
678 "FP_TOP_REG", "FP_SECOND_REG", \
679 "FLOAT_REGS", \
680 "ALL_REGS" }
681
682 /* Define which registers fit in which classes.
683 This is an initializer for a vector of HARD_REG_SET
684 of length N_REG_CLASSES. */
685
686 #define REG_CLASS_CONTENTS \
687 { 0, \
688 0x1, 0x2, 0x4, 0x8, /* AREG, DREG, CREG, BREG */ \
689 0x3, /* AD_REGS */ \
690 0xf, /* Q_REGS */ \
691 0x10, 0x20, /* SIREG, DIREG */ \
692 0x7f, /* INDEX_REGS */ \
693 0x100ff, /* GENERAL_REGS */ \
694 0x0100, 0x0200, /* FP_TOP_REG, FP_SECOND_REG */ \
695 0xff00, /* FLOAT_REGS */ \
696 0x1ffff }
697
698 /* The same information, inverted:
699 Return the class number of the smallest class containing
700 reg number REGNO. This could be a conditional expression
701 or could index an array. */
702
703 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
704
705 /* When defined, the compiler allows registers explicitly used in the
706 rtl to be used as spill registers but prevents the compiler from
707 extending the lifetime of these registers. */
708
709 #define SMALL_REGISTER_CLASSES
710
711 #define QI_REG_P(X) \
712 (REG_P (X) && REGNO (X) < 4)
713 #define NON_QI_REG_P(X) \
714 (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER)
715
716 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
717 #define FP_REGNO_P(n) ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG)
718
719 #define STACK_REG_P(xop) (REG_P (xop) && \
720 REGNO (xop) >= FIRST_STACK_REG && \
721 REGNO (xop) <= LAST_STACK_REG)
722
723 #define NON_STACK_REG_P(xop) (REG_P (xop) && ! STACK_REG_P (xop))
724
725 #define STACK_TOP_P(xop) (REG_P (xop) && REGNO (xop) == FIRST_STACK_REG)
726
727 /* Try to maintain the accuracy of the death notes for regs satisfying the
728 following. Important for stack like regs, to know when to pop. */
729
730 /* #define PRESERVE_DEATH_INFO_REGNO_P(x) FP_REGNO_P(x) */
731
732 /* 1 if register REGNO can magically overlap other regs.
733 Note that nonzero values work only in very special circumstances. */
734
735 /* #define OVERLAPPING_REGNO_P(REGNO) FP_REGNO_P (REGNO) */
736
737 /* The class value for index registers, and the one for base regs. */
738
739 #define INDEX_REG_CLASS INDEX_REGS
740 #define BASE_REG_CLASS GENERAL_REGS
741
742 /* Get reg_class from a letter such as appears in the machine description. */
743
744 #define REG_CLASS_FROM_LETTER(C) \
745 ((C) == 'r' ? GENERAL_REGS : \
746 (C) == 'q' ? Q_REGS : \
747 (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
748 ? FLOAT_REGS \
749 : NO_REGS) : \
750 (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
751 ? FP_TOP_REG \
752 : NO_REGS) : \
753 (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
754 ? FP_SECOND_REG \
755 : NO_REGS) : \
756 (C) == 'a' ? AREG : \
757 (C) == 'b' ? BREG : \
758 (C) == 'c' ? CREG : \
759 (C) == 'd' ? DREG : \
760 (C) == 'A' ? AD_REGS : \
761 (C) == 'D' ? DIREG : \
762 (C) == 'S' ? SIREG : NO_REGS)
763
764 /* The letters I, J, K, L and M in a register constraint string
765 can be used to stand for particular ranges of immediate operands.
766 This macro defines what the ranges are.
767 C is the letter, and VALUE is a constant value.
768 Return 1 if VALUE is in the range specified by C.
769
770 I is for non-DImode shifts.
771 J is for DImode shifts.
772 K and L are for an `andsi' optimization.
773 M is for shifts that can be executed by the "lea" opcode.
774 */
775
776 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
777 ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31 : \
778 (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 : \
779 (C) == 'K' ? (VALUE) == 0xff : \
780 (C) == 'L' ? (VALUE) == 0xffff : \
781 (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3 : \
782 (C) == 'N' ? (VALUE) >= 0 && (VALUE) <= 255 :\
783 (C) == 'O' ? (VALUE) >= 0 && (VALUE) <= 32 : \
784 0)
785
786 /* Similar, but for floating constants, and defining letters G and H.
787 Here VALUE is the CONST_DOUBLE rtx itself. We allow constants even if
788 TARGET_387 isn't set, because the stack register converter may need to
789 load 0.0 into the function value register. */
790
791 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
792 ((C) == 'G' ? standard_80387_constant_p (VALUE) : 0)
793
794 /* Place additional restrictions on the register class to use when it
795 is necessary to be able to hold a value of mode MODE in a reload
796 register for which class CLASS would ordinarily be used. */
797
798 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
799 ((MODE) == QImode && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS) \
800 ? Q_REGS : (CLASS))
801
802 /* Given an rtx X being reloaded into a reg required to be
803 in class CLASS, return the class of reg to actually use.
804 In general this is just CLASS; but on some machines
805 in some cases it is preferable to use a more restrictive class.
806 On the 80386 series, we prevent floating constants from being
807 reloaded into floating registers (since no move-insn can do that)
808 and we ensure that QImodes aren't reloaded into the esi or edi reg. */
809
810 /* Put float CONST_DOUBLE in the constant pool instead of fp regs.
811 QImode must go into class Q_REGS.
812 Narrow ALL_REGS to GENERAL_REGS. This supports allowing movsf and
813 movdf to do mem-to-mem moves through integer regs. */
814
815 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
816 (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode ? NO_REGS \
817 : GET_MODE (X) == QImode && ! reg_class_subset_p (CLASS, Q_REGS) ? Q_REGS \
818 : ((CLASS) == ALL_REGS \
819 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) ? GENERAL_REGS \
820 : (CLASS))
821
822 /* If we are copying between general and FP registers, we need a memory
823 location. */
824
825 #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
826 ((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \
827 || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2)))
828
829 /* Return the maximum number of consecutive registers
830 needed to represent mode MODE in a register of class CLASS. */
831 /* On the 80386, this is the size of MODE in words,
832 except in the FP regs, where a single reg is always enough. */
833 #define CLASS_MAX_NREGS(CLASS, MODE) \
834 (FLOAT_CLASS_P (CLASS) ? 1 : \
835 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
836
837 /* A C expression whose value is nonzero if pseudos that have been
838 assigned to registers of class CLASS would likely be spilled
839 because registers of CLASS are needed for spill registers.
840
841 The default value of this macro returns 1 if CLASS has exactly one
842 register and zero otherwise. On most machines, this default
843 should be used. Only define this macro to some other expression
844 if pseudo allocated by `local-alloc.c' end up in memory because
845 their hard registers were needed for spill registers. If this
846 macro returns nonzero for those classes, those pseudos will only
847 be allocated by `global.c', which knows how to reallocate the
848 pseudo to another register. If there would not be another
849 register available for reallocation, you should not change the
850 definition of this macro since the only effect of such a
851 definition would be to slow down register allocation. */
852
853 #define CLASS_LIKELY_SPILLED_P(CLASS) \
854 (((CLASS) == AREG) \
855 || ((CLASS) == DREG) \
856 || ((CLASS) == CREG) \
857 || ((CLASS) == BREG) \
858 || ((CLASS) == AD_REGS) \
859 || ((CLASS) == SIREG) \
860 || ((CLASS) == DIREG))
861
862 \f
863 /* Stack layout; function entry, exit and calling. */
864
865 /* Define this if pushing a word on the stack
866 makes the stack pointer a smaller address. */
867 #define STACK_GROWS_DOWNWARD
868
869 /* Define this if the nominal address of the stack frame
870 is at the high-address end of the local variables;
871 that is, each additional local variable allocated
872 goes at a more negative offset in the frame. */
873 #define FRAME_GROWS_DOWNWARD
874
875 /* Offset within stack frame to start allocating local variables at.
876 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
877 first local allocated. Otherwise, it is the offset to the BEGINNING
878 of the first local allocated. */
879 #define STARTING_FRAME_OFFSET 0
880
881 /* If we generate an insn to push BYTES bytes,
882 this says how many the stack pointer really advances by.
883 On 386 pushw decrements by exactly 2 no matter what the position was.
884 On the 386 there is no pushb; we use pushw instead, and this
885 has the effect of rounding up to 2. */
886
887 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & (-2))
888
889 /* Offset of first parameter from the argument pointer register value. */
890 #define FIRST_PARM_OFFSET(FNDECL) 0
891
892 /* Value is the number of bytes of arguments automatically
893 popped when returning from a subroutine call.
894 FUNDECL is the declaration node of the function (as a tree),
895 FUNTYPE is the data type of the function (as a tree),
896 or for a library call it is an identifier node for the subroutine name.
897 SIZE is the number of bytes of arguments passed on the stack.
898
899 On the 80386, the RTD insn may be used to pop them if the number
900 of args is fixed, but if the number is variable then the caller
901 must pop them all. RTD can't be used for library calls now
902 because the library is compiled with the Unix compiler.
903 Use of RTD is a selectable option, since it is incompatible with
904 standard Unix calling sequences. If the option is not selected,
905 the caller must always pop the args.
906
907 The attribute stdcall is equivalent to RTD on a per module basis. */
908
909 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
910 (i386_return_pops_args (FUNDECL, FUNTYPE, SIZE))
911
912 /* Define how to find the value returned by a function.
913 VALTYPE is the data type of the value (as a tree).
914 If the precise function being called is known, FUNC is its FUNCTION_DECL;
915 otherwise, FUNC is 0. */
916 #define FUNCTION_VALUE(VALTYPE, FUNC) \
917 gen_rtx (REG, TYPE_MODE (VALTYPE), \
918 VALUE_REGNO (TYPE_MODE (VALTYPE)))
919
920 /* Define how to find the value returned by a library function
921 assuming the value has mode MODE. */
922
923 #define LIBCALL_VALUE(MODE) \
924 gen_rtx (REG, MODE, VALUE_REGNO (MODE))
925
926 /* Define the size of the result block used for communication between
927 untyped_call and untyped_return. The block contains a DImode value
928 followed by the block used by fnsave and frstor. */
929
930 #define APPLY_RESULT_SIZE (8+108)
931
932 /* 1 if N is a possible register number for function argument passing. */
933 #define FUNCTION_ARG_REGNO_P(N) ((N) >= 0 && (N) < REGPARM_MAX)
934
935 /* Define a data type for recording info about an argument list
936 during the scan of that argument list. This data type should
937 hold all necessary information about the function itself
938 and about the args processed so far, enough to enable macros
939 such as FUNCTION_ARG to determine where the next arg should go. */
940
941 typedef struct i386_args {
942 int words; /* # words passed so far */
943 int nregs; /* # registers available for passing */
944 int regno; /* next available register number */
945 } CUMULATIVE_ARGS;
946
947 /* Initialize a variable CUM of type CUMULATIVE_ARGS
948 for a call to a function whose data type is FNTYPE.
949 For a library call, FNTYPE is 0. */
950
951 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
952 (init_cumulative_args (&CUM, FNTYPE, LIBNAME))
953
954 /* Update the data in CUM to advance over an argument
955 of mode MODE and data type TYPE.
956 (TYPE is null for libcalls where that information may not be available.) */
957
958 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
959 (function_arg_advance (&CUM, MODE, TYPE, NAMED))
960
961 /* Define where to put the arguments to a function.
962 Value is zero to push the argument on the stack,
963 or a hard register in which to store the argument.
964
965 MODE is the argument's machine mode.
966 TYPE is the data type of the argument (as a tree).
967 This is null for libcalls where that information may
968 not be available.
969 CUM is a variable of type CUMULATIVE_ARGS which gives info about
970 the preceding args and about the function being called.
971 NAMED is nonzero if this argument is a named parameter
972 (otherwise it is an extra parameter matching an ellipsis). */
973
974 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
975 (function_arg (&CUM, MODE, TYPE, NAMED))
976
977 /* For an arg passed partly in registers and partly in memory,
978 this is the number of registers used.
979 For args passed entirely in registers or entirely in memory, zero. */
980
981 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
982 (function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED))
983
984 /* This macro is invoked just before the start of a function.
985 It is used here to output code for -fpic that will load the
986 return address into %ebx. */
987
988 #undef ASM_OUTPUT_FUNCTION_PREFIX
989 #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, FNNAME) \
990 asm_output_function_prefix (FILE, FNNAME)
991
992 /* This macro generates the assembly code for function entry.
993 FILE is a stdio stream to output the code to.
994 SIZE is an int: how many units of temporary storage to allocate.
995 Refer to the array `regs_ever_live' to determine which registers
996 to save; `regs_ever_live[I]' is nonzero if register number I
997 is ever used in the function. This macro is responsible for
998 knowing which registers should not be saved even if used. */
999
1000 #define FUNCTION_PROLOGUE(FILE, SIZE) \
1001 function_prologue (FILE, SIZE)
1002
1003 /* Output assembler code to FILE to increment profiler label # LABELNO
1004 for profiling a function entry. */
1005
1006 #define FUNCTION_PROFILER(FILE, LABELNO) \
1007 { \
1008 if (flag_pic) \
1009 { \
1010 fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \
1011 LPREFIX, (LABELNO)); \
1012 fprintf (FILE, "\tcall *_mcount@GOT(%%ebx)\n"); \
1013 } \
1014 else \
1015 { \
1016 fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
1017 fprintf (FILE, "\tcall _mcount\n"); \
1018 } \
1019 }
1020
1021
1022 /* There are three profiling modes for basic blocks available.
1023 The modes are selected at compile time by using the options
1024 -a or -ax of the gnu compiler.
1025 The variable `profile_block_flag' will be set according to the
1026 selected option.
1027
1028 profile_block_flag == 0, no option used:
1029
1030 No profiling done.
1031
1032 profile_block_flag == 1, -a option used.
1033
1034 Count frequency of execution of every basic block.
1035
1036 profile_block_flag == 2, -ax option used.
1037
1038 Generate code to allow several different profiling modes at run time.
1039 Available modes are:
1040 Produce a trace of all basic blocks.
1041 Count frequency of jump instructions executed.
1042 In every mode it is possible to start profiling upon entering
1043 certain functions and to disable profiling of some other functions.
1044
1045 The result of basic-block profiling will be written to a file `bb.out'.
1046 If the -ax option is used parameters for the profiling will be read
1047 from file `bb.in'.
1048
1049 */
1050
1051 /* The following macro shall output assembler code to FILE
1052 to initialize basic-block profiling.
1053
1054 If profile_block_flag == 2
1055
1056 Output code to call the subroutine `__bb_init_trace_func'
1057 and pass two parameters to it. The first parameter is
1058 the address of a block allocated in the object module.
1059 The second parameter is the number of the first basic block
1060 of the function.
1061
1062 The name of the block is a local symbol made with this statement:
1063
1064 ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
1065
1066 Of course, since you are writing the definition of
1067 `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
1068 can take a short cut in the definition of this macro and use the
1069 name that you know will result.
1070
1071 The number of the first basic block of the function is
1072 passed to the macro in BLOCK_OR_LABEL.
1073
1074 If described in a virtual assembler language the code to be
1075 output looks like:
1076
1077 parameter1 <- LPBX0
1078 parameter2 <- BLOCK_OR_LABEL
1079 call __bb_init_trace_func
1080
1081 else if profile_block_flag != 0
1082
1083 Output code to call the subroutine `__bb_init_func'
1084 and pass one single parameter to it, which is the same
1085 as the first parameter to `__bb_init_trace_func'.
1086
1087 The first word of this parameter is a flag which will be nonzero if
1088 the object module has already been initialized. So test this word
1089 first, and do not call `__bb_init_func' if the flag is nonzero.
1090 Note: When profile_block_flag == 2 the test need not be done
1091 but `__bb_init_trace_func' *must* be called.
1092
1093 BLOCK_OR_LABEL may be used to generate a label number as a
1094 branch destination in case `__bb_init_func' will not be called.
1095
1096 If described in a virtual assembler language the code to be
1097 output looks like:
1098
1099 cmp (LPBX0),0
1100 jne local_label
1101 parameter1 <- LPBX0
1102 call __bb_init_func
1103 local_label:
1104
1105 */
1106
1107 #undef FUNCTION_BLOCK_PROFILER
1108 #define FUNCTION_BLOCK_PROFILER(FILE, BLOCK_OR_LABEL) \
1109 do \
1110 { \
1111 static int num_func = 0; \
1112 rtx xops[8]; \
1113 char block_table[80], false_label[80]; \
1114 \
1115 ASM_GENERATE_INTERNAL_LABEL (block_table, "LPBX", 0); \
1116 \
1117 xops[1] = gen_rtx (SYMBOL_REF, VOIDmode, block_table); \
1118 xops[5] = stack_pointer_rtx; \
1119 xops[7] = gen_rtx (REG, Pmode, 0); /* eax */ \
1120 \
1121 CONSTANT_POOL_ADDRESS_P (xops[1]) = TRUE; \
1122 \
1123 switch (profile_block_flag) \
1124 { \
1125 \
1126 case 2: \
1127 \
1128 xops[2] = GEN_INT ((BLOCK_OR_LABEL)); \
1129 xops[3] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, "__bb_init_trace_func")); \
1130 xops[6] = GEN_INT (8); \
1131 \
1132 output_asm_insn (AS1(push%L2,%2), xops); \
1133 if (!flag_pic) \
1134 output_asm_insn (AS1(push%L1,%1), xops); \
1135 else \
1136 { \
1137 output_asm_insn (AS2 (lea%L7,%a1,%7), xops); \
1138 output_asm_insn (AS1 (push%L7,%7), xops); \
1139 } \
1140 \
1141 output_asm_insn (AS1(call,%P3), xops); \
1142 output_asm_insn (AS2(add%L0,%6,%5), xops); \
1143 \
1144 break; \
1145 \
1146 default: \
1147 \
1148 ASM_GENERATE_INTERNAL_LABEL (false_label, "LPBZ", num_func); \
1149 \
1150 xops[0] = const0_rtx; \
1151 xops[2] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, false_label)); \
1152 xops[3] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, "__bb_init_func")); \
1153 xops[4] = gen_rtx (MEM, Pmode, xops[1]); \
1154 xops[6] = GEN_INT (4); \
1155 \
1156 CONSTANT_POOL_ADDRESS_P (xops[2]) = TRUE; \
1157 \
1158 output_asm_insn (AS2(cmp%L4,%0,%4), xops); \
1159 output_asm_insn (AS1(jne,%2), xops); \
1160 \
1161 if (!flag_pic) \
1162 output_asm_insn (AS1(push%L1,%1), xops); \
1163 else \
1164 { \
1165 output_asm_insn (AS2 (lea%L7,%a1,%7), xops); \
1166 output_asm_insn (AS1 (push%L7,%7), xops); \
1167 } \
1168 \
1169 output_asm_insn (AS1(call,%P3), xops); \
1170 output_asm_insn (AS2(add%L0,%6,%5), xops); \
1171 ASM_OUTPUT_INTERNAL_LABEL (FILE, "LPBZ", num_func); \
1172 num_func++; \
1173 \
1174 break; \
1175 \
1176 } \
1177 } \
1178 while (0)
1179
1180 /* The following macro shall output assembler code to FILE
1181 to increment a counter associated with basic block number BLOCKNO.
1182
1183 If profile_block_flag == 2
1184
1185 Output code to initialize the global structure `__bb' and
1186 call the function `__bb_trace_func' which will increment the
1187 counter.
1188
1189 `__bb' consists of two words. In the first word the number
1190 of the basic block has to be stored. In the second word
1191 the address of a block allocated in the object module
1192 has to be stored.
1193
1194 The basic block number is given by BLOCKNO.
1195
1196 The address of the block is given by the label created with
1197
1198 ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
1199
1200 by FUNCTION_BLOCK_PROFILER.
1201
1202 Of course, since you are writing the definition of
1203 `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
1204 can take a short cut in the definition of this macro and use the
1205 name that you know will result.
1206
1207 If described in a virtual assembler language the code to be
1208 output looks like:
1209
1210 move BLOCKNO -> (__bb)
1211 move LPBX0 -> (__bb+4)
1212 call __bb_trace_func
1213
1214 Note that function `__bb_trace_func' must not change the
1215 machine state, especially the flag register. To grant
1216 this, you must output code to save and restore registers
1217 either in this macro or in the macros MACHINE_STATE_SAVE
1218 and MACHINE_STATE_RESTORE. The last two macros will be
1219 used in the function `__bb_trace_func', so you must make
1220 sure that the function prologue does not change any
1221 register prior to saving it with MACHINE_STATE_SAVE.
1222
1223 else if profile_block_flag != 0
1224
1225 Output code to increment the counter directly.
1226 Basic blocks are numbered separately from zero within each
1227 compiled object module. The count associated with block number
1228 BLOCKNO is at index BLOCKNO in an array of words; the name of
1229 this array is a local symbol made with this statement:
1230
1231 ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 2);
1232
1233 Of course, since you are writing the definition of
1234 `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
1235 can take a short cut in the definition of this macro and use the
1236 name that you know will result.
1237
1238 If described in a virtual assembler language the code to be
1239 output looks like:
1240
1241 inc (LPBX2+4*BLOCKNO)
1242
1243 */
1244
1245 #define BLOCK_PROFILER(FILE, BLOCKNO) \
1246 do \
1247 { \
1248 rtx xops[8], cnt_rtx; \
1249 char counts[80]; \
1250 char *block_table = counts; \
1251 \
1252 switch (profile_block_flag) \
1253 { \
1254 \
1255 case 2: \
1256 \
1257 ASM_GENERATE_INTERNAL_LABEL (block_table, "LPBX", 0); \
1258 \
1259 xops[1] = gen_rtx (SYMBOL_REF, VOIDmode, block_table); \
1260 xops[2] = GEN_INT ((BLOCKNO)); \
1261 xops[3] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, "__bb_trace_func")); \
1262 xops[4] = gen_rtx (SYMBOL_REF, VOIDmode, "__bb"); \
1263 xops[5] = plus_constant (xops[4], 4); \
1264 xops[0] = gen_rtx (MEM, SImode, xops[4]); \
1265 xops[6] = gen_rtx (MEM, SImode, xops[5]); \
1266 \
1267 CONSTANT_POOL_ADDRESS_P (xops[1]) = TRUE; \
1268 \
1269 fprintf(FILE, "\tpushf\n"); \
1270 output_asm_insn (AS2(mov%L0,%2,%0), xops); \
1271 if (flag_pic) \
1272 { \
1273 xops[7] = gen_rtx (REG, Pmode, 0); /* eax */ \
1274 output_asm_insn (AS1(push%L7,%7), xops); \
1275 output_asm_insn (AS2(lea%L7,%a1,%7), xops); \
1276 output_asm_insn (AS2(mov%L6,%7,%6), xops); \
1277 output_asm_insn (AS1(pop%L7,%7), xops); \
1278 } \
1279 else \
1280 output_asm_insn (AS2(mov%L6,%1,%6), xops); \
1281 output_asm_insn (AS1(call,%P3), xops); \
1282 fprintf(FILE, "\tpopf\n"); \
1283 \
1284 break; \
1285 \
1286 default: \
1287 \
1288 ASM_GENERATE_INTERNAL_LABEL (counts, "LPBX", 2); \
1289 cnt_rtx = gen_rtx (SYMBOL_REF, VOIDmode, counts); \
1290 SYMBOL_REF_FLAG (cnt_rtx) = TRUE; \
1291 \
1292 if (BLOCKNO) \
1293 cnt_rtx = plus_constant (cnt_rtx, (BLOCKNO)*4); \
1294 \
1295 if (flag_pic) \
1296 cnt_rtx = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, cnt_rtx); \
1297 \
1298 xops[0] = gen_rtx (MEM, SImode, cnt_rtx); \
1299 output_asm_insn (AS1(inc%L0,%0), xops); \
1300 \
1301 break; \
1302 \
1303 } \
1304 } \
1305 while (0)
1306
1307 /* The following macro shall output assembler code to FILE
1308 to indicate a return from function during basic-block profiling.
1309
1310 If profiling_block_flag == 2:
1311
1312 Output assembler code to call function `__bb_trace_ret'.
1313
1314 Note that function `__bb_trace_ret' must not change the
1315 machine state, especially the flag register. To grant
1316 this, you must output code to save and restore registers
1317 either in this macro or in the macros MACHINE_STATE_SAVE_RET
1318 and MACHINE_STATE_RESTORE_RET. The last two macros will be
1319 used in the function `__bb_trace_ret', so you must make
1320 sure that the function prologue does not change any
1321 register prior to saving it with MACHINE_STATE_SAVE_RET.
1322
1323 else if profiling_block_flag != 0:
1324
1325 The macro will not be used, so it need not distinguish
1326 these cases.
1327 */
1328
1329 #define FUNCTION_BLOCK_PROFILER_EXIT(FILE) \
1330 do \
1331 { \
1332 rtx xops[1]; \
1333 \
1334 xops[0] = gen_rtx (MEM, Pmode, gen_rtx (SYMBOL_REF, VOIDmode, "__bb_trace_ret")); \
1335 \
1336 output_asm_insn (AS1(call,%P0), xops); \
1337 \
1338 } \
1339 while (0)
1340
1341 /* The function `__bb_trace_func' is called in every basic block
1342 and is not allowed to change the machine state. Saving (restoring)
1343 the state can either be done in the BLOCK_PROFILER macro,
1344 before calling function (rsp. after returning from function)
1345 `__bb_trace_func', or it can be done inside the function by
1346 defining the macros:
1347
1348 MACHINE_STATE_SAVE(ID)
1349 MACHINE_STATE_RESTORE(ID)
1350
1351 In the latter case care must be taken, that the prologue code
1352 of function `__bb_trace_func' does not already change the
1353 state prior to saving it with MACHINE_STATE_SAVE.
1354
1355 The parameter `ID' is a string identifying a unique macro use.
1356
1357 On the i386 the initialization code at the begin of
1358 function `__bb_trace_func' contains a `sub' instruction
1359 therefore we handle save and restore of the flag register
1360 in the BLOCK_PROFILER macro. */
1361
1362 #define MACHINE_STATE_SAVE(ID) \
1363 asm (" pushl %eax"); \
1364 asm (" pushl %ecx"); \
1365 asm (" pushl %edx"); \
1366 asm (" pushl %esi");
1367
1368 #define MACHINE_STATE_RESTORE(ID) \
1369 asm (" popl %esi"); \
1370 asm (" popl %edx"); \
1371 asm (" popl %ecx"); \
1372 asm (" popl %eax");
1373
1374 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1375 the stack pointer does not matter. The value is tested only in
1376 functions that have frame pointers.
1377 No definition is equivalent to always zero. */
1378 /* Note on the 386 it might be more efficient not to define this since
1379 we have to restore it ourselves from the frame pointer, in order to
1380 use pop */
1381
1382 #define EXIT_IGNORE_STACK 1
1383
1384 /* This macro generates the assembly code for function exit,
1385 on machines that need it. If FUNCTION_EPILOGUE is not defined
1386 then individual return instructions are generated for each
1387 return statement. Args are same as for FUNCTION_PROLOGUE.
1388
1389 The function epilogue should not depend on the current stack pointer!
1390 It should use the frame pointer only. This is mandatory because
1391 of alloca; we also take advantage of it to omit stack adjustments
1392 before returning.
1393
1394 If the last non-note insn in the function is a BARRIER, then there
1395 is no need to emit a function prologue, because control does not fall
1396 off the end. This happens if the function ends in an "exit" call, or
1397 if a `return' insn is emitted directly into the function. */
1398
1399 #if 0
1400 #define FUNCTION_BEGIN_EPILOGUE(FILE) \
1401 do { \
1402 rtx last = get_last_insn (); \
1403 if (last && GET_CODE (last) == NOTE) \
1404 last = prev_nonnote_insn (last); \
1405 /* if (! last || GET_CODE (last) != BARRIER) \
1406 function_epilogue (FILE, SIZE);*/ \
1407 } while (0)
1408 #endif
1409
1410 #define FUNCTION_EPILOGUE(FILE, SIZE) \
1411 function_epilogue (FILE, SIZE)
1412
1413 /* Output assembler code for a block containing the constant parts
1414 of a trampoline, leaving space for the variable parts. */
1415
1416 /* On the 386, the trampoline contains three instructions:
1417 mov #STATIC,ecx
1418 mov #FUNCTION,eax
1419 jmp @eax */
1420 #define TRAMPOLINE_TEMPLATE(FILE) \
1421 { \
1422 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb9)); \
1423 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
1424 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
1425 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb8)); \
1426 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
1427 ASM_OUTPUT_SHORT (FILE, const0_rtx); \
1428 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xff)); \
1429 ASM_OUTPUT_CHAR (FILE, GEN_INT (0xe0)); \
1430 }
1431
1432 /* Length in units of the trampoline for entering a nested function. */
1433
1434 #define TRAMPOLINE_SIZE 12
1435
1436 /* Emit RTL insns to initialize the variable parts of a trampoline.
1437 FNADDR is an RTX for the address of the function's pure code.
1438 CXT is an RTX for the static chain value for the function. */
1439
1440 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1441 { \
1442 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 1)), CXT); \
1443 emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 6)), FNADDR); \
1444 }
1445 \f
1446 /* Definitions for register eliminations.
1447
1448 This is an array of structures. Each structure initializes one pair
1449 of eliminable registers. The "from" register number is given first,
1450 followed by "to". Eliminations of the same "from" register are listed
1451 in order of preference.
1452
1453 We have two registers that can be eliminated on the i386. First, the
1454 frame pointer register can often be eliminated in favor of the stack
1455 pointer register. Secondly, the argument pointer register can always be
1456 eliminated; it is replaced with either the stack or frame pointer. */
1457
1458 #define ELIMINABLE_REGS \
1459 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1460 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
1461 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
1462
1463 /* Given FROM and TO register numbers, say whether this elimination is allowed.
1464 Frame pointer elimination is automatically handled.
1465
1466 For the i386, if frame pointer elimination is being done, we would like to
1467 convert ap into sp, not fp.
1468
1469 All other eliminations are valid. */
1470
1471 #define CAN_ELIMINATE(FROM, TO) \
1472 ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \
1473 ? ! frame_pointer_needed \
1474 : 1)
1475
1476 /* Define the offset between two registers, one to be eliminated, and the other
1477 its replacement, at the start of a routine. */
1478
1479 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1480 { \
1481 if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \
1482 (OFFSET) = 8; /* Skip saved PC and previous frame pointer */ \
1483 else \
1484 { \
1485 int regno; \
1486 int offset = 0; \
1487 \
1488 for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
1489 if ((regs_ever_live[regno] && ! call_used_regs[regno]) \
1490 || (current_function_uses_pic_offset_table \
1491 && regno == PIC_OFFSET_TABLE_REGNUM)) \
1492 offset += 4; \
1493 \
1494 (OFFSET) = offset + get_frame_size (); \
1495 \
1496 if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \
1497 (OFFSET) += 4; /* Skip saved PC */ \
1498 } \
1499 }
1500 \f
1501 /* Addressing modes, and classification of registers for them. */
1502
1503 /* #define HAVE_POST_INCREMENT */
1504 /* #define HAVE_POST_DECREMENT */
1505
1506 /* #define HAVE_PRE_DECREMENT */
1507 /* #define HAVE_PRE_INCREMENT */
1508
1509 /* Macros to check register numbers against specific register classes. */
1510
1511 /* These assume that REGNO is a hard or pseudo reg number.
1512 They give nonzero only if REGNO is a hard reg of the suitable class
1513 or a pseudo reg currently allocated to a suitable hard reg.
1514 Since they use reg_renumber, they are safe only once reg_renumber
1515 has been allocated, which happens in local-alloc.c. */
1516
1517 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1518 ((REGNO) < STACK_POINTER_REGNUM \
1519 || (unsigned) reg_renumber[REGNO] < STACK_POINTER_REGNUM)
1520
1521 #define REGNO_OK_FOR_BASE_P(REGNO) \
1522 ((REGNO) <= STACK_POINTER_REGNUM \
1523 || (REGNO) == ARG_POINTER_REGNUM \
1524 || (unsigned) reg_renumber[REGNO] <= STACK_POINTER_REGNUM)
1525
1526 #define REGNO_OK_FOR_SIREG_P(REGNO) ((REGNO) == 4 || reg_renumber[REGNO] == 4)
1527 #define REGNO_OK_FOR_DIREG_P(REGNO) ((REGNO) == 5 || reg_renumber[REGNO] == 5)
1528
1529 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1530 and check its validity for a certain class.
1531 We have two alternate definitions for each of them.
1532 The usual definition accepts all pseudo regs; the other rejects
1533 them unless they have been allocated suitable hard regs.
1534 The symbol REG_OK_STRICT causes the latter definition to be used.
1535
1536 Most source files want to accept pseudo regs in the hope that
1537 they will get allocated to the class that the insn wants them to be in.
1538 Source files for reload pass need to be strict.
1539 After reload, it makes no difference, since pseudo regs have
1540 been eliminated by then. */
1541
1542
1543 /* Non strict versions, pseudos are ok */
1544 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) \
1545 (REGNO (X) < STACK_POINTER_REGNUM \
1546 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1547
1548 #define REG_OK_FOR_BASE_NONSTRICT_P(X) \
1549 (REGNO (X) <= STACK_POINTER_REGNUM \
1550 || REGNO (X) == ARG_POINTER_REGNUM \
1551 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1552
1553 #define REG_OK_FOR_STRREG_NONSTRICT_P(X) \
1554 (REGNO (X) == 4 || REGNO (X) == 5 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1555
1556 /* Strict versions, hard registers only */
1557 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1558 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1559 #define REG_OK_FOR_STRREG_STRICT_P(X) \
1560 (REGNO_OK_FOR_DIREG_P (REGNO (X)) || REGNO_OK_FOR_SIREG_P (REGNO (X)))
1561
1562 #ifndef REG_OK_STRICT
1563 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P(X)
1564 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P(X)
1565 #define REG_OK_FOR_STRREG_P(X) REG_OK_FOR_STRREG_NONSTRICT_P(X)
1566
1567 #else
1568 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P(X)
1569 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P(X)
1570 #define REG_OK_FOR_STRREG_P(X) REG_OK_FOR_STRREG_STRICT_P(X)
1571 #endif
1572
1573 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1574 that is a valid memory address for an instruction.
1575 The MODE argument is the machine mode for the MEM expression
1576 that wants to use this address.
1577
1578 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
1579 except for CONSTANT_ADDRESS_P which is usually machine-independent.
1580
1581 See legitimize_pic_address in i386.c for details as to what
1582 constitutes a legitimate address when -fpic is used. */
1583
1584 #define MAX_REGS_PER_ADDRESS 2
1585
1586 #define CONSTANT_ADDRESS_P(X) \
1587 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
1588 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
1589 || GET_CODE (X) == HIGH)
1590
1591 /* Nonzero if the constant value X is a legitimate general operand.
1592 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1593
1594 #define LEGITIMATE_CONSTANT_P(X) 1
1595
1596 #ifdef REG_OK_STRICT
1597 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1598 { \
1599 if (legitimate_address_p (MODE, X, 1)) \
1600 goto ADDR; \
1601 }
1602
1603 #else
1604 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1605 { \
1606 if (legitimate_address_p (MODE, X, 0)) \
1607 goto ADDR; \
1608 }
1609
1610 #endif
1611
1612 /* Try machine-dependent ways of modifying an illegitimate address
1613 to be legitimate. If we find one, return the new, valid address.
1614 This macro is used in only one place: `memory_address' in explow.c.
1615
1616 OLDX is the address as it was before break_out_memory_refs was called.
1617 In some cases it is useful to look at this to decide what needs to be done.
1618
1619 MODE and WIN are passed so that this macro can use
1620 GO_IF_LEGITIMATE_ADDRESS.
1621
1622 It is always safe for this macro to do nothing. It exists to recognize
1623 opportunities to optimize the output.
1624
1625 For the 80386, we handle X+REG by loading X into a register R and
1626 using R+REG. R will go in a general reg and indexing will be used.
1627 However, if REG is a broken-out memory address or multiplication,
1628 nothing needs to be done because REG can certainly go in a general reg.
1629
1630 When -fpic is used, special handling is needed for symbolic references.
1631 See comments by legitimize_pic_address in i386.c for details. */
1632
1633 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
1634 { \
1635 rtx orig_x = (X); \
1636 (X) = legitimize_address (X, OLDX, MODE); \
1637 if (memory_address_p (MODE, X)) \
1638 goto WIN; \
1639 }
1640
1641 #define REWRITE_ADDRESS(x) rewrite_address(x)
1642
1643 /* Nonzero if the constant value X is a legitimate general operand
1644 when generating PIC code. It is given that flag_pic is on and
1645 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1646
1647 #define LEGITIMATE_PIC_OPERAND_P(X) \
1648 (! SYMBOLIC_CONST (X) \
1649 || (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X)))
1650
1651 #define SYMBOLIC_CONST(X) \
1652 (GET_CODE (X) == SYMBOL_REF \
1653 || GET_CODE (X) == LABEL_REF \
1654 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
1655
1656 /* Go to LABEL if ADDR (a legitimate address expression)
1657 has an effect that depends on the machine mode it is used for.
1658 On the 80386, only postdecrement and postincrement address depend thus
1659 (the amount of decrement or increment being the length of the operand). */
1660 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1661 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL
1662 \f
1663 /* Define this macro if references to a symbol must be treated
1664 differently depending on something about the variable or
1665 function named by the symbol (such as what section it is in).
1666
1667 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
1668 so that we may access it directly in the GOT. */
1669
1670 #define ENCODE_SECTION_INFO(DECL) \
1671 do \
1672 { \
1673 if (flag_pic) \
1674 { \
1675 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
1676 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
1677 \
1678 if (TARGET_DEBUG_ADDR \
1679 && TREE_CODE_CLASS (TREE_CODE (DECL)) == 'd') \
1680 { \
1681 fprintf (stderr, "Encode %s, public = %s\n", \
1682 IDENTIFIER_POINTER (DECL_NAME (DECL)), \
1683 TREE_PUBLIC (DECL)); \
1684 } \
1685 \
1686 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
1687 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
1688 || ! TREE_PUBLIC (DECL)); \
1689 } \
1690 } \
1691 while (0)
1692
1693 /* Initialize data used by insn expanders. This is called from
1694 init_emit, once for each function, before code is generated.
1695 For 386, clear stack slot assignments remembered from previous
1696 functions. */
1697
1698 #define INIT_EXPANDERS clear_386_stack_locals ()
1699
1700 /* The `FINALIZE_PIC' macro serves as a hook to emit these special
1701 codes once the function is being compiled into assembly code, but
1702 not before. (It is not done before, because in the case of
1703 compiling an inline function, it would lead to multiple PIC
1704 prologues being included in functions which used inline functions
1705 and were compiled to assembly language.) */
1706
1707 #define FINALIZE_PIC \
1708 do \
1709 { \
1710 extern int current_function_uses_pic_offset_table; \
1711 \
1712 current_function_uses_pic_offset_table |= profile_flag | profile_block_flag; \
1713 } \
1714 while (0)
1715
1716 \f
1717 /* If defined, a C expression whose value is nonzero if IDENTIFIER
1718 with arguments ARGS is a valid machine specific attribute for DECL.
1719 The attributes in ATTRIBUTES have previously been assigned to DECL. */
1720
1721 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, NAME, ARGS) \
1722 (i386_valid_decl_attribute_p (DECL, ATTRIBUTES, NAME, ARGS))
1723
1724 /* If defined, a C expression whose value is nonzero if IDENTIFIER
1725 with arguments ARGS is a valid machine specific attribute for TYPE.
1726 The attributes in ATTRIBUTES have previously been assigned to TYPE. */
1727
1728 #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, NAME, ARGS) \
1729 (i386_valid_type_attribute_p (TYPE, ATTRIBUTES, NAME, ARGS))
1730
1731 /* If defined, a C expression whose value is zero if the attributes on
1732 TYPE1 and TYPE2 are incompatible, one if they are compatible, and
1733 two if they are nearly compatible (which causes a warning to be
1734 generated). */
1735
1736 #define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \
1737 (i386_comp_type_attributes (TYPE1, TYPE2))
1738
1739 /* If defined, a C statement that assigns default attributes to newly
1740 defined TYPE. */
1741
1742 /* #define SET_DEFAULT_TYPE_ATTRIBUTES (TYPE) */
1743
1744 /* Max number of args passed in registers. If this is more than 3, we will
1745 have problems with ebx (register #4), since it is a caller save register and
1746 is also used as the pic register in ELF. So for now, don't allow more than
1747 3 registers to be passed in registers. */
1748
1749 #define REGPARM_MAX 3
1750
1751 \f
1752 /* Specify the machine mode that this machine uses
1753 for the index in the tablejump instruction. */
1754 #define CASE_VECTOR_MODE Pmode
1755
1756 /* Define this if the tablejump instruction expects the table
1757 to contain offsets from the address of the table.
1758 Do not define this if the table should contain absolute addresses. */
1759 /* #define CASE_VECTOR_PC_RELATIVE */
1760
1761 /* Specify the tree operation to be used to convert reals to integers.
1762 This should be changed to take advantage of fist --wfs ??
1763 */
1764 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
1765
1766 /* This is the kind of divide that is easiest to do in the general case. */
1767 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
1768
1769 /* Define this as 1 if `char' should by default be signed; else as 0. */
1770 #define DEFAULT_SIGNED_CHAR 1
1771
1772 /* Max number of bytes we can move from memory to memory
1773 in one reasonably fast instruction. */
1774 #define MOVE_MAX 4
1775
1776 /* The number of scalar move insns which should be generated instead
1777 of a string move insn or a library call. Increasing the value
1778 will always make code faster, but eventually incurs high cost in
1779 increased code size.
1780
1781 If you don't define this, a reasonable default is used.
1782
1783 Make this large on i386, since the block move is very inefficient with small
1784 blocks, and the hard register needs of the block move require much reload
1785 work. */
1786
1787 #define MOVE_RATIO 5
1788
1789 /* Define if shifts truncate the shift count
1790 which implies one can omit a sign-extension or zero-extension
1791 of a shift count. */
1792 /* On i386, shifts do truncate the count. But bit opcodes don't. */
1793
1794 /* #define SHIFT_COUNT_TRUNCATED */
1795
1796 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1797 is done just by pretending it is already truncated. */
1798 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1799
1800 /* We assume that the store-condition-codes instructions store 0 for false
1801 and some other value for true. This is the value stored for true. */
1802
1803 #define STORE_FLAG_VALUE 1
1804
1805 /* When a prototype says `char' or `short', really pass an `int'.
1806 (The 386 can't easily push less than an int.) */
1807
1808 #define PROMOTE_PROTOTYPES
1809
1810 /* Specify the machine mode that pointers have.
1811 After generation of rtl, the compiler makes no further distinction
1812 between pointers and any other objects of this machine mode. */
1813 #define Pmode SImode
1814
1815 /* A function address in a call instruction
1816 is a byte address (for indexing purposes)
1817 so give the MEM rtx a byte's mode. */
1818 #define FUNCTION_MODE QImode
1819 \f
1820 /* A part of a C `switch' statement that describes the relative costs
1821 of constant RTL expressions. It must contain `case' labels for
1822 expression codes `const_int', `const', `symbol_ref', `label_ref'
1823 and `const_double'. Each case must ultimately reach a `return'
1824 statement to return the relative cost of the use of that kind of
1825 constant value in an expression. The cost may depend on the
1826 precise value of the constant, which is available for examination
1827 in X, and the rtx code of the expression in which it is contained,
1828 found in OUTER_CODE.
1829
1830 CODE is the expression code--redundant, since it can be obtained
1831 with `GET_CODE (X)'. */
1832
1833 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
1834 case CONST_INT: \
1835 case CONST: \
1836 case LABEL_REF: \
1837 case SYMBOL_REF: \
1838 return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 1; \
1839 \
1840 case CONST_DOUBLE: \
1841 { \
1842 int code; \
1843 if (GET_MODE (RTX) == VOIDmode) \
1844 return 2; \
1845 \
1846 code = standard_80387_constant_p (RTX); \
1847 return code == 1 ? 0 : \
1848 code == 2 ? 1 : \
1849 2; \
1850 }
1851
1852 /* Delete the definition here when TOPLEVEL_COSTS_N_INSNS gets added to cse.c */
1853 #define TOPLEVEL_COSTS_N_INSNS(N) {total = COSTS_N_INSNS (N); break;}
1854
1855 /* Like `CONST_COSTS' but applies to nonconstant RTL expressions.
1856 This can be used, for example, to indicate how costly a multiply
1857 instruction is. In writing this macro, you can use the construct
1858 `COSTS_N_INSNS (N)' to specify a cost equal to N fast
1859 instructions. OUTER_CODE is the code of the expression in which X
1860 is contained.
1861
1862 This macro is optional; do not define it if the default cost
1863 assumptions are adequate for the target machine. */
1864
1865 #define RTX_COSTS(X,CODE,OUTER_CODE) \
1866 case ASHIFT: \
1867 if (GET_CODE (XEXP (X, 1)) == CONST_INT \
1868 && GET_MODE (XEXP (X, 0)) == SImode) \
1869 { \
1870 HOST_WIDE_INT value = INTVAL (XEXP (X, 1)); \
1871 \
1872 if (value == 1) \
1873 return COSTS_N_INSNS (ix86_cost->add) \
1874 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1875 \
1876 if (value == 2 || value == 3) \
1877 return COSTS_N_INSNS (ix86_cost->lea) \
1878 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1879 } \
1880 /* fall through */ \
1881 \
1882 case ROTATE: \
1883 case ASHIFTRT: \
1884 case LSHIFTRT: \
1885 case ROTATERT: \
1886 if (GET_MODE (XEXP (X, 0)) == DImode) \
1887 { \
1888 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
1889 if (INTVAL (XEXP (X, 1)) > 32) \
1890 return COSTS_N_INSNS(ix86_cost->shift_const + 2); \
1891 else \
1892 return COSTS_N_INSNS(ix86_cost->shift_const * 2); \
1893 return ((GET_CODE (XEXP (X, 1)) == AND \
1894 ? COSTS_N_INSNS(ix86_cost->shift_var * 2) \
1895 : COSTS_N_INSNS(ix86_cost->shift_var * 6 + 2)) \
1896 + rtx_cost(XEXP (X, 0), OUTER_CODE)); \
1897 } \
1898 return COSTS_N_INSNS (GET_CODE (XEXP (X, 1)) == CONST_INT \
1899 ? ix86_cost->shift_const \
1900 : ix86_cost->shift_var) \
1901 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1902 \
1903 case MULT: \
1904 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
1905 { \
1906 unsigned HOST_WIDE_INT value = INTVAL (XEXP (X, 1)); \
1907 int nbits = 0; \
1908 \
1909 if (value == 2) \
1910 return COSTS_N_INSNS (ix86_cost->add) \
1911 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1912 if (value == 4 || value == 8) \
1913 return COSTS_N_INSNS (ix86_cost->lea) \
1914 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1915 \
1916 while (value != 0) \
1917 { \
1918 nbits++; \
1919 value >>= 1; \
1920 } \
1921 \
1922 if (nbits == 1) \
1923 return COSTS_N_INSNS (ix86_cost->shift_const) \
1924 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1925 \
1926 return COSTS_N_INSNS (ix86_cost->mult_init \
1927 + nbits * ix86_cost->mult_bit) \
1928 + rtx_cost(XEXP (X, 0), OUTER_CODE); \
1929 } \
1930 \
1931 else /* This is arbitrary */ \
1932 TOPLEVEL_COSTS_N_INSNS (ix86_cost->mult_init \
1933 + 7 * ix86_cost->mult_bit); \
1934 \
1935 case DIV: \
1936 case UDIV: \
1937 case MOD: \
1938 case UMOD: \
1939 TOPLEVEL_COSTS_N_INSNS (ix86_cost->divide); \
1940 \
1941 case PLUS: \
1942 if (GET_CODE (XEXP (X, 0)) == REG \
1943 && GET_MODE (XEXP (X, 0)) == SImode \
1944 && GET_CODE (XEXP (X, 1)) == PLUS) \
1945 return COSTS_N_INSNS (ix86_cost->lea); \
1946 \
1947 /* fall through */ \
1948 case AND: \
1949 case IOR: \
1950 case XOR: \
1951 case MINUS: \
1952 if (GET_MODE (X) == DImode) \
1953 return COSTS_N_INSNS (ix86_cost->add) * 2 \
1954 + (rtx_cost (XEXP (X, 0), OUTER_CODE) \
1955 << (GET_MODE (XEXP (X, 0)) != DImode)) \
1956 + (rtx_cost (XEXP (X, 1), OUTER_CODE) \
1957 << (GET_MODE (XEXP (X, 1)) != DImode)); \
1958 case NEG: \
1959 case NOT: \
1960 if (GET_MODE (X) == DImode) \
1961 TOPLEVEL_COSTS_N_INSNS (ix86_cost->add * 2) \
1962 TOPLEVEL_COSTS_N_INSNS (ix86_cost->add)
1963
1964
1965 /* An expression giving the cost of an addressing mode that contains
1966 ADDRESS. If not defined, the cost is computed from the ADDRESS
1967 expression and the `CONST_COSTS' values.
1968
1969 For most CISC machines, the default cost is a good approximation
1970 of the true cost of the addressing mode. However, on RISC
1971 machines, all instructions normally have the same length and
1972 execution time. Hence all addresses will have equal costs.
1973
1974 In cases where more than one form of an address is known, the form
1975 with the lowest cost will be used. If multiple forms have the
1976 same, lowest, cost, the one that is the most complex will be used.
1977
1978 For example, suppose an address that is equal to the sum of a
1979 register and a constant is used twice in the same basic block.
1980 When this macro is not defined, the address will be computed in a
1981 register and memory references will be indirect through that
1982 register. On machines where the cost of the addressing mode
1983 containing the sum is no higher than that of a simple indirect
1984 reference, this will produce an additional instruction and
1985 possibly require an additional register. Proper specification of
1986 this macro eliminates this overhead for such machines.
1987
1988 Similar use of this macro is made in strength reduction of loops.
1989
1990 ADDRESS need not be valid as an address. In such a case, the cost
1991 is not relevant and can be any value; invalid addresses need not be
1992 assigned a different cost.
1993
1994 On machines where an address involving more than one register is as
1995 cheap as an address computation involving only one register,
1996 defining `ADDRESS_COST' to reflect this can cause two registers to
1997 be live over a region of code where only one would have been if
1998 `ADDRESS_COST' were not defined in that manner. This effect should
1999 be considered in the definition of this macro. Equivalent costs
2000 should probably only be given to addresses with different numbers
2001 of registers on machines with lots of registers.
2002
2003 This macro will normally either not be defined or be defined as a
2004 constant.
2005
2006 For i386, it is better to use a complex address than let gcc copy
2007 the address into a reg and make a new pseudo. But not if the address
2008 requires to two regs - that would mean more pseudos with longer
2009 lifetimes. */
2010
2011 #define ADDRESS_COST(RTX) \
2012 ((CONSTANT_P (RTX) \
2013 || (GET_CODE (RTX) == PLUS && CONSTANT_P (XEXP (RTX, 1)) \
2014 && REG_P (XEXP (RTX, 0)))) ? 0 \
2015 : REG_P (RTX) ? 1 \
2016 : 2)
2017
2018 /* A C expression for the cost of moving data of mode M between a
2019 register and memory. A value of 2 is the default; this cost is
2020 relative to those in `REGISTER_MOVE_COST'.
2021
2022 If moving between registers and memory is more expensive than
2023 between two registers, you should define this macro to express the
2024 relative cost.
2025
2026 On the i386, copying between floating-point and fixed-point
2027 registers is expensive. */
2028
2029 #define REGISTER_MOVE_COST(CLASS1, CLASS2) \
2030 (((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \
2031 || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) ? 10 \
2032 : 2)
2033
2034
2035 /* A C expression for the cost of moving data of mode M between a
2036 register and memory. A value of 2 is the default; this cost is
2037 relative to those in `REGISTER_MOVE_COST'.
2038
2039 If moving between registers and memory is more expensive than
2040 between two registers, you should define this macro to express the
2041 relative cost. */
2042
2043 /* #define MEMORY_MOVE_COST(M) 2 */
2044
2045 /* A C expression for the cost of a branch instruction. A value of 1
2046 is the default; other values are interpreted relative to that. */
2047
2048 #define BRANCH_COST i386_branch_cost
2049
2050 /* Define this macro as a C expression which is nonzero if accessing
2051 less than a word of memory (i.e. a `char' or a `short') is no
2052 faster than accessing a word of memory, i.e., if such access
2053 require more than one instruction or if there is no difference in
2054 cost between byte and (aligned) word loads.
2055
2056 When this macro is not defined, the compiler will access a field by
2057 finding the smallest containing object; when it is defined, a
2058 fullword load will be used if alignment permits. Unless bytes
2059 accesses are faster than word accesses, using word accesses is
2060 preferable since it may eliminate subsequent memory access if
2061 subsequent accesses occur to other fields in the same word of the
2062 structure, but to different bytes. */
2063
2064 #define SLOW_BYTE_ACCESS 0
2065
2066 /* Nonzero if access to memory by shorts is slow and undesirable. */
2067 #define SLOW_SHORT_ACCESS 0
2068
2069 /* Define this macro if zero-extension (of a `char' or `short' to an
2070 `int') can be done faster if the destination is a register that is
2071 known to be zero.
2072
2073 If you define this macro, you must have instruction patterns that
2074 recognize RTL structures like this:
2075
2076 (set (strict_low_part (subreg:QI (reg:SI ...) 0)) ...)
2077
2078 and likewise for `HImode'. */
2079
2080 /* #define SLOW_ZERO_EXTEND */
2081
2082 /* Define this macro to be the value 1 if unaligned accesses have a
2083 cost many times greater than aligned accesses, for example if they
2084 are emulated in a trap handler.
2085
2086 When this macro is non-zero, the compiler will act as if
2087 `STRICT_ALIGNMENT' were non-zero when generating code for block
2088 moves. This can cause significantly more instructions to be
2089 produced. Therefore, do not set this macro non-zero if unaligned
2090 accesses only add a cycle or two to the time for a memory access.
2091
2092 If the value of this macro is always zero, it need not be defined. */
2093
2094 /* #define SLOW_UNALIGNED_ACCESS 0 */
2095
2096 /* Define this macro to inhibit strength reduction of memory
2097 addresses. (On some machines, such strength reduction seems to do
2098 harm rather than good.) */
2099
2100 /* #define DONT_REDUCE_ADDR */
2101
2102 /* Define this macro if it is as good or better to call a constant
2103 function address than to call an address kept in a register.
2104
2105 Desirable on the 386 because a CALL with a constant address is
2106 faster than one with a register address. */
2107
2108 #define NO_FUNCTION_CSE
2109
2110 /* Define this macro if it is as good or better for a function to call
2111 itself with an explicit address than to call an address kept in a
2112 register. */
2113
2114 #define NO_RECURSIVE_FUNCTION_CSE
2115
2116 /* A C statement (sans semicolon) to update the integer variable COST
2117 based on the relationship between INSN that is dependent on
2118 DEP_INSN through the dependence LINK. The default is to make no
2119 adjustment to COST. This can be used for example to specify to
2120 the scheduler that an output- or anti-dependence does not incur
2121 the same cost as a data-dependence. */
2122
2123 #define ADJUST_COST(insn,link,dep_insn,cost) \
2124 { \
2125 rtx next_inst; \
2126 if (GET_CODE (dep_insn) == CALL_INSN) \
2127 (cost) = 0; \
2128 \
2129 else if (GET_CODE (dep_insn) == INSN \
2130 && GET_CODE (PATTERN (dep_insn)) == SET \
2131 && GET_CODE (SET_DEST (PATTERN (dep_insn))) == REG \
2132 && GET_CODE (insn) == INSN \
2133 && GET_CODE (PATTERN (insn)) == SET \
2134 && !reg_overlap_mentioned_p (SET_DEST (PATTERN (dep_insn)), \
2135 SET_SRC (PATTERN (insn)))) \
2136 { \
2137 (cost) = 0; \
2138 } \
2139 \
2140 else if (GET_CODE (insn) == JUMP_INSN) \
2141 { \
2142 (cost) = 0; \
2143 } \
2144 \
2145 if (TARGET_PENTIUM) \
2146 { \
2147 if (cost !=0 && is_fp_insn (insn) && is_fp_insn (dep_insn) \
2148 && !is_fp_dest (dep_insn)) \
2149 { \
2150 (cost) = 0; \
2151 } \
2152 \
2153 if (agi_dependent (insn, dep_insn)) \
2154 { \
2155 (cost) = 3; \
2156 } \
2157 else if (GET_CODE (insn) == INSN \
2158 && GET_CODE (PATTERN (insn)) == SET \
2159 && SET_DEST (PATTERN (insn)) == cc0_rtx \
2160 && (next_inst = next_nonnote_insn (insn)) \
2161 && GET_CODE (next_inst) == JUMP_INSN) \
2162 { /* compare probably paired with jump */ \
2163 (cost) = 0; \
2164 } \
2165 } \
2166 else \
2167 if (!is_fp_dest (dep_insn)) \
2168 { \
2169 if(!agi_dependent (insn, dep_insn)) \
2170 (cost) = 0; \
2171 else if (TARGET_486) \
2172 (cost) = 2; \
2173 } \
2174 else \
2175 if (is_fp_store (insn) && is_fp_insn (dep_insn) \
2176 && NEXT_INSN (insn) && NEXT_INSN (NEXT_INSN (insn)) \
2177 && NEXT_INSN (NEXT_INSN (NEXT_INSN (insn))) \
2178 && (GET_CODE (NEXT_INSN (insn)) == INSN) \
2179 && (GET_CODE (NEXT_INSN (NEXT_INSN (insn))) == JUMP_INSN) \
2180 && (GET_CODE (NEXT_INSN (NEXT_INSN (NEXT_INSN (insn)))) == NOTE) \
2181 && (NOTE_LINE_NUMBER (NEXT_INSN (NEXT_INSN (NEXT_INSN (insn)))) \
2182 == NOTE_INSN_LOOP_END)) \
2183 { \
2184 (cost) = 3; \
2185 } \
2186 }
2187
2188
2189 #define ADJUST_BLOCKAGE(last_insn,insn,blockage) \
2190 { \
2191 if (is_fp_store (last_insn) && is_fp_insn (insn) \
2192 && NEXT_INSN (last_insn) && NEXT_INSN (NEXT_INSN (last_insn)) \
2193 && NEXT_INSN (NEXT_INSN (NEXT_INSN (last_insn))) \
2194 && (GET_CODE (NEXT_INSN (last_insn)) == INSN) \
2195 && (GET_CODE (NEXT_INSN (NEXT_INSN (last_insn))) == JUMP_INSN) \
2196 && (GET_CODE (NEXT_INSN (NEXT_INSN (NEXT_INSN (last_insn)))) == NOTE) \
2197 && (NOTE_LINE_NUMBER (NEXT_INSN (NEXT_INSN (NEXT_INSN (last_insn)))) \
2198 == NOTE_INSN_LOOP_END)) \
2199 { \
2200 (blockage) = 3; \
2201 } \
2202 }
2203
2204 \f
2205 /* Add any extra modes needed to represent the condition code.
2206
2207 For the i386, we need separate modes when floating-point equality
2208 comparisons are being done. */
2209
2210 #define EXTRA_CC_MODES CCFPEQmode
2211
2212 /* Define the names for the modes specified above. */
2213 #define EXTRA_CC_NAMES "CCFPEQ"
2214
2215 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
2216 return the mode to be used for the comparison.
2217
2218 For floating-point equality comparisons, CCFPEQmode should be used.
2219 VOIDmode should be used in all other cases. */
2220
2221 #define SELECT_CC_MODE(OP,X,Y) \
2222 (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
2223 && ((OP) == EQ || (OP) == NE) ? CCFPEQmode : VOIDmode)
2224
2225 /* Define the information needed to generate branch and scc insns. This is
2226 stored from the compare operation. Note that we can't use "rtx" here
2227 since it hasn't been defined! */
2228
2229 extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)();
2230
2231 /* Tell final.c how to eliminate redundant test instructions. */
2232
2233 /* Here we define machine-dependent flags and fields in cc_status
2234 (see `conditions.h'). */
2235
2236 /* Set if the cc value was actually from the 80387 and
2237 we are testing eax directly (i.e. no sahf) */
2238 #define CC_TEST_AX 020000
2239
2240 /* Set if the cc value is actually in the 80387, so a floating point
2241 conditional branch must be output. */
2242 #define CC_IN_80387 04000
2243
2244 /* Set if the CC value was stored in a nonstandard way, so that
2245 the state of equality is indicated by zero in the carry bit. */
2246 #define CC_Z_IN_NOT_C 010000
2247
2248 /* Set if the CC value was actually from the 80387 and loaded directly
2249 into the eflags instead of via eax/sahf. */
2250 #define CC_FCOMI 040000
2251
2252 /* Store in cc_status the expressions
2253 that the condition codes will describe
2254 after execution of an instruction whose pattern is EXP.
2255 Do not alter them if the instruction would not alter the cc's. */
2256
2257 #define NOTICE_UPDATE_CC(EXP, INSN) \
2258 notice_update_cc((EXP))
2259
2260 /* Output a signed jump insn. Use template NORMAL ordinarily, or
2261 FLOAT following a floating point comparison.
2262 Use NO_OV following an arithmetic insn that set the cc's
2263 before a test insn that was deleted.
2264 NO_OV may be zero, meaning final should reinsert the test insn
2265 because the jump cannot be handled properly without it. */
2266
2267 #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \
2268 { \
2269 if (cc_prev_status.flags & CC_IN_80387) \
2270 return FLOAT; \
2271 if (cc_prev_status.flags & CC_NO_OVERFLOW) \
2272 return NO_OV; \
2273 return NORMAL; \
2274 }
2275 \f
2276 /* Control the assembler format that we output, to the extent
2277 this does not vary between assemblers. */
2278
2279 /* How to refer to registers in assembler output.
2280 This sequence is indexed by compiler's hard-register-number (see above). */
2281
2282 /* In order to refer to the first 8 regs as 32 bit regs prefix an "e"
2283 For non floating point regs, the following are the HImode names.
2284
2285 For float regs, the stack top is sometimes referred to as "%st(0)"
2286 instead of just "%st". PRINT_REG handles this with the "y" code. */
2287
2288 #define HI_REGISTER_NAMES \
2289 {"ax","dx","cx","bx","si","di","bp","sp", \
2290 "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","" }
2291
2292 #define REGISTER_NAMES HI_REGISTER_NAMES
2293
2294 /* Table of additional register names to use in user input. */
2295
2296 #define ADDITIONAL_REGISTER_NAMES \
2297 { "eax", 0, "edx", 1, "ecx", 2, "ebx", 3, \
2298 "esi", 4, "edi", 5, "ebp", 6, "esp", 7, \
2299 "al", 0, "dl", 1, "cl", 2, "bl", 3, \
2300 "ah", 0, "dh", 1, "ch", 2, "bh", 3 }
2301
2302 /* Note we are omitting these since currently I don't know how
2303 to get gcc to use these, since they want the same but different
2304 number as al, and ax.
2305 */
2306
2307 /* note the last four are not really qi_registers, but
2308 the md will have to never output movb into one of them
2309 only a movw . There is no movb into the last four regs */
2310
2311 #define QI_REGISTER_NAMES \
2312 {"al", "dl", "cl", "bl", "si", "di", "bp", "sp",}
2313
2314 /* These parallel the array above, and can be used to access bits 8:15
2315 of regs 0 through 3. */
2316
2317 #define QI_HIGH_REGISTER_NAMES \
2318 {"ah", "dh", "ch", "bh", }
2319
2320 /* How to renumber registers for dbx and gdb. */
2321
2322 /* {0,2,1,3,6,7,4,5,12,13,14,15,16,17} */
2323 #define DBX_REGISTER_NUMBER(n) \
2324 ((n) == 0 ? 0 : \
2325 (n) == 1 ? 2 : \
2326 (n) == 2 ? 1 : \
2327 (n) == 3 ? 3 : \
2328 (n) == 4 ? 6 : \
2329 (n) == 5 ? 7 : \
2330 (n) == 6 ? 4 : \
2331 (n) == 7 ? 5 : \
2332 (n) + 4)
2333
2334 /* This is how to output the definition of a user-level label named NAME,
2335 such as the label on a static function or variable NAME. */
2336
2337 #define ASM_OUTPUT_LABEL(FILE,NAME) \
2338 (assemble_name (FILE, NAME), fputs (":\n", FILE))
2339
2340 /* This is how to output an assembler line defining a `double' constant. */
2341
2342 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
2343 do { long l[2]; \
2344 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
2345 if (sizeof (int) == sizeof (long)) \
2346 fprintf (FILE, "%s 0x%x,0x%x\n", ASM_LONG, l[0], l[1]); \
2347 else \
2348 fprintf (FILE, "%s 0x%lx,0x%lx\n", ASM_LONG, l[0], l[1]); \
2349 } while (0)
2350
2351 /* This is how to output a `long double' extended real constant. */
2352
2353 #undef ASM_OUTPUT_LONG_DOUBLE
2354 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
2355 do { long l[3]; \
2356 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
2357 if (sizeof (int) == sizeof (long)) \
2358 fprintf (FILE, "%s 0x%x,0x%x,0x%x\n", ASM_LONG, l[0], l[1], l[2]); \
2359 else \
2360 fprintf (FILE, "%s 0x%lx,0x%lx,0x%lx\n", ASM_LONG, l[0], l[1], l[2]); \
2361 } while (0)
2362
2363 /* This is how to output an assembler line defining a `float' constant. */
2364
2365 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
2366 do { long l; \
2367 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
2368 if (sizeof (int) == sizeof (long)) \
2369 fprintf ((FILE), "%s 0x%x\n", ASM_LONG, l); \
2370 else \
2371 fprintf ((FILE), "%s 0x%lx\n", ASM_LONG, l); \
2372 } while (0)
2373
2374 /* Store in OUTPUT a string (made with alloca) containing
2375 an assembler-name for a local static variable named NAME.
2376 LABELNO is an integer which is different for each call. */
2377
2378 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2379 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2380 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2381
2382
2383
2384 /* This is how to output an assembler line defining an `int' constant. */
2385
2386 #define ASM_OUTPUT_INT(FILE,VALUE) \
2387 ( fprintf (FILE, "%s ", ASM_LONG), \
2388 output_addr_const (FILE,(VALUE)), \
2389 putc('\n',FILE))
2390
2391 /* Likewise for `char' and `short' constants. */
2392 /* is this supposed to do align too?? */
2393
2394 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
2395 ( fprintf (FILE, "%s ", ASM_SHORT), \
2396 output_addr_const (FILE,(VALUE)), \
2397 putc('\n',FILE))
2398
2399 /*
2400 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
2401 ( fprintf (FILE, "%s ", ASM_BYTE_OP), \
2402 output_addr_const (FILE,(VALUE)), \
2403 fputs (",", FILE), \
2404 output_addr_const (FILE,(VALUE)), \
2405 fputs (" >> 8\n",FILE))
2406 */
2407
2408
2409 #define ASM_OUTPUT_CHAR(FILE,VALUE) \
2410 ( fprintf (FILE, "%s ", ASM_BYTE_OP), \
2411 output_addr_const (FILE, (VALUE)), \
2412 putc ('\n', FILE))
2413
2414 /* This is how to output an assembler line for a numeric constant byte. */
2415
2416 #define ASM_OUTPUT_BYTE(FILE,VALUE) \
2417 fprintf ((FILE), "%s 0x%x\n", ASM_BYTE_OP, (VALUE))
2418
2419 /* This is how to output an insn to push a register on the stack.
2420 It need not be very fast code. */
2421
2422 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
2423 fprintf (FILE, "\tpushl e%s\n", reg_names[REGNO])
2424
2425 /* This is how to output an insn to pop a register from the stack.
2426 It need not be very fast code. */
2427
2428 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
2429 fprintf (FILE, "\tpopl e%s\n", reg_names[REGNO])
2430
2431 /* This is how to output an element of a case-vector that is absolute.
2432 */
2433
2434 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
2435 fprintf (FILE, "%s %s%d\n", ASM_LONG, LPREFIX, VALUE)
2436
2437 /* This is how to output an element of a case-vector that is relative.
2438 We don't use these on the 386 yet, because the ATT assembler can't do
2439 forward reference the differences.
2440 */
2441
2442 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
2443 fprintf (FILE, "\t.word %s%d-%s%d\n",LPREFIX, VALUE,LPREFIX, REL)
2444
2445 /* Define the parentheses used to group arithmetic operations
2446 in assembler code. */
2447
2448 #define ASM_OPEN_PAREN ""
2449 #define ASM_CLOSE_PAREN ""
2450
2451 /* Define results of standard character escape sequences. */
2452 #define TARGET_BELL 007
2453 #define TARGET_BS 010
2454 #define TARGET_TAB 011
2455 #define TARGET_NEWLINE 012
2456 #define TARGET_VT 013
2457 #define TARGET_FF 014
2458 #define TARGET_CR 015
2459 \f
2460 /* Print operand X (an rtx) in assembler syntax to file FILE.
2461 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2462 The CODE z takes the size of operand from the following digit, and
2463 outputs b,w,or l respectively.
2464
2465 On the 80386, we use several such letters:
2466 f -- float insn (print a CONST_DOUBLE as a float rather than in hex).
2467 L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
2468 R -- print the prefix for register names.
2469 z -- print the opcode suffix for the size of the current operand.
2470 * -- print a star (in certain assembler syntax)
2471 w -- print the operand as if it's a "word" (HImode) even if it isn't.
2472 b -- print the operand as if it's a byte (QImode) even if it isn't.
2473 c -- don't print special prefixes before constant operands. */
2474
2475 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
2476 ((CODE) == '*')
2477
2478 /* Print the name of a register based on its machine mode and number.
2479 If CODE is 'w', pretend the mode is HImode.
2480 If CODE is 'b', pretend the mode is QImode.
2481 If CODE is 'k', pretend the mode is SImode.
2482 If CODE is 'h', pretend the reg is the `high' byte register.
2483 If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op. */
2484
2485 extern char *hi_reg_name[];
2486 extern char *qi_reg_name[];
2487 extern char *qi_high_reg_name[];
2488
2489 #define PRINT_REG(X, CODE, FILE) \
2490 do { if (REGNO (X) == ARG_POINTER_REGNUM) \
2491 abort (); \
2492 fprintf (FILE, "%s", RP); \
2493 switch ((CODE == 'w' ? 2 \
2494 : CODE == 'b' ? 1 \
2495 : CODE == 'k' ? 4 \
2496 : CODE == 'y' ? 3 \
2497 : CODE == 'h' ? 0 \
2498 : GET_MODE_SIZE (GET_MODE (X)))) \
2499 { \
2500 case 3: \
2501 if (STACK_TOP_P (X)) \
2502 { \
2503 fputs ("st(0)", FILE); \
2504 break; \
2505 } \
2506 case 4: \
2507 case 8: \
2508 case 12: \
2509 if (! FP_REG_P (X)) fputs ("e", FILE); \
2510 case 2: \
2511 fputs (hi_reg_name[REGNO (X)], FILE); \
2512 break; \
2513 case 1: \
2514 fputs (qi_reg_name[REGNO (X)], FILE); \
2515 break; \
2516 case 0: \
2517 fputs (qi_high_reg_name[REGNO (X)], FILE); \
2518 break; \
2519 } \
2520 } while (0)
2521
2522 #define PRINT_OPERAND(FILE, X, CODE) \
2523 print_operand (FILE, X, CODE)
2524
2525 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
2526 print_operand_address (FILE, ADDR)
2527
2528 /* Print the name of a register for based on its machine mode and number.
2529 This macro is used to print debugging output.
2530 This macro is different from PRINT_REG in that it may be used in
2531 programs that are not linked with aux-output.o. */
2532
2533 #define DEBUG_PRINT_REG(X, CODE, FILE) \
2534 do { static char *hi_name[] = HI_REGISTER_NAMES; \
2535 static char *qi_name[] = QI_REGISTER_NAMES; \
2536 fprintf (FILE, "%d %s", REGNO (X), RP); \
2537 if (REGNO (X) == ARG_POINTER_REGNUM) \
2538 { fputs ("argp", FILE); break; } \
2539 if (STACK_TOP_P (X)) \
2540 { fputs ("st(0)", FILE); break; } \
2541 if (FP_REG_P (X)) \
2542 { fputs (hi_name[REGNO(X)], FILE); break; } \
2543 switch (GET_MODE_SIZE (GET_MODE (X))) \
2544 { \
2545 default: \
2546 fputs ("e", FILE); \
2547 case 2: \
2548 fputs (hi_name[REGNO (X)], FILE); \
2549 break; \
2550 case 1: \
2551 fputs (qi_name[REGNO (X)], FILE); \
2552 break; \
2553 } \
2554 } while (0)
2555
2556 /* Output the prefix for an immediate operand, or for an offset operand. */
2557 #define PRINT_IMMED_PREFIX(FILE) fputs (IP, (FILE))
2558 #define PRINT_OFFSET_PREFIX(FILE) fputs (IP, (FILE))
2559
2560 /* Routines in libgcc that return floats must return them in an fp reg,
2561 just as other functions do which return such values.
2562 These macros make that happen. */
2563
2564 #define FLOAT_VALUE_TYPE float
2565 #define INTIFY(FLOATVAL) FLOATVAL
2566
2567 /* Nonzero if INSN magically clobbers register REGNO. */
2568
2569 /* #define INSN_CLOBBERS_REGNO_P(INSN, REGNO) \
2570 (FP_REGNO_P (REGNO) \
2571 && (GET_CODE (INSN) == JUMP_INSN || GET_CODE (INSN) == BARRIER))
2572 */
2573
2574 /* a letter which is not needed by the normal asm syntax, which
2575 we can use for operand syntax in the extended asm */
2576
2577 #define ASM_OPERAND_LETTER '#'
2578 \f
2579 #define RET return ""
2580 #define AT_SP(mode) (gen_rtx (MEM, (mode), stack_pointer_rtx))
2581 \f
2582 /* Helper macros to expand a binary/unary operator if needed */
2583 #define IX86_EXPAND_BINARY_OPERATOR(OP, MODE, OPERANDS) \
2584 do { \
2585 if (!ix86_expand_binary_operator (OP, MODE, OPERANDS)) \
2586 FAIL; \
2587 } while (0)
2588
2589 #define IX86_EXPAND_UNARY_OPERATOR(OP, MODE, OPERANDS) \
2590 do { \
2591 if (!ix86_expand_unary_operator (OP, MODE, OPERANDS,)) \
2592 FAIL; \
2593 } while (0)
2594
2595 \f
2596 /* Functions in i386.c */
2597 extern void override_options ();
2598 extern void order_regs_for_local_alloc ();
2599 extern char *output_strlen_unroll ();
2600 extern int i386_valid_decl_attribute_p ();
2601 extern int i386_valid_type_attribute_p ();
2602 extern int i386_return_pops_args ();
2603 extern int i386_comp_type_attributes ();
2604 extern void init_cumulative_args ();
2605 extern void function_arg_advance ();
2606 extern struct rtx_def *function_arg ();
2607 extern int function_arg_partial_nregs ();
2608 extern char *output_strlen_unroll ();
2609 extern void output_op_from_reg ();
2610 extern void output_to_reg ();
2611 extern char *singlemove_string ();
2612 extern char *output_move_double ();
2613 extern char *output_move_memory ();
2614 extern char *output_move_pushmem ();
2615 extern int standard_80387_constant_p ();
2616 extern char *output_move_const_single ();
2617 extern int symbolic_operand ();
2618 extern int call_insn_operand ();
2619 extern int expander_call_insn_operand ();
2620 extern int symbolic_reference_mentioned_p ();
2621 extern int ix86_expand_binary_operator ();
2622 extern int ix86_binary_operator_ok ();
2623 extern int ix86_expand_unary_operator ();
2624 extern int ix86_unary_operator_ok ();
2625 extern void emit_pic_move ();
2626 extern void function_prologue ();
2627 extern int simple_386_epilogue ();
2628 extern void function_epilogue ();
2629 extern int legitimate_address_p ();
2630 extern struct rtx_def *legitimize_pic_address ();
2631 extern struct rtx_def *legitimize_address ();
2632 extern void print_operand ();
2633 extern void print_operand_address ();
2634 extern void notice_update_cc ();
2635 extern void split_di ();
2636 extern int binary_387_op ();
2637 extern int shift_op ();
2638 extern int VOIDmode_compare_op ();
2639 extern char *output_387_binary_op ();
2640 extern char *output_fix_trunc ();
2641 extern char *output_float_compare ();
2642 extern char *output_fp_cc0_set ();
2643 extern void save_386_machine_status ();
2644 extern void restore_386_machine_status ();
2645 extern void clear_386_stack_locals ();
2646 extern struct rtx_def *assign_386_stack_local ();
2647 extern int is_mul ();
2648 extern int is_div ();
2649 extern int last_to_set_cc ();
2650 extern int doesnt_set_condition_code ();
2651 extern int sets_condition_code ();
2652 extern int str_immediate_operand ();
2653 extern int is_fp_insn ();
2654 extern int is_fp_dest ();
2655 extern int is_fp_store ();
2656 extern int agi_dependent ();
2657 extern int reg_mentioned_in_mem ();
2658
2659 #ifdef NOTYET
2660 extern struct rtx_def *copy_all_rtx ();
2661 extern void rewrite_address ();
2662 #endif
2663
2664 /* Variables in i386.c */
2665 extern char *ix86_cpu_string; /* for -mcpu=<xxx> */
2666 extern char *ix86_arch_string; /* for -march=<xxx> */
2667 extern char *i386_reg_alloc_order; /* register allocation order */
2668 extern char *i386_regparm_string; /* # registers to use to pass args */
2669 extern char *i386_align_loops_string; /* power of two alignment for loops */
2670 extern char *i386_align_jumps_string; /* power of two alignment for non-loop jumps */
2671 extern char *i386_align_funcs_string; /* power of two alignment for functions */
2672 extern char *i386_branch_cost_string; /* values 1-5: see jump.c */
2673 extern int i386_regparm; /* i386_regparm_string as a number */
2674 extern int i386_align_loops; /* power of two alignment for loops */
2675 extern int i386_align_jumps; /* power of two alignment for non-loop jumps */
2676 extern int i386_align_funcs; /* power of two alignment for functions */
2677 extern int i386_branch_cost; /* values 1-5: see jump.c */
2678 extern char *hi_reg_name[]; /* names for 16 bit regs */
2679 extern char *qi_reg_name[]; /* names for 8 bit regs (low) */
2680 extern char *qi_high_reg_name[]; /* names for 8 bit regs (high) */
2681 extern enum reg_class regclass_map[]; /* smalled class containing REGNO */
2682 extern struct rtx_def *i386_compare_op0; /* operand 0 for comparisons */
2683 extern struct rtx_def *i386_compare_op1; /* operand 1 for comparisons */
2684
2685 /* External variables used */
2686 extern int optimize; /* optimization level */
2687 extern int obey_regdecls; /* TRUE if stupid register allocation */
2688
2689 /* External functions used */
2690 extern struct rtx_def *force_operand ();
2691
2692 \f
2693 /*
2694 Local variables:
2695 version-control: t
2696 End:
2697 */
This page took 0.155474 seconds and 5 git commands to generate.