]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/i386.h
i * libgcc1-test.c, libgcc1.c, config/i386/perform.h: Delete file.
[thirdparty/gcc.git] / gcc / config / i386 / i386.h
1 /* Definitions of target machine for GNU compiler for IA-32.
2 Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001 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 RP, IP, LPREFIX, PUT_OP_SIZE, USE_STAR,
34 ADDR_BEG, ADDR_END, PRINT_IREG, PRINT_SCALE, PRINT_B_I_S, and many
35 that start with ASM_ or end in ASM_OP. */
36
37 /* Stubs for half-pic support if not OSF/1 reference platform. */
38
39 #ifndef HALF_PIC_P
40 #define HALF_PIC_P() 0
41 #define HALF_PIC_NUMBER_PTRS 0
42 #define HALF_PIC_NUMBER_REFS 0
43 #define HALF_PIC_ENCODE(DECL)
44 #define HALF_PIC_DECLARE(NAME)
45 #define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it.")
46 #define HALF_PIC_ADDRESS_P(X) 0
47 #define HALF_PIC_PTR(X) X
48 #define HALF_PIC_FINISH(STREAM)
49 #endif
50
51 /* Define the specific costs for a given cpu */
52
53 struct processor_costs {
54 int add; /* cost of an add instruction */
55 int lea; /* cost of a lea instruction */
56 int shift_var; /* variable shift costs */
57 int shift_const; /* constant shift costs */
58 int mult_init; /* cost of starting a multiply */
59 int mult_bit; /* cost of multiply per each bit set */
60 int divide; /* cost of a divide/mod */
61 int large_insn; /* insns larger than this cost more */
62 int move_ratio; /* The threshold of number of scalar
63 memory-to-memory move insns. */
64 int movzbl_load; /* cost of loading using movzbl */
65 int int_load[3]; /* cost of loading integer registers
66 in QImode, HImode and SImode relative
67 to reg-reg move (2). */
68 int int_store[3]; /* cost of storing integer register
69 in QImode, HImode and SImode */
70 int fp_move; /* cost of reg,reg fld/fst */
71 int fp_load[3]; /* cost of loading FP register
72 in SFmode, DFmode and XFmode */
73 int fp_store[3]; /* cost of storing FP register
74 in SFmode, DFmode and XFmode */
75 int mmx_move; /* cost of moving MMX register. */
76 int mmx_load[2]; /* cost of loading MMX register
77 in SImode and DImode */
78 int mmx_store[2]; /* cost of storing MMX register
79 in SImode and DImode */
80 int sse_move; /* cost of moving SSE register. */
81 int sse_load[3]; /* cost of loading SSE register
82 in SImode, DImode and TImode*/
83 int sse_store[3]; /* cost of storing SSE register
84 in SImode, DImode and TImode*/
85 int mmxsse_to_integer; /* cost of moving mmxsse register to
86 integer and vice versa. */
87 };
88
89 extern struct processor_costs *ix86_cost;
90
91 /* Run-time compilation parameters selecting different hardware subsets. */
92
93 extern int target_flags;
94
95 /* Macros used in the machine description to test the flags. */
96
97 /* configure can arrange to make this 2, to force a 486. */
98
99 #ifndef TARGET_CPU_DEFAULT
100 #define TARGET_CPU_DEFAULT 0
101 #endif
102
103 /* Masks for the -m switches */
104 #define MASK_80387 0x00000001 /* Hardware floating point */
105 #define MASK_RTD 0x00000002 /* Use ret that pops args */
106 #define MASK_ALIGN_DOUBLE 0x00000004 /* align doubles to 2 word boundary */
107 #define MASK_SVR3_SHLIB 0x00000008 /* Uninit locals into bss */
108 #define MASK_IEEE_FP 0x00000010 /* IEEE fp comparisons */
109 #define MASK_FLOAT_RETURNS 0x00000020 /* Return float in st(0) */
110 #define MASK_NO_FANCY_MATH_387 0x00000040 /* Disable sin, cos, sqrt */
111 #define MASK_OMIT_LEAF_FRAME_POINTER 0x080 /* omit leaf frame pointers */
112 #define MASK_STACK_PROBE 0x00000100 /* Enable stack probing */
113 #define MASK_NO_ALIGN_STROPS 0x00001000 /* Enable aligning of string ops. */
114 #define MASK_INLINE_ALL_STROPS 0x00002000 /* Inline stringops in all cases */
115 #define MASK_NO_PUSH_ARGS 0x00004000 /* Use push instructions */
116 #define MASK_ACCUMULATE_OUTGOING_ARGS 0x00008000/* Accumulate outgoing args */
117 #define MASK_MMX 0x00010000 /* Support MMX regs/builtins */
118 #define MASK_SSE 0x00020000 /* Support SSE regs/builtins */
119 #define MASK_SSE2 0x00040000 /* Support SSE2 regs/builtins */
120 #define MASK_128BIT_LONG_DOUBLE 0x00080000 /* long double size is 128bit */
121 #define MASK_MIX_SSE_I387 0x00100000 /* Mix SSE and i387 instructions */
122 #define MASK_64BIT 0x00200000 /* Produce 64bit code */
123 #define MASK_NO_RED_ZONE 0x00400000 /* Do not use red zone */
124
125 /* Temporary codegen switches */
126 #define MASK_INTEL_SYNTAX 0x00000200
127 #define MASK_DEBUG_ARG 0x00000400 /* function_arg */
128 #define MASK_DEBUG_ADDR 0x00000800 /* GO_IF_LEGITIMATE_ADDRESS */
129
130 /* Use the floating point instructions */
131 #define TARGET_80387 (target_flags & MASK_80387)
132
133 /* Compile using ret insn that pops args.
134 This will not work unless you use prototypes at least
135 for all functions that can take varying numbers of args. */
136 #define TARGET_RTD (target_flags & MASK_RTD)
137
138 /* Align doubles to a two word boundary. This breaks compatibility with
139 the published ABI's for structures containing doubles, but produces
140 faster code on the pentium. */
141 #define TARGET_ALIGN_DOUBLE (target_flags & MASK_ALIGN_DOUBLE)
142
143 /* Use push instructions to save outgoing args. */
144 #define TARGET_PUSH_ARGS (!(target_flags & MASK_NO_PUSH_ARGS))
145
146 /* Accumulate stack adjustments to prologue/epilogue. */
147 #define TARGET_ACCUMULATE_OUTGOING_ARGS \
148 (target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
149
150 /* Put uninitialized locals into bss, not data.
151 Meaningful only on svr3. */
152 #define TARGET_SVR3_SHLIB (target_flags & MASK_SVR3_SHLIB)
153
154 /* Use IEEE floating point comparisons. These handle correctly the cases
155 where the result of a comparison is unordered. Normally SIGFPE is
156 generated in such cases, in which case this isn't needed. */
157 #define TARGET_IEEE_FP (target_flags & MASK_IEEE_FP)
158
159 /* Functions that return a floating point value may return that value
160 in the 387 FPU or in 386 integer registers. If set, this flag causes
161 the 387 to be used, which is compatible with most calling conventions. */
162 #define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & MASK_FLOAT_RETURNS)
163
164 /* Long double is 128bit instead of 96bit, even when only 80bits are used.
165 This mode wastes cache, but avoid missaligned data accesses and simplifies
166 address calculations. */
167 #define TARGET_128BIT_LONG_DOUBLE (target_flags & MASK_128BIT_LONG_DOUBLE)
168
169 /* Disable generation of FP sin, cos and sqrt operations for 387.
170 This is because FreeBSD lacks these in the math-emulator-code */
171 #define TARGET_NO_FANCY_MATH_387 (target_flags & MASK_NO_FANCY_MATH_387)
172
173 /* Don't create frame pointers for leaf functions */
174 #define TARGET_OMIT_LEAF_FRAME_POINTER \
175 (target_flags & MASK_OMIT_LEAF_FRAME_POINTER)
176
177 /* Debug GO_IF_LEGITIMATE_ADDRESS */
178 #define TARGET_DEBUG_ADDR (target_flags & MASK_DEBUG_ADDR)
179
180 /* Debug FUNCTION_ARG macros */
181 #define TARGET_DEBUG_ARG (target_flags & MASK_DEBUG_ARG)
182
183 /* 64bit Sledgehammer mode */
184 #ifdef TARGET_BI_ARCH
185 #define TARGET_64BIT (target_flags & MASK_64BIT)
186 #else
187 #ifdef TARGET_64BIT_DEFAULT
188 #define TARGET_64BIT 1
189 #else
190 #define TARGET_64BIT 0
191 #endif
192 #endif
193
194 #define TARGET_386 (ix86_cpu == PROCESSOR_I386)
195 #define TARGET_486 (ix86_cpu == PROCESSOR_I486)
196 #define TARGET_PENTIUM (ix86_cpu == PROCESSOR_PENTIUM)
197 #define TARGET_PENTIUMPRO (ix86_cpu == PROCESSOR_PENTIUMPRO)
198 #define TARGET_K6 (ix86_cpu == PROCESSOR_K6)
199 #define TARGET_ATHLON (ix86_cpu == PROCESSOR_ATHLON)
200 #define TARGET_PENTIUM4 (ix86_cpu == PROCESSOR_PENTIUM4)
201
202 #define CPUMASK (1 << ix86_cpu)
203 extern const int x86_use_leave, x86_push_memory, x86_zero_extend_with_and;
204 extern const int x86_use_bit_test, x86_cmove, x86_deep_branch;
205 extern const int x86_unroll_strlen;
206 extern const int x86_double_with_add, x86_partial_reg_stall, x86_movx;
207 extern const int x86_use_loop, x86_use_fiop, x86_use_mov0;
208 extern const int x86_use_cltd, x86_read_modify_write;
209 extern const int x86_read_modify, x86_split_long_moves;
210 extern const int x86_promote_QImode, x86_single_stringop;
211 extern const int x86_himode_math, x86_qimode_math, x86_promote_qi_regs;
212 extern const int x86_promote_hi_regs, x86_integer_DFmode_moves;
213 extern const int x86_add_esp_4, x86_add_esp_8, x86_sub_esp_4, x86_sub_esp_8;
214 extern const int x86_partial_reg_dependency, x86_memory_mismatch_stall;
215
216 #define TARGET_USE_LEAVE (x86_use_leave & CPUMASK)
217 #define TARGET_PUSH_MEMORY (x86_push_memory & CPUMASK)
218 #define TARGET_ZERO_EXTEND_WITH_AND (x86_zero_extend_with_and & CPUMASK)
219 #define TARGET_USE_BIT_TEST (x86_use_bit_test & CPUMASK)
220 #define TARGET_UNROLL_STRLEN (x86_unroll_strlen & CPUMASK)
221 /* For sane SSE instruction set generation we need fcomi instruction. It is
222 safe to enable all CMOVE instructions. */
223 #define TARGET_CMOVE ((x86_cmove & (1 << ix86_arch)) || TARGET_SSE)
224 #define TARGET_DEEP_BRANCH_PREDICTION (x86_deep_branch & CPUMASK)
225 #define TARGET_DOUBLE_WITH_ADD (x86_double_with_add & CPUMASK)
226 #define TARGET_USE_SAHF ((x86_use_sahf & CPUMASK) && !TARGET_64BIT)
227 #define TARGET_MOVX (x86_movx & CPUMASK)
228 #define TARGET_PARTIAL_REG_STALL (x86_partial_reg_stall & CPUMASK)
229 #define TARGET_USE_LOOP (x86_use_loop & CPUMASK)
230 #define TARGET_USE_FIOP (x86_use_fiop & CPUMASK)
231 #define TARGET_USE_MOV0 (x86_use_mov0 & CPUMASK)
232 #define TARGET_USE_CLTD (x86_use_cltd & CPUMASK)
233 #define TARGET_SPLIT_LONG_MOVES (x86_split_long_moves & CPUMASK)
234 #define TARGET_READ_MODIFY_WRITE (x86_read_modify_write & CPUMASK)
235 #define TARGET_READ_MODIFY (x86_read_modify & CPUMASK)
236 #define TARGET_PROMOTE_QImode (x86_promote_QImode & CPUMASK)
237 #define TARGET_SINGLE_STRINGOP (x86_single_stringop & CPUMASK)
238 #define TARGET_QIMODE_MATH (x86_qimode_math & CPUMASK)
239 #define TARGET_HIMODE_MATH (x86_himode_math & CPUMASK)
240 #define TARGET_PROMOTE_QI_REGS (x86_promote_qi_regs & CPUMASK)
241 #define TARGET_PROMOTE_HI_REGS (x86_promote_hi_regs & CPUMASK)
242 #define TARGET_ADD_ESP_4 (x86_add_esp_4 & CPUMASK)
243 #define TARGET_ADD_ESP_8 (x86_add_esp_8 & CPUMASK)
244 #define TARGET_SUB_ESP_4 (x86_sub_esp_4 & CPUMASK)
245 #define TARGET_SUB_ESP_8 (x86_sub_esp_8 & CPUMASK)
246 #define TARGET_INTEGER_DFMODE_MOVES (x86_integer_DFmode_moves & CPUMASK)
247 #define TARGET_PARTIAL_REG_DEPENDENCY (x86_partial_reg_dependency & CPUMASK)
248 #define TARGET_MEMORY_MISMATCH_STALL (x86_memory_mismatch_stall & CPUMASK)
249
250 #define TARGET_STACK_PROBE (target_flags & MASK_STACK_PROBE)
251
252 #define TARGET_ALIGN_STRINGOPS (!(target_flags & MASK_NO_ALIGN_STROPS))
253 #define TARGET_INLINE_ALL_STRINGOPS (target_flags & MASK_INLINE_ALL_STROPS)
254
255 #define ASSEMBLER_DIALECT ((target_flags & MASK_INTEL_SYNTAX) != 0)
256
257 #define TARGET_SSE ((target_flags & (MASK_SSE | MASK_SSE2)) != 0)
258 #define TARGET_SSE2 ((target_flags & MASK_SSE2) != 0)
259 #define TARGET_MIX_SSE_I387 ((target_flags & MASK_MIX_SSE_I387) != 0)
260 #define TARGET_MMX ((target_flags & MASK_MMX) != 0)
261
262 #define TARGET_RED_ZONE (!(target_flags & MASK_NO_RED_ZONE))
263
264 #define TARGET_SWITCHES \
265 { { "80387", MASK_80387, N_("Use hardware fp") }, \
266 { "no-80387", -MASK_80387, N_("Do not use hardware fp") }, \
267 { "hard-float", MASK_80387, N_("Use hardware fp") }, \
268 { "soft-float", -MASK_80387, N_("Do not use hardware fp") }, \
269 { "no-soft-float", MASK_80387, N_("Use hardware fp") }, \
270 { "386", 0, N_("Same as -mcpu=i386") }, \
271 { "486", 0, N_("Same as -mcpu=i486") }, \
272 { "pentium", 0, N_("Same as -mcpu=pentium") }, \
273 { "pentiumpro", 0, N_("Same as -mcpu=pentiumpro") }, \
274 { "rtd", MASK_RTD, \
275 N_("Alternate calling convention") }, \
276 { "no-rtd", -MASK_RTD, \
277 N_("Use normal calling convention") }, \
278 { "align-double", MASK_ALIGN_DOUBLE, \
279 N_("Align some doubles on dword boundary") }, \
280 { "no-align-double", -MASK_ALIGN_DOUBLE, \
281 N_("Align doubles on word boundary") }, \
282 { "svr3-shlib", MASK_SVR3_SHLIB, \
283 N_("Uninitialized locals in .bss") }, \
284 { "no-svr3-shlib", -MASK_SVR3_SHLIB, \
285 N_("Uninitialized locals in .data") }, \
286 { "ieee-fp", MASK_IEEE_FP, \
287 N_("Use IEEE math for fp comparisons") }, \
288 { "no-ieee-fp", -MASK_IEEE_FP, \
289 N_("Do not use IEEE math for fp comparisons") }, \
290 { "fp-ret-in-387", MASK_FLOAT_RETURNS, \
291 N_("Return values of functions in FPU registers") }, \
292 { "no-fp-ret-in-387", -MASK_FLOAT_RETURNS , \
293 N_("Do not return values of functions in FPU registers")}, \
294 { "no-fancy-math-387", MASK_NO_FANCY_MATH_387, \
295 N_("Do not generate sin, cos, sqrt for FPU") }, \
296 { "fancy-math-387", -MASK_NO_FANCY_MATH_387, \
297 N_("Generate sin, cos, sqrt for FPU")}, \
298 { "omit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER, \
299 N_("Omit the frame pointer in leaf functions") }, \
300 { "no-omit-leaf-frame-pointer",-MASK_OMIT_LEAF_FRAME_POINTER, "" }, \
301 { "debug-addr", MASK_DEBUG_ADDR, 0 /* undocumented */ }, \
302 { "no-debug-addr", -MASK_DEBUG_ADDR, 0 /* undocumented */ }, \
303 { "debug-arg", MASK_DEBUG_ARG, 0 /* undocumented */ }, \
304 { "no-debug-arg", -MASK_DEBUG_ARG, 0 /* undocumented */ }, \
305 { "stack-arg-probe", MASK_STACK_PROBE, \
306 N_("Enable stack probing") }, \
307 { "no-stack-arg-probe", -MASK_STACK_PROBE, "" }, \
308 { "windows", 0, 0 /* undocumented */ }, \
309 { "dll", 0, 0 /* undocumented */ }, \
310 { "intel-syntax", MASK_INTEL_SYNTAX, \
311 N_("Emit Intel syntax assembler opcodes") }, \
312 { "no-intel-syntax", -MASK_INTEL_SYNTAX, "" }, \
313 { "align-stringops", -MASK_NO_ALIGN_STROPS, \
314 N_("Align destination of the string operations") }, \
315 { "no-align-stringops", MASK_NO_ALIGN_STROPS, \
316 N_("Do not align destination of the string operations") }, \
317 { "inline-all-stringops", MASK_INLINE_ALL_STROPS, \
318 N_("Inline all known string operations") }, \
319 { "no-inline-all-stringops", -MASK_INLINE_ALL_STROPS, \
320 N_("Do not inline all known string operations") }, \
321 { "push-args", -MASK_NO_PUSH_ARGS, \
322 N_("Use push instructions to save outgoing arguments") }, \
323 { "no-push-args", MASK_NO_PUSH_ARGS, \
324 N_("Do not use push instructions to save outgoing arguments") }, \
325 { "accumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS, \
326 N_("Use push instructions to save outgoing arguments") }, \
327 { "no-accumulate-outgoing-args",-MASK_ACCUMULATE_OUTGOING_ARGS, \
328 N_("Do not use push instructions to save outgoing arguments") }, \
329 { "mmx", MASK_MMX, N_("Support MMX builtins") }, \
330 { "no-mmx", -MASK_MMX, \
331 N_("Do not support MMX builtins") }, \
332 { "sse", MASK_SSE, \
333 N_("Support MMX and SSE builtins and code generation") }, \
334 { "no-sse", -MASK_SSE, \
335 N_("Do not support MMX and SSE builtins and code generation") }, \
336 { "sse2", MASK_SSE2, \
337 N_("Support MMX, SSE and SSE2 builtins and code generation") }, \
338 { "no-sse2", -MASK_SSE2, \
339 N_("Do not support MMX, SSE and SSE2 builtins and code generation") }, \
340 { "mix-sse-i387", MASK_MIX_SSE_I387, \
341 N_("Use both SSE and i387 instruction sets for floating point arithmetics") },\
342 { "nomix-sse-i387", -MASK_MIX_SSE_I387, \
343 N_("Use both SSE and i387 instruction sets for floating point arithmetics") },\
344 { "128bit-long-double", MASK_128BIT_LONG_DOUBLE, \
345 N_("sizeof(long double) is 16.") }, \
346 { "96bit-long-double", -MASK_128BIT_LONG_DOUBLE, \
347 N_("sizeof(long double) is 12.") }, \
348 { "64", MASK_64BIT, \
349 N_("Generate 64bit x86-64 code") }, \
350 { "32", -MASK_64BIT, \
351 N_("Generate 32bit i386 code") }, \
352 { "red-zone", -MASK_NO_RED_ZONE, \
353 N_("Use red-zone in the x86-64 code") }, \
354 { "no-red-zone", MASK_NO_RED_ZONE, \
355 N_("do not use red-zone in the x86-64 code") }, \
356 SUBTARGET_SWITCHES \
357 { "", TARGET_DEFAULT, 0 }}
358
359 #ifdef TARGET_64BIT_DEFAULT
360 #define TARGET_DEFAULT (MASK_64BIT | TARGET_SUBTARGET_DEFAULT)
361 #else
362 #define TARGET_DEFAULT TARGET_SUBTARGET_DEFAULT
363 #endif
364
365 /* Which processor to schedule for. The cpu attribute defines a list that
366 mirrors this list, so changes to i386.md must be made at the same time. */
367
368 enum processor_type
369 {
370 PROCESSOR_I386, /* 80386 */
371 PROCESSOR_I486, /* 80486DX, 80486SX, 80486DX[24] */
372 PROCESSOR_PENTIUM,
373 PROCESSOR_PENTIUMPRO,
374 PROCESSOR_K6,
375 PROCESSOR_ATHLON,
376 PROCESSOR_PENTIUM4,
377 PROCESSOR_max
378 };
379
380 extern enum processor_type ix86_cpu;
381
382 extern int ix86_arch;
383
384 /* This macro is similar to `TARGET_SWITCHES' but defines names of
385 command options that have values. Its definition is an
386 initializer with a subgrouping for each command option.
387
388 Each subgrouping contains a string constant, that defines the
389 fixed part of the option name, and the address of a variable. The
390 variable, type `char *', is set to the variable part of the given
391 option if the fixed part matches. The actual option name is made
392 by appending `-m' to the specified name. */
393 #define TARGET_OPTIONS \
394 { { "cpu=", &ix86_cpu_string, \
395 N_("Schedule code for given CPU")}, \
396 { "arch=", &ix86_arch_string, \
397 N_("Generate code for given CPU")}, \
398 { "regparm=", &ix86_regparm_string, \
399 N_("Number of registers used to pass integer arguments") }, \
400 { "align-loops=", &ix86_align_loops_string, \
401 N_("Loop code aligned to this power of 2") }, \
402 { "align-jumps=", &ix86_align_jumps_string, \
403 N_("Jump targets are aligned to this power of 2") }, \
404 { "align-functions=", &ix86_align_funcs_string, \
405 N_("Function starts are aligned to this power of 2") }, \
406 { "preferred-stack-boundary=", \
407 &ix86_preferred_stack_boundary_string, \
408 N_("Attempt to keep stack aligned to this power of 2") }, \
409 { "branch-cost=", &ix86_branch_cost_string, \
410 N_("Branches are this expensive (1-5, arbitrary units)") }, \
411 { "cmodel=", &ix86_cmodel_string, \
412 N_("Use given x86-64 code model") }, \
413 SUBTARGET_OPTIONS \
414 }
415
416 /* Sometimes certain combinations of command options do not make
417 sense on a particular target machine. You can define a macro
418 `OVERRIDE_OPTIONS' to take account of this. This macro, if
419 defined, is executed once just after all the command options have
420 been parsed.
421
422 Don't use this macro to turn on various extra optimizations for
423 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
424
425 #define OVERRIDE_OPTIONS override_options ()
426
427 /* These are meant to be redefined in the host dependent files */
428 #define SUBTARGET_SWITCHES
429 #define SUBTARGET_OPTIONS
430
431 /* Define this to change the optimizations performed by default. */
432 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE) optimization_options(LEVEL,SIZE)
433
434 /* Specs for the compiler proper */
435
436 #ifndef CC1_CPU_SPEC
437 #define CC1_CPU_SPEC "\
438 %{!mcpu*: \
439 %{m386:-mcpu=i386 \
440 %n`-m386' is deprecated. Use `-march' or `-mcpu' instead.\n} \
441 %{m486:-mcpu=i486 \
442 %n`-m486' is deprecated. Use `-march' or `-mcpu' instead.\n} \
443 %{mpentium:-mcpu=pentium \
444 %n`-mpentium' is deprecated. Use `-march' or `-mcpu' instead.\n} \
445 %{mpentiumpro:-mcpu=pentiumpro \
446 %n`-mpentiumpro' is deprecated. Use `-march' or `-mcpu' instead.\n}}"
447 #endif
448 \f
449 #ifndef CPP_CPU_DEFAULT_SPEC
450 #if TARGET_CPU_DEFAULT == 1
451 #define CPP_CPU_DEFAULT_SPEC "-D__tune_i486__"
452 #endif
453 #if TARGET_CPU_DEFAULT == 2
454 #define CPP_CPU_DEFAULT_SPEC "-D__tune_i586__ -D__tune_pentium__"
455 #endif
456 #if TARGET_CPU_DEFAULT == 3
457 #define CPP_CPU_DEFAULT_SPEC "-D__tune_i686__ -D__tune_pentiumpro__"
458 #endif
459 #if TARGET_CPU_DEFAULT == 4
460 #define CPP_CPU_DEFAULT_SPEC "-D__tune_k6__"
461 #endif
462 #if TARGET_CPU_DEFAULT == 5
463 #define CPP_CPU_DEFAULT_SPEC "-D__tune_athlon__"
464 #endif
465 #if TARGET_CPU_DEFAULT == 6
466 #define CPP_CPU_DEFAULT_SPEC "-D__tune_pentium4__"
467 #endif
468 #ifndef CPP_CPU_DEFAULT_SPEC
469 #define CPP_CPU_DEFAULT_SPEC "-D__tune_i386__"
470 #endif
471 #endif /* CPP_CPU_DEFAULT_SPEC */
472
473 #ifdef NO_BUILTIN_SIZE_TYPE
474 #define CPP_CPU32_SIZE_TYPE_SPEC \
475 " -D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int"
476 #define CPP_CPU64_SIZE_TYPE_SPEC \
477 " -D__SIZE_TYPE__=unsigned\\ long\\ int -D__PTRDIFF_TYPE__=long\\ int"
478 #else
479 #define CPP_CPU32_SIZE_TYPE_SPEC ""
480 #define CPP_CPU64_SIZE_TYPE_SPEC ""
481 #endif
482
483 #define CPP_CPU32_SPEC \
484 "-Acpu=i386 -Amachine=i386 %{!ansi:%{!std=c*:%{!std=i*:-Di386}}} -D__i386 \
485 -D__i386__ %(cpp_cpu32sizet)"
486
487 #define CPP_CPU64_SPEC \
488 "-Acpu=x86_64 -Amachine=x86_64 -D__x86_64 -D__x86_64__ %(cpp_cpu64sizet)"
489
490 #define CPP_CPUCOMMON_SPEC "\
491 %{march=i386:%{!mcpu*:-D__tune_i386__ }}\
492 %{march=i486:-D__i486 -D__i486__ %{!mcpu*:-D__tune_i486__ }}\
493 %{march=pentium|march=i586:-D__i586 -D__i586__ -D__pentium -D__pentium__ \
494 %{!mcpu*:-D__tune_i586__ -D__tune_pentium__ }}\
495 %{march=pentiumpro|march=i686:-D__i686 -D__i686__ \
496 -D__pentiumpro -D__pentiumpro__ \
497 %{!mcpu*:-D__tune_i686__ -D__tune_pentiumpro__ }}\
498 %{march=k6:-D__k6 -D__k6__ %{!mcpu*:-D__tune_k6__ }}\
499 %{march=athlon:-D__athlon -D__athlon__ %{!mcpu*:-D__tune_athlon__ }}\
500 %{march=pentium4:-D__pentium4 -D__pentium4__ %{!mcpu*:-D__tune_pentium4__ }}\
501 %{m386|mcpu=i386:-D__tune_i386__ }\
502 %{m486|mcpu=i486:-D__tune_i486__ }\
503 %{mpentium|mcpu=pentium|mcpu=i586:-D__tune_i586__ -D__tune_pentium__ }\
504 %{mpentiumpro|mcpu=pentiumpro|mcpu=i686:-D__tune_i686__ -D__tune_pentiumpro__ }\
505 %{mcpu=k6:-D__tune_k6__ }\
506 %{mcpu=athlon:-D__tune_athlon__ }\
507 %{mcpu=pentium4:-D__tune_pentium4__ }\
508 %{!march*:%{!mcpu*:%{!m386:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}}}"
509
510 #ifndef CPP_CPU_SPEC
511 #ifdef TARGET_BI_ARCH
512 #ifdef TARGET_64BIT_DEFAULT
513 #define CPP_CPU_SPEC "%{m32:%(cpp_cpu32)}%{!m32:%(cpp_cpu64)} %(cpp_cpucommon)"
514 #else
515 #define CPP_CPU_SPEC "%{m64:%(cpp_cpu64)}%{!m64:%(cpp_cpu32)} %(cpp_cpucommon)"
516 #endif
517 #else
518 #ifdef TARGET_64BIT_DEFAULT
519 #define CPP_CPU_SPEC "%(cpp_cpu64) %(cpp_cpucommon)"
520 #else
521 #define CPP_CPU_SPEC "%(cpp_cpu32) %(cpp_cpucommon)"
522 #endif
523 #endif
524 #endif
525
526 #ifndef CC1_SPEC
527 #define CC1_SPEC "%(cc1_cpu) "
528 #endif
529
530 /* This macro defines names of additional specifications to put in the
531 specs that can be used in various specifications like CC1_SPEC. Its
532 definition is an initializer with a subgrouping for each command option.
533
534 Each subgrouping contains a string constant, that defines the
535 specification name, and a string constant that used by the GNU CC driver
536 program.
537
538 Do not define this macro if it does not need to do anything. */
539
540 #ifndef SUBTARGET_EXTRA_SPECS
541 #define SUBTARGET_EXTRA_SPECS
542 #endif
543
544 #define EXTRA_SPECS \
545 { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC }, \
546 { "cpp_cpu", CPP_CPU_SPEC }, \
547 { "cpp_cpu32", CPP_CPU32_SPEC }, \
548 { "cpp_cpu64", CPP_CPU64_SPEC }, \
549 { "cpp_cpu32sizet", CPP_CPU32_SIZE_TYPE_SPEC }, \
550 { "cpp_cpu64sizet", CPP_CPU64_SIZE_TYPE_SPEC }, \
551 { "cpp_cpucommon", CPP_CPUCOMMON_SPEC }, \
552 { "cc1_cpu", CC1_CPU_SPEC }, \
553 SUBTARGET_EXTRA_SPECS
554 \f
555 /* target machine storage layout */
556
557 /* Define for XFmode or TFmode extended real floating point support.
558 This will automatically cause REAL_ARITHMETIC to be defined.
559
560 The XFmode is specified by i386 ABI, while TFmode may be faster
561 due to alignment and simplifications in the address calculations.
562 */
563 #define LONG_DOUBLE_TYPE_SIZE (TARGET_128BIT_LONG_DOUBLE ? 128 : 96)
564 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
565 #ifdef __x86_64__
566 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
567 #else
568 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 96
569 #endif
570 /* Tell real.c that this is the 80-bit Intel extended float format
571 packaged in a 128-bit or 96bit entity. */
572 #define INTEL_EXTENDED_IEEE_FORMAT
573
574
575 #define SHORT_TYPE_SIZE 16
576 #define INT_TYPE_SIZE 32
577 #define FLOAT_TYPE_SIZE 32
578 #define LONG_TYPE_SIZE BITS_PER_WORD
579 #define MAX_WCHAR_TYPE_SIZE 32
580 #define DOUBLE_TYPE_SIZE 64
581 #define LONG_LONG_TYPE_SIZE 64
582
583 #if defined (TARGET_BI_ARCH) || defined (TARGET_64BIT_DEFAULT)
584 #define MAX_BITS_PER_WORD 64
585 #define MAX_LONG_TYPE_SIZE 64
586 #else
587 #define MAX_BITS_PER_WORD 32
588 #define MAX_LONG_TYPE_SIZE 32
589 #endif
590
591 /* Define if you don't want extended real, but do want to use the
592 software floating point emulator for REAL_ARITHMETIC and
593 decimal <-> binary conversion. */
594 /* #define REAL_ARITHMETIC */
595
596 /* Define this if most significant byte of a word is the lowest numbered. */
597 /* That is true on the 80386. */
598
599 #define BITS_BIG_ENDIAN 0
600
601 /* Define this if most significant byte of a word is the lowest numbered. */
602 /* That is not true on the 80386. */
603 #define BYTES_BIG_ENDIAN 0
604
605 /* Define this if most significant word of a multiword number is the lowest
606 numbered. */
607 /* Not true for 80386 */
608 #define WORDS_BIG_ENDIAN 0
609
610 /* number of bits in an addressable storage unit */
611 #define BITS_PER_UNIT 8
612
613 /* Width in bits of a "word", which is the contents of a machine register.
614 Note that this is not necessarily the width of data type `int';
615 if using 16-bit ints on a 80386, this would still be 32.
616 But on a machine with 16-bit registers, this would be 16. */
617 #define BITS_PER_WORD (TARGET_64BIT ? 64 : 32)
618
619 /* Width of a word, in units (bytes). */
620 #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
621 #define MIN_UNITS_PER_WORD 4
622
623 /* Width in bits of a pointer.
624 See also the macro `Pmode' defined below. */
625 #define POINTER_SIZE BITS_PER_WORD
626
627 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
628 #define PARM_BOUNDARY BITS_PER_WORD
629
630 /* Boundary (in *bits*) on which stack pointer should be aligned. */
631 #define STACK_BOUNDARY BITS_PER_WORD
632
633 /* Boundary (in *bits*) on which the stack pointer preferrs to be
634 aligned; the compiler cannot rely on having this alignment. */
635 #define PREFERRED_STACK_BOUNDARY ix86_preferred_stack_boundary
636
637 /* Allocation boundary for the code of a function. */
638 #define FUNCTION_BOUNDARY 16
639
640 /* Alignment of field after `int : 0' in a structure. */
641
642 #define EMPTY_FIELD_BOUNDARY BITS_PER_WORD
643
644 /* Minimum size in bits of the largest boundary to which any
645 and all fundamental data types supported by the hardware
646 might need to be aligned. No data type wants to be aligned
647 rounder than this.
648
649 Pentium+ preferrs DFmode values to be aligned to 64 bit boundary
650 and Pentium Pro XFmode values at 128 bit boundaries. */
651
652 #define BIGGEST_ALIGNMENT 128
653
654 /* Decide whether a variable of mode MODE must be 128 bit aligned. */
655 #define ALIGN_MODE_128(MODE) \
656 ((MODE) == XFmode || (MODE) == TFmode || ((MODE) == TImode) \
657 || (MODE) == V4SFmode || (MODE) == V4SImode)
658
659 /* The published ABIs say that doubles should be aligned on word
660 boundaries, so lower the aligment for structure fields unless
661 -malign-double is set. */
662 /* BIGGEST_FIELD_ALIGNMENT is also used in libobjc, where it must be
663 constant. Use the smaller value in that context. */
664 #ifndef IN_TARGET_LIBS
665 #define BIGGEST_FIELD_ALIGNMENT (TARGET_64BIT ? 128 : (TARGET_ALIGN_DOUBLE ? 64 : 32))
666 #else
667 #define BIGGEST_FIELD_ALIGNMENT 32
668 #endif
669
670 /* If defined, a C expression to compute the alignment given to a
671 constant that is being placed in memory. EXP is the constant
672 and ALIGN is the alignment that the object would ordinarily have.
673 The value of this macro is used instead of that alignment to align
674 the object.
675
676 If this macro is not defined, then ALIGN is used.
677
678 The typical use of this macro is to increase alignment for string
679 constants to be word aligned so that `strcpy' calls that copy
680 constants can be done inline. */
681
682 #define CONSTANT_ALIGNMENT(EXP, ALIGN) ix86_constant_alignment (EXP, ALIGN)
683
684 /* If defined, a C expression to compute the alignment for a static
685 variable. TYPE is the data type, and ALIGN is the alignment that
686 the object would ordinarily have. The value of this macro is used
687 instead of that alignment to align the object.
688
689 If this macro is not defined, then ALIGN is used.
690
691 One use of this macro is to increase alignment of medium-size
692 data to make it all fit in fewer cache lines. Another is to
693 cause character arrays to be word-aligned so that `strcpy' calls
694 that copy constants to character arrays can be done inline. */
695
696 #define DATA_ALIGNMENT(TYPE, ALIGN) ix86_data_alignment (TYPE, ALIGN)
697
698 /* If defined, a C expression to compute the alignment for a local
699 variable. TYPE is the data type, and ALIGN is the alignment that
700 the object would ordinarily have. The value of this macro is used
701 instead of that alignment to align the object.
702
703 If this macro is not defined, then ALIGN is used.
704
705 One use of this macro is to increase alignment of medium-size
706 data to make it all fit in fewer cache lines. */
707
708 #define LOCAL_ALIGNMENT(TYPE, ALIGN) ix86_local_alignment (TYPE, ALIGN)
709
710 /* Set this non-zero if move instructions will actually fail to work
711 when given unaligned data. */
712 #define STRICT_ALIGNMENT 0
713
714 /* If bit field type is int, don't let it cross an int,
715 and give entire struct the alignment of an int. */
716 /* Required on the 386 since it doesn't have bitfield insns. */
717 #define PCC_BITFIELD_TYPE_MATTERS 1
718 \f
719 /* Standard register usage. */
720
721 /* This processor has special stack-like registers. See reg-stack.c
722 for details. */
723
724 #define STACK_REGS
725 #define IS_STACK_MODE(mode) (mode==DFmode || mode==SFmode \
726 || mode==XFmode || mode==TFmode)
727
728 /* Number of actual hardware registers.
729 The hardware registers are assigned numbers for the compiler
730 from 0 to just below FIRST_PSEUDO_REGISTER.
731 All registers that the compiler knows about must be given numbers,
732 even those that are not normally considered general registers.
733
734 In the 80386 we give the 8 general purpose registers the numbers 0-7.
735 We number the floating point registers 8-15.
736 Note that registers 0-7 can be accessed as a short or int,
737 while only 0-3 may be used with byte `mov' instructions.
738
739 Reg 16 does not correspond to any hardware register, but instead
740 appears in the RTL as an argument pointer prior to reload, and is
741 eliminated during reloading in favor of either the stack or frame
742 pointer. */
743
744 #define FIRST_PSEUDO_REGISTER 53
745
746 /* Number of hardware registers that go into the DWARF-2 unwind info.
747 If not defined, equals FIRST_PSEUDO_REGISTER. */
748
749 #define DWARF_FRAME_REGISTERS 17
750
751 /* 1 for registers that have pervasive standard uses
752 and are not available for the register allocator.
753 On the 80386, the stack pointer is such, as is the arg pointer.
754
755 The value is an mask - bit 1 is set for fixed registers
756 for 32bit target, while 2 is set for fixed registers for 64bit.
757 Proper value is computed in the CONDITIONAL_REGISTER_USAGE.
758 */
759 #define FIXED_REGISTERS \
760 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7*/ \
761 { 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, \
762 /*arg,flags,fpsr,dir,frame*/ \
763 3, 3, 3, 3, 3, \
764 /*xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7*/ \
765 0, 0, 0, 0, 0, 0, 0, 0, \
766 /*mmx0,mmx1,mmx2,mmx3,mmx4,mmx5,mmx6,mmx7*/ \
767 0, 0, 0, 0, 0, 0, 0, 0, \
768 /* r8, r9, r10, r11, r12, r13, r14, r15*/ \
769 1, 1, 1, 1, 1, 1, 1, 1, \
770 /*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/ \
771 1, 1, 1, 1, 1, 1, 1, 1}
772
773
774 /* 1 for registers not available across function calls.
775 These must include the FIXED_REGISTERS and also any
776 registers that can be used without being saved.
777 The latter must include the registers where values are returned
778 and the register where structure-value addresses are passed.
779 Aside from that, you can include as many other registers as you like.
780
781 The value is an mask - bit 1 is set for call used
782 for 32bit target, while 2 is set for call used for 64bit.
783 Proper value is computed in the CONDITIONAL_REGISTER_USAGE.
784 */
785 #define CALL_USED_REGISTERS \
786 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7*/ \
787 { 3, 3, 3, 0, 2, 2, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, \
788 /*arg,flags,fpsr,dir,frame*/ \
789 3, 3, 3, 3, 3, \
790 /*xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7*/ \
791 3, 3, 3, 3, 3, 3, 3, 3, \
792 /*mmx0,mmx1,mmx2,mmx3,mmx4,mmx5,mmx6,mmx7*/ \
793 3, 3, 3, 3, 3, 3, 3, 3, \
794 /* r8, r9, r10, r11, r12, r13, r14, r15*/ \
795 3, 3, 3, 3, 1, 1, 1, 1, \
796 /*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/ \
797 3, 3, 3, 3, 3, 3, 3, 3} \
798
799 /* Order in which to allocate registers. Each register must be
800 listed once, even those in FIXED_REGISTERS. List frame pointer
801 late and fixed registers last. Note that, in general, we prefer
802 registers listed in CALL_USED_REGISTERS, keeping the others
803 available for storage of persistent values.
804
805 Three different versions of REG_ALLOC_ORDER have been tried:
806
807 If the order is edx, ecx, eax, ... it produces a slightly faster compiler,
808 but slower code on simple functions returning values in eax.
809
810 If the order is eax, ecx, edx, ... it causes reload to abort when compiling
811 perl 4.036 due to not being able to create a DImode register (to hold a 2
812 word union).
813
814 If the order is eax, edx, ecx, ... it produces better code for simple
815 functions, and a slightly slower compiler. Users complained about the code
816 generated by allocating edx first, so restore the 'natural' order of things. */
817
818 #define REG_ALLOC_ORDER \
819 /*ax,dx,cx,*/ \
820 { 0, 1, 2, \
821 /* bx,si,di,bp,sp,*/ \
822 3, 4, 5, 6, 7, \
823 /*r8,r9,r10,r11,*/ \
824 37,38, 39, 40, \
825 /*r12,r15,r14,r13*/ \
826 41, 44, 43, 42, \
827 /*xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7*/ \
828 21, 22, 23, 24, 25, 26, 27, 28, \
829 /*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/ \
830 45, 46, 47, 48, 49, 50, 51, 52, \
831 /*st,st1,st2,st3,st4,st5,st6,st7*/ \
832 8, 9, 10, 11, 12, 13, 14, 15, \
833 /*,arg,cc,fpsr,dir,frame*/ \
834 16,17, 18, 19, 20, \
835 /*mmx0,mmx1,mmx2,mmx3,mmx4,mmx5,mmx6,mmx7*/ \
836 29, 30, 31, 32, 33, 34, 35, 36 }
837
838 /* Macro to conditionally modify fixed_regs/call_used_regs. */
839 #define CONDITIONAL_REGISTER_USAGE \
840 { \
841 int i; \
842 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) \
843 { \
844 fixed_regs[i] = (fixed_regs[i] & (TARGET_64BIT ? 2 : 1)) != 0; \
845 call_used_regs[i] = (call_used_regs[i] \
846 & (TARGET_64BIT ? 2 : 1)) != 0; \
847 } \
848 if (flag_pic) \
849 { \
850 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
851 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
852 } \
853 if (! TARGET_MMX) \
854 { \
855 int i; \
856 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) \
857 if (TEST_HARD_REG_BIT (reg_class_contents[(int)MMX_REGS], i)) \
858 fixed_regs[i] = call_used_regs[i] = 1; \
859 } \
860 if (! TARGET_SSE) \
861 { \
862 int i; \
863 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) \
864 if (TEST_HARD_REG_BIT (reg_class_contents[(int)SSE_REGS], i)) \
865 fixed_regs[i] = call_used_regs[i] = 1; \
866 } \
867 if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387) \
868 { \
869 int i; \
870 HARD_REG_SET x; \
871 COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]); \
872 for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) \
873 if (TEST_HARD_REG_BIT (x, i)) \
874 fixed_regs[i] = call_used_regs[i] = 1; \
875 } \
876 }
877
878 /* Return number of consecutive hard regs needed starting at reg REGNO
879 to hold something of mode MODE.
880 This is ordinarily the length in words of a value of mode MODE
881 but can be less for certain modes in special long registers.
882
883 Actually there are no two word move instructions for consecutive
884 registers. And only registers 0-3 may have mov byte instructions
885 applied to them.
886 */
887
888 #define HARD_REGNO_NREGS(REGNO, MODE) \
889 (FP_REGNO_P (REGNO) || SSE_REGNO_P (REGNO) || MMX_REGNO_P (REGNO) \
890 ? (COMPLEX_MODE_P (MODE) ? 2 : 1) \
891 : (MODE == TFmode \
892 ? (TARGET_64BIT ? 2 : 3) \
893 : MODE == TCmode \
894 ? (TARGET_64BIT ? 4 : 6) \
895 : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
896
897 #define VALID_SSE_REG_MODE(MODE) \
898 ((MODE) == TImode || (MODE) == V4SFmode || (MODE) == V4SImode \
899 || (MODE) == SFmode \
900 || (TARGET_SSE2 && ((MODE) == DFmode || VALID_MMX_REG_MODE (MODE))))
901
902 #define VALID_MMX_REG_MODE(MODE) \
903 ((MODE) == DImode || (MODE) == V8QImode || (MODE) == V4HImode \
904 || (MODE) == V2SImode || (MODE) == SImode)
905
906 #define VECTOR_MODE_SUPPORTED_P(MODE) \
907 (VALID_SSE_REG_MODE (MODE) && TARGET_SSE ? 1 \
908 : VALID_MMX_REG_MODE (MODE) && TARGET_MMX ? 1 : 0)
909
910 #define VALID_FP_MODE_P(mode) \
911 ((mode) == SFmode || (mode) == DFmode || (mode) == TFmode \
912 || (!TARGET_64BIT && (mode) == XFmode) \
913 || (mode) == SCmode || (mode) == DCmode || (mode) == TCmode\
914 || (!TARGET_64BIT && (mode) == XCmode))
915
916 #define VALID_INT_MODE_P(mode) \
917 ((mode) == QImode || (mode) == HImode || (mode) == SImode \
918 || (mode) == DImode \
919 || (mode) == CQImode || (mode) == CHImode || (mode) == CSImode \
920 || (mode) == CDImode)
921
922 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
923
924 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
925 ix86_hard_regno_mode_ok (REGNO, MODE)
926
927 /* Value is 1 if it is a good idea to tie two pseudo registers
928 when one has mode MODE1 and one has mode MODE2.
929 If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
930 for any hard reg, then this must be 0 for correct output. */
931
932 #define MODES_TIEABLE_P(MODE1, MODE2) \
933 ((MODE1) == (MODE2) \
934 || (((MODE1) == HImode || (MODE1) == SImode \
935 || ((MODE1) == QImode \
936 && (TARGET_64BIT || !TARGET_PARTIAL_REG_STALL)) \
937 || ((MODE1) == DImode && TARGET_64BIT)) \
938 && ((MODE2) == HImode || (MODE2) == SImode \
939 || ((MODE1) == QImode \
940 && (TARGET_64BIT || !TARGET_PARTIAL_REG_STALL)) \
941 || ((MODE2) == DImode && TARGET_64BIT))))
942
943
944 /* Specify the modes required to caller save a given hard regno.
945 We do this on i386 to prevent flags from being saved at all.
946
947 Kill any attempts to combine saving of modes. */
948
949 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
950 (CC_REGNO_P (REGNO) ? VOIDmode \
951 : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode \
952 : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS)) \
953 : (MODE) == HImode && !TARGET_PARTIAL_REG_STALL ? SImode \
954 : (MODE) == QImode && (REGNO) >= 4 && !TARGET_64BIT ? SImode \
955 : (MODE))
956 /* Specify the registers used for certain standard purposes.
957 The values of these macros are register numbers. */
958
959 /* on the 386 the pc register is %eip, and is not usable as a general
960 register. The ordinary mov instructions won't work */
961 /* #define PC_REGNUM */
962
963 /* Register to use for pushing function arguments. */
964 #define STACK_POINTER_REGNUM 7
965
966 /* Base register for access to local variables of the function. */
967 #define HARD_FRAME_POINTER_REGNUM 6
968
969 /* Base register for access to local variables of the function. */
970 #define FRAME_POINTER_REGNUM 20
971
972 /* First floating point reg */
973 #define FIRST_FLOAT_REG 8
974
975 /* First & last stack-like regs */
976 #define FIRST_STACK_REG FIRST_FLOAT_REG
977 #define LAST_STACK_REG (FIRST_FLOAT_REG + 7)
978
979 #define FLAGS_REG 17
980 #define FPSR_REG 18
981 #define DIRFLAG_REG 19
982
983 #define FIRST_SSE_REG (FRAME_POINTER_REGNUM + 1)
984 #define LAST_SSE_REG (FIRST_SSE_REG + 7)
985
986 #define FIRST_MMX_REG (LAST_SSE_REG + 1)
987 #define LAST_MMX_REG (FIRST_MMX_REG + 7)
988
989 #define FIRST_REX_INT_REG (LAST_MMX_REG + 1)
990 #define LAST_REX_INT_REG (FIRST_REX_INT_REG + 7)
991
992 #define FIRST_REX_SSE_REG (LAST_REX_INT_REG + 1)
993 #define LAST_REX_SSE_REG (FIRST_REX_SSE_REG + 7)
994
995 /* Value should be nonzero if functions must have frame pointers.
996 Zero means the frame pointer need not be set up (and parms
997 may be accessed via the stack pointer) in functions that seem suitable.
998 This is computed in `reload', in reload1.c. */
999 #define FRAME_POINTER_REQUIRED ix86_frame_pointer_required ()
1000
1001 /* Override this in other tm.h files to cope with various OS losage
1002 requiring a frame pointer. */
1003 #ifndef SUBTARGET_FRAME_POINTER_REQUIRED
1004 #define SUBTARGET_FRAME_POINTER_REQUIRED 0
1005 #endif
1006
1007 /* Make sure we can access arbitrary call frames. */
1008 #define SETUP_FRAME_ADDRESSES() ix86_setup_frame_addresses ()
1009
1010 /* Base register for access to arguments of the function. */
1011 #define ARG_POINTER_REGNUM 16
1012
1013 /* Register in which static-chain is passed to a function.
1014 We do use ECX as static chain register for 32 bit ABI. On the
1015 64bit ABI, ECX is an argument register, so we use R10 instead. */
1016 #define STATIC_CHAIN_REGNUM (TARGET_64BIT ? FIRST_REX_INT_REG + 10 - 8 : 2)
1017
1018 /* Register to hold the addressing base for position independent
1019 code access to data items.
1020 We don't use PIC pointer for 64bit mode. Define the regnum to
1021 dummy value to prevent gcc from pesimizing code dealing with EBX.
1022 */
1023 #define PIC_OFFSET_TABLE_REGNUM (TARGET_64BIT ? INVALID_REGNUM : 3)
1024
1025 /* Register in which address to store a structure value
1026 arrives in the function. On the 386, the prologue
1027 copies this from the stack to register %eax. */
1028 #define STRUCT_VALUE_INCOMING 0
1029
1030 /* Place in which caller passes the structure value address.
1031 0 means push the value on the stack like an argument. */
1032 #define STRUCT_VALUE 0
1033
1034 /* A C expression which can inhibit the returning of certain function
1035 values in registers, based on the type of value. A nonzero value
1036 says to return the function value in memory, just as large
1037 structures are always returned. Here TYPE will be a C expression
1038 of type `tree', representing the data type of the value.
1039
1040 Note that values of mode `BLKmode' must be explicitly handled by
1041 this macro. Also, the option `-fpcc-struct-return' takes effect
1042 regardless of this macro. On most systems, it is possible to
1043 leave the macro undefined; this causes a default definition to be
1044 used, whose value is the constant 1 for `BLKmode' values, and 0
1045 otherwise.
1046
1047 Do not use this macro to indicate that structures and unions
1048 should always be returned in memory. You should instead use
1049 `DEFAULT_PCC_STRUCT_RETURN' to indicate this. */
1050
1051 #define RETURN_IN_MEMORY(TYPE) \
1052 ((TYPE_MODE (TYPE) == BLKmode) \
1053 || (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8)\
1054 || (int_size_in_bytes (TYPE) > 12 && TYPE_MODE (TYPE) != TImode \
1055 && TYPE_MODE (TYPE) != TFmode && ! VECTOR_MODE_P (TYPE_MODE (TYPE))))
1056
1057 \f
1058 /* Define the classes of registers for register constraints in the
1059 machine description. Also define ranges of constants.
1060
1061 One of the classes must always be named ALL_REGS and include all hard regs.
1062 If there is more than one class, another class must be named NO_REGS
1063 and contain no registers.
1064
1065 The name GENERAL_REGS must be the name of a class (or an alias for
1066 another name such as ALL_REGS). This is the class of registers
1067 that is allowed by "g" or "r" in a register constraint.
1068 Also, registers outside this class are allocated only when
1069 instructions express preferences for them.
1070
1071 The classes must be numbered in nondecreasing order; that is,
1072 a larger-numbered class must never be contained completely
1073 in a smaller-numbered class.
1074
1075 For any two classes, it is very desirable that there be another
1076 class that represents their union.
1077
1078 It might seem that class BREG is unnecessary, since no useful 386
1079 opcode needs reg %ebx. But some systems pass args to the OS in ebx,
1080 and the "b" register constraint is useful in asms for syscalls.
1081
1082 The flags and fpsr registers are in no class. */
1083
1084 enum reg_class
1085 {
1086 NO_REGS,
1087 AREG, DREG, CREG, BREG, SIREG, DIREG,
1088 AD_REGS, /* %eax/%edx for DImode */
1089 Q_REGS, /* %eax %ebx %ecx %edx */
1090 NON_Q_REGS, /* %esi %edi %ebp %esp */
1091 INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */
1092 LEGACY_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
1093 GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp %r8 - %r15*/
1094 FP_TOP_REG, FP_SECOND_REG, /* %st(0) %st(1) */
1095 FLOAT_REGS,
1096 SSE_REGS,
1097 MMX_REGS,
1098 FP_TOP_SSE_REGS,
1099 FP_SECOND_SSE_REGS,
1100 FLOAT_SSE_REGS,
1101 FLOAT_INT_REGS,
1102 INT_SSE_REGS,
1103 FLOAT_INT_SSE_REGS,
1104 ALL_REGS, LIM_REG_CLASSES
1105 };
1106
1107 #define N_REG_CLASSES (int) LIM_REG_CLASSES
1108
1109 #define INTEGER_CLASS_P(CLASS) (reg_class_subset_p (CLASS, GENERAL_REGS))
1110 #define FLOAT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, FLOAT_REGS))
1111 #define SSE_CLASS_P(CLASS) (reg_class_subset_p (CLASS, SSE_REGS))
1112 #define MMX_CLASS_P(CLASS) (reg_class_subset_p (CLASS, MMX_REGS))
1113 #define MAYBE_INTEGER_CLASS_P(CLASS) (reg_classes_intersect_p (CLASS, GENERAL_REGS))
1114 #define MAYBE_FLOAT_CLASS_P(CLASS) (reg_classes_intersect_p (CLASS, FLOAT_REGS))
1115 #define MAYBE_SSE_CLASS_P(CLASS) (reg_classes_intersect_p (SSE_REGS, CLASS))
1116 #define MAYBE_MMX_CLASS_P(CLASS) (reg_classes_intersect_p (MMX_REGS, CLASS))
1117
1118 #define Q_CLASS_P(CLASS) (reg_class_subset_p (CLASS, Q_REGS))
1119
1120 /* Give names of register classes as strings for dump file. */
1121
1122 #define REG_CLASS_NAMES \
1123 { "NO_REGS", \
1124 "AREG", "DREG", "CREG", "BREG", \
1125 "SIREG", "DIREG", \
1126 "AD_REGS", \
1127 "Q_REGS", "NON_Q_REGS", \
1128 "INDEX_REGS", \
1129 "LEGACY_REGS", \
1130 "GENERAL_REGS", \
1131 "FP_TOP_REG", "FP_SECOND_REG", \
1132 "FLOAT_REGS", \
1133 "SSE_REGS", \
1134 "MMX_REGS", \
1135 "FP_TOP_SSE_REGS", \
1136 "FP_SECOND_SSE_REGS", \
1137 "FLOAT_SSE_REGS", \
1138 "FLOAT_INT_REGS", \
1139 "INT_SSE_REGS", \
1140 "FLOAT_INT_SSE_REGS", \
1141 "ALL_REGS" }
1142
1143 /* Define which registers fit in which classes.
1144 This is an initializer for a vector of HARD_REG_SET
1145 of length N_REG_CLASSES. */
1146
1147 #define REG_CLASS_CONTENTS \
1148 { { 0x00, 0x0 }, \
1149 { 0x01, 0x0 }, { 0x02, 0x0 }, /* AREG, DREG */ \
1150 { 0x04, 0x0 }, { 0x08, 0x0 }, /* CREG, BREG */ \
1151 { 0x10, 0x0 }, { 0x20, 0x0 }, /* SIREG, DIREG */ \
1152 { 0x03, 0x0 }, /* AD_REGS */ \
1153 { 0x0f, 0x0 }, /* Q_REGS */ \
1154 { 0x1100f0, 0x1fe0 }, /* NON_Q_REGS */ \
1155 { 0x7f, 0x1fe0 }, /* INDEX_REGS */ \
1156 { 0x1100ff, 0x0 }, /* LEGACY_REGS */ \
1157 { 0x1100ff, 0x1fe0 }, /* GENERAL_REGS */ \
1158 { 0x100, 0x0 }, { 0x0200, 0x0 },/* FP_TOP_REG, FP_SECOND_REG */\
1159 { 0xff00, 0x0 }, /* FLOAT_REGS */ \
1160 { 0x1fe00000,0x1fe000 }, /* SSE_REGS */ \
1161 { 0xe0000000, 0x1f }, /* MMX_REGS */ \
1162 { 0x1fe00100,0x1fe000 }, /* FP_TOP_SSE_REG */ \
1163 { 0x1fe00200,0x1fe000 }, /* FP_SECOND_SSE_REG */ \
1164 { 0x1fe0ff00,0x1fe000 }, /* FLOAT_SSE_REGS */ \
1165 { 0x1ffff, 0x1fe0 }, /* FLOAT_INT_REGS */ \
1166 { 0x1fe100ff,0x1fffe0 }, /* INT_SSE_REGS */ \
1167 { 0x1fe1ffff,0x1fffe0 }, /* FLOAT_INT_SSE_REGS */ \
1168 { 0xffffffff,0x1fffff } \
1169 }
1170
1171 /* The same information, inverted:
1172 Return the class number of the smallest class containing
1173 reg number REGNO. This could be a conditional expression
1174 or could index an array. */
1175
1176 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
1177
1178 /* When defined, the compiler allows registers explicitly used in the
1179 rtl to be used as spill registers but prevents the compiler from
1180 extending the lifetime of these registers. */
1181
1182 #define SMALL_REGISTER_CLASSES 1
1183
1184 #define QI_REG_P(X) \
1185 (REG_P (X) && REGNO (X) < 4)
1186
1187 #define GENERAL_REGNO_P(n) \
1188 ((n) < 8 || REX_INT_REGNO_P (n))
1189
1190 #define GENERAL_REG_P(X) \
1191 (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
1192
1193 #define ANY_QI_REG_P(X) (TARGET_64BIT ? GENERAL_REG_P(X) : QI_REG_P (X))
1194
1195 #define NON_QI_REG_P(X) \
1196 (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER)
1197
1198 #define REX_INT_REGNO_P(n) ((n) >= FIRST_REX_INT_REG && (n) <= LAST_REX_INT_REG)
1199 #define REX_INT_REG_P(X) (REG_P (X) && REX_INT_REGNO_P (REGNO (X)))
1200
1201 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
1202 #define FP_REGNO_P(n) ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG)
1203 #define ANY_FP_REG_P(X) (REG_P (X) && ANY_FP_REGNO_P (REGNO (X)))
1204 #define ANY_FP_REGNO_P(n) (FP_REGNO_P (n) || SSE_REGNO_P (n))
1205
1206 #define SSE_REGNO_P(n) \
1207 (((n) >= FIRST_SSE_REG && (n) <= LAST_SSE_REG) \
1208 || ((n) >= FIRST_REX_SSE_REG && (n) <= LAST_REX_SSE_REG))
1209
1210 #define SSE_REGNO(n) \
1211 ((n) < 8 ? FIRST_SSE_REG + (n) : FIRST_REX_SSE_REG + (n) - 8)
1212 #define SSE_REG_P(n) (REG_P (n) && SSE_REGNO_P (REGNO (n)))
1213
1214 #define SSE_FLOAT_MODE_P(m) \
1215 ((TARGET_SSE && (m) == SFmode) || (TARGET_SSE2 && (m) == DFmode))
1216
1217 #define MMX_REGNO_P(n) ((n) >= FIRST_MMX_REG && (n) <= LAST_MMX_REG)
1218 #define MMX_REG_P(xop) (REG_P (xop) && MMX_REGNO_P (REGNO (xop)))
1219
1220 #define STACK_REG_P(xop) (REG_P (xop) && \
1221 REGNO (xop) >= FIRST_STACK_REG && \
1222 REGNO (xop) <= LAST_STACK_REG)
1223
1224 #define NON_STACK_REG_P(xop) (REG_P (xop) && ! STACK_REG_P (xop))
1225
1226 #define STACK_TOP_P(xop) (REG_P (xop) && REGNO (xop) == FIRST_STACK_REG)
1227
1228 #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
1229 #define CC_REGNO_P(X) ((X) == FLAGS_REG || (X) == FPSR_REG)
1230
1231 /* Indicate whether hard register numbered REG_NO should be converted
1232 to SSA form. */
1233 #define CONVERT_HARD_REGISTER_TO_SSA_P(REG_NO) \
1234 (REG_NO == FLAGS_REG || REG_NO == ARG_POINTER_REGNUM)
1235
1236 /* The class value for index registers, and the one for base regs. */
1237
1238 #define INDEX_REG_CLASS INDEX_REGS
1239 #define BASE_REG_CLASS GENERAL_REGS
1240
1241 /* Get reg_class from a letter such as appears in the machine description. */
1242
1243 #define REG_CLASS_FROM_LETTER(C) \
1244 ((C) == 'r' ? GENERAL_REGS : \
1245 (C) == 'R' ? LEGACY_REGS : \
1246 (C) == 'q' ? TARGET_64BIT ? GENERAL_REGS : Q_REGS : \
1247 (C) == 'Q' ? Q_REGS : \
1248 (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
1249 ? FLOAT_REGS \
1250 : NO_REGS) : \
1251 (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
1252 ? FP_TOP_REG \
1253 : NO_REGS) : \
1254 (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \
1255 ? FP_SECOND_REG \
1256 : NO_REGS) : \
1257 (C) == 'a' ? AREG : \
1258 (C) == 'b' ? BREG : \
1259 (C) == 'c' ? CREG : \
1260 (C) == 'd' ? DREG : \
1261 (C) == 'x' ? TARGET_SSE ? SSE_REGS : NO_REGS : \
1262 (C) == 'Y' ? TARGET_SSE2? SSE_REGS : NO_REGS : \
1263 (C) == 'y' ? TARGET_MMX ? MMX_REGS : NO_REGS : \
1264 (C) == 'A' ? AD_REGS : \
1265 (C) == 'D' ? DIREG : \
1266 (C) == 'S' ? SIREG : NO_REGS)
1267
1268 /* The letters I, J, K, L and M in a register constraint string
1269 can be used to stand for particular ranges of immediate operands.
1270 This macro defines what the ranges are.
1271 C is the letter, and VALUE is a constant value.
1272 Return 1 if VALUE is in the range specified by C.
1273
1274 I is for non-DImode shifts.
1275 J is for DImode shifts.
1276 K is for signed imm8 operands.
1277 L is for andsi as zero-extending move.
1278 M is for shifts that can be executed by the "lea" opcode.
1279 N is for immedaite operands for out/in instructions (0-255)
1280 */
1281
1282 #define CONST_OK_FOR_LETTER_P(VALUE, C) \
1283 ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31 \
1284 : (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 \
1285 : (C) == 'K' ? (VALUE) >= -128 && (VALUE) <= 127 \
1286 : (C) == 'L' ? (VALUE) == 0xff || (VALUE) == 0xffff \
1287 : (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3 \
1288 : (C) == 'N' ? (VALUE) >= 0 && (VALUE) <= 255 \
1289 : 0)
1290
1291 /* Similar, but for floating constants, and defining letters G and H.
1292 Here VALUE is the CONST_DOUBLE rtx itself. We allow constants even if
1293 TARGET_387 isn't set, because the stack register converter may need to
1294 load 0.0 into the function value register. */
1295
1296 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
1297 ((C) == 'G' ? standard_80387_constant_p (VALUE) \
1298 : ((C) == 'H' ? standard_sse_constant_p (VALUE) : 0))
1299
1300 /* A C expression that defines the optional machine-dependent
1301 constraint letters that can be used to segregate specific types of
1302 operands, usually memory references, for the target machine. Any
1303 letter that is not elsewhere defined and not matched by
1304 `REG_CLASS_FROM_LETTER' may be used. Normally this macro will not
1305 be defined.
1306
1307 If it is required for a particular target machine, it should
1308 return 1 if VALUE corresponds to the operand type represented by
1309 the constraint letter C. If C is not defined as an extra
1310 constraint, the value returned should be 0 regardless of VALUE. */
1311
1312 #define EXTRA_CONSTRAINT(VALUE, C) \
1313 ((C) == 'e' ? x86_64_sign_extended_value (VALUE) \
1314 : (C) == 'Z' ? x86_64_zero_extended_value (VALUE) \
1315 : 0)
1316
1317 /* Place additional restrictions on the register class to use when it
1318 is necessary to be able to hold a value of mode MODE in a reload
1319 register for which class CLASS would ordinarily be used. */
1320
1321 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
1322 ((MODE) == QImode && !TARGET_64BIT \
1323 && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS) \
1324 ? Q_REGS : (CLASS))
1325
1326 /* Given an rtx X being reloaded into a reg required to be
1327 in class CLASS, return the class of reg to actually use.
1328 In general this is just CLASS; but on some machines
1329 in some cases it is preferable to use a more restrictive class.
1330 On the 80386 series, we prevent floating constants from being
1331 reloaded into floating registers (since no move-insn can do that)
1332 and we ensure that QImodes aren't reloaded into the esi or edi reg. */
1333
1334 /* Put float CONST_DOUBLE in the constant pool instead of fp regs.
1335 QImode must go into class Q_REGS.
1336 Narrow ALL_REGS to GENERAL_REGS. This supports allowing movsf and
1337 movdf to do mem-to-mem moves through integer regs. */
1338
1339 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
1340 ix86_preferred_reload_class (X, CLASS)
1341
1342 /* If we are copying between general and FP registers, we need a memory
1343 location. The same is true for SSE and MMX registers. */
1344 #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \
1345 ix86_secondary_memory_needed (CLASS1, CLASS2, MODE, 1)
1346
1347 /* QImode spills from non-QI registers need a scratch. This does not
1348 happen often -- the only example so far requires an uninitialized
1349 pseudo. */
1350
1351 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS,MODE,OUT) \
1352 ((CLASS) == GENERAL_REGS && !TARGET_64BIT && (MODE) == QImode \
1353 ? Q_REGS : NO_REGS)
1354
1355 /* Return the maximum number of consecutive registers
1356 needed to represent mode MODE in a register of class CLASS. */
1357 /* On the 80386, this is the size of MODE in words,
1358 except in the FP regs, where a single reg is always enough.
1359 The TFmodes are really just 80bit values, so we use only 3 registers
1360 to hold them, instead of 4, as the size would suggest.
1361 */
1362 #define CLASS_MAX_NREGS(CLASS, MODE) \
1363 (!MAYBE_INTEGER_CLASS_P (CLASS) \
1364 ? (COMPLEX_MODE_P (MODE) ? 2 : 1) \
1365 : ((GET_MODE_SIZE ((MODE) == TFmode ? XFmode : (MODE)) \
1366 + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1367
1368 /* A C expression whose value is nonzero if pseudos that have been
1369 assigned to registers of class CLASS would likely be spilled
1370 because registers of CLASS are needed for spill registers.
1371
1372 The default value of this macro returns 1 if CLASS has exactly one
1373 register and zero otherwise. On most machines, this default
1374 should be used. Only define this macro to some other expression
1375 if pseudo allocated by `local-alloc.c' end up in memory because
1376 their hard registers were needed for spill registers. If this
1377 macro returns nonzero for those classes, those pseudos will only
1378 be allocated by `global.c', which knows how to reallocate the
1379 pseudo to another register. If there would not be another
1380 register available for reallocation, you should not change the
1381 definition of this macro since the only effect of such a
1382 definition would be to slow down register allocation. */
1383
1384 #define CLASS_LIKELY_SPILLED_P(CLASS) \
1385 (((CLASS) == AREG) \
1386 || ((CLASS) == DREG) \
1387 || ((CLASS) == CREG) \
1388 || ((CLASS) == BREG) \
1389 || ((CLASS) == AD_REGS) \
1390 || ((CLASS) == SIREG) \
1391 || ((CLASS) == DIREG))
1392
1393 /* A C statement that adds to CLOBBERS any hard regs the port wishes
1394 to automatically clobber for all asms.
1395
1396 We do this in the new i386 backend to maintain source compatibility
1397 with the old cc0-based compiler. */
1398
1399 #define MD_ASM_CLOBBERS(CLOBBERS) \
1400 do { \
1401 (CLOBBERS) = tree_cons (NULL_TREE, build_string (5, "flags"), (CLOBBERS));\
1402 (CLOBBERS) = tree_cons (NULL_TREE, build_string (4, "fpsr"), (CLOBBERS)); \
1403 (CLOBBERS) = tree_cons (NULL_TREE, build_string (7, "dirflag"), (CLOBBERS)); \
1404 } while (0)
1405 \f
1406 /* Stack layout; function entry, exit and calling. */
1407
1408 /* Define this if pushing a word on the stack
1409 makes the stack pointer a smaller address. */
1410 #define STACK_GROWS_DOWNWARD
1411
1412 /* Define this if the nominal address of the stack frame
1413 is at the high-address end of the local variables;
1414 that is, each additional local variable allocated
1415 goes at a more negative offset in the frame. */
1416 #define FRAME_GROWS_DOWNWARD
1417
1418 /* Offset within stack frame to start allocating local variables at.
1419 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1420 first local allocated. Otherwise, it is the offset to the BEGINNING
1421 of the first local allocated. */
1422 #define STARTING_FRAME_OFFSET 0
1423
1424 /* If we generate an insn to push BYTES bytes,
1425 this says how many the stack pointer really advances by.
1426 On 386 pushw decrements by exactly 2 no matter what the position was.
1427 On the 386 there is no pushb; we use pushw instead, and this
1428 has the effect of rounding up to 2.
1429
1430 For 64bit ABI we round up to 8 bytes.
1431 */
1432
1433 #define PUSH_ROUNDING(BYTES) \
1434 (TARGET_64BIT \
1435 ? (((BYTES) + 7) & (-8)) \
1436 : (((BYTES) + 1) & (-2)))
1437
1438 /* If defined, the maximum amount of space required for outgoing arguments will
1439 be computed and placed into the variable
1440 `current_function_outgoing_args_size'. No space will be pushed onto the
1441 stack for each call; instead, the function prologue should increase the stack
1442 frame size by this amount. */
1443
1444 #define ACCUMULATE_OUTGOING_ARGS TARGET_ACCUMULATE_OUTGOING_ARGS
1445
1446 /* If defined, a C expression whose value is nonzero when we want to use PUSH
1447 instructions to pass outgoing arguments. */
1448
1449 #define PUSH_ARGS (TARGET_PUSH_ARGS && !ACCUMULATE_OUTGOING_ARGS)
1450
1451 /* Offset of first parameter from the argument pointer register value. */
1452 #define FIRST_PARM_OFFSET(FNDECL) 0
1453
1454 /* Define this macro if functions should assume that stack space has been
1455 allocated for arguments even when their values are passed in registers.
1456
1457 The value of this macro is the size, in bytes, of the area reserved for
1458 arguments passed in registers for the function represented by FNDECL.
1459
1460 This space can be allocated by the caller, or be a part of the
1461 machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
1462 which. */
1463 #define REG_PARM_STACK_SPACE(FNDECL) 0
1464
1465 /* Define as a C expression that evaluates to nonzero if we do not know how
1466 to pass TYPE solely in registers. The file expr.h defines a
1467 definition that is usually appropriate, refer to expr.h for additional
1468 documentation. If `REG_PARM_STACK_SPACE' is defined, the argument will be
1469 computed in the stack and then loaded into a register. */
1470 #define MUST_PASS_IN_STACK(MODE,TYPE) \
1471 ((TYPE) != 0 \
1472 && (TREE_CODE (TYPE_SIZE (TYPE)) != INTEGER_CST \
1473 || TREE_ADDRESSABLE (TYPE) \
1474 || ((MODE) == TImode) \
1475 || ((MODE) == BLKmode \
1476 && ! ((TYPE) != 0 && TREE_CODE (TYPE_SIZE (TYPE)) == INTEGER_CST \
1477 && 0 == (int_size_in_bytes (TYPE) \
1478 % (PARM_BOUNDARY / BITS_PER_UNIT))) \
1479 && (FUNCTION_ARG_PADDING (MODE, TYPE) \
1480 == (BYTES_BIG_ENDIAN ? upward : downward)))))
1481
1482 /* Value is the number of bytes of arguments automatically
1483 popped when returning from a subroutine call.
1484 FUNDECL is the declaration node of the function (as a tree),
1485 FUNTYPE is the data type of the function (as a tree),
1486 or for a library call it is an identifier node for the subroutine name.
1487 SIZE is the number of bytes of arguments passed on the stack.
1488
1489 On the 80386, the RTD insn may be used to pop them if the number
1490 of args is fixed, but if the number is variable then the caller
1491 must pop them all. RTD can't be used for library calls now
1492 because the library is compiled with the Unix compiler.
1493 Use of RTD is a selectable option, since it is incompatible with
1494 standard Unix calling sequences. If the option is not selected,
1495 the caller must always pop the args.
1496
1497 The attribute stdcall is equivalent to RTD on a per module basis. */
1498
1499 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \
1500 (ix86_return_pops_args (FUNDECL, FUNTYPE, SIZE))
1501
1502 /* Define how to find the value returned by a function.
1503 VALTYPE is the data type of the value (as a tree).
1504 If the precise function being called is known, FUNC is its FUNCTION_DECL;
1505 otherwise, FUNC is 0. */
1506 #define FUNCTION_VALUE(VALTYPE, FUNC) \
1507 gen_rtx_REG (TYPE_MODE (VALTYPE), \
1508 VALUE_REGNO (TYPE_MODE (VALTYPE)))
1509
1510 /* Define how to find the value returned by a library function
1511 assuming the value has mode MODE. */
1512
1513 #define LIBCALL_VALUE(MODE) \
1514 gen_rtx_REG (MODE, VALUE_REGNO (MODE))
1515
1516 /* Define the size of the result block used for communication between
1517 untyped_call and untyped_return. The block contains a DImode value
1518 followed by the block used by fnsave and frstor. */
1519
1520 #define APPLY_RESULT_SIZE (8+108)
1521
1522 /* 1 if N is a possible register number for function argument passing. */
1523 #define FUNCTION_ARG_REGNO_P(N) ((N) < REGPARM_MAX)
1524
1525 /* Define a data type for recording info about an argument list
1526 during the scan of that argument list. This data type should
1527 hold all necessary information about the function itself
1528 and about the args processed so far, enough to enable macros
1529 such as FUNCTION_ARG to determine where the next arg should go. */
1530
1531 typedef struct ix86_args {
1532 int words; /* # words passed so far */
1533 int nregs; /* # registers available for passing */
1534 int regno; /* next available register number */
1535 int sse_words; /* # sse words passed so far */
1536 int sse_nregs; /* # sse registers available for passing */
1537 int sse_regno; /* next available sse register number */
1538 } CUMULATIVE_ARGS;
1539
1540 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1541 for a call to a function whose data type is FNTYPE.
1542 For a library call, FNTYPE is 0. */
1543
1544 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \
1545 (init_cumulative_args (&CUM, FNTYPE, LIBNAME))
1546
1547 /* Update the data in CUM to advance over an argument
1548 of mode MODE and data type TYPE.
1549 (TYPE is null for libcalls where that information may not be available.) */
1550
1551 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1552 (function_arg_advance (&CUM, MODE, TYPE, NAMED))
1553
1554 /* Define where to put the arguments to a function.
1555 Value is zero to push the argument on the stack,
1556 or a hard register in which to store the argument.
1557
1558 MODE is the argument's machine mode.
1559 TYPE is the data type of the argument (as a tree).
1560 This is null for libcalls where that information may
1561 not be available.
1562 CUM is a variable of type CUMULATIVE_ARGS which gives info about
1563 the preceding args and about the function being called.
1564 NAMED is nonzero if this argument is a named parameter
1565 (otherwise it is an extra parameter matching an ellipsis). */
1566
1567 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1568 (function_arg (&CUM, MODE, TYPE, NAMED))
1569
1570 /* For an arg passed partly in registers and partly in memory,
1571 this is the number of registers used.
1572 For args passed entirely in registers or entirely in memory, zero. */
1573
1574 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
1575
1576 /* If PIC, we cannot make sibling calls to global functions
1577 because the PLT requires %ebx live.
1578 If we are returning floats on the register stack, we cannot make
1579 sibling calls to functions that return floats. (The stack adjust
1580 instruction will wind up after the sibcall jump, and not be executed.) */
1581 #define FUNCTION_OK_FOR_SIBCALL(DECL) \
1582 (DECL \
1583 && (! flag_pic || ! TREE_PUBLIC (DECL)) \
1584 && (! TARGET_FLOAT_RETURNS_IN_80387 \
1585 || ! FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (DECL)))) \
1586 || FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (cfun->decl))))))
1587
1588 /* This macro is invoked at the end of compilation. It is used here to
1589 output code for -fpic that will load the return address into %ebx. */
1590
1591 #undef ASM_FILE_END
1592 #define ASM_FILE_END(FILE) ix86_asm_file_end (FILE)
1593
1594 /* Output assembler code to FILE to increment profiler label # LABELNO
1595 for profiling a function entry. */
1596
1597 #define FUNCTION_PROFILER(FILE, LABELNO) \
1598 { \
1599 if (flag_pic) \
1600 { \
1601 fprintf (FILE, "\tleal\t%sP%d@GOTOFF(%%ebx),%%edx\n", \
1602 LPREFIX, (LABELNO)); \
1603 fprintf (FILE, "\tcall\t*_mcount@GOT(%%ebx)\n"); \
1604 } \
1605 else \
1606 { \
1607 fprintf (FILE, "\tmovl\t$%sP%d,%%edx\n", LPREFIX, (LABELNO)); \
1608 fprintf (FILE, "\tcall\t_mcount\n"); \
1609 } \
1610 }
1611
1612
1613 /* There are three profiling modes for basic blocks available.
1614 The modes are selected at compile time by using the options
1615 -a or -ax of the gnu compiler.
1616 The variable `profile_block_flag' will be set according to the
1617 selected option.
1618
1619 profile_block_flag == 0, no option used:
1620
1621 No profiling done.
1622
1623 profile_block_flag == 1, -a option used.
1624
1625 Count frequency of execution of every basic block.
1626
1627 profile_block_flag == 2, -ax option used.
1628
1629 Generate code to allow several different profiling modes at run time.
1630 Available modes are:
1631 Produce a trace of all basic blocks.
1632 Count frequency of jump instructions executed.
1633 In every mode it is possible to start profiling upon entering
1634 certain functions and to disable profiling of some other functions.
1635
1636 The result of basic-block profiling will be written to a file `bb.out'.
1637 If the -ax option is used parameters for the profiling will be read
1638 from file `bb.in'.
1639
1640 */
1641
1642 /* The following macro shall output assembler code to FILE
1643 to initialize basic-block profiling. */
1644
1645 #undef FUNCTION_BLOCK_PROFILER
1646 #define FUNCTION_BLOCK_PROFILER(FILE, BLOCK_OR_LABEL) \
1647 ix86_output_function_block_profiler (FILE, BLOCK_OR_LABEL)
1648
1649 /* The following macro shall output assembler code to FILE
1650 to increment a counter associated with basic block number BLOCKNO. */
1651
1652 #define BLOCK_PROFILER(FILE, BLOCKNO) \
1653 ix86_output_block_profiler (FILE, BLOCKNO)
1654
1655 /* The following macro shall output rtl for the epilogue
1656 to indicate a return from function during basic-block profiling.
1657
1658 If profiling_block_flag == 2:
1659
1660 Output assembler code to call function `__bb_trace_ret'.
1661
1662 Note that function `__bb_trace_ret' must not change the
1663 machine state, especially the flag register. To grant
1664 this, you must output code to save and restore registers
1665 either in this macro or in the macros MACHINE_STATE_SAVE
1666 and MACHINE_STATE_RESTORE. The last two macros will be
1667 used in the function `__bb_trace_ret', so you must make
1668 sure that the function prologue does not change any
1669 register prior to saving it with MACHINE_STATE_SAVE.
1670
1671 else if profiling_block_flag != 0:
1672
1673 The macro will not be used, so it need not distinguish
1674 these cases.
1675 */
1676
1677 #define FUNCTION_BLOCK_PROFILER_EXIT \
1678 emit_call_insn (gen_call (gen_rtx_MEM (QImode, \
1679 gen_rtx_SYMBOL_REF (VOIDmode, "__bb_trace_ret")), \
1680 const0_rtx, constm1_rtx))
1681
1682 /* The function `__bb_trace_func' is called in every basic block
1683 and is not allowed to change the machine state. Saving (restoring)
1684 the state can either be done in the BLOCK_PROFILER macro,
1685 before calling function (rsp. after returning from function)
1686 `__bb_trace_func', or it can be done inside the function by
1687 defining the macros:
1688
1689 MACHINE_STATE_SAVE(ID)
1690 MACHINE_STATE_RESTORE(ID)
1691
1692 In the latter case care must be taken, that the prologue code
1693 of function `__bb_trace_func' does not already change the
1694 state prior to saving it with MACHINE_STATE_SAVE.
1695
1696 The parameter `ID' is a string identifying a unique macro use.
1697
1698 On the i386 the initialization code at the begin of
1699 function `__bb_trace_func' contains a `sub' instruction
1700 therefore we handle save and restore of the flag register
1701 in the BLOCK_PROFILER macro.
1702
1703 Note that ebx, esi, and edi are callee-save, so we don't have to
1704 preserve them explicitly. */
1705
1706 #define MACHINE_STATE_SAVE(ID) \
1707 do { \
1708 register int eax_ __asm__("eax"); \
1709 register int ecx_ __asm__("ecx"); \
1710 register int edx_ __asm__("edx"); \
1711 __asm__ __volatile__ ("\
1712 push{l} %0\n\t\
1713 push{l} %1\n\t\
1714 push{l} %2" \
1715 : : "r"(eax_), "r"(ecx_), "r"(edx_)); \
1716 } while (0);
1717
1718 #define MACHINE_STATE_RESTORE(ID) \
1719 do { \
1720 register int eax_ __asm__("eax"); \
1721 register int ecx_ __asm__("ecx"); \
1722 register int edx_ __asm__("edx"); \
1723 __asm__ __volatile__ ("\
1724 pop{l} %2\n\t\
1725 pop{l} %1\n\t\
1726 pop{l} %0" \
1727 : "=r"(eax_), "=r"(ecx_), "=r"(edx_)); \
1728 } while (0);
1729
1730 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1731 the stack pointer does not matter. The value is tested only in
1732 functions that have frame pointers.
1733 No definition is equivalent to always zero. */
1734 /* Note on the 386 it might be more efficient not to define this since
1735 we have to restore it ourselves from the frame pointer, in order to
1736 use pop */
1737
1738 #define EXIT_IGNORE_STACK 1
1739
1740 /* Output assembler code for a block containing the constant parts
1741 of a trampoline, leaving space for the variable parts. */
1742
1743 /* On the 386, the trampoline contains two instructions:
1744 mov #STATIC,ecx
1745 jmp FUNCTION
1746 The trampoline is generated entirely at runtime. The operand of JMP
1747 is the address of FUNCTION relative to the instruction following the
1748 JMP (which is 5 bytes long). */
1749
1750 /* Length in units of the trampoline for entering a nested function. */
1751
1752 #define TRAMPOLINE_SIZE (TARGET_64BIT ? 23 : 10)
1753
1754 /* Emit RTL insns to initialize the variable parts of a trampoline.
1755 FNADDR is an RTX for the address of the function's pure code.
1756 CXT is an RTX for the static chain value for the function. */
1757
1758 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1759 x86_initialize_trampoline (TRAMP, FNADDR, CXT)
1760 \f
1761 /* Definitions for register eliminations.
1762
1763 This is an array of structures. Each structure initializes one pair
1764 of eliminable registers. The "from" register number is given first,
1765 followed by "to". Eliminations of the same "from" register are listed
1766 in order of preference.
1767
1768 There are two registers that can always be eliminated on the i386.
1769 The frame pointer and the arg pointer can be replaced by either the
1770 hard frame pointer or to the stack pointer, depending upon the
1771 circumstances. The hard frame pointer is not used before reload and
1772 so it is not eligible for elimination. */
1773
1774 #define ELIMINABLE_REGS \
1775 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1776 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
1777 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
1778 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} \
1779
1780 /* Given FROM and TO register numbers, say whether this elimination is
1781 allowed. Frame pointer elimination is automatically handled.
1782
1783 All other eliminations are valid. */
1784
1785 #define CAN_ELIMINATE(FROM, TO) \
1786 ((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
1787
1788 /* Define the offset between two registers, one to be eliminated, and the other
1789 its replacement, at the start of a routine. */
1790
1791 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1792 (OFFSET) = ix86_initial_elimination_offset (FROM, TO)
1793 \f
1794 /* Addressing modes, and classification of registers for them. */
1795
1796 /* #define HAVE_POST_INCREMENT 0 */
1797 /* #define HAVE_POST_DECREMENT 0 */
1798
1799 /* #define HAVE_PRE_DECREMENT 0 */
1800 /* #define HAVE_PRE_INCREMENT 0 */
1801
1802 /* Macros to check register numbers against specific register classes. */
1803
1804 /* These assume that REGNO is a hard or pseudo reg number.
1805 They give nonzero only if REGNO is a hard reg of the suitable class
1806 or a pseudo reg currently allocated to a suitable hard reg.
1807 Since they use reg_renumber, they are safe only once reg_renumber
1808 has been allocated, which happens in local-alloc.c. */
1809
1810 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1811 ((REGNO) < STACK_POINTER_REGNUM \
1812 || (REGNO >= FIRST_REX_INT_REG \
1813 && (REGNO) <= LAST_REX_INT_REG) \
1814 || ((unsigned) reg_renumber[REGNO] >= FIRST_REX_INT_REG \
1815 && (unsigned) reg_renumber[REGNO] <= LAST_REX_INT_REG) \
1816 || (unsigned) reg_renumber[REGNO] < STACK_POINTER_REGNUM)
1817
1818 #define REGNO_OK_FOR_BASE_P(REGNO) \
1819 ((REGNO) <= STACK_POINTER_REGNUM \
1820 || (REGNO) == ARG_POINTER_REGNUM \
1821 || (REGNO) == FRAME_POINTER_REGNUM \
1822 || (REGNO >= FIRST_REX_INT_REG \
1823 && (REGNO) <= LAST_REX_INT_REG) \
1824 || ((unsigned) reg_renumber[REGNO] >= FIRST_REX_INT_REG \
1825 && (unsigned) reg_renumber[REGNO] <= LAST_REX_INT_REG) \
1826 || (unsigned) reg_renumber[REGNO] <= STACK_POINTER_REGNUM)
1827
1828 #define REGNO_OK_FOR_SIREG_P(REGNO) ((REGNO) == 4 || reg_renumber[REGNO] == 4)
1829 #define REGNO_OK_FOR_DIREG_P(REGNO) ((REGNO) == 5 || reg_renumber[REGNO] == 5)
1830
1831 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1832 and check its validity for a certain class.
1833 We have two alternate definitions for each of them.
1834 The usual definition accepts all pseudo regs; the other rejects
1835 them unless they have been allocated suitable hard regs.
1836 The symbol REG_OK_STRICT causes the latter definition to be used.
1837
1838 Most source files want to accept pseudo regs in the hope that
1839 they will get allocated to the class that the insn wants them to be in.
1840 Source files for reload pass need to be strict.
1841 After reload, it makes no difference, since pseudo regs have
1842 been eliminated by then. */
1843
1844
1845 /* Non strict versions, pseudos are ok */
1846 #define REG_OK_FOR_INDEX_NONSTRICT_P(X) \
1847 (REGNO (X) < STACK_POINTER_REGNUM \
1848 || (REGNO (X) >= FIRST_REX_INT_REG \
1849 && REGNO (X) <= LAST_REX_INT_REG) \
1850 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1851
1852 #define REG_OK_FOR_BASE_NONSTRICT_P(X) \
1853 (REGNO (X) <= STACK_POINTER_REGNUM \
1854 || REGNO (X) == ARG_POINTER_REGNUM \
1855 || REGNO (X) == FRAME_POINTER_REGNUM \
1856 || (REGNO (X) >= FIRST_REX_INT_REG \
1857 && REGNO (X) <= LAST_REX_INT_REG) \
1858 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1859
1860 /* Strict versions, hard registers only */
1861 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1862 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
1863
1864 #ifndef REG_OK_STRICT
1865 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_NONSTRICT_P(X)
1866 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NONSTRICT_P(X)
1867
1868 #else
1869 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_INDEX_STRICT_P(X)
1870 #define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P(X)
1871 #endif
1872
1873 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1874 that is a valid memory address for an instruction.
1875 The MODE argument is the machine mode for the MEM expression
1876 that wants to use this address.
1877
1878 The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
1879 except for CONSTANT_ADDRESS_P which is usually machine-independent.
1880
1881 See legitimize_pic_address in i386.c for details as to what
1882 constitutes a legitimate address when -fpic is used. */
1883
1884 #define MAX_REGS_PER_ADDRESS 2
1885
1886 #define CONSTANT_ADDRESS_P(X) \
1887 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
1888 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \
1889 || GET_CODE (X) == CONST_DOUBLE)
1890
1891 /* Nonzero if the constant value X is a legitimate general operand.
1892 It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1893
1894 #define LEGITIMATE_CONSTANT_P(X) 1
1895
1896 #ifdef REG_OK_STRICT
1897 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1898 { \
1899 if (legitimate_address_p (MODE, X, 1)) \
1900 goto ADDR; \
1901 }
1902
1903 #else
1904 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
1905 { \
1906 if (legitimate_address_p (MODE, X, 0)) \
1907 goto ADDR; \
1908 }
1909
1910 #endif
1911
1912 /* If defined, a C expression to determine the base term of address X.
1913 This macro is used in only one place: `find_base_term' in alias.c.
1914
1915 It is always safe for this macro to not be defined. It exists so
1916 that alias analysis can understand machine-dependent addresses.
1917
1918 The typical use of this macro is to handle addresses containing
1919 a label_ref or symbol_ref within an UNSPEC. */
1920
1921 #define FIND_BASE_TERM(X) ix86_find_base_term (x)
1922
1923 /* Try machine-dependent ways of modifying an illegitimate address
1924 to be legitimate. If we find one, return the new, valid address.
1925 This macro is used in only one place: `memory_address' in explow.c.
1926
1927 OLDX is the address as it was before break_out_memory_refs was called.
1928 In some cases it is useful to look at this to decide what needs to be done.
1929
1930 MODE and WIN are passed so that this macro can use
1931 GO_IF_LEGITIMATE_ADDRESS.
1932
1933 It is always safe for this macro to do nothing. It exists to recognize
1934 opportunities to optimize the output.
1935
1936 For the 80386, we handle X+REG by loading X into a register R and
1937 using R+REG. R will go in a general reg and indexing will be used.
1938 However, if REG is a broken-out memory address or multiplication,
1939 nothing needs to be done because REG can certainly go in a general reg.
1940
1941 When -fpic is used, special handling is needed for symbolic references.
1942 See comments by legitimize_pic_address in i386.c for details. */
1943
1944 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
1945 { \
1946 (X) = legitimize_address (X, OLDX, MODE); \
1947 if (memory_address_p (MODE, X)) \
1948 goto WIN; \
1949 }
1950
1951 #define REWRITE_ADDRESS(x) rewrite_address(x)
1952
1953 /* Nonzero if the constant value X is a legitimate general operand
1954 when generating PIC code. It is given that flag_pic is on and
1955 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
1956
1957 #define LEGITIMATE_PIC_OPERAND_P(X) \
1958 (! SYMBOLIC_CONST (X) \
1959 || legitimate_pic_address_disp_p (X))
1960
1961 #define SYMBOLIC_CONST(X) \
1962 (GET_CODE (X) == SYMBOL_REF \
1963 || GET_CODE (X) == LABEL_REF \
1964 || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
1965
1966 /* Go to LABEL if ADDR (a legitimate address expression)
1967 has an effect that depends on the machine mode it is used for.
1968 On the 80386, only postdecrement and postincrement address depend thus
1969 (the amount of decrement or increment being the length of the operand). */
1970 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
1971 if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL
1972 \f
1973 /* Codes for all the SSE/MMX builtins. */
1974 enum ix86_builtins
1975 {
1976 IX86_BUILTIN_ADDPS,
1977 IX86_BUILTIN_ADDSS,
1978 IX86_BUILTIN_DIVPS,
1979 IX86_BUILTIN_DIVSS,
1980 IX86_BUILTIN_MULPS,
1981 IX86_BUILTIN_MULSS,
1982 IX86_BUILTIN_SUBPS,
1983 IX86_BUILTIN_SUBSS,
1984
1985 IX86_BUILTIN_CMPEQPS,
1986 IX86_BUILTIN_CMPLTPS,
1987 IX86_BUILTIN_CMPLEPS,
1988 IX86_BUILTIN_CMPGTPS,
1989 IX86_BUILTIN_CMPGEPS,
1990 IX86_BUILTIN_CMPNEQPS,
1991 IX86_BUILTIN_CMPNLTPS,
1992 IX86_BUILTIN_CMPNLEPS,
1993 IX86_BUILTIN_CMPNGTPS,
1994 IX86_BUILTIN_CMPNGEPS,
1995 IX86_BUILTIN_CMPORDPS,
1996 IX86_BUILTIN_CMPUNORDPS,
1997 IX86_BUILTIN_CMPNEPS,
1998 IX86_BUILTIN_CMPEQSS,
1999 IX86_BUILTIN_CMPLTSS,
2000 IX86_BUILTIN_CMPLESS,
2001 IX86_BUILTIN_CMPGTSS,
2002 IX86_BUILTIN_CMPGESS,
2003 IX86_BUILTIN_CMPNEQSS,
2004 IX86_BUILTIN_CMPNLTSS,
2005 IX86_BUILTIN_CMPNLESS,
2006 IX86_BUILTIN_CMPNGTSS,
2007 IX86_BUILTIN_CMPNGESS,
2008 IX86_BUILTIN_CMPORDSS,
2009 IX86_BUILTIN_CMPUNORDSS,
2010 IX86_BUILTIN_CMPNESS,
2011
2012 IX86_BUILTIN_COMIEQSS,
2013 IX86_BUILTIN_COMILTSS,
2014 IX86_BUILTIN_COMILESS,
2015 IX86_BUILTIN_COMIGTSS,
2016 IX86_BUILTIN_COMIGESS,
2017 IX86_BUILTIN_COMINEQSS,
2018 IX86_BUILTIN_UCOMIEQSS,
2019 IX86_BUILTIN_UCOMILTSS,
2020 IX86_BUILTIN_UCOMILESS,
2021 IX86_BUILTIN_UCOMIGTSS,
2022 IX86_BUILTIN_UCOMIGESS,
2023 IX86_BUILTIN_UCOMINEQSS,
2024
2025 IX86_BUILTIN_CVTPI2PS,
2026 IX86_BUILTIN_CVTPS2PI,
2027 IX86_BUILTIN_CVTSI2SS,
2028 IX86_BUILTIN_CVTSS2SI,
2029 IX86_BUILTIN_CVTTPS2PI,
2030 IX86_BUILTIN_CVTTSS2SI,
2031 IX86_BUILTIN_M_FROM_INT,
2032 IX86_BUILTIN_M_TO_INT,
2033
2034 IX86_BUILTIN_MAXPS,
2035 IX86_BUILTIN_MAXSS,
2036 IX86_BUILTIN_MINPS,
2037 IX86_BUILTIN_MINSS,
2038
2039 IX86_BUILTIN_LOADAPS,
2040 IX86_BUILTIN_LOADUPS,
2041 IX86_BUILTIN_STOREAPS,
2042 IX86_BUILTIN_STOREUPS,
2043 IX86_BUILTIN_LOADSS,
2044 IX86_BUILTIN_STORESS,
2045 IX86_BUILTIN_MOVSS,
2046
2047 IX86_BUILTIN_MOVHLPS,
2048 IX86_BUILTIN_MOVLHPS,
2049 IX86_BUILTIN_LOADHPS,
2050 IX86_BUILTIN_LOADLPS,
2051 IX86_BUILTIN_STOREHPS,
2052 IX86_BUILTIN_STORELPS,
2053
2054 IX86_BUILTIN_MASKMOVQ,
2055 IX86_BUILTIN_MOVMSKPS,
2056 IX86_BUILTIN_PMOVMSKB,
2057
2058 IX86_BUILTIN_MOVNTPS,
2059 IX86_BUILTIN_MOVNTQ,
2060
2061 IX86_BUILTIN_PACKSSWB,
2062 IX86_BUILTIN_PACKSSDW,
2063 IX86_BUILTIN_PACKUSWB,
2064
2065 IX86_BUILTIN_PADDB,
2066 IX86_BUILTIN_PADDW,
2067 IX86_BUILTIN_PADDD,
2068 IX86_BUILTIN_PADDSB,
2069 IX86_BUILTIN_PADDSW,
2070 IX86_BUILTIN_PADDUSB,
2071 IX86_BUILTIN_PADDUSW,
2072 IX86_BUILTIN_PSUBB,
2073 IX86_BUILTIN_PSUBW,
2074 IX86_BUILTIN_PSUBD,
2075 IX86_BUILTIN_PSUBSB,
2076 IX86_BUILTIN_PSUBSW,
2077 IX86_BUILTIN_PSUBUSB,
2078 IX86_BUILTIN_PSUBUSW,
2079
2080 IX86_BUILTIN_PAND,
2081 IX86_BUILTIN_PANDN,
2082 IX86_BUILTIN_POR,
2083 IX86_BUILTIN_PXOR,
2084
2085 IX86_BUILTIN_PAVGB,
2086 IX86_BUILTIN_PAVGW,
2087
2088 IX86_BUILTIN_PCMPEQB,
2089 IX86_BUILTIN_PCMPEQW,
2090 IX86_BUILTIN_PCMPEQD,
2091 IX86_BUILTIN_PCMPGTB,
2092 IX86_BUILTIN_PCMPGTW,
2093 IX86_BUILTIN_PCMPGTD,
2094
2095 IX86_BUILTIN_PEXTRW,
2096 IX86_BUILTIN_PINSRW,
2097
2098 IX86_BUILTIN_PMADDWD,
2099
2100 IX86_BUILTIN_PMAXSW,
2101 IX86_BUILTIN_PMAXUB,
2102 IX86_BUILTIN_PMINSW,
2103 IX86_BUILTIN_PMINUB,
2104
2105 IX86_BUILTIN_PMULHUW,
2106 IX86_BUILTIN_PMULHW,
2107 IX86_BUILTIN_PMULLW,
2108
2109 IX86_BUILTIN_PSADBW,
2110 IX86_BUILTIN_PSHUFW,
2111
2112 IX86_BUILTIN_PSLLW,
2113 IX86_BUILTIN_PSLLD,
2114 IX86_BUILTIN_PSLLQ,
2115 IX86_BUILTIN_PSRAW,
2116 IX86_BUILTIN_PSRAD,
2117 IX86_BUILTIN_PSRLW,
2118 IX86_BUILTIN_PSRLD,
2119 IX86_BUILTIN_PSRLQ,
2120 IX86_BUILTIN_PSLLWI,
2121 IX86_BUILTIN_PSLLDI,
2122 IX86_BUILTIN_PSLLQI,
2123 IX86_BUILTIN_PSRAWI,
2124 IX86_BUILTIN_PSRADI,
2125 IX86_BUILTIN_PSRLWI,
2126 IX86_BUILTIN_PSRLDI,
2127 IX86_BUILTIN_PSRLQI,
2128
2129 IX86_BUILTIN_PUNPCKHBW,
2130 IX86_BUILTIN_PUNPCKHWD,
2131 IX86_BUILTIN_PUNPCKHDQ,
2132 IX86_BUILTIN_PUNPCKLBW,
2133 IX86_BUILTIN_PUNPCKLWD,
2134 IX86_BUILTIN_PUNPCKLDQ,
2135
2136 IX86_BUILTIN_SHUFPS,
2137
2138 IX86_BUILTIN_RCPPS,
2139 IX86_BUILTIN_RCPSS,
2140 IX86_BUILTIN_RSQRTPS,
2141 IX86_BUILTIN_RSQRTSS,
2142 IX86_BUILTIN_SQRTPS,
2143 IX86_BUILTIN_SQRTSS,
2144
2145 IX86_BUILTIN_UNPCKHPS,
2146 IX86_BUILTIN_UNPCKLPS,
2147
2148 IX86_BUILTIN_ANDPS,
2149 IX86_BUILTIN_ANDNPS,
2150 IX86_BUILTIN_ORPS,
2151 IX86_BUILTIN_XORPS,
2152
2153 IX86_BUILTIN_EMMS,
2154 IX86_BUILTIN_LDMXCSR,
2155 IX86_BUILTIN_STMXCSR,
2156 IX86_BUILTIN_SFENCE,
2157 IX86_BUILTIN_PREFETCH,
2158
2159 /* Composite builtins, expand to more than one insn. */
2160 IX86_BUILTIN_SETPS1,
2161 IX86_BUILTIN_SETPS,
2162 IX86_BUILTIN_CLRPS,
2163 IX86_BUILTIN_SETRPS,
2164 IX86_BUILTIN_LOADPS1,
2165 IX86_BUILTIN_LOADRPS,
2166 IX86_BUILTIN_STOREPS1,
2167 IX86_BUILTIN_STORERPS,
2168
2169 IX86_BUILTIN_MMX_ZERO,
2170
2171 IX86_BUILTIN_MAX
2172 };
2173
2174 /* Initialize the target-specific builtin functions. Only do something
2175 if TARGET_MMX is nonzero; we take care in ix86_init_builtins not to
2176 enable any SSE builtins if TARGET_SSE is zero. */
2177 #define MD_INIT_BUILTINS \
2178 do \
2179 { \
2180 if (TARGET_MMX) \
2181 ix86_init_builtins (); \
2182 } \
2183 while (0)
2184
2185 /* Expand a target-specific builtin function. */
2186 #define MD_EXPAND_BUILTIN(EXP, TARGET, SUBTARGET, MODE, IGNORE) \
2187 ix86_expand_builtin (EXP, TARGET, SUBTARGET, MODE, IGNORE)
2188 \f
2189 /* Define this macro if references to a symbol must be treated
2190 differently depending on something about the variable or
2191 function named by the symbol (such as what section it is in).
2192
2193 On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
2194 so that we may access it directly in the GOT. */
2195
2196 #define ENCODE_SECTION_INFO(DECL) \
2197 do \
2198 { \
2199 if (flag_pic) \
2200 { \
2201 rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
2202 ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \
2203 \
2204 if (GET_CODE (rtl) == MEM) \
2205 { \
2206 if (TARGET_DEBUG_ADDR \
2207 && TREE_CODE_CLASS (TREE_CODE (DECL)) == 'd') \
2208 { \
2209 fprintf (stderr, "Encode %s, public = %d\n", \
2210 IDENTIFIER_POINTER (DECL_NAME (DECL)), \
2211 TREE_PUBLIC (DECL)); \
2212 } \
2213 \
2214 SYMBOL_REF_FLAG (XEXP (rtl, 0)) \
2215 = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \
2216 || ! TREE_PUBLIC (DECL)); \
2217 } \
2218 } \
2219 } \
2220 while (0)
2221
2222 /* The `FINALIZE_PIC' macro serves as a hook to emit these special
2223 codes once the function is being compiled into assembly code, but
2224 not before. (It is not done before, because in the case of
2225 compiling an inline function, it would lead to multiple PIC
2226 prologues being included in functions which used inline functions
2227 and were compiled to assembly language.) */
2228
2229 #define FINALIZE_PIC \
2230 do \
2231 { \
2232 current_function_uses_pic_offset_table |= profile_flag | profile_block_flag; \
2233 } \
2234 while (0)
2235
2236 \f
2237 /* If defined, a C expression whose value is nonzero if IDENTIFIER
2238 with arguments ARGS is a valid machine specific attribute for DECL.
2239 The attributes in ATTRIBUTES have previously been assigned to DECL. */
2240
2241 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, NAME, ARGS) \
2242 (ix86_valid_decl_attribute_p (DECL, ATTRIBUTES, NAME, ARGS))
2243
2244 /* If defined, a C expression whose value is nonzero if IDENTIFIER
2245 with arguments ARGS is a valid machine specific attribute for TYPE.
2246 The attributes in ATTRIBUTES have previously been assigned to TYPE. */
2247
2248 #define VALID_MACHINE_TYPE_ATTRIBUTE(TYPE, ATTRIBUTES, NAME, ARGS) \
2249 (ix86_valid_type_attribute_p (TYPE, ATTRIBUTES, NAME, ARGS))
2250
2251 /* If defined, a C expression whose value is zero if the attributes on
2252 TYPE1 and TYPE2 are incompatible, one if they are compatible, and
2253 two if they are nearly compatible (which causes a warning to be
2254 generated). */
2255
2256 #define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \
2257 (ix86_comp_type_attributes (TYPE1, TYPE2))
2258
2259 /* If defined, a C statement that assigns default attributes to newly
2260 defined TYPE. */
2261
2262 /* #define SET_DEFAULT_TYPE_ATTRIBUTES (TYPE) */
2263
2264 /* Max number of args passed in registers. If this is more than 3, we will
2265 have problems with ebx (register #4), since it is a caller save register and
2266 is also used as the pic register in ELF. So for now, don't allow more than
2267 3 registers to be passed in registers. */
2268
2269 #define REGPARM_MAX (TARGET_64BIT ? 6 : 3)
2270
2271 #define SSE_REGPARM_MAX (TARGET_64BIT ? 16 : 0)
2272
2273 \f
2274 /* Specify the machine mode that this machine uses
2275 for the index in the tablejump instruction. */
2276 #define CASE_VECTOR_MODE Pmode
2277
2278 /* Define as C expression which evaluates to nonzero if the tablejump
2279 instruction expects the table to contain offsets from the address of the
2280 table.
2281 Do not define this if the table should contain absolute addresses. */
2282 /* #define CASE_VECTOR_PC_RELATIVE 1 */
2283
2284 /* Specify the tree operation to be used to convert reals to integers.
2285 This should be changed to take advantage of fist --wfs ??
2286 */
2287 #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
2288
2289 /* This is the kind of divide that is easiest to do in the general case. */
2290 #define EASY_DIV_EXPR TRUNC_DIV_EXPR
2291
2292 /* Define this as 1 if `char' should by default be signed; else as 0. */
2293 #define DEFAULT_SIGNED_CHAR 1
2294
2295 /* Max number of bytes we can move from memory to memory
2296 in one reasonably fast instruction. */
2297 #define MOVE_MAX 16
2298
2299 /* MOVE_MAX_PIECES is the number of bytes at a time which we can
2300 move efficiently, as opposed to MOVE_MAX which is the maximum
2301 number of bytes we can move with a single instruction. */
2302 #define MOVE_MAX_PIECES (TARGET_64BIT ? 8 : 4)
2303
2304 /* If a memory-to-memory move would take MOVE_RATIO or more simple
2305 move-instruction pairs, we will do a movstr or libcall instead.
2306 Increasing the value will always make code faster, but eventually
2307 incurs high cost in increased code size.
2308
2309 If you don't define this, a reasonable default is used. */
2310
2311 #define MOVE_RATIO (optimize_size ? 3 : ix86_cost->move_ratio)
2312
2313 /* Define if shifts truncate the shift count
2314 which implies one can omit a sign-extension or zero-extension
2315 of a shift count. */
2316 /* On i386, shifts do truncate the count. But bit opcodes don't. */
2317
2318 /* #define SHIFT_COUNT_TRUNCATED */
2319
2320 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2321 is done just by pretending it is already truncated. */
2322 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2323
2324 /* We assume that the store-condition-codes instructions store 0 for false
2325 and some other value for true. This is the value stored for true. */
2326
2327 #define STORE_FLAG_VALUE 1
2328
2329 /* When a prototype says `char' or `short', really pass an `int'.
2330 (The 386 can't easily push less than an int.) */
2331
2332 #define PROMOTE_PROTOTYPES 1
2333
2334 /* A macro to update M and UNSIGNEDP when an object whose type is
2335 TYPE and which has the specified mode and signedness is to be
2336 stored in a register. This macro is only called when TYPE is a
2337 scalar type.
2338
2339 On i386 it is sometimes usefull to promote HImode and QImode
2340 quantities to SImode. The choice depends on target type. */
2341
2342 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
2343 if (((MODE) == HImode && TARGET_PROMOTE_HI_REGS) \
2344 || ((MODE) == QImode && TARGET_PROMOTE_QI_REGS)) \
2345 (MODE) = SImode;
2346
2347 /* Specify the machine mode that pointers have.
2348 After generation of rtl, the compiler makes no further distinction
2349 between pointers and any other objects of this machine mode. */
2350 #define Pmode (TARGET_64BIT ? DImode : SImode)
2351
2352 /* A function address in a call instruction
2353 is a byte address (for indexing purposes)
2354 so give the MEM rtx a byte's mode. */
2355 #define FUNCTION_MODE QImode
2356 \f
2357 /* A part of a C `switch' statement that describes the relative costs
2358 of constant RTL expressions. It must contain `case' labels for
2359 expression codes `const_int', `const', `symbol_ref', `label_ref'
2360 and `const_double'. Each case must ultimately reach a `return'
2361 statement to return the relative cost of the use of that kind of
2362 constant value in an expression. The cost may depend on the
2363 precise value of the constant, which is available for examination
2364 in X, and the rtx code of the expression in which it is contained,
2365 found in OUTER_CODE.
2366
2367 CODE is the expression code--redundant, since it can be obtained
2368 with `GET_CODE (X)'. */
2369
2370 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
2371 case CONST_INT: \
2372 return (unsigned) INTVAL (RTX) < 256 ? 0 : 1; \
2373 case CONST: \
2374 case LABEL_REF: \
2375 case SYMBOL_REF: \
2376 return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 1; \
2377 \
2378 case CONST_DOUBLE: \
2379 { \
2380 int code; \
2381 if (GET_MODE (RTX) == VOIDmode) \
2382 return 2; \
2383 \
2384 code = standard_80387_constant_p (RTX); \
2385 return code == 1 ? 0 : \
2386 code == 2 ? 1 : \
2387 2; \
2388 }
2389
2390 /* Delete the definition here when TOPLEVEL_COSTS_N_INSNS gets added to cse.c */
2391 #define TOPLEVEL_COSTS_N_INSNS(N) \
2392 do { total = COSTS_N_INSNS (N); goto egress_rtx_costs; } while (0)
2393
2394 /* Like `CONST_COSTS' but applies to nonconstant RTL expressions.
2395 This can be used, for example, to indicate how costly a multiply
2396 instruction is. In writing this macro, you can use the construct
2397 `COSTS_N_INSNS (N)' to specify a cost equal to N fast
2398 instructions. OUTER_CODE is the code of the expression in which X
2399 is contained.
2400
2401 This macro is optional; do not define it if the default cost
2402 assumptions are adequate for the target machine. */
2403
2404 #define RTX_COSTS(X,CODE,OUTER_CODE) \
2405 case ASHIFT: \
2406 if (GET_CODE (XEXP (X, 1)) == CONST_INT \
2407 && GET_MODE (XEXP (X, 0)) == SImode) \
2408 { \
2409 HOST_WIDE_INT value = INTVAL (XEXP (X, 1)); \
2410 if (value == 1) \
2411 TOPLEVEL_COSTS_N_INSNS (ix86_cost->add); \
2412 if (value == 2 || value == 3) \
2413 TOPLEVEL_COSTS_N_INSNS (ix86_cost->lea); \
2414 } \
2415 /* fall through */ \
2416 \
2417 case ROTATE: \
2418 case ASHIFTRT: \
2419 case LSHIFTRT: \
2420 case ROTATERT: \
2421 if (GET_MODE (XEXP (X, 0)) == DImode) \
2422 { \
2423 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
2424 { \
2425 if (INTVAL (XEXP (X, 1)) > 32) \
2426 TOPLEVEL_COSTS_N_INSNS(ix86_cost->shift_const + 2); \
2427 else \
2428 TOPLEVEL_COSTS_N_INSNS(ix86_cost->shift_const * 2); \
2429 } \
2430 else \
2431 { \
2432 if (GET_CODE (XEXP (X, 1)) == AND) \
2433 TOPLEVEL_COSTS_N_INSNS(ix86_cost->shift_var * 2); \
2434 else \
2435 TOPLEVEL_COSTS_N_INSNS(ix86_cost->shift_var * 6 + 2); \
2436 } \
2437 } \
2438 else \
2439 { \
2440 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
2441 TOPLEVEL_COSTS_N_INSNS (ix86_cost->shift_const); \
2442 else \
2443 TOPLEVEL_COSTS_N_INSNS (ix86_cost->shift_var); \
2444 } \
2445 break; \
2446 \
2447 case MULT: \
2448 if (GET_CODE (XEXP (X, 1)) == CONST_INT) \
2449 { \
2450 unsigned HOST_WIDE_INT value = INTVAL (XEXP (X, 1)); \
2451 int nbits = 0; \
2452 \
2453 while (value != 0) \
2454 { \
2455 nbits++; \
2456 value >>= 1; \
2457 } \
2458 \
2459 TOPLEVEL_COSTS_N_INSNS (ix86_cost->mult_init \
2460 + nbits * ix86_cost->mult_bit); \
2461 } \
2462 else /* This is arbitrary */ \
2463 TOPLEVEL_COSTS_N_INSNS (ix86_cost->mult_init \
2464 + 7 * ix86_cost->mult_bit); \
2465 \
2466 case DIV: \
2467 case UDIV: \
2468 case MOD: \
2469 case UMOD: \
2470 TOPLEVEL_COSTS_N_INSNS (ix86_cost->divide); \
2471 \
2472 case PLUS: \
2473 if (GET_CODE (XEXP (X, 0)) == PLUS \
2474 && GET_CODE (XEXP (XEXP (X, 0), 0)) == MULT \
2475 && GET_CODE (XEXP (XEXP (XEXP (X, 0), 0), 1)) == CONST_INT \
2476 && GET_CODE (XEXP (X, 1)) == CONST_INT) \
2477 { \
2478 HOST_WIDE_INT val = INTVAL (XEXP (XEXP (XEXP (X, 0), 0), 1)); \
2479 if (val == 2 || val == 4 || val == 8) \
2480 { \
2481 return (COSTS_N_INSNS (ix86_cost->lea) \
2482 + rtx_cost (XEXP (XEXP (X, 0), 1), OUTER_CODE) \
2483 + rtx_cost (XEXP (XEXP (XEXP (X, 0), 0), 0), OUTER_CODE) \
2484 + rtx_cost (XEXP (X, 1), OUTER_CODE)); \
2485 } \
2486 } \
2487 else if (GET_CODE (XEXP (X, 0)) == MULT \
2488 && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT) \
2489 { \
2490 HOST_WIDE_INT val = INTVAL (XEXP (XEXP (X, 0), 1)); \
2491 if (val == 2 || val == 4 || val == 8) \
2492 { \
2493 return (COSTS_N_INSNS (ix86_cost->lea) \
2494 + rtx_cost (XEXP (XEXP (X, 0), 0), OUTER_CODE) \
2495 + rtx_cost (XEXP (X, 1), OUTER_CODE)); \
2496 } \
2497 } \
2498 else if (GET_CODE (XEXP (X, 0)) == PLUS) \
2499 { \
2500 return (COSTS_N_INSNS (ix86_cost->lea) \
2501 + rtx_cost (XEXP (XEXP (X, 0), 0), OUTER_CODE) \
2502 + rtx_cost (XEXP (XEXP (X, 0), 1), OUTER_CODE) \
2503 + rtx_cost (XEXP (X, 1), OUTER_CODE)); \
2504 } \
2505 \
2506 /* fall through */ \
2507 case AND: \
2508 case IOR: \
2509 case XOR: \
2510 case MINUS: \
2511 if (GET_MODE (X) == DImode) \
2512 return (COSTS_N_INSNS (ix86_cost->add) * 2 \
2513 + (rtx_cost (XEXP (X, 0), OUTER_CODE) \
2514 << (GET_MODE (XEXP (X, 0)) != DImode)) \
2515 + (rtx_cost (XEXP (X, 1), OUTER_CODE) \
2516 << (GET_MODE (XEXP (X, 1)) != DImode))); \
2517 \
2518 /* fall through */ \
2519 case NEG: \
2520 case NOT: \
2521 if (GET_MODE (X) == DImode) \
2522 TOPLEVEL_COSTS_N_INSNS (ix86_cost->add * 2); \
2523 TOPLEVEL_COSTS_N_INSNS (ix86_cost->add); \
2524 \
2525 egress_rtx_costs: \
2526 break;
2527
2528
2529 /* An expression giving the cost of an addressing mode that contains
2530 ADDRESS. If not defined, the cost is computed from the ADDRESS
2531 expression and the `CONST_COSTS' values.
2532
2533 For most CISC machines, the default cost is a good approximation
2534 of the true cost of the addressing mode. However, on RISC
2535 machines, all instructions normally have the same length and
2536 execution time. Hence all addresses will have equal costs.
2537
2538 In cases where more than one form of an address is known, the form
2539 with the lowest cost will be used. If multiple forms have the
2540 same, lowest, cost, the one that is the most complex will be used.
2541
2542 For example, suppose an address that is equal to the sum of a
2543 register and a constant is used twice in the same basic block.
2544 When this macro is not defined, the address will be computed in a
2545 register and memory references will be indirect through that
2546 register. On machines where the cost of the addressing mode
2547 containing the sum is no higher than that of a simple indirect
2548 reference, this will produce an additional instruction and
2549 possibly require an additional register. Proper specification of
2550 this macro eliminates this overhead for such machines.
2551
2552 Similar use of this macro is made in strength reduction of loops.
2553
2554 ADDRESS need not be valid as an address. In such a case, the cost
2555 is not relevant and can be any value; invalid addresses need not be
2556 assigned a different cost.
2557
2558 On machines where an address involving more than one register is as
2559 cheap as an address computation involving only one register,
2560 defining `ADDRESS_COST' to reflect this can cause two registers to
2561 be live over a region of code where only one would have been if
2562 `ADDRESS_COST' were not defined in that manner. This effect should
2563 be considered in the definition of this macro. Equivalent costs
2564 should probably only be given to addresses with different numbers
2565 of registers on machines with lots of registers.
2566
2567 This macro will normally either not be defined or be defined as a
2568 constant.
2569
2570 For i386, it is better to use a complex address than let gcc copy
2571 the address into a reg and make a new pseudo. But not if the address
2572 requires to two regs - that would mean more pseudos with longer
2573 lifetimes. */
2574
2575 #define ADDRESS_COST(RTX) \
2576 ix86_address_cost (RTX)
2577
2578 /* A C expression for the cost of moving data from a register in class FROM to
2579 one in class TO. The classes are expressed using the enumeration values
2580 such as `GENERAL_REGS'. A value of 2 is the default; other values are
2581 interpreted relative to that.
2582
2583 It is not required that the cost always equal 2 when FROM is the same as TO;
2584 on some machines it is expensive to move between registers if they are not
2585 general registers. */
2586
2587 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
2588 ix86_register_move_cost (MODE, CLASS1, CLASS2)
2589
2590 /* A C expression for the cost of moving data of mode M between a
2591 register and memory. A value of 2 is the default; this cost is
2592 relative to those in `REGISTER_MOVE_COST'.
2593
2594 If moving between registers and memory is more expensive than
2595 between two registers, you should define this macro to express the
2596 relative cost. */
2597
2598 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \
2599 ix86_memory_move_cost (MODE, CLASS, IN)
2600
2601 /* A C expression for the cost of a branch instruction. A value of 1
2602 is the default; other values are interpreted relative to that. */
2603
2604 #define BRANCH_COST ix86_branch_cost
2605
2606 /* Define this macro as a C expression which is nonzero if accessing
2607 less than a word of memory (i.e. a `char' or a `short') is no
2608 faster than accessing a word of memory, i.e., if such access
2609 require more than one instruction or if there is no difference in
2610 cost between byte and (aligned) word loads.
2611
2612 When this macro is not defined, the compiler will access a field by
2613 finding the smallest containing object; when it is defined, a
2614 fullword load will be used if alignment permits. Unless bytes
2615 accesses are faster than word accesses, using word accesses is
2616 preferable since it may eliminate subsequent memory access if
2617 subsequent accesses occur to other fields in the same word of the
2618 structure, but to different bytes. */
2619
2620 #define SLOW_BYTE_ACCESS 0
2621
2622 /* Nonzero if access to memory by shorts is slow and undesirable. */
2623 #define SLOW_SHORT_ACCESS 0
2624
2625 /* Define this macro if zero-extension (of a `char' or `short' to an
2626 `int') can be done faster if the destination is a register that is
2627 known to be zero.
2628
2629 If you define this macro, you must have instruction patterns that
2630 recognize RTL structures like this:
2631
2632 (set (strict_low_part (subreg:QI (reg:SI ...) 0)) ...)
2633
2634 and likewise for `HImode'. */
2635
2636 /* #define SLOW_ZERO_EXTEND */
2637
2638 /* Define this macro to be the value 1 if unaligned accesses have a
2639 cost many times greater than aligned accesses, for example if they
2640 are emulated in a trap handler.
2641
2642 When this macro is non-zero, the compiler will act as if
2643 `STRICT_ALIGNMENT' were non-zero when generating code for block
2644 moves. This can cause significantly more instructions to be
2645 produced. Therefore, do not set this macro non-zero if unaligned
2646 accesses only add a cycle or two to the time for a memory access.
2647
2648 If the value of this macro is always zero, it need not be defined. */
2649
2650 /* #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 0 */
2651
2652 /* Define this macro to inhibit strength reduction of memory
2653 addresses. (On some machines, such strength reduction seems to do
2654 harm rather than good.) */
2655
2656 /* #define DONT_REDUCE_ADDR */
2657
2658 /* Define this macro if it is as good or better to call a constant
2659 function address than to call an address kept in a register.
2660
2661 Desirable on the 386 because a CALL with a constant address is
2662 faster than one with a register address. */
2663
2664 #define NO_FUNCTION_CSE
2665
2666 /* Define this macro if it is as good or better for a function to call
2667 itself with an explicit address than to call an address kept in a
2668 register. */
2669
2670 #define NO_RECURSIVE_FUNCTION_CSE
2671
2672 /* A C statement (sans semicolon) to update the integer variable COST
2673 based on the relationship between INSN that is dependent on
2674 DEP_INSN through the dependence LINK. The default is to make no
2675 adjustment to COST. This can be used for example to specify to
2676 the scheduler that an output- or anti-dependence does not incur
2677 the same cost as a data-dependence. */
2678
2679 #define ADJUST_COST(insn,link,dep_insn,cost) \
2680 (cost) = ix86_adjust_cost(insn, link, dep_insn, cost)
2681
2682 #define ISSUE_RATE \
2683 ix86_issue_rate ()
2684
2685 #define MD_SCHED_INIT(DUMP, SCHED_VERBOSE, MAX_READY) \
2686 ix86_sched_init (DUMP, SCHED_VERBOSE)
2687
2688 #define MD_SCHED_REORDER(DUMP, SCHED_VERBOSE, READY, N_READY, CLOCK, CIM) \
2689 (CIM) = ix86_sched_reorder (DUMP, SCHED_VERBOSE, READY, N_READY, CLOCK)
2690
2691 #define MD_SCHED_VARIABLE_ISSUE(DUMP, SCHED_VERBOSE, INSN, CAN_ISSUE_MORE) \
2692 ((CAN_ISSUE_MORE) = \
2693 ix86_variable_issue (DUMP, SCHED_VERBOSE, INSN, CAN_ISSUE_MORE))
2694 \f
2695 /* Add any extra modes needed to represent the condition code.
2696
2697 For the i386, we need separate modes when floating-point
2698 equality comparisons are being done.
2699
2700 Add CCNO to indicate comparisons against zero that requires
2701 Overflow flag to be unset. Sign bit test is used instead and
2702 thus can be used to form "a&b>0" type of tests.
2703
2704 Add CCGC to indicate comparisons agains zero that allows
2705 unspecified garbage in the Carry flag. This mode is used
2706 by inc/dec instructions.
2707
2708 Add CCGOC to indicate comparisons agains zero that allows
2709 unspecified garbage in the Carry and Overflow flag. This
2710 mode is used to simulate comparisons of (a-b) and (a+b)
2711 against zero using sub/cmp/add operations.
2712
2713 Add CCZ to indicate that only the Zero flag is valid. */
2714
2715 #define EXTRA_CC_MODES \
2716 CC(CCGCmode, "CCGC") \
2717 CC(CCGOCmode, "CCGOC") \
2718 CC(CCNOmode, "CCNO") \
2719 CC(CCZmode, "CCZ") \
2720 CC(CCFPmode, "CCFP") \
2721 CC(CCFPUmode, "CCFPU")
2722
2723 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
2724 return the mode to be used for the comparison.
2725
2726 For floating-point equality comparisons, CCFPEQmode should be used.
2727 VOIDmode should be used in all other cases.
2728
2729 For integer comparisons against zero, reduce to CCNOmode or CCZmode if
2730 possible, to allow for more combinations. */
2731
2732 #define SELECT_CC_MODE(OP,X,Y) ix86_cc_mode (OP, X, Y)
2733
2734 /* Return non-zero if MODE implies a floating point inequality can be
2735 reversed. */
2736
2737 #define REVERSIBLE_CC_MODE(MODE) 1
2738
2739 /* A C expression whose value is reversed condition code of the CODE for
2740 comparison done in CC_MODE mode. */
2741 #define REVERSE_CONDITION(CODE, MODE) \
2742 ((MODE) != CCFPmode && (MODE) != CCFPUmode ? reverse_condition (CODE) \
2743 : reverse_condition_maybe_unordered (CODE))
2744
2745 \f
2746 /* Control the assembler format that we output, to the extent
2747 this does not vary between assemblers. */
2748
2749 /* How to refer to registers in assembler output.
2750 This sequence is indexed by compiler's hard-register-number (see above). */
2751
2752 /* In order to refer to the first 8 regs as 32 bit regs prefix an "e"
2753 For non floating point regs, the following are the HImode names.
2754
2755 For float regs, the stack top is sometimes referred to as "%st(0)"
2756 instead of just "%st". PRINT_REG handles this with the "y" code. */
2757
2758 #define HI_REGISTER_NAMES \
2759 {"ax","dx","cx","bx","si","di","bp","sp", \
2760 "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","", \
2761 "flags","fpsr", "dirflag", "frame" }
2762
2763 #undef HI_REGISTER_NAMES
2764 #define HI_REGISTER_NAMES \
2765 {"ax","dx","cx","bx","si","di","bp","sp", \
2766 "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","", \
2767 "flags","fpsr", "dirflag", "frame", \
2768 "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7", \
2769 "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" , \
2770 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
2771 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}
2772
2773 #define REGISTER_NAMES HI_REGISTER_NAMES
2774
2775 /* Table of additional register names to use in user input. */
2776
2777 #define ADDITIONAL_REGISTER_NAMES \
2778 { { "eax", 0 }, { "edx", 1 }, { "ecx", 2 }, { "ebx", 3 }, \
2779 { "esi", 4 }, { "edi", 5 }, { "ebp", 6 }, { "esp", 7 }, \
2780 { "rax", 0 }, { "rdx", 1 }, { "rcx", 2 }, { "rbx", 3 }, \
2781 { "rsi", 4 }, { "rdi", 5 }, { "rbp", 6 }, { "rsp", 7 }, \
2782 { "al", 0 }, { "dl", 1 }, { "cl", 2 }, { "bl", 3 }, \
2783 { "ah", 0 }, { "dh", 1 }, { "ch", 2 }, { "bh", 3 }, \
2784 { "mm0", 8}, { "mm1", 9}, { "mm2", 10}, { "mm3", 11}, \
2785 { "mm4", 12}, { "mm5", 13}, { "mm6", 14}, { "mm7", 15} }
2786
2787 /* Note we are omitting these since currently I don't know how
2788 to get gcc to use these, since they want the same but different
2789 number as al, and ax.
2790 */
2791
2792 #define QI_REGISTER_NAMES \
2793 {"al", "dl", "cl", "bl", "sil", "dil", "bpl", "spl",}
2794
2795 /* These parallel the array above, and can be used to access bits 8:15
2796 of regs 0 through 3. */
2797
2798 #define QI_HIGH_REGISTER_NAMES \
2799 {"ah", "dh", "ch", "bh", }
2800
2801 #define MMX_REGISTER_NAMES \
2802 {0,0,0,0,0,0,0,0,"mm0","mm1","mm2","mm3","mm4","mm5","mm6","mm7"}
2803
2804 /* How to renumber registers for dbx and gdb. */
2805
2806 #define DBX_REGISTER_NUMBER(n) \
2807 (TARGET_64BIT ? dbx64_register_map[n] : dbx_register_map[n])
2808
2809 extern int const dbx_register_map[FIRST_PSEUDO_REGISTER];
2810 extern int const dbx64_register_map[FIRST_PSEUDO_REGISTER];
2811 extern int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER];
2812
2813 /* Before the prologue, RA is at 0(%esp). */
2814 #define INCOMING_RETURN_ADDR_RTX \
2815 gen_rtx_MEM (VOIDmode, gen_rtx_REG (VOIDmode, STACK_POINTER_REGNUM))
2816
2817 /* After the prologue, RA is at -4(AP) in the current frame. */
2818 #define RETURN_ADDR_RTX(COUNT, FRAME) \
2819 ((COUNT) == 0 \
2820 ? gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, -UNITS_PER_WORD)) \
2821 : gen_rtx_MEM (Pmode, plus_constant (FRAME, UNITS_PER_WORD)))
2822
2823 /* PC is dbx register 8; let's use that column for RA. */
2824 #define DWARF_FRAME_RETURN_COLUMN (TARGET_64BIT ? 16 : 8)
2825
2826 /* Before the prologue, the top of the frame is at 4(%esp). */
2827 #define INCOMING_FRAME_SP_OFFSET UNITS_PER_WORD
2828
2829 /* Describe how we implement __builtin_eh_return. */
2830 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) : INVALID_REGNUM)
2831 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 2)
2832
2833 /* Select a format to encode pointers in exception handling data. CODE
2834 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
2835 true if the symbol may be affected by dynamic relocations.
2836
2837 ??? All x86 object file formats are capable of representing this.
2838 After all, the relocation needed is the same as for the call insn.
2839 Whether or not a particular assembler allows us to enter such, I
2840 guess we'll have to see. */
2841 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
2842 (flag_pic ? (GLOBAL ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
2843 : DW_EH_PE_absptr)
2844
2845 /* This is how to output the definition of a user-level label named NAME,
2846 such as the label on a static function or variable NAME. */
2847
2848 #define ASM_OUTPUT_LABEL(FILE,NAME) \
2849 (assemble_name (FILE, NAME), fputs (":\n", FILE))
2850
2851 /* This is how to output an assembler line defining a `double' constant. */
2852
2853 #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
2854 do { long l[2]; \
2855 REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
2856 fprintf (FILE, "%s\t0x%lx,0x%lx\n", ASM_LONG, l[0], l[1]); \
2857 } while (0)
2858
2859 /* This is how to output a `long double' extended real constant. */
2860
2861 #undef ASM_OUTPUT_LONG_DOUBLE
2862 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
2863 do { long l[4]; \
2864 REAL_VALUE_TO_TARGET_LONG_DOUBLE (VALUE, l); \
2865 if (TARGET_128BIT_LONG_DOUBLE) \
2866 fprintf (FILE, "%s\t0x%lx,0x%lx,0x%lx,0x0\n", ASM_LONG, l[0], l[1], l[2]); \
2867 else \
2868 fprintf (FILE, "%s\t0x%lx,0x%lx,0x%lx\n", ASM_LONG, l[0], l[1], l[2]); \
2869 } while (0)
2870
2871 /* This is how to output an assembler line defining a `float' constant. */
2872
2873 #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
2874 do { long l; \
2875 REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
2876 fprintf ((FILE), "%s\t0x%lx\n", ASM_LONG, l); \
2877 } while (0)
2878
2879 /* Store in OUTPUT a string (made with alloca) containing
2880 an assembler-name for a local static variable named NAME.
2881 LABELNO is an integer which is different for each call. */
2882
2883 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
2884 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
2885 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
2886
2887 /* This is how to output an assembler line defining an `int' constant. */
2888
2889 #define ASM_OUTPUT_INT(FILE,VALUE) \
2890 ( fprintf (FILE, "%s\t", ASM_LONG), \
2891 output_addr_const (FILE,(VALUE)), \
2892 putc('\n',FILE))
2893
2894 /* Likewise for `char' and `short' constants. */
2895 /* is this supposed to do align too?? */
2896
2897 #define ASM_OUTPUT_SHORT(FILE,VALUE) \
2898 ( fprintf (FILE, "%s\t", ASM_SHORT), \
2899 output_addr_const (FILE,(VALUE)), \
2900 putc('\n',FILE))
2901
2902 #define ASM_OUTPUT_CHAR(FILE,VALUE) \
2903 ( fprintf (FILE, "%s", ASM_BYTE_OP), \
2904 output_addr_const (FILE, (VALUE)), \
2905 putc ('\n', FILE))
2906
2907 /* This is how to output an assembler line for a numeric constant byte. */
2908
2909 #define ASM_OUTPUT_BYTE(FILE,VALUE) \
2910 asm_fprintf ((FILE), "%s0x%x\n", ASM_BYTE_OP, (VALUE))
2911
2912 /* This is how to output an insn to push a register on the stack.
2913 It need not be very fast code. */
2914
2915 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
2916 asm_fprintf (FILE, "\tpush{l}\t%%e%s\n", reg_names[REGNO])
2917
2918 /* This is how to output an insn to pop a register from the stack.
2919 It need not be very fast code. */
2920
2921 #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
2922 asm_fprintf (FILE, "\tpop{l}\t%%e%s\n", reg_names[REGNO])
2923
2924 /* This is how to output an element of a case-vector that is absolute.
2925 */
2926
2927 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
2928 fprintf (FILE, "%s %s%d\n", ASM_LONG, LPREFIX, VALUE)
2929
2930 /* This is how to output an element of a case-vector that is relative.
2931 We don't use these on the 386 yet, because the ATT assembler can't do
2932 forward reference the differences.
2933 */
2934
2935 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
2936 fprintf (FILE, "\t%s\t%s%d-%s%d\n",ASM_LONG, LPREFIX, VALUE, LPREFIX, REL)
2937
2938 /* A C statement that outputs an address constant appropriate to
2939 for DWARF debugging. */
2940
2941 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,X) \
2942 i386_dwarf_output_addr_const((FILE),(X))
2943
2944 /* Either simplify a location expression, or return the original. */
2945
2946 #define ASM_SIMPLIFY_DWARF_ADDR(X) \
2947 i386_simplify_dwarf_addr(X)
2948
2949 /* Define the parentheses used to group arithmetic operations
2950 in assembler code. */
2951
2952 #define ASM_OPEN_PAREN ""
2953 #define ASM_CLOSE_PAREN ""
2954
2955 /* Define results of standard character escape sequences. */
2956 #define TARGET_BELL 007
2957 #define TARGET_BS 010
2958 #define TARGET_TAB 011
2959 #define TARGET_NEWLINE 012
2960 #define TARGET_VT 013
2961 #define TARGET_FF 014
2962 #define TARGET_CR 015
2963 \f
2964 /* Print operand X (an rtx) in assembler syntax to file FILE.
2965 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2966 The CODE z takes the size of operand from the following digit, and
2967 outputs b,w,or l respectively.
2968
2969 On the 80386, we use several such letters:
2970 f -- float insn (print a CONST_DOUBLE as a float rather than in hex).
2971 L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
2972 R -- print the prefix for register names.
2973 z -- print the opcode suffix for the size of the current operand.
2974 * -- print a star (in certain assembler syntax)
2975 A -- print an absolute memory reference.
2976 P -- if PIC, print an @PLT suffix.
2977 X -- don't print any sort of PIC '@' suffix for a symbol.
2978 s -- ??? something to do with double shifts. not actually used, afaik.
2979 C -- print a conditional move suffix corresponding to the op code.
2980 c -- likewise, but reverse the condition.
2981 F,f -- likewise, but for floating-point. */
2982
2983 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
2984 ((CODE) == '*')
2985
2986 /* Print the name of a register based on its machine mode and number.
2987 If CODE is 'w', pretend the mode is HImode.
2988 If CODE is 'b', pretend the mode is QImode.
2989 If CODE is 'k', pretend the mode is SImode.
2990 If CODE is 'd', pretend the mode is DImode.
2991 If CODE is 'h', pretend the reg is the `high' byte register.
2992 If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op. */
2993
2994 #define PRINT_REG(X, CODE, FILE) \
2995 print_reg (X, CODE, FILE)
2996
2997 #define PRINT_OPERAND(FILE, X, CODE) \
2998 print_operand (FILE, X, CODE)
2999
3000 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
3001 print_operand_address (FILE, ADDR)
3002
3003 /* Print the name of a register for based on its machine mode and number.
3004 This macro is used to print debugging output.
3005 This macro is different from PRINT_REG in that it may be used in
3006 programs that are not linked with aux-output.o. */
3007
3008 #define DEBUG_PRINT_REG(X, CODE, FILE) \
3009 do { static const char * const hi_name[] = HI_REGISTER_NAMES; \
3010 static const char * const qi_name[] = QI_REGISTER_NAMES; \
3011 fprintf (FILE, "%d ", REGNO (X)); \
3012 if (REGNO (X) == FLAGS_REG) \
3013 { fputs ("flags", FILE); break; } \
3014 if (REGNO (X) == DIRFLAG_REG) \
3015 { fputs ("dirflag", FILE); break; } \
3016 if (REGNO (X) == FPSR_REG) \
3017 { fputs ("fpsr", FILE); break; } \
3018 if (REGNO (X) == ARG_POINTER_REGNUM) \
3019 { fputs ("argp", FILE); break; } \
3020 if (REGNO (X) == FRAME_POINTER_REGNUM) \
3021 { fputs ("frame", FILE); break; } \
3022 if (STACK_TOP_P (X)) \
3023 { fputs ("st(0)", FILE); break; } \
3024 if (FP_REG_P (X)) \
3025 { fputs (hi_name[REGNO(X)], FILE); break; } \
3026 if (REX_INT_REG_P (X)) \
3027 { \
3028 switch (GET_MODE_SIZE (GET_MODE (X))) \
3029 { \
3030 default: \
3031 case 8: \
3032 fprintf (FILE, "r%i", REGNO (X) \
3033 - FIRST_REX_INT_REG + 8); \
3034 break; \
3035 case 4: \
3036 fprintf (FILE, "r%id", REGNO (X) \
3037 - FIRST_REX_INT_REG + 8); \
3038 break; \
3039 case 2: \
3040 fprintf (FILE, "r%iw", REGNO (X) \
3041 - FIRST_REX_INT_REG + 8); \
3042 break; \
3043 case 1: \
3044 fprintf (FILE, "r%ib", REGNO (X) \
3045 - FIRST_REX_INT_REG + 8); \
3046 break; \
3047 } \
3048 break; \
3049 } \
3050 switch (GET_MODE_SIZE (GET_MODE (X))) \
3051 { \
3052 case 8: \
3053 fputs ("r", FILE); \
3054 fputs (hi_name[REGNO (X)], FILE); \
3055 break; \
3056 default: \
3057 fputs ("e", FILE); \
3058 case 2: \
3059 fputs (hi_name[REGNO (X)], FILE); \
3060 break; \
3061 case 1: \
3062 fputs (qi_name[REGNO (X)], FILE); \
3063 break; \
3064 } \
3065 } while (0)
3066
3067 /* a letter which is not needed by the normal asm syntax, which
3068 we can use for operand syntax in the extended asm */
3069
3070 #define ASM_OPERAND_LETTER '#'
3071 #define RET return ""
3072 #define AT_SP(mode) (gen_rtx_MEM ((mode), stack_pointer_rtx))
3073 \f
3074 /* Define the codes that are matched by predicates in i386.c. */
3075
3076 #define PREDICATE_CODES \
3077 {"x86_64_immediate_operand", {CONST_INT, SUBREG, REG, \
3078 SYMBOL_REF, LABEL_REF, CONST}}, \
3079 {"x86_64_nonmemory_operand", {CONST_INT, SUBREG, REG, \
3080 SYMBOL_REF, LABEL_REF, CONST}}, \
3081 {"x86_64_movabs_operand", {CONST_INT, SUBREG, REG, \
3082 SYMBOL_REF, LABEL_REF, CONST}}, \
3083 {"x86_64_szext_nonmemory_operand", {CONST_INT, SUBREG, REG, \
3084 SYMBOL_REF, LABEL_REF, CONST}}, \
3085 {"x86_64_general_operand", {CONST_INT, SUBREG, REG, MEM, \
3086 SYMBOL_REF, LABEL_REF, CONST}}, \
3087 {"x86_64_szext_general_operand", {CONST_INT, SUBREG, REG, MEM, \
3088 SYMBOL_REF, LABEL_REF, CONST}}, \
3089 {"x86_64_zext_immediate_operand", {CONST_INT, CONST_DOUBLE, CONST, \
3090 SYMBOL_REF, LABEL_REF}}, \
3091 {"shiftdi_operand", {SUBREG, REG, MEM}}, \
3092 {"const_int_1_operand", {CONST_INT}}, \
3093 {"symbolic_operand", {SYMBOL_REF, LABEL_REF, CONST}}, \
3094 {"aligned_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, \
3095 LABEL_REF, SUBREG, REG, MEM}}, \
3096 {"pic_symbolic_operand", {CONST}}, \
3097 {"call_insn_operand", {REG, SUBREG, MEM, SYMBOL_REF}}, \
3098 {"constant_call_address_operand", {SYMBOL_REF, CONST}}, \
3099 {"const0_operand", {CONST_INT, CONST_DOUBLE}}, \
3100 {"const1_operand", {CONST_INT}}, \
3101 {"const248_operand", {CONST_INT}}, \
3102 {"incdec_operand", {CONST_INT}}, \
3103 {"mmx_reg_operand", {REG}}, \
3104 {"reg_no_sp_operand", {SUBREG, REG}}, \
3105 {"general_no_elim_operand", {CONST_INT, CONST_DOUBLE, CONST, \
3106 SYMBOL_REF, LABEL_REF, SUBREG, REG, MEM}}, \
3107 {"nonmemory_no_elim_operand", {CONST_INT, REG, SUBREG}}, \
3108 {"q_regs_operand", {SUBREG, REG}}, \
3109 {"non_q_regs_operand", {SUBREG, REG}}, \
3110 {"fcmov_comparison_operator", {EQ, NE, LTU, GTU, LEU, GEU, UNORDERED, \
3111 ORDERED, LT, UNLT, GT, UNGT, LE, UNLE, \
3112 GE, UNGE, LTGT, UNEQ}}, \
3113 {"sse_comparison_operator", {EQ, LT, LE, UNORDERED, NE, UNGE, UNGT, \
3114 ORDERED, UNEQ, UNLT, UNLE, LTGT, GE, GT \
3115 }}, \
3116 {"ix86_comparison_operator", {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, \
3117 GTU, UNORDERED, ORDERED, UNLE, UNLT, \
3118 UNGE, UNGT, LTGT, UNEQ }}, \
3119 {"cmp_fp_expander_operand", {CONST_DOUBLE, SUBREG, REG, MEM}}, \
3120 {"ext_register_operand", {SUBREG, REG}}, \
3121 {"binary_fp_operator", {PLUS, MINUS, MULT, DIV}}, \
3122 {"mult_operator", {MULT}}, \
3123 {"div_operator", {DIV}}, \
3124 {"arith_or_logical_operator", {PLUS, MULT, AND, IOR, XOR, SMIN, SMAX, \
3125 UMIN, UMAX, COMPARE, MINUS, DIV, MOD, \
3126 UDIV, UMOD, ASHIFT, ROTATE, ASHIFTRT, \
3127 LSHIFTRT, ROTATERT}}, \
3128 {"promotable_binary_operator", {PLUS, MULT, AND, IOR, XOR, ASHIFT}}, \
3129 {"memory_displacement_operand", {MEM}}, \
3130 {"cmpsi_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, \
3131 LABEL_REF, SUBREG, REG, MEM, AND}}, \
3132 {"long_memory_operand", {MEM}},
3133
3134 /* A list of predicates that do special things with modes, and so
3135 should not elicit warnings for VOIDmode match_operand. */
3136
3137 #define SPECIAL_MODE_PREDICATES \
3138 "ext_register_operand",
3139 \f
3140 /* CM_32 is used by 32bit ABI
3141 CM_SMALL is small model assuming that all code and data fits in the first
3142 31bits of address space.
3143 CM_KERNEL is model assuming that all code and data fits in the negative
3144 31bits of address space.
3145 CM_MEDIUM is model assuming that code fits in the first 31bits of address
3146 space. Size of data is unlimited.
3147 CM_LARGE is model making no assumptions about size of particular sections.
3148
3149 CM_SMALL_PIC is model for PIC libraries assuming that code+data+got/plt
3150 tables first in 31bits of address space.
3151 */
3152 enum cmodel {
3153 CM_32,
3154 CM_SMALL,
3155 CM_KERNEL,
3156 CM_MEDIUM,
3157 CM_LARGE,
3158 CM_SMALL_PIC
3159 };
3160
3161 /* Size of the RED_ZONE area. */
3162 #define RED_ZONE_SIZE 128
3163 /* Reserved area of the red zone for temporaries. */
3164 #define RED_ZONE_RESERVE 8
3165 /* Valud of -mcmodel specified by user. */
3166 extern const char *ix86_cmodel_string;
3167 extern enum cmodel ix86_cmodel;
3168 \f
3169 /* Variables in i386.c */
3170 extern const char *ix86_cpu_string; /* for -mcpu=<xxx> */
3171 extern const char *ix86_arch_string; /* for -march=<xxx> */
3172 extern const char *ix86_regparm_string; /* # registers to use to pass args */
3173 extern const char *ix86_align_loops_string; /* power of two alignment for loops */
3174 extern const char *ix86_align_jumps_string; /* power of two alignment for non-loop jumps */
3175 extern const char *ix86_align_funcs_string; /* power of two alignment for functions */
3176 extern const char *ix86_preferred_stack_boundary_string;/* power of two alignment for stack boundary */
3177 extern const char *ix86_branch_cost_string; /* values 1-5: see jump.c */
3178 extern int ix86_regparm; /* ix86_regparm_string as a number */
3179 extern int ix86_preferred_stack_boundary; /* preferred stack boundary alignment in bits */
3180 extern int ix86_branch_cost; /* values 1-5: see jump.c */
3181 extern const char * const hi_reg_name[]; /* names for 16 bit regs */
3182 extern const char * const qi_reg_name[]; /* names for 8 bit regs (low) */
3183 extern const char * const qi_high_reg_name[]; /* names for 8 bit regs (high) */
3184 extern enum reg_class const regclass_map[]; /* smalled class containing REGNO */
3185 extern struct rtx_def *ix86_compare_op0; /* operand 0 for comparisons */
3186 extern struct rtx_def *ix86_compare_op1; /* operand 1 for comparisons */
3187 \f
3188 /*
3189 Local variables:
3190 version-control: t
3191 End:
3192 */