OSDN Git Service

* config/i386/i386.c (print_reg): Abort if REGNO (x) is a
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / i386.h
1 /* Definitions of target machine for GCC for IA-32.
2    Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3    2001, 2002, 2003 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC 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 GCC 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 GCC; 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 /* Define the specific costs for a given cpu */
38
39 struct processor_costs {
40   const int add;                /* cost of an add instruction */
41   const int lea;                /* cost of a lea instruction */
42   const int shift_var;          /* variable shift costs */
43   const int shift_const;        /* constant shift costs */
44   const int mult_init[5];       /* cost of starting a multiply 
45                                    in QImode, HImode, SImode, DImode, TImode*/
46   const int mult_bit;           /* cost of multiply per each bit set */
47   const int divide[5];          /* cost of a divide/mod 
48                                    in QImode, HImode, SImode, DImode, TImode*/
49   int movsx;                    /* The cost of movsx operation.  */
50   int movzx;                    /* The cost of movzx operation.  */
51   const int large_insn;         /* insns larger than this cost more */
52   const int move_ratio;         /* The threshold of number of scalar
53                                    memory-to-memory move insns.  */
54   const int movzbl_load;        /* cost of loading using movzbl */
55   const int int_load[3];        /* cost of loading integer registers
56                                    in QImode, HImode and SImode relative
57                                    to reg-reg move (2).  */
58   const int int_store[3];       /* cost of storing integer register
59                                    in QImode, HImode and SImode */
60   const int fp_move;            /* cost of reg,reg fld/fst */
61   const int fp_load[3];         /* cost of loading FP register
62                                    in SFmode, DFmode and XFmode */
63   const int fp_store[3];        /* cost of storing FP register
64                                    in SFmode, DFmode and XFmode */
65   const int mmx_move;           /* cost of moving MMX register.  */
66   const int mmx_load[2];        /* cost of loading MMX register
67                                    in SImode and DImode */
68   const int mmx_store[2];       /* cost of storing MMX register
69                                    in SImode and DImode */
70   const int sse_move;           /* cost of moving SSE register.  */
71   const int sse_load[3];        /* cost of loading SSE register
72                                    in SImode, DImode and TImode*/
73   const int sse_store[3];       /* cost of storing SSE register
74                                    in SImode, DImode and TImode*/
75   const int mmxsse_to_integer;  /* cost of moving mmxsse register to
76                                    integer and vice versa.  */
77   const int prefetch_block;     /* bytes moved to cache for prefetch.  */
78   const int simultaneous_prefetches; /* number of parallel prefetch
79                                    operations.  */
80   const int branch_cost;        /* Default value for BRANCH_COST.  */
81   const int fadd;               /* cost of FADD and FSUB instructions.  */
82   const int fmul;               /* cost of FMUL instruction.  */
83   const int fdiv;               /* cost of FDIV instruction.  */
84   const int fabs;               /* cost of FABS instruction.  */
85   const int fchs;               /* cost of FCHS instruction.  */
86   const int fsqrt;              /* cost of FSQRT instruction.  */
87 };
88
89 extern const 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 #ifdef TARGET_64BIT_DEFAULT
101 #define TARGET_CPU_DEFAULT TARGET_CPU_DEFAULT_k8
102 #else
103 #define TARGET_CPU_DEFAULT 0
104 #endif
105 #endif
106
107 /* Masks for the -m switches */
108 #define MASK_80387              0x00000001      /* Hardware floating point */
109 #define MASK_RTD                0x00000002      /* Use ret that pops args */
110 #define MASK_ALIGN_DOUBLE       0x00000004      /* align doubles to 2 word boundary */
111 #define MASK_SVR3_SHLIB         0x00000008      /* Uninit locals into bss */
112 #define MASK_IEEE_FP            0x00000010      /* IEEE fp comparisons */
113 #define MASK_FLOAT_RETURNS      0x00000020      /* Return float in st(0) */
114 #define MASK_NO_FANCY_MATH_387  0x00000040      /* Disable sin, cos, sqrt */
115 #define MASK_OMIT_LEAF_FRAME_POINTER 0x080      /* omit leaf frame pointers */
116 #define MASK_STACK_PROBE        0x00000100      /* Enable stack probing */
117 #define MASK_NO_ALIGN_STROPS    0x00000200      /* Enable aligning of string ops.  */
118 #define MASK_INLINE_ALL_STROPS  0x00000400      /* Inline stringops in all cases */
119 #define MASK_NO_PUSH_ARGS       0x00000800      /* Use push instructions */
120 #define MASK_ACCUMULATE_OUTGOING_ARGS 0x00001000/* Accumulate outgoing args */
121 #define MASK_MMX                0x00002000      /* Support MMX regs/builtins */
122 #define MASK_SSE                0x00004000      /* Support SSE regs/builtins */
123 #define MASK_SSE2               0x00008000      /* Support SSE2 regs/builtins */
124 #define MASK_PNI                0x00010000      /* Support PNI regs/builtins */
125 #define MASK_3DNOW              0x00020000      /* Support 3Dnow builtins */
126 #define MASK_3DNOW_A            0x00040000      /* Support Athlon 3Dnow builtins */
127 #define MASK_128BIT_LONG_DOUBLE 0x00080000      /* long double size is 128bit */
128 #define MASK_64BIT              0x00100000      /* Produce 64bit code */
129 #define MASK_MS_BITFIELD_LAYOUT 0x00200000      /* Use native (MS) bitfield layout */
130 #define MASK_TLS_DIRECT_SEG_REFS 0x00400000     /* Avoid adding %gs:0  */
131
132 /* Unused:                      0x03e0000       */
133
134 /* ... overlap with subtarget options starts by 0x04000000.  */
135 #define MASK_NO_RED_ZONE        0x04000000      /* Do not use red zone */
136
137 /* Use the floating point instructions */
138 #define TARGET_80387 (target_flags & MASK_80387)
139
140 /* Compile using ret insn that pops args.
141    This will not work unless you use prototypes at least
142    for all functions that can take varying numbers of args.  */
143 #define TARGET_RTD (target_flags & MASK_RTD)
144
145 /* Align doubles to a two word boundary.  This breaks compatibility with
146    the published ABI's for structures containing doubles, but produces
147    faster code on the pentium.  */
148 #define TARGET_ALIGN_DOUBLE (target_flags & MASK_ALIGN_DOUBLE)
149
150 /* Use push instructions to save outgoing args.  */
151 #define TARGET_PUSH_ARGS (!(target_flags & MASK_NO_PUSH_ARGS))
152
153 /* Accumulate stack adjustments to prologue/epilogue.  */
154 #define TARGET_ACCUMULATE_OUTGOING_ARGS \
155  (target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
156
157 /* Put uninitialized locals into bss, not data.
158    Meaningful only on svr3.  */
159 #define TARGET_SVR3_SHLIB (target_flags & MASK_SVR3_SHLIB)
160
161 /* Use IEEE floating point comparisons.  These handle correctly the cases
162    where the result of a comparison is unordered.  Normally SIGFPE is
163    generated in such cases, in which case this isn't needed.  */
164 #define TARGET_IEEE_FP (target_flags & MASK_IEEE_FP)
165
166 /* Functions that return a floating point value may return that value
167    in the 387 FPU or in 386 integer registers.  If set, this flag causes
168    the 387 to be used, which is compatible with most calling conventions.  */
169 #define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & MASK_FLOAT_RETURNS)
170
171 /* Long double is 128bit instead of 96bit, even when only 80bits are used.
172    This mode wastes cache, but avoid misaligned data accesses and simplifies
173    address calculations.  */
174 #define TARGET_128BIT_LONG_DOUBLE (target_flags & MASK_128BIT_LONG_DOUBLE)
175
176 /* Disable generation of FP sin, cos and sqrt operations for 387.
177    This is because FreeBSD lacks these in the math-emulator-code */
178 #define TARGET_NO_FANCY_MATH_387 (target_flags & MASK_NO_FANCY_MATH_387)
179
180 /* Don't create frame pointers for leaf functions */
181 #define TARGET_OMIT_LEAF_FRAME_POINTER \
182   (target_flags & MASK_OMIT_LEAF_FRAME_POINTER)
183
184 /* Debug GO_IF_LEGITIMATE_ADDRESS */
185 #define TARGET_DEBUG_ADDR (ix86_debug_addr_string != 0)
186
187 /* Debug FUNCTION_ARG macros */
188 #define TARGET_DEBUG_ARG (ix86_debug_arg_string != 0)
189
190 /* 64bit Sledgehammer mode.  For libgcc2 we make sure this is a
191    compile-time constant.  */
192 #ifdef IN_LIBGCC2
193 #ifdef __x86_64__
194 #define TARGET_64BIT 1
195 #else
196 #define TARGET_64BIT 0
197 #endif
198 #else
199 #ifdef TARGET_BI_ARCH
200 #define TARGET_64BIT (target_flags & MASK_64BIT)
201 #else
202 #if TARGET_64BIT_DEFAULT
203 #define TARGET_64BIT 1
204 #else
205 #define TARGET_64BIT 0
206 #endif
207 #endif
208 #endif
209
210 /* Avoid adding %gs:0 in TLS references; use %gs:address directly.  */
211 #define TARGET_TLS_DIRECT_SEG_REFS (target_flags & MASK_TLS_DIRECT_SEG_REFS)
212
213 #define TARGET_386 (ix86_tune == PROCESSOR_I386)
214 #define TARGET_486 (ix86_tune == PROCESSOR_I486)
215 #define TARGET_PENTIUM (ix86_tune == PROCESSOR_PENTIUM)
216 #define TARGET_PENTIUMPRO (ix86_tune == PROCESSOR_PENTIUMPRO)
217 #define TARGET_K6 (ix86_tune == PROCESSOR_K6)
218 #define TARGET_ATHLON (ix86_tune == PROCESSOR_ATHLON)
219 #define TARGET_PENTIUM4 (ix86_tune == PROCESSOR_PENTIUM4)
220 #define TARGET_K8 (ix86_tune == PROCESSOR_K8)
221 #define TARGET_ATHLON_K8 (TARGET_K8 || TARGET_ATHLON)
222
223 #define TUNEMASK (1 << ix86_tune)
224 extern const int x86_use_leave, x86_push_memory, x86_zero_extend_with_and;
225 extern const int x86_use_bit_test, x86_cmove, x86_deep_branch;
226 extern const int x86_branch_hints, x86_unroll_strlen;
227 extern const int x86_double_with_add, x86_partial_reg_stall, x86_movx;
228 extern const int x86_use_loop, x86_use_fiop, x86_use_mov0;
229 extern const int x86_use_cltd, x86_read_modify_write;
230 extern const int x86_read_modify, x86_split_long_moves;
231 extern const int x86_promote_QImode, x86_single_stringop, x86_fast_prefix;
232 extern const int x86_himode_math, x86_qimode_math, x86_promote_qi_regs;
233 extern const int x86_promote_hi_regs, x86_integer_DFmode_moves;
234 extern const int x86_add_esp_4, x86_add_esp_8, x86_sub_esp_4, x86_sub_esp_8;
235 extern const int x86_partial_reg_dependency, x86_memory_mismatch_stall;
236 extern const int x86_accumulate_outgoing_args, x86_prologue_using_move;
237 extern const int x86_epilogue_using_move, x86_decompose_lea;
238 extern const int x86_arch_always_fancy_math_387, x86_shift1;
239 extern const int x86_sse_partial_reg_dependency, x86_sse_partial_regs;
240 extern const int x86_sse_typeless_stores, x86_sse_load0_by_pxor;
241 extern const int x86_use_ffreep, x86_sse_partial_regs_for_cvtsd2ss;
242 extern const int x86_inter_unit_moves;
243 extern int x86_prefetch_sse;
244
245 #define TARGET_USE_LEAVE (x86_use_leave & TUNEMASK)
246 #define TARGET_PUSH_MEMORY (x86_push_memory & TUNEMASK)
247 #define TARGET_ZERO_EXTEND_WITH_AND (x86_zero_extend_with_and & TUNEMASK)
248 #define TARGET_USE_BIT_TEST (x86_use_bit_test & TUNEMASK)
249 #define TARGET_UNROLL_STRLEN (x86_unroll_strlen & TUNEMASK)
250 /* For sane SSE instruction set generation we need fcomi instruction.  It is
251    safe to enable all CMOVE instructions.  */
252 #define TARGET_CMOVE ((x86_cmove & (1 << ix86_arch)) || TARGET_SSE)
253 #define TARGET_DEEP_BRANCH_PREDICTION (x86_deep_branch & TUNEMASK)
254 #define TARGET_BRANCH_PREDICTION_HINTS (x86_branch_hints & TUNEMASK)
255 #define TARGET_DOUBLE_WITH_ADD (x86_double_with_add & TUNEMASK)
256 #define TARGET_USE_SAHF ((x86_use_sahf & TUNEMASK) && !TARGET_64BIT)
257 #define TARGET_MOVX (x86_movx & TUNEMASK)
258 #define TARGET_PARTIAL_REG_STALL (x86_partial_reg_stall & TUNEMASK)
259 #define TARGET_USE_LOOP (x86_use_loop & TUNEMASK)
260 #define TARGET_USE_FIOP (x86_use_fiop & TUNEMASK)
261 #define TARGET_USE_MOV0 (x86_use_mov0 & TUNEMASK)
262 #define TARGET_USE_CLTD (x86_use_cltd & TUNEMASK)
263 #define TARGET_SPLIT_LONG_MOVES (x86_split_long_moves & TUNEMASK)
264 #define TARGET_READ_MODIFY_WRITE (x86_read_modify_write & TUNEMASK)
265 #define TARGET_READ_MODIFY (x86_read_modify & TUNEMASK)
266 #define TARGET_PROMOTE_QImode (x86_promote_QImode & TUNEMASK)
267 #define TARGET_FAST_PREFIX (x86_fast_prefix & TUNEMASK)
268 #define TARGET_SINGLE_STRINGOP (x86_single_stringop & TUNEMASK)
269 #define TARGET_QIMODE_MATH (x86_qimode_math & TUNEMASK)
270 #define TARGET_HIMODE_MATH (x86_himode_math & TUNEMASK)
271 #define TARGET_PROMOTE_QI_REGS (x86_promote_qi_regs & TUNEMASK)
272 #define TARGET_PROMOTE_HI_REGS (x86_promote_hi_regs & TUNEMASK)
273 #define TARGET_ADD_ESP_4 (x86_add_esp_4 & TUNEMASK)
274 #define TARGET_ADD_ESP_8 (x86_add_esp_8 & TUNEMASK)
275 #define TARGET_SUB_ESP_4 (x86_sub_esp_4 & TUNEMASK)
276 #define TARGET_SUB_ESP_8 (x86_sub_esp_8 & TUNEMASK)
277 #define TARGET_INTEGER_DFMODE_MOVES (x86_integer_DFmode_moves & TUNEMASK)
278 #define TARGET_PARTIAL_REG_DEPENDENCY (x86_partial_reg_dependency & TUNEMASK)
279 #define TARGET_SSE_PARTIAL_REG_DEPENDENCY \
280                                       (x86_sse_partial_reg_dependency & TUNEMASK)
281 #define TARGET_SSE_PARTIAL_REGS (x86_sse_partial_regs & TUNEMASK)
282 #define TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS \
283                                 (x86_sse_partial_regs_for_cvtsd2ss & TUNEMASK)
284 #define TARGET_SSE_TYPELESS_STORES (x86_sse_typeless_stores & TUNEMASK)
285 #define TARGET_SSE_TYPELESS_LOAD0 (x86_sse_typeless_load0 & TUNEMASK)
286 #define TARGET_SSE_LOAD0_BY_PXOR (x86_sse_load0_by_pxor & TUNEMASK)
287 #define TARGET_MEMORY_MISMATCH_STALL (x86_memory_mismatch_stall & TUNEMASK)
288 #define TARGET_PROLOGUE_USING_MOVE (x86_prologue_using_move & TUNEMASK)
289 #define TARGET_EPILOGUE_USING_MOVE (x86_epilogue_using_move & TUNEMASK)
290 #define TARGET_DECOMPOSE_LEA (x86_decompose_lea & TUNEMASK)
291 #define TARGET_PREFETCH_SSE (x86_prefetch_sse)
292 #define TARGET_SHIFT1 (x86_shift1 & TUNEMASK)
293 #define TARGET_USE_FFREEP (x86_use_ffreep & TUNEMASK)
294 #define TARGET_REP_MOVL_OPTIMAL (x86_rep_movl_optimal & TUNEMASK)
295 #define TARGET_INTER_UNIT_MOVES (x86_inter_unit_moves & TUNEMASK)
296
297 #define TARGET_STACK_PROBE (target_flags & MASK_STACK_PROBE)
298
299 #define TARGET_ALIGN_STRINGOPS (!(target_flags & MASK_NO_ALIGN_STROPS))
300 #define TARGET_INLINE_ALL_STRINGOPS (target_flags & MASK_INLINE_ALL_STROPS)
301
302 #define ASSEMBLER_DIALECT (ix86_asm_dialect)
303
304 #define TARGET_SSE ((target_flags & MASK_SSE) != 0)
305 #define TARGET_SSE2 ((target_flags & MASK_SSE2) != 0)
306 #define TARGET_PNI ((target_flags & MASK_PNI) != 0)
307 #define TARGET_SSE_MATH ((ix86_fpmath & FPMATH_SSE) != 0)
308 #define TARGET_MIX_SSE_I387 ((ix86_fpmath & FPMATH_SSE) \
309                              && (ix86_fpmath & FPMATH_387))
310 #define TARGET_MMX ((target_flags & MASK_MMX) != 0)
311 #define TARGET_3DNOW ((target_flags & MASK_3DNOW) != 0)
312 #define TARGET_3DNOW_A ((target_flags & MASK_3DNOW_A) != 0)
313
314 #define TARGET_RED_ZONE (!(target_flags & MASK_NO_RED_ZONE))
315
316 #define TARGET_USE_MS_BITFIELD_LAYOUT  (target_flags & MASK_MS_BITFIELD_LAYOUT)
317
318 #define TARGET_GNU_TLS (ix86_tls_dialect == TLS_DIALECT_GNU)
319 #define TARGET_SUN_TLS (ix86_tls_dialect == TLS_DIALECT_SUN)
320
321 /* WARNING: Do not mark empty strings for translation, as calling
322             gettext on an empty string does NOT return an empty
323             string. */
324
325
326 #define TARGET_SWITCHES                                                       \
327 { { "80387",                     MASK_80387, N_("Use hardware fp") },         \
328   { "no-80387",                 -MASK_80387, N_("Do not use hardware fp") },  \
329   { "hard-float",                MASK_80387, N_("Use hardware fp") },         \
330   { "soft-float",               -MASK_80387, N_("Do not use hardware fp") },  \
331   { "no-soft-float",             MASK_80387, N_("Use hardware fp") },         \
332   { "386",                       0, "" /*Deprecated.*/},                      \
333   { "486",                       0, "" /*Deprecated.*/},                      \
334   { "pentium",                   0, "" /*Deprecated.*/},                      \
335   { "pentiumpro",                0, "" /*Deprecated.*/},                      \
336   { "intel-syntax",              0, "" /*Deprecated.*/},                      \
337   { "no-intel-syntax",           0, "" /*Deprecated.*/},                      \
338   { "rtd",                       MASK_RTD,                                    \
339     N_("Alternate calling convention") },                                     \
340   { "no-rtd",                   -MASK_RTD,                                    \
341     N_("Use normal calling convention") },                                    \
342   { "align-double",              MASK_ALIGN_DOUBLE,                           \
343     N_("Align some doubles on dword boundary") },                             \
344   { "no-align-double",          -MASK_ALIGN_DOUBLE,                           \
345     N_("Align doubles on word boundary") },                                   \
346   { "svr3-shlib",                MASK_SVR3_SHLIB,                             \
347     N_("Uninitialized locals in .bss")  },                                    \
348   { "no-svr3-shlib",            -MASK_SVR3_SHLIB,                             \
349     N_("Uninitialized locals in .data") },                                    \
350   { "ieee-fp",                   MASK_IEEE_FP,                                \
351     N_("Use IEEE math for fp comparisons") },                                 \
352   { "no-ieee-fp",               -MASK_IEEE_FP,                                \
353     N_("Do not use IEEE math for fp comparisons") },                          \
354   { "fp-ret-in-387",             MASK_FLOAT_RETURNS,                          \
355     N_("Return values of functions in FPU registers") },                      \
356   { "no-fp-ret-in-387",         -MASK_FLOAT_RETURNS ,                         \
357     N_("Do not return values of functions in FPU registers")},                \
358   { "no-fancy-math-387",         MASK_NO_FANCY_MATH_387,                      \
359     N_("Do not generate sin, cos, sqrt for FPU") },                           \
360   { "fancy-math-387",           -MASK_NO_FANCY_MATH_387,                      \
361      N_("Generate sin, cos, sqrt for FPU")},                                  \
362   { "omit-leaf-frame-pointer",   MASK_OMIT_LEAF_FRAME_POINTER,                \
363     N_("Omit the frame pointer in leaf functions") },                         \
364   { "no-omit-leaf-frame-pointer",-MASK_OMIT_LEAF_FRAME_POINTER, "" },         \
365   { "stack-arg-probe",           MASK_STACK_PROBE,                            \
366     N_("Enable stack probing") },                                             \
367   { "no-stack-arg-probe",       -MASK_STACK_PROBE, "" },                      \
368   { "windows",                  0, 0 /* undocumented */ },                    \
369   { "dll",                      0,  0 /* undocumented */ },                   \
370   { "align-stringops",          -MASK_NO_ALIGN_STROPS,                        \
371     N_("Align destination of the string operations") },                       \
372   { "no-align-stringops",        MASK_NO_ALIGN_STROPS,                        \
373     N_("Do not align destination of the string operations") },                \
374   { "inline-all-stringops",      MASK_INLINE_ALL_STROPS,                      \
375     N_("Inline all known string operations") },                               \
376   { "no-inline-all-stringops",  -MASK_INLINE_ALL_STROPS,                      \
377     N_("Do not inline all known string operations") },                        \
378   { "push-args",                -MASK_NO_PUSH_ARGS,                           \
379     N_("Use push instructions to save outgoing arguments") },                 \
380   { "no-push-args",             MASK_NO_PUSH_ARGS,                            \
381     N_("Do not use push instructions to save outgoing arguments") },          \
382   { "accumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS,                \
383     N_("Use push instructions to save outgoing arguments") },                 \
384   { "no-accumulate-outgoing-args",-MASK_ACCUMULATE_OUTGOING_ARGS,             \
385     N_("Do not use push instructions to save outgoing arguments") },          \
386   { "mmx",                       MASK_MMX,                                    \
387     N_("Support MMX built-in functions") },                                   \
388   { "no-mmx",                    -MASK_MMX,                                   \
389     N_("Do not support MMX built-in functions") },                            \
390   { "3dnow",                     MASK_3DNOW,                                  \
391     N_("Support 3DNow! built-in functions") },                                \
392   { "no-3dnow",                  -MASK_3DNOW,                                 \
393     N_("Do not support 3DNow! built-in functions") },                         \
394   { "sse",                       MASK_SSE,                                    \
395     N_("Support MMX and SSE built-in functions and code generation") },       \
396   { "no-sse",                    -MASK_SSE,                                   \
397     N_("Do not support MMX and SSE built-in functions and code generation") },\
398   { "sse2",                      MASK_SSE2,                                   \
399     N_("Support MMX, SSE and SSE2 built-in functions and code generation") }, \
400   { "no-sse2",                   -MASK_SSE2,                                  \
401     N_("Do not support MMX, SSE and SSE2 built-in functions and code generation") },    \
402   { "pni",                       MASK_PNI,                                    \
403     N_("Support MMX, SSE, SSE2 and PNI built-in functions and code generation") },\
404   { "no-pni",                    -MASK_PNI,                                   \
405     N_("Do not support MMX, SSE, SSE2 and PNI built-in functions and code generation") },\
406   { "128bit-long-double",        MASK_128BIT_LONG_DOUBLE,                     \
407     N_("sizeof(long double) is 16") },                                        \
408   { "96bit-long-double",        -MASK_128BIT_LONG_DOUBLE,                     \
409     N_("sizeof(long double) is 12") },                                        \
410   { "64",                       MASK_64BIT,                                   \
411     N_("Generate 64bit x86-64 code") },                                       \
412   { "32",                       -MASK_64BIT,                                  \
413     N_("Generate 32bit i386 code") },                                         \
414   { "ms-bitfields",             MASK_MS_BITFIELD_LAYOUT,                      \
415     N_("Use native (MS) bitfield layout") },                                  \
416   { "no-ms-bitfields",          -MASK_MS_BITFIELD_LAYOUT,                     \
417     N_("Use gcc default bitfield layout") },                                  \
418   { "red-zone",                 -MASK_NO_RED_ZONE,                            \
419     N_("Use red-zone in the x86-64 code") },                                  \
420   { "no-red-zone",              MASK_NO_RED_ZONE,                             \
421     N_("Do not use red-zone in the x86-64 code") },                           \
422   { "tls-direct-seg-refs",      MASK_TLS_DIRECT_SEG_REFS,                     \
423     N_("Use direct references against %gs when accessing tls data") },        \
424   { "no-tls-direct-seg-refs",   -MASK_TLS_DIRECT_SEG_REFS,                    \
425     N_("Do not use direct references against %gs when accessing tls data") }, \
426   SUBTARGET_SWITCHES                                                          \
427   { "",                                                                       \
428     TARGET_DEFAULT | TARGET_64BIT_DEFAULT | TARGET_SUBTARGET_DEFAULT          \
429     | TARGET_TLS_DIRECT_SEG_REFS_DEFAULT, 0 }}
430
431 #ifndef TARGET_64BIT_DEFAULT
432 #define TARGET_64BIT_DEFAULT 0
433 #endif
434 #ifndef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
435 #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 0
436 #endif
437
438 /* Once GDB has been enhanced to deal with functions without frame
439    pointers, we can change this to allow for elimination of
440    the frame pointer in leaf functions.  */
441 #define TARGET_DEFAULT 0
442
443 /* This is not really a target flag, but is done this way so that
444    it's analogous to similar code for Mach-O on PowerPC.  darwin.h
445    redefines this to 1.  */
446 #define TARGET_MACHO 0
447
448 /* This macro is similar to `TARGET_SWITCHES' but defines names of
449    command options that have values.  Its definition is an
450    initializer with a subgrouping for each command option.
451
452    Each subgrouping contains a string constant, that defines the
453    fixed part of the option name, and the address of a variable.  The
454    variable, type `char *', is set to the variable part of the given
455    option if the fixed part matches.  The actual option name is made
456    by appending `-m' to the specified name.  */
457 #define TARGET_OPTIONS                                          \
458 { { "tune=",            &ix86_tune_string,                      \
459     N_("Schedule code for given CPU"), 0},                      \
460   { "fpmath=",          &ix86_fpmath_string,                    \
461     N_("Generate floating point mathematics using given instruction set"), 0},\
462   { "arch=",            &ix86_arch_string,                      \
463     N_("Generate code for given CPU"), 0},                      \
464   { "regparm=",         &ix86_regparm_string,                   \
465     N_("Number of registers used to pass integer arguments"), 0},\
466   { "align-loops=",     &ix86_align_loops_string,               \
467     N_("Loop code aligned to this power of 2"), 0},             \
468   { "align-jumps=",     &ix86_align_jumps_string,               \
469     N_("Jump targets are aligned to this power of 2"), 0},      \
470   { "align-functions=", &ix86_align_funcs_string,               \
471     N_("Function starts are aligned to this power of 2"), 0},   \
472   { "preferred-stack-boundary=",                                \
473     &ix86_preferred_stack_boundary_string,                      \
474     N_("Attempt to keep stack aligned to this power of 2"), 0}, \
475   { "branch-cost=",     &ix86_branch_cost_string,               \
476     N_("Branches are this expensive (1-5, arbitrary units)"), 0},\
477   { "cmodel=", &ix86_cmodel_string,                             \
478     N_("Use given x86-64 code model"), 0},                      \
479   { "debug-arg", &ix86_debug_arg_string,                        \
480     "" /* Undocumented. */, 0},                                 \
481   { "debug-addr", &ix86_debug_addr_string,                      \
482     "" /* Undocumented. */, 0},                                 \
483   { "asm=", &ix86_asm_string,                                   \
484     N_("Use given assembler dialect"), 0},                      \
485   { "tls-dialect=", &ix86_tls_dialect_string,                   \
486     N_("Use given thread-local storage dialect"), 0},           \
487   SUBTARGET_OPTIONS                                             \
488 }
489
490 /* Sometimes certain combinations of command options do not make
491    sense on a particular target machine.  You can define a macro
492    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
493    defined, is executed once just after all the command options have
494    been parsed.
495
496    Don't use this macro to turn on various extra optimizations for
497    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
498
499 #define OVERRIDE_OPTIONS override_options ()
500
501 /* These are meant to be redefined in the host dependent files */
502 #define SUBTARGET_SWITCHES
503 #define SUBTARGET_OPTIONS
504
505 /* Define this to change the optimizations performed by default.  */
506 #define OPTIMIZATION_OPTIONS(LEVEL, SIZE) \
507   optimization_options ((LEVEL), (SIZE))
508
509 /* Support for configure-time defaults of some command line options.  */
510 #define OPTION_DEFAULT_SPECS \
511   {"arch", "%{!march=*:-march=%(VALUE)}"}, \
512   {"tune", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }, \
513   {"cpu", "%{!mtune=*:%{!mcpu=*:%{!march=*:-mtune=%(VALUE)}}}" }
514
515 /* Specs for the compiler proper */
516
517 #ifndef CC1_CPU_SPEC
518 #define CC1_CPU_SPEC "\
519 %{!mtune*: \
520 %{m386:mtune=i386 \
521 %n`-m386' is deprecated. Use `-march=i386' or `-mtune=i386' instead.\n} \
522 %{m486:-mtune=i486 \
523 %n`-m486' is deprecated. Use `-march=i486' or `-mtune=i486' instead.\n} \
524 %{mpentium:-mtune=pentium \
525 %n`-mpentium' is deprecated. Use `-march=pentium' or `-mtune=pentium' instead.\n} \
526 %{mpentiumpro:-mtune=pentiumpro \
527 %n`-mpentiumpro' is deprecated. Use `-march=pentiumpro' or `-mtune=pentiumpro' instead.\n} \
528 %{mcpu=*:-mtune=%* \
529 %n`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.\n}} \
530 %<mcpu=* \
531 %{mintel-syntax:-masm=intel \
532 %n`-mintel-syntax' is deprecated. Use `-masm=intel' instead.\n} \
533 %{mno-intel-syntax:-masm=att \
534 %n`-mno-intel-syntax' is deprecated. Use `-masm=att' instead.\n}"
535 #endif
536 \f
537 /* Target CPU builtins.  */
538 #define TARGET_CPU_CPP_BUILTINS()                               \
539   do                                                            \
540     {                                                           \
541       size_t arch_len = strlen (ix86_arch_string);              \
542       size_t tune_len = strlen (ix86_tune_string);              \
543       int last_arch_char = ix86_arch_string[arch_len - 1];      \
544       int last_tune_char = ix86_tune_string[tune_len - 1];              \
545                                                                 \
546       if (TARGET_64BIT)                                         \
547         {                                                       \
548           builtin_assert ("cpu=x86_64");                        \
549           builtin_define ("__amd64");                           \
550           builtin_define ("__amd64__");                         \
551           builtin_define ("__x86_64");                          \
552           builtin_define ("__x86_64__");                        \
553           builtin_define ("__amd64");                           \
554           builtin_define ("__amd64__");                         \
555         }                                                       \
556       else                                                      \
557         {                                                       \
558           builtin_assert ("cpu=i386");                          \
559           builtin_assert ("machine=i386");                      \
560           builtin_define_std ("i386");                          \
561         }                                                       \
562                                                                 \
563       /* Built-ins based on -mtune= (or -march= if no           \
564          -mtune= given).  */                                    \
565       if (TARGET_386)                                           \
566         builtin_define ("__tune_i386__");                       \
567       else if (TARGET_486)                                      \
568         builtin_define ("__tune_i486__");                       \
569       else if (TARGET_PENTIUM)                                  \
570         {                                                       \
571           builtin_define ("__tune_i586__");                     \
572           builtin_define ("__tune_pentium__");                  \
573           if (last_tune_char == 'x')                            \
574             builtin_define ("__tune_pentium_mmx__");            \
575         }                                                       \
576       else if (TARGET_PENTIUMPRO)                               \
577         {                                                       \
578           builtin_define ("__tune_i686__");                     \
579           builtin_define ("__tune_pentiumpro__");               \
580           switch (last_tune_char)                               \
581             {                                                   \
582             case '3':                                           \
583               builtin_define ("__tune_pentium3__");             \
584               /* FALLTHRU */                                    \
585             case '2':                                           \
586               builtin_define ("__tune_pentium2__");             \
587               break;                                            \
588             }                                                   \
589         }                                                       \
590       else if (TARGET_K6)                                       \
591         {                                                       \
592           builtin_define ("__tune_k6__");                       \
593           if (last_tune_char == '2')                            \
594             builtin_define ("__tune_k6_2__");                   \
595           else if (last_tune_char == '3')                       \
596             builtin_define ("__tune_k6_3__");                   \
597         }                                                       \
598       else if (TARGET_ATHLON)                                   \
599         {                                                       \
600           builtin_define ("__tune_athlon__");                   \
601           /* Only plain "athlon" lacks SSE.  */                 \
602           if (last_tune_char != 'n')                            \
603             builtin_define ("__tune_athlon_sse__");             \
604         }                                                       \
605       else if (TARGET_K8)                                       \
606         builtin_define ("__tune_k8__");                         \
607       else if (TARGET_PENTIUM4)                                 \
608         builtin_define ("__tune_pentium4__");                   \
609                                                                 \
610       if (TARGET_MMX)                                           \
611         builtin_define ("__MMX__");                             \
612       if (TARGET_3DNOW)                                         \
613         builtin_define ("__3dNOW__");                           \
614       if (TARGET_3DNOW_A)                                       \
615         builtin_define ("__3dNOW_A__");                         \
616       if (TARGET_SSE)                                           \
617         builtin_define ("__SSE__");                             \
618       if (TARGET_SSE2)                                          \
619         builtin_define ("__SSE2__");                            \
620       if (TARGET_PNI)                                           \
621         builtin_define ("__PNI__");                             \
622       if (TARGET_SSE_MATH && TARGET_SSE)                        \
623         builtin_define ("__SSE_MATH__");                        \
624       if (TARGET_SSE_MATH && TARGET_SSE2)                       \
625         builtin_define ("__SSE2_MATH__");                       \
626                                                                 \
627       /* Built-ins based on -march=.  */                        \
628       if (ix86_arch == PROCESSOR_I486)                          \
629         {                                                       \
630           builtin_define ("__i486");                            \
631           builtin_define ("__i486__");                          \
632         }                                                       \
633       else if (ix86_arch == PROCESSOR_PENTIUM)                  \
634         {                                                       \
635           builtin_define ("__i586");                            \
636           builtin_define ("__i586__");                          \
637           builtin_define ("__pentium");                         \
638           builtin_define ("__pentium__");                       \
639           if (last_arch_char == 'x')                            \
640             builtin_define ("__pentium_mmx__");                 \
641         }                                                       \
642       else if (ix86_arch == PROCESSOR_PENTIUMPRO)               \
643         {                                                       \
644           builtin_define ("__i686");                            \
645           builtin_define ("__i686__");                          \
646           builtin_define ("__pentiumpro");                      \
647           builtin_define ("__pentiumpro__");                    \
648         }                                                       \
649       else if (ix86_arch == PROCESSOR_K6)                       \
650         {                                                       \
651                                                                 \
652           builtin_define ("__k6");                              \
653           builtin_define ("__k6__");                            \
654           if (last_arch_char == '2')                            \
655             builtin_define ("__k6_2__");                        \
656           else if (last_arch_char == '3')                       \
657             builtin_define ("__k6_3__");                        \
658         }                                                       \
659       else if (ix86_arch == PROCESSOR_ATHLON)                   \
660         {                                                       \
661           builtin_define ("__athlon");                          \
662           builtin_define ("__athlon__");                        \
663           /* Only plain "athlon" lacks SSE.  */                 \
664           if (last_arch_char != 'n')                            \
665             builtin_define ("__athlon_sse__");                  \
666         }                                                       \
667       else if (ix86_arch == PROCESSOR_K8)                       \
668         {                                                       \
669           builtin_define ("__k8");                              \
670           builtin_define ("__k8__");                            \
671         }                                                       \
672       else if (ix86_arch == PROCESSOR_PENTIUM4)                 \
673         {                                                       \
674           builtin_define ("__pentium4");                        \
675           builtin_define ("__pentium4__");                      \
676         }                                                       \
677     }                                                           \
678   while (0)
679
680 #define TARGET_CPU_DEFAULT_i386 0
681 #define TARGET_CPU_DEFAULT_i486 1
682 #define TARGET_CPU_DEFAULT_pentium 2
683 #define TARGET_CPU_DEFAULT_pentium_mmx 3
684 #define TARGET_CPU_DEFAULT_pentiumpro 4
685 #define TARGET_CPU_DEFAULT_pentium2 5
686 #define TARGET_CPU_DEFAULT_pentium3 6
687 #define TARGET_CPU_DEFAULT_pentium4 7
688 #define TARGET_CPU_DEFAULT_k6 8
689 #define TARGET_CPU_DEFAULT_k6_2 9
690 #define TARGET_CPU_DEFAULT_k6_3 10
691 #define TARGET_CPU_DEFAULT_athlon 11
692 #define TARGET_CPU_DEFAULT_athlon_sse 12
693 #define TARGET_CPU_DEFAULT_k8 13
694
695 #define TARGET_CPU_DEFAULT_NAMES {"i386", "i486", "pentium", "pentium-mmx",\
696                                   "pentiumpro", "pentium2", "pentium3", \
697                                   "pentium4", "k6", "k6-2", "k6-3",\
698                                   "athlon", "athlon-4", "k8"}
699
700 #ifndef CC1_SPEC
701 #define CC1_SPEC "%(cc1_cpu) "
702 #endif
703
704 /* This macro defines names of additional specifications to put in the
705    specs that can be used in various specifications like CC1_SPEC.  Its
706    definition is an initializer with a subgrouping for each command option.
707
708    Each subgrouping contains a string constant, that defines the
709    specification name, and a string constant that used by the GCC driver
710    program.
711
712    Do not define this macro if it does not need to do anything.  */
713
714 #ifndef SUBTARGET_EXTRA_SPECS
715 #define SUBTARGET_EXTRA_SPECS
716 #endif
717
718 #define EXTRA_SPECS                                                     \
719   { "cc1_cpu",  CC1_CPU_SPEC },                                         \
720   SUBTARGET_EXTRA_SPECS
721 \f
722 /* target machine storage layout */
723
724 /* Define for XFmode or TFmode extended real floating point support.
725    The XFmode is specified by i386 ABI, while TFmode may be faster
726    due to alignment and simplifications in the address calculations.  */
727 #define LONG_DOUBLE_TYPE_SIZE (TARGET_128BIT_LONG_DOUBLE ? 128 : 96)
728 #define MAX_LONG_DOUBLE_TYPE_SIZE 128
729 #ifdef __x86_64__
730 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
731 #else
732 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 96
733 #endif
734
735 /* Set the value of FLT_EVAL_METHOD in float.h.  When using only the
736    FPU, assume that the fpcw is set to extended precision; when using
737    only SSE, rounding is correct; when using both SSE and the FPU,
738    the rounding precision is indeterminate, since either may be chosen
739    apparently at random.  */
740 #define TARGET_FLT_EVAL_METHOD \
741   (TARGET_MIX_SSE_I387 ? -1 : TARGET_SSE_MATH ? 0 : 2)
742
743 #define SHORT_TYPE_SIZE 16
744 #define INT_TYPE_SIZE 32
745 #define FLOAT_TYPE_SIZE 32
746 #define LONG_TYPE_SIZE BITS_PER_WORD
747 #define MAX_WCHAR_TYPE_SIZE 32
748 #define DOUBLE_TYPE_SIZE 64
749 #define LONG_LONG_TYPE_SIZE 64
750
751 #if defined (TARGET_BI_ARCH) || TARGET_64BIT_DEFAULT
752 #define MAX_BITS_PER_WORD 64
753 #define MAX_LONG_TYPE_SIZE 64
754 #else
755 #define MAX_BITS_PER_WORD 32
756 #define MAX_LONG_TYPE_SIZE 32
757 #endif
758
759 /* Define this if most significant byte of a word is the lowest numbered.  */
760 /* That is true on the 80386.  */
761
762 #define BITS_BIG_ENDIAN 0
763
764 /* Define this if most significant byte of a word is the lowest numbered.  */
765 /* That is not true on the 80386.  */
766 #define BYTES_BIG_ENDIAN 0
767
768 /* Define this if most significant word of a multiword number is the lowest
769    numbered.  */
770 /* Not true for 80386 */
771 #define WORDS_BIG_ENDIAN 0
772
773 /* Width of a word, in units (bytes).  */
774 #define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4)
775 #ifdef IN_LIBGCC2
776 #define MIN_UNITS_PER_WORD      (TARGET_64BIT ? 8 : 4)
777 #else
778 #define MIN_UNITS_PER_WORD      4
779 #endif
780
781 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
782 #define PARM_BOUNDARY BITS_PER_WORD
783
784 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
785 #define STACK_BOUNDARY BITS_PER_WORD
786
787 /* Boundary (in *bits*) on which the stack pointer prefers to be
788    aligned; the compiler cannot rely on having this alignment.  */
789 #define PREFERRED_STACK_BOUNDARY ix86_preferred_stack_boundary
790
791 /* As of July 2001, many runtimes to not align the stack properly when
792    entering main.  This causes expand_main_function to forcibly align
793    the stack, which results in aligned frames for functions called from
794    main, though it does nothing for the alignment of main itself.  */
795 #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN \
796   (ix86_preferred_stack_boundary > STACK_BOUNDARY && !TARGET_64BIT)
797
798 /* Minimum allocation boundary for the code of a function.  */
799 #define FUNCTION_BOUNDARY 8
800
801 /* C++ stores the virtual bit in the lowest bit of function pointers.  */
802 #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_pfn
803
804 /* Alignment of field after `int : 0' in a structure.  */
805
806 #define EMPTY_FIELD_BOUNDARY BITS_PER_WORD
807
808 /* Minimum size in bits of the largest boundary to which any
809    and all fundamental data types supported by the hardware
810    might need to be aligned. No data type wants to be aligned
811    rounder than this.
812
813    Pentium+ prefers DFmode values to be aligned to 64 bit boundary
814    and Pentium Pro XFmode values at 128 bit boundaries.  */
815
816 #define BIGGEST_ALIGNMENT 128
817
818 /* Decide whether a variable of mode MODE should be 128 bit aligned.  */
819 #define ALIGN_MODE_128(MODE) \
820  ((MODE) == XFmode || (MODE) == TFmode || SSE_REG_MODE_P (MODE))
821
822 /* The published ABIs say that doubles should be aligned on word
823    boundaries, so lower the alignment for structure fields unless
824    -malign-double is set.  */
825
826 /* ??? Blah -- this macro is used directly by libobjc.  Since it
827    supports no vector modes, cut out the complexity and fall back
828    on BIGGEST_FIELD_ALIGNMENT.  */
829 #ifdef IN_TARGET_LIBS
830 #ifdef __x86_64__
831 #define BIGGEST_FIELD_ALIGNMENT 128
832 #else
833 #define BIGGEST_FIELD_ALIGNMENT 32
834 #endif
835 #else
836 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
837    x86_field_alignment (FIELD, COMPUTED)
838 #endif
839
840 /* If defined, a C expression to compute the alignment given to a
841    constant that is being placed in memory.  EXP is the constant
842    and ALIGN is the alignment that the object would ordinarily have.
843    The value of this macro is used instead of that alignment to align
844    the object.
845
846    If this macro is not defined, then ALIGN is used.
847
848    The typical use of this macro is to increase alignment for string
849    constants to be word aligned so that `strcpy' calls that copy
850    constants can be done inline.  */
851
852 #define CONSTANT_ALIGNMENT(EXP, ALIGN) ix86_constant_alignment ((EXP), (ALIGN))
853
854 /* If defined, a C expression to compute the alignment for a static
855    variable.  TYPE is the data type, and ALIGN is the alignment that
856    the object would ordinarily have.  The value of this macro is used
857    instead of that alignment to align the object.
858
859    If this macro is not defined, then ALIGN is used.
860
861    One use of this macro is to increase alignment of medium-size
862    data to make it all fit in fewer cache lines.  Another is to
863    cause character arrays to be word-aligned so that `strcpy' calls
864    that copy constants to character arrays can be done inline.  */
865
866 #define DATA_ALIGNMENT(TYPE, ALIGN) ix86_data_alignment ((TYPE), (ALIGN))
867
868 /* If defined, a C expression to compute the alignment for a local
869    variable.  TYPE is the data type, and ALIGN is the alignment that
870    the object would ordinarily have.  The value of this macro is used
871    instead of that alignment to align the object.
872
873    If this macro is not defined, then ALIGN is used.
874
875    One use of this macro is to increase alignment of medium-size
876    data to make it all fit in fewer cache lines.  */
877
878 #define LOCAL_ALIGNMENT(TYPE, ALIGN) ix86_local_alignment ((TYPE), (ALIGN))
879
880 /* If defined, a C expression that gives the alignment boundary, in
881    bits, of an argument with the specified mode and type.  If it is
882    not defined, `PARM_BOUNDARY' is used for all arguments.  */
883
884 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
885   ix86_function_arg_boundary ((MODE), (TYPE))
886
887 /* Set this nonzero if move instructions will actually fail to work
888    when given unaligned data.  */
889 #define STRICT_ALIGNMENT 0
890
891 /* If bit field type is int, don't let it cross an int,
892    and give entire struct the alignment of an int.  */
893 /* Required on the 386 since it doesn't have bit-field insns.  */
894 #define PCC_BITFIELD_TYPE_MATTERS 1
895 \f
896 /* Standard register usage.  */
897
898 /* This processor has special stack-like registers.  See reg-stack.c
899    for details.  */
900
901 #define STACK_REGS
902 #define IS_STACK_MODE(MODE)                                     \
903   ((MODE) == DFmode || (MODE) == SFmode || (MODE) == XFmode     \
904    || (MODE) == TFmode)
905
906 /* Number of actual hardware registers.
907    The hardware registers are assigned numbers for the compiler
908    from 0 to just below FIRST_PSEUDO_REGISTER.
909    All registers that the compiler knows about must be given numbers,
910    even those that are not normally considered general registers.
911
912    In the 80386 we give the 8 general purpose registers the numbers 0-7.
913    We number the floating point registers 8-15.
914    Note that registers 0-7 can be accessed as a  short or int,
915    while only 0-3 may be used with byte `mov' instructions.
916
917    Reg 16 does not correspond to any hardware register, but instead
918    appears in the RTL as an argument pointer prior to reload, and is
919    eliminated during reloading in favor of either the stack or frame
920    pointer.  */
921
922 #define FIRST_PSEUDO_REGISTER 53
923
924 /* Number of hardware registers that go into the DWARF-2 unwind info.
925    If not defined, equals FIRST_PSEUDO_REGISTER.  */
926
927 #define DWARF_FRAME_REGISTERS 17
928
929 /* 1 for registers that have pervasive standard uses
930    and are not available for the register allocator.
931    On the 80386, the stack pointer is such, as is the arg pointer.
932
933    The value is a mask - bit 1 is set for fixed registers
934    for 32bit target, while 2 is set for fixed registers for 64bit.
935    Proper value is computed in the CONDITIONAL_REGISTER_USAGE.
936  */
937 #define FIXED_REGISTERS                                         \
938 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7*/      \
939 {  0, 0, 0, 0, 0, 0, 0, 3, 0,  0,  0,  0,  0,  0,  0,  0,       \
940 /*arg,flags,fpsr,dir,frame*/                                    \
941     3,    3,   3,  3,    3,                                     \
942 /*xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7*/                     \
943      0,   0,   0,   0,   0,   0,   0,   0,                      \
944 /*mmx0,mmx1,mmx2,mmx3,mmx4,mmx5,mmx6,mmx7*/                     \
945      0,   0,   0,   0,   0,   0,   0,   0,                      \
946 /*  r8,  r9, r10, r11, r12, r13, r14, r15*/                     \
947      1,   1,   1,   1,   1,   1,   1,   1,                      \
948 /*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/               \
949      1,   1,    1,    1,    1,    1,    1,    1}
950
951
952 /* 1 for registers not available across function calls.
953    These must include the FIXED_REGISTERS and also any
954    registers that can be used without being saved.
955    The latter must include the registers where values are returned
956    and the register where structure-value addresses are passed.
957    Aside from that, you can include as many other registers as you like.
958
959    The value is a mask - bit 1 is set for call used
960    for 32bit target, while 2 is set for call used for 64bit.
961    Proper value is computed in the CONDITIONAL_REGISTER_USAGE.
962 */
963 #define CALL_USED_REGISTERS                                     \
964 /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7*/      \
965 {  3, 3, 3, 0, 2, 2, 0, 3, 3,  3,  3,  3,  3,  3,  3,  3,       \
966 /*arg,flags,fpsr,dir,frame*/                                    \
967      3,   3,   3,  3,    3,                                     \
968 /*xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7*/                     \
969      3,   3,   3,   3,   3,  3,    3,   3,                      \
970 /*mmx0,mmx1,mmx2,mmx3,mmx4,mmx5,mmx6,mmx7*/                     \
971      3,   3,   3,   3,   3,   3,   3,   3,                      \
972 /*  r8,  r9, r10, r11, r12, r13, r14, r15*/                     \
973      3,   3,   3,   3,   1,   1,   1,   1,                      \
974 /*xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15*/               \
975      3,   3,    3,    3,    3,    3,    3,    3}                \
976
977 /* Order in which to allocate registers.  Each register must be
978    listed once, even those in FIXED_REGISTERS.  List frame pointer
979    late and fixed registers last.  Note that, in general, we prefer
980    registers listed in CALL_USED_REGISTERS, keeping the others
981    available for storage of persistent values.
982
983    The ORDER_REGS_FOR_LOCAL_ALLOC actually overwrite the order,
984    so this is just empty initializer for array.  */
985
986 #define REG_ALLOC_ORDER                                         \
987 {  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,\
988    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,  \
989    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,  \
990    48, 49, 50, 51, 52 }
991
992 /* ORDER_REGS_FOR_LOCAL_ALLOC is a macro which permits reg_alloc_order
993    to be rearranged based on a particular function.  When using sse math,
994    we want to allocate SSE before x87 registers and vice vera.  */
995
996 #define ORDER_REGS_FOR_LOCAL_ALLOC x86_order_regs_for_local_alloc ()
997
998
999 /* Macro to conditionally modify fixed_regs/call_used_regs.  */
1000 #define CONDITIONAL_REGISTER_USAGE                                      \
1001 do {                                                                    \
1002     int i;                                                              \
1003     for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)                         \
1004       {                                                                 \
1005         fixed_regs[i] = (fixed_regs[i] & (TARGET_64BIT ? 2 : 1)) != 0;  \
1006         call_used_regs[i] = (call_used_regs[i]                          \
1007                              & (TARGET_64BIT ? 2 : 1)) != 0;            \
1008       }                                                                 \
1009     if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM)                      \
1010       {                                                                 \
1011         fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1;                        \
1012         call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1;                    \
1013       }                                                                 \
1014     if (! TARGET_MMX)                                                   \
1015       {                                                                 \
1016         int i;                                                          \
1017         for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)                     \
1018           if (TEST_HARD_REG_BIT (reg_class_contents[(int)MMX_REGS], i)) \
1019             fixed_regs[i] = call_used_regs[i] = 1;                      \
1020       }                                                                 \
1021     if (! TARGET_SSE)                                                   \
1022       {                                                                 \
1023         int i;                                                          \
1024         for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)                     \
1025           if (TEST_HARD_REG_BIT (reg_class_contents[(int)SSE_REGS], i)) \
1026             fixed_regs[i] = call_used_regs[i] = 1;                      \
1027       }                                                                 \
1028     if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387)              \
1029       {                                                                 \
1030         int i;                                                          \
1031         HARD_REG_SET x;                                                 \
1032         COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]);     \
1033         for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)                     \
1034           if (TEST_HARD_REG_BIT (x, i))                                 \
1035             fixed_regs[i] = call_used_regs[i] = 1;                      \
1036       }                                                                 \
1037   } while (0)
1038
1039 /* Return number of consecutive hard regs needed starting at reg REGNO
1040    to hold something of mode MODE.
1041    This is ordinarily the length in words of a value of mode MODE
1042    but can be less for certain modes in special long registers.
1043
1044    Actually there are no two word move instructions for consecutive
1045    registers.  And only registers 0-3 may have mov byte instructions
1046    applied to them.
1047    */
1048
1049 #define HARD_REGNO_NREGS(REGNO, MODE)   \
1050   (FP_REGNO_P (REGNO) || SSE_REGNO_P (REGNO) || MMX_REGNO_P (REGNO)     \
1051    ? (COMPLEX_MODE_P (MODE) ? 2 : 1)                                    \
1052    : ((MODE) == TFmode                                                  \
1053       ? (TARGET_64BIT ? 2 : 3)                                          \
1054       : (MODE) == TCmode                                                \
1055       ? (TARGET_64BIT ? 4 : 6)                                          \
1056       : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
1057
1058 #define VALID_SSE2_REG_MODE(MODE) \
1059     ((MODE) == V16QImode || (MODE) == V8HImode || (MODE) == V2DFmode    \
1060      || (MODE) == V2DImode)
1061
1062 #define VALID_SSE_REG_MODE(MODE)                                        \
1063     ((MODE) == TImode || (MODE) == V4SFmode || (MODE) == V4SImode       \
1064      || (MODE) == SFmode                                                \
1065      /* Always accept SSE2 modes so that xmmintrin.h compiles.  */      \
1066      || VALID_SSE2_REG_MODE (MODE)                                      \
1067      || (TARGET_SSE2 && ((MODE) == DFmode || VALID_MMX_REG_MODE (MODE))))
1068
1069 #define VALID_MMX_REG_MODE_3DNOW(MODE) \
1070     ((MODE) == V2SFmode || (MODE) == SFmode)
1071
1072 #define VALID_MMX_REG_MODE(MODE)                                        \
1073     ((MODE) == DImode || (MODE) == V8QImode || (MODE) == V4HImode       \
1074      || (MODE) == V2SImode || (MODE) == SImode)
1075
1076 #define VECTOR_MODE_SUPPORTED_P(MODE)                                   \
1077     (VALID_SSE_REG_MODE (MODE) && TARGET_SSE ? 1                        \
1078      : VALID_MMX_REG_MODE (MODE) && TARGET_MMX ? 1                      \
1079      : VALID_MMX_REG_MODE_3DNOW (MODE) && TARGET_3DNOW ? 1 : 0)
1080
1081 #define VALID_FP_MODE_P(MODE)                                           \
1082     ((MODE) == SFmode || (MODE) == DFmode || (MODE) == TFmode           \
1083      || (!TARGET_64BIT && (MODE) == XFmode)                             \
1084      || (MODE) == SCmode || (MODE) == DCmode || (MODE) == TCmode        \
1085      || (!TARGET_64BIT && (MODE) == XCmode))
1086
1087 #define VALID_INT_MODE_P(MODE)                                          \
1088     ((MODE) == QImode || (MODE) == HImode || (MODE) == SImode           \
1089      || (MODE) == DImode                                                \
1090      || (MODE) == CQImode || (MODE) == CHImode || (MODE) == CSImode     \
1091      || (MODE) == CDImode                                               \
1092      || (TARGET_64BIT && ((MODE) == TImode || (MODE) == CTImode)))
1093
1094 /* Return true for modes passed in SSE registers.  */
1095 #define SSE_REG_MODE_P(MODE) \
1096  ((MODE) == TImode || (MODE) == V16QImode                               \
1097    || (MODE) == V8HImode || (MODE) == V2DFmode || (MODE) == V2DImode    \
1098    || (MODE) == V4SFmode || (MODE) == V4SImode)
1099
1100 /* Return true for modes passed in MMX registers.  */
1101 #define MMX_REG_MODE_P(MODE) \
1102  ((MODE) == V8QImode || (MODE) == V4HImode || (MODE) == V2SImode        \
1103    || (MODE) == V2SFmode)
1104
1105 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.  */
1106
1107 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
1108    ix86_hard_regno_mode_ok ((REGNO), (MODE))
1109
1110 /* Value is 1 if it is a good idea to tie two pseudo registers
1111    when one has mode MODE1 and one has mode MODE2.
1112    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
1113    for any hard reg, then this must be 0 for correct output.  */
1114
1115 #define MODES_TIEABLE_P(MODE1, MODE2)                           \
1116   ((MODE1) == (MODE2)                                           \
1117    || (((MODE1) == HImode || (MODE1) == SImode                  \
1118         || ((MODE1) == QImode                                   \
1119             && (TARGET_64BIT || !TARGET_PARTIAL_REG_STALL))     \
1120         || ((MODE1) == DImode && TARGET_64BIT))                 \
1121        && ((MODE2) == HImode || (MODE2) == SImode               \
1122            || ((MODE2) == QImode                                \
1123                && (TARGET_64BIT || !TARGET_PARTIAL_REG_STALL))  \
1124            || ((MODE2) == DImode && TARGET_64BIT))))
1125
1126 /* It is possible to write patterns to move flags; but until someone
1127    does it,  */
1128 #define AVOID_CCMODE_COPIES
1129
1130 /* Specify the modes required to caller save a given hard regno.
1131    We do this on i386 to prevent flags from being saved at all.
1132
1133    Kill any attempts to combine saving of modes.  */
1134
1135 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE)                 \
1136   (CC_REGNO_P (REGNO) ? VOIDmode                                        \
1137    : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode                      \
1138    : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), false)\
1139    : (MODE) == HImode && !TARGET_PARTIAL_REG_STALL ? SImode             \
1140    : (MODE) == QImode && (REGNO) >= 4 && !TARGET_64BIT ? SImode         \
1141    : (MODE))
1142 /* Specify the registers used for certain standard purposes.
1143    The values of these macros are register numbers.  */
1144
1145 /* on the 386 the pc register is %eip, and is not usable as a general
1146    register.  The ordinary mov instructions won't work */
1147 /* #define PC_REGNUM  */
1148
1149 /* Register to use for pushing function arguments.  */
1150 #define STACK_POINTER_REGNUM 7
1151
1152 /* Base register for access to local variables of the function.  */
1153 #define HARD_FRAME_POINTER_REGNUM 6
1154
1155 /* Base register for access to local variables of the function.  */
1156 #define FRAME_POINTER_REGNUM 20
1157
1158 /* First floating point reg */
1159 #define FIRST_FLOAT_REG 8
1160
1161 /* First & last stack-like regs */
1162 #define FIRST_STACK_REG FIRST_FLOAT_REG
1163 #define LAST_STACK_REG (FIRST_FLOAT_REG + 7)
1164
1165 #define FLAGS_REG 17
1166 #define FPSR_REG 18
1167 #define DIRFLAG_REG 19
1168
1169 #define FIRST_SSE_REG (FRAME_POINTER_REGNUM + 1)
1170 #define LAST_SSE_REG  (FIRST_SSE_REG + 7)
1171
1172 #define FIRST_MMX_REG  (LAST_SSE_REG + 1)
1173 #define LAST_MMX_REG   (FIRST_MMX_REG + 7)
1174
1175 #define FIRST_REX_INT_REG  (LAST_MMX_REG + 1)
1176 #define LAST_REX_INT_REG   (FIRST_REX_INT_REG + 7)
1177
1178 #define FIRST_REX_SSE_REG  (LAST_REX_INT_REG + 1)
1179 #define LAST_REX_SSE_REG   (FIRST_REX_SSE_REG + 7)
1180
1181 /* Value should be nonzero if functions must have frame pointers.
1182    Zero means the frame pointer need not be set up (and parms
1183    may be accessed via the stack pointer) in functions that seem suitable.
1184    This is computed in `reload', in reload1.c.  */
1185 #define FRAME_POINTER_REQUIRED  ix86_frame_pointer_required ()
1186
1187 /* Override this in other tm.h files to cope with various OS losage
1188    requiring a frame pointer.  */
1189 #ifndef SUBTARGET_FRAME_POINTER_REQUIRED
1190 #define SUBTARGET_FRAME_POINTER_REQUIRED 0
1191 #endif
1192
1193 /* Make sure we can access arbitrary call frames.  */
1194 #define SETUP_FRAME_ADDRESSES()  ix86_setup_frame_addresses ()
1195
1196 /* Base register for access to arguments of the function.  */
1197 #define ARG_POINTER_REGNUM 16
1198
1199 /* Register in which static-chain is passed to a function.
1200    We do use ECX as static chain register for 32 bit ABI.  On the
1201    64bit ABI, ECX is an argument register, so we use R10 instead.  */
1202 #define STATIC_CHAIN_REGNUM (TARGET_64BIT ? FIRST_REX_INT_REG + 10 - 8 : 2)
1203
1204 /* Register to hold the addressing base for position independent
1205    code access to data items.  We don't use PIC pointer for 64bit
1206    mode.  Define the regnum to dummy value to prevent gcc from
1207    pessimizing code dealing with EBX.
1208
1209    To avoid clobbering a call-saved register unnecessarily, we renumber
1210    the pic register when possible.  The change is visible after the
1211    prologue has been emitted.  */
1212
1213 #define REAL_PIC_OFFSET_TABLE_REGNUM  3
1214
1215 #define PIC_OFFSET_TABLE_REGNUM                         \
1216   (TARGET_64BIT || !flag_pic ? INVALID_REGNUM           \
1217    : reload_completed ? REGNO (pic_offset_table_rtx)    \
1218    : REAL_PIC_OFFSET_TABLE_REGNUM)
1219
1220 #define GOT_SYMBOL_NAME "_GLOBAL_OFFSET_TABLE_"
1221
1222 /* Register in which address to store a structure value
1223    arrives in the function.  On the 386, the prologue
1224    copies this from the stack to register %eax.  */
1225 #define STRUCT_VALUE_INCOMING 0
1226
1227 /* Place in which caller passes the structure value address.
1228    0 means push the value on the stack like an argument.  */
1229 #define STRUCT_VALUE 0
1230
1231 /* A C expression which can inhibit the returning of certain function
1232    values in registers, based on the type of value.  A nonzero value
1233    says to return the function value in memory, just as large
1234    structures are always returned.  Here TYPE will be a C expression
1235    of type `tree', representing the data type of the value.
1236
1237    Note that values of mode `BLKmode' must be explicitly handled by
1238    this macro.  Also, the option `-fpcc-struct-return' takes effect
1239    regardless of this macro.  On most systems, it is possible to
1240    leave the macro undefined; this causes a default definition to be
1241    used, whose value is the constant 1 for `BLKmode' values, and 0
1242    otherwise.
1243
1244    Do not use this macro to indicate that structures and unions
1245    should always be returned in memory.  You should instead use
1246    `DEFAULT_PCC_STRUCT_RETURN' to indicate this.  */
1247
1248 #define RETURN_IN_MEMORY(TYPE) \
1249   ix86_return_in_memory (TYPE)
1250
1251 /* This is overridden by <cygwin.h>.  */
1252 #define MS_AGGREGATE_RETURN 0
1253
1254 \f
1255 /* Define the classes of registers for register constraints in the
1256    machine description.  Also define ranges of constants.
1257
1258    One of the classes must always be named ALL_REGS and include all hard regs.
1259    If there is more than one class, another class must be named NO_REGS
1260    and contain no registers.
1261
1262    The name GENERAL_REGS must be the name of a class (or an alias for
1263    another name such as ALL_REGS).  This is the class of registers
1264    that is allowed by "g" or "r" in a register constraint.
1265    Also, registers outside this class are allocated only when
1266    instructions express preferences for them.
1267
1268    The classes must be numbered in nondecreasing order; that is,
1269    a larger-numbered class must never be contained completely
1270    in a smaller-numbered class.
1271
1272    For any two classes, it is very desirable that there be another
1273    class that represents their union.
1274
1275    It might seem that class BREG is unnecessary, since no useful 386
1276    opcode needs reg %ebx.  But some systems pass args to the OS in ebx,
1277    and the "b" register constraint is useful in asms for syscalls.
1278
1279    The flags and fpsr registers are in no class.  */
1280
1281 enum reg_class
1282 {
1283   NO_REGS,
1284   AREG, DREG, CREG, BREG, SIREG, DIREG,
1285   AD_REGS,                      /* %eax/%edx for DImode */
1286   Q_REGS,                       /* %eax %ebx %ecx %edx */
1287   NON_Q_REGS,                   /* %esi %edi %ebp %esp */
1288   INDEX_REGS,                   /* %eax %ebx %ecx %edx %esi %edi %ebp */
1289   LEGACY_REGS,                  /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
1290   GENERAL_REGS,                 /* %eax %ebx %ecx %edx %esi %edi %ebp %esp %r8 - %r15*/
1291   FP_TOP_REG, FP_SECOND_REG,    /* %st(0) %st(1) */
1292   FLOAT_REGS,
1293   SSE_REGS,
1294   MMX_REGS,
1295   FP_TOP_SSE_REGS,
1296   FP_SECOND_SSE_REGS,
1297   FLOAT_SSE_REGS,
1298   FLOAT_INT_REGS,
1299   INT_SSE_REGS,
1300   FLOAT_INT_SSE_REGS,
1301   ALL_REGS, LIM_REG_CLASSES
1302 };
1303
1304 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
1305
1306 #define INTEGER_CLASS_P(CLASS) \
1307   reg_class_subset_p ((CLASS), GENERAL_REGS)
1308 #define FLOAT_CLASS_P(CLASS) \
1309   reg_class_subset_p ((CLASS), FLOAT_REGS)
1310 #define SSE_CLASS_P(CLASS) \
1311   reg_class_subset_p ((CLASS), SSE_REGS)
1312 #define MMX_CLASS_P(CLASS) \
1313   reg_class_subset_p ((CLASS), MMX_REGS)
1314 #define MAYBE_INTEGER_CLASS_P(CLASS) \
1315   reg_classes_intersect_p ((CLASS), GENERAL_REGS)
1316 #define MAYBE_FLOAT_CLASS_P(CLASS) \
1317   reg_classes_intersect_p ((CLASS), FLOAT_REGS)
1318 #define MAYBE_SSE_CLASS_P(CLASS) \
1319   reg_classes_intersect_p (SSE_REGS, (CLASS))
1320 #define MAYBE_MMX_CLASS_P(CLASS) \
1321   reg_classes_intersect_p (MMX_REGS, (CLASS))
1322
1323 #define Q_CLASS_P(CLASS) \
1324   reg_class_subset_p ((CLASS), Q_REGS)
1325
1326 /* Give names of register classes as strings for dump file.   */
1327
1328 #define REG_CLASS_NAMES \
1329 {  "NO_REGS",                           \
1330    "AREG", "DREG", "CREG", "BREG",      \
1331    "SIREG", "DIREG",                    \
1332    "AD_REGS",                           \
1333    "Q_REGS", "NON_Q_REGS",              \
1334    "INDEX_REGS",                        \
1335    "LEGACY_REGS",                       \
1336    "GENERAL_REGS",                      \
1337    "FP_TOP_REG", "FP_SECOND_REG",       \
1338    "FLOAT_REGS",                        \
1339    "SSE_REGS",                          \
1340    "MMX_REGS",                          \
1341    "FP_TOP_SSE_REGS",                   \
1342    "FP_SECOND_SSE_REGS",                \
1343    "FLOAT_SSE_REGS",                    \
1344    "FLOAT_INT_REGS",                    \
1345    "INT_SSE_REGS",                      \
1346    "FLOAT_INT_SSE_REGS",                \
1347    "ALL_REGS" }
1348
1349 /* Define which registers fit in which classes.
1350    This is an initializer for a vector of HARD_REG_SET
1351    of length N_REG_CLASSES.  */
1352
1353 #define REG_CLASS_CONTENTS                                              \
1354 {     { 0x00,     0x0 },                                                \
1355       { 0x01,     0x0 }, { 0x02, 0x0 }, /* AREG, DREG */                \
1356       { 0x04,     0x0 }, { 0x08, 0x0 }, /* CREG, BREG */                \
1357       { 0x10,     0x0 }, { 0x20, 0x0 }, /* SIREG, DIREG */              \
1358       { 0x03,     0x0 },                /* AD_REGS */                   \
1359       { 0x0f,     0x0 },                /* Q_REGS */                    \
1360   { 0x1100f0,  0x1fe0 },                /* NON_Q_REGS */                \
1361       { 0x7f,  0x1fe0 },                /* INDEX_REGS */                \
1362   { 0x1100ff,  0x0 },                   /* LEGACY_REGS */               \
1363   { 0x1100ff,  0x1fe0 },                /* GENERAL_REGS */              \
1364      { 0x100,     0x0 }, { 0x0200, 0x0 },/* FP_TOP_REG, FP_SECOND_REG */\
1365     { 0xff00,     0x0 },                /* FLOAT_REGS */                \
1366 { 0x1fe00000,0x1fe000 },                /* SSE_REGS */                  \
1367 { 0xe0000000,    0x1f },                /* MMX_REGS */                  \
1368 { 0x1fe00100,0x1fe000 },                /* FP_TOP_SSE_REG */            \
1369 { 0x1fe00200,0x1fe000 },                /* FP_SECOND_SSE_REG */         \
1370 { 0x1fe0ff00,0x1fe000 },                /* FLOAT_SSE_REGS */            \
1371    { 0x1ffff,  0x1fe0 },                /* FLOAT_INT_REGS */            \
1372 { 0x1fe100ff,0x1fffe0 },                /* INT_SSE_REGS */              \
1373 { 0x1fe1ffff,0x1fffe0 },                /* FLOAT_INT_SSE_REGS */        \
1374 { 0xffffffff,0x1fffff }                                                 \
1375 }
1376
1377 /* The same information, inverted:
1378    Return the class number of the smallest class containing
1379    reg number REGNO.  This could be a conditional expression
1380    or could index an array.  */
1381
1382 #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
1383
1384 /* When defined, the compiler allows registers explicitly used in the
1385    rtl to be used as spill registers but prevents the compiler from
1386    extending the lifetime of these registers.  */
1387
1388 #define SMALL_REGISTER_CLASSES 1
1389
1390 #define QI_REG_P(X) \
1391   (REG_P (X) && REGNO (X) < 4)
1392
1393 #define GENERAL_REGNO_P(N) \
1394   ((N) < 8 || REX_INT_REGNO_P (N))
1395
1396 #define GENERAL_REG_P(X) \
1397   (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
1398
1399 #define ANY_QI_REG_P(X) (TARGET_64BIT ? GENERAL_REG_P(X) : QI_REG_P (X))
1400
1401 #define NON_QI_REG_P(X) \
1402   (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER)
1403
1404 #define REX_INT_REGNO_P(N) ((N) >= FIRST_REX_INT_REG && (N) <= LAST_REX_INT_REG)
1405 #define REX_INT_REG_P(X) (REG_P (X) && REX_INT_REGNO_P (REGNO (X)))
1406
1407 #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
1408 #define FP_REGNO_P(N) ((N) >= FIRST_STACK_REG && (N) <= LAST_STACK_REG)
1409 #define ANY_FP_REG_P(X) (REG_P (X) && ANY_FP_REGNO_P (REGNO (X)))
1410 #define ANY_FP_REGNO_P(N) (FP_REGNO_P (N) || SSE_REGNO_P (N))
1411
1412 #define SSE_REGNO_P(N) \
1413   (((N) >= FIRST_SSE_REG && (N) <= LAST_SSE_REG) \
1414    || ((N) >= FIRST_REX_SSE_REG && (N) <= LAST_REX_SSE_REG))
1415
1416 #define REX_SSE_REGNO_P(N) \
1417    ((N) >= FIRST_REX_SSE_REG && (N) <= LAST_REX_SSE_REG)
1418
1419 #define SSE_REGNO(N) \
1420   ((N) < 8 ? FIRST_SSE_REG + (N) : FIRST_REX_SSE_REG + (N) - 8)
1421 #define SSE_REG_P(N) (REG_P (N) && SSE_REGNO_P (REGNO (N)))
1422
1423 #define SSE_FLOAT_MODE_P(MODE) \
1424   ((TARGET_SSE && (MODE) == SFmode) || (TARGET_SSE2 && (MODE) == DFmode))
1425
1426 #define MMX_REGNO_P(N) ((N) >= FIRST_MMX_REG && (N) <= LAST_MMX_REG)
1427 #define MMX_REG_P(XOP) (REG_P (XOP) && MMX_REGNO_P (REGNO (XOP)))
1428
1429 #define STACK_REG_P(XOP)                \
1430   (REG_P (XOP) &&                       \
1431    REGNO (XOP) >= FIRST_STACK_REG &&    \
1432    REGNO (XOP) <= LAST_STACK_REG)
1433
1434 #define NON_STACK_REG_P(XOP) (REG_P (XOP) && ! STACK_REG_P (XOP))
1435
1436 #define STACK_TOP_P(XOP) (REG_P (XOP) && REGNO (XOP) == FIRST_STACK_REG)
1437
1438 #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
1439 #define CC_REGNO_P(X) ((X) == FLAGS_REG || (X) == FPSR_REG)
1440
1441 /* Indicate whether hard register numbered REG_NO should be converted
1442    to SSA form.  */
1443 #define CONVERT_HARD_REGISTER_TO_SSA_P(REG_NO) \
1444   ((REG_NO) == FLAGS_REG || (REG_NO) == ARG_POINTER_REGNUM)
1445
1446 /* The class value for index registers, and the one for base regs.  */
1447
1448 #define INDEX_REG_CLASS INDEX_REGS
1449 #define BASE_REG_CLASS GENERAL_REGS
1450
1451 /* Get reg_class from a letter such as appears in the machine description.  */
1452
1453 #define REG_CLASS_FROM_LETTER(C)        \
1454   ((C) == 'r' ? GENERAL_REGS :                                  \
1455    (C) == 'R' ? LEGACY_REGS :                                   \
1456    (C) == 'q' ? TARGET_64BIT ? GENERAL_REGS : Q_REGS :          \
1457    (C) == 'Q' ? Q_REGS :                                        \
1458    (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387  \
1459                  ? FLOAT_REGS                                   \
1460                  : NO_REGS) :                                   \
1461    (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387  \
1462                  ? FP_TOP_REG                                   \
1463                  : NO_REGS) :                                   \
1464    (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387  \
1465                  ? FP_SECOND_REG                                \
1466                  : NO_REGS) :                                   \
1467    (C) == 'a' ? AREG :                                          \
1468    (C) == 'b' ? BREG :                                          \
1469    (C) == 'c' ? CREG :                                          \
1470    (C) == 'd' ? DREG :                                          \
1471    (C) == 'x' ? TARGET_SSE ? SSE_REGS : NO_REGS :               \
1472    (C) == 'Y' ? TARGET_SSE2? SSE_REGS : NO_REGS :               \
1473    (C) == 'y' ? TARGET_MMX ? MMX_REGS : NO_REGS :               \
1474    (C) == 'A' ? AD_REGS :                                       \
1475    (C) == 'D' ? DIREG :                                         \
1476    (C) == 'S' ? SIREG : NO_REGS)
1477
1478 /* The letters I, J, K, L and M in a register constraint string
1479    can be used to stand for particular ranges of immediate operands.
1480    This macro defines what the ranges are.
1481    C is the letter, and VALUE is a constant value.
1482    Return 1 if VALUE is in the range specified by C.
1483
1484    I is for non-DImode shifts.
1485    J is for DImode shifts.
1486    K is for signed imm8 operands.
1487    L is for andsi as zero-extending move.
1488    M is for shifts that can be executed by the "lea" opcode.
1489    N is for immediate operands for out/in instructions (0-255)
1490    */
1491
1492 #define CONST_OK_FOR_LETTER_P(VALUE, C)                         \
1493   ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31                   \
1494    : (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63                 \
1495    : (C) == 'K' ? (VALUE) >= -128 && (VALUE) <= 127             \
1496    : (C) == 'L' ? (VALUE) == 0xff || (VALUE) == 0xffff          \
1497    : (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3                  \
1498    : (C) == 'N' ? (VALUE) >= 0 && (VALUE) <= 255                \
1499    : 0)
1500
1501 /* Similar, but for floating constants, and defining letters G and H.
1502    Here VALUE is the CONST_DOUBLE rtx itself.  We allow constants even if
1503    TARGET_387 isn't set, because the stack register converter may need to
1504    load 0.0 into the function value register.  */
1505
1506 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)  \
1507   ((C) == 'G' ? standard_80387_constant_p (VALUE) \
1508    : 0)
1509
1510 /* A C expression that defines the optional machine-dependent
1511    constraint letters that can be used to segregate specific types of
1512    operands, usually memory references, for the target machine.  Any
1513    letter that is not elsewhere defined and not matched by
1514    `REG_CLASS_FROM_LETTER' may be used.  Normally this macro will not
1515    be defined.
1516
1517    If it is required for a particular target machine, it should
1518    return 1 if VALUE corresponds to the operand type represented by
1519    the constraint letter C.  If C is not defined as an extra
1520    constraint, the value returned should be 0 regardless of VALUE.  */
1521
1522 #define EXTRA_CONSTRAINT(VALUE, D)                              \
1523   ((D) == 'e' ? x86_64_sign_extended_value (VALUE)              \
1524    : (D) == 'Z' ? x86_64_zero_extended_value (VALUE)            \
1525    : (D) == 'C' ? standard_sse_constant_p (VALUE)               \
1526    : 0)
1527
1528 /* Place additional restrictions on the register class to use when it
1529    is necessary to be able to hold a value of mode MODE in a reload
1530    register for which class CLASS would ordinarily be used.  */
1531
1532 #define LIMIT_RELOAD_CLASS(MODE, CLASS)                         \
1533   ((MODE) == QImode && !TARGET_64BIT                            \
1534    && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS           \
1535        || (CLASS) == LEGACY_REGS || (CLASS) == INDEX_REGS)      \
1536    ? Q_REGS : (CLASS))
1537
1538 /* Given an rtx X being reloaded into a reg required to be
1539    in class CLASS, return the class of reg to actually use.
1540    In general this is just CLASS; but on some machines
1541    in some cases it is preferable to use a more restrictive class.
1542    On the 80386 series, we prevent floating constants from being
1543    reloaded into floating registers (since no move-insn can do that)
1544    and we ensure that QImodes aren't reloaded into the esi or edi reg.  */
1545
1546 /* Put float CONST_DOUBLE in the constant pool instead of fp regs.
1547    QImode must go into class Q_REGS.
1548    Narrow ALL_REGS to GENERAL_REGS.  This supports allowing movsf and
1549    movdf to do mem-to-mem moves through integer regs.  */
1550
1551 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
1552    ix86_preferred_reload_class ((X), (CLASS))
1553
1554 /* If we are copying between general and FP registers, we need a memory
1555    location. The same is true for SSE and MMX registers.  */
1556 #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
1557   ix86_secondary_memory_needed ((CLASS1), (CLASS2), (MODE), 1)
1558
1559 /* QImode spills from non-QI registers need a scratch.  This does not
1560    happen often -- the only example so far requires an uninitialized
1561    pseudo.  */
1562
1563 #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, OUT)                 \
1564   (((CLASS) == GENERAL_REGS || (CLASS) == LEGACY_REGS                   \
1565     || (CLASS) == INDEX_REGS) && !TARGET_64BIT && (MODE) == QImode      \
1566    ? Q_REGS : NO_REGS)
1567
1568 /* Return the maximum number of consecutive registers
1569    needed to represent mode MODE in a register of class CLASS.  */
1570 /* On the 80386, this is the size of MODE in words,
1571    except in the FP regs, where a single reg is always enough.
1572    The TFmodes are really just 80bit values, so we use only 3 registers
1573    to hold them, instead of 4, as the size would suggest.
1574  */
1575 #define CLASS_MAX_NREGS(CLASS, MODE)                                    \
1576  (!MAYBE_INTEGER_CLASS_P (CLASS)                                        \
1577   ? (COMPLEX_MODE_P (MODE) ? 2 : 1)                                     \
1578   : ((GET_MODE_SIZE ((MODE) == TFmode ? XFmode : (MODE))                \
1579      + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
1580
1581 /* A C expression whose value is nonzero if pseudos that have been
1582    assigned to registers of class CLASS would likely be spilled
1583    because registers of CLASS are needed for spill registers.
1584
1585    The default value of this macro returns 1 if CLASS has exactly one
1586    register and zero otherwise.  On most machines, this default
1587    should be used.  Only define this macro to some other expression
1588    if pseudo allocated by `local-alloc.c' end up in memory because
1589    their hard registers were needed for spill registers.  If this
1590    macro returns nonzero for those classes, those pseudos will only
1591    be allocated by `global.c', which knows how to reallocate the
1592    pseudo to another register.  If there would not be another
1593    register available for reallocation, you should not change the
1594    definition of this macro since the only effect of such a
1595    definition would be to slow down register allocation.  */
1596
1597 #define CLASS_LIKELY_SPILLED_P(CLASS)                                   \
1598   (((CLASS) == AREG)                                                    \
1599    || ((CLASS) == DREG)                                                 \
1600    || ((CLASS) == CREG)                                                 \
1601    || ((CLASS) == BREG)                                                 \
1602    || ((CLASS) == AD_REGS)                                              \
1603    || ((CLASS) == SIREG)                                                \
1604    || ((CLASS) == DIREG))
1605
1606 /* Return a class of registers that cannot change FROM mode to TO mode.
1607   
1608    x87 registers can't do subreg as all values are reformated to extended
1609    precision.  XMM registers does not support with nonzero offsets equal
1610    to 4, 8 and 12 otherwise valid for integer registers. Since we can't
1611    determine these, prohibit all nonparadoxical subregs changing size.  */
1612
1613 #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)       \
1614   (GET_MODE_SIZE (TO) < GET_MODE_SIZE (FROM)            \
1615    ? reg_classes_intersect_p (FLOAT_SSE_REGS, (CLASS))  \
1616      || MAYBE_MMX_CLASS_P (CLASS)                       \
1617    : GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)         \
1618    ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
1619
1620 /* A C statement that adds to CLOBBERS any hard regs the port wishes
1621    to automatically clobber for all asms.
1622
1623    We do this in the new i386 backend to maintain source compatibility
1624    with the old cc0-based compiler.  */
1625
1626 #define MD_ASM_CLOBBERS(CLOBBERS)                                       \
1627   do {                                                                  \
1628     (CLOBBERS) = tree_cons (NULL_TREE, build_string (5, "flags"),       \
1629                             (CLOBBERS));                                \
1630     (CLOBBERS) = tree_cons (NULL_TREE, build_string (4, "fpsr"),        \
1631                             (CLOBBERS));                                \
1632     (CLOBBERS) = tree_cons (NULL_TREE, build_string (7, "dirflag"),     \
1633                             (CLOBBERS));                                \
1634   } while (0)
1635 \f
1636 /* Stack layout; function entry, exit and calling.  */
1637
1638 /* Define this if pushing a word on the stack
1639    makes the stack pointer a smaller address.  */
1640 #define STACK_GROWS_DOWNWARD
1641
1642 /* Define this if the nominal address of the stack frame
1643    is at the high-address end of the local variables;
1644    that is, each additional local variable allocated
1645    goes at a more negative offset in the frame.  */
1646 #define FRAME_GROWS_DOWNWARD
1647
1648 /* Offset within stack frame to start allocating local variables at.
1649    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
1650    first local allocated.  Otherwise, it is the offset to the BEGINNING
1651    of the first local allocated.  */
1652 #define STARTING_FRAME_OFFSET 0
1653
1654 /* If we generate an insn to push BYTES bytes,
1655    this says how many the stack pointer really advances by.
1656    On 386 pushw decrements by exactly 2 no matter what the position was.
1657    On the 386 there is no pushb; we use pushw instead, and this
1658    has the effect of rounding up to 2.
1659
1660    For 64bit ABI we round up to 8 bytes.
1661  */
1662
1663 #define PUSH_ROUNDING(BYTES) \
1664   (TARGET_64BIT              \
1665    ? (((BYTES) + 7) & (-8))  \
1666    : (((BYTES) + 1) & (-2)))
1667
1668 /* If defined, the maximum amount of space required for outgoing arguments will
1669    be computed and placed into the variable
1670    `current_function_outgoing_args_size'.  No space will be pushed onto the
1671    stack for each call; instead, the function prologue should increase the stack
1672    frame size by this amount.  */
1673
1674 #define ACCUMULATE_OUTGOING_ARGS TARGET_ACCUMULATE_OUTGOING_ARGS
1675
1676 /* If defined, a C expression whose value is nonzero when we want to use PUSH
1677    instructions to pass outgoing arguments.  */
1678
1679 #define PUSH_ARGS (TARGET_PUSH_ARGS && !ACCUMULATE_OUTGOING_ARGS)
1680
1681 /* We want the stack and args grow in opposite directions, even if
1682    PUSH_ARGS is 0.  */
1683 #define PUSH_ARGS_REVERSED 1
1684
1685 /* Offset of first parameter from the argument pointer register value.  */
1686 #define FIRST_PARM_OFFSET(FNDECL) 0
1687
1688 /* Define this macro if functions should assume that stack space has been
1689    allocated for arguments even when their values are passed in registers.
1690
1691    The value of this macro is the size, in bytes, of the area reserved for
1692    arguments passed in registers for the function represented by FNDECL.
1693
1694    This space can be allocated by the caller, or be a part of the
1695    machine-dependent stack frame: `OUTGOING_REG_PARM_STACK_SPACE' says
1696    which.  */
1697 #define REG_PARM_STACK_SPACE(FNDECL) 0
1698
1699 /* Define as a C expression that evaluates to nonzero if we do not know how
1700    to pass TYPE solely in registers.  The file expr.h defines a
1701    definition that is usually appropriate, refer to expr.h for additional
1702    documentation. If `REG_PARM_STACK_SPACE' is defined, the argument will be
1703    computed in the stack and then loaded into a register.  */
1704 #define MUST_PASS_IN_STACK(MODE, TYPE)  ix86_must_pass_in_stack ((MODE), (TYPE))
1705
1706 /* Value is the number of bytes of arguments automatically
1707    popped when returning from a subroutine call.
1708    FUNDECL is the declaration node of the function (as a tree),
1709    FUNTYPE is the data type of the function (as a tree),
1710    or for a library call it is an identifier node for the subroutine name.
1711    SIZE is the number of bytes of arguments passed on the stack.
1712
1713    On the 80386, the RTD insn may be used to pop them if the number
1714      of args is fixed, but if the number is variable then the caller
1715      must pop them all.  RTD can't be used for library calls now
1716      because the library is compiled with the Unix compiler.
1717    Use of RTD is a selectable option, since it is incompatible with
1718    standard Unix calling sequences.  If the option is not selected,
1719    the caller must always pop the args.
1720
1721    The attribute stdcall is equivalent to RTD on a per module basis.  */
1722
1723 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, SIZE) \
1724   ix86_return_pops_args ((FUNDECL), (FUNTYPE), (SIZE))
1725
1726 /* Define how to find the value returned by a function.
1727    VALTYPE is the data type of the value (as a tree).
1728    If the precise function being called is known, FUNC is its FUNCTION_DECL;
1729    otherwise, FUNC is 0.  */
1730 #define FUNCTION_VALUE(VALTYPE, FUNC)  \
1731    ix86_function_value (VALTYPE)
1732
1733 #define FUNCTION_VALUE_REGNO_P(N) \
1734   ix86_function_value_regno_p (N)
1735
1736 /* Define how to find the value returned by a library function
1737    assuming the value has mode MODE.  */
1738
1739 #define LIBCALL_VALUE(MODE) \
1740   ix86_libcall_value (MODE)
1741
1742 /* Define the size of the result block used for communication between
1743    untyped_call and untyped_return.  The block contains a DImode value
1744    followed by the block used by fnsave and frstor.  */
1745
1746 #define APPLY_RESULT_SIZE (8+108)
1747
1748 /* 1 if N is a possible register number for function argument passing.  */
1749 #define FUNCTION_ARG_REGNO_P(N) ix86_function_arg_regno_p (N)
1750
1751 /* Define a data type for recording info about an argument list
1752    during the scan of that argument list.  This data type should
1753    hold all necessary information about the function itself
1754    and about the args processed so far, enough to enable macros
1755    such as FUNCTION_ARG to determine where the next arg should go.  */
1756
1757 typedef struct ix86_args {
1758   int words;                    /* # words passed so far */
1759   int nregs;                    /* # registers available for passing */
1760   int regno;                    /* next available register number */
1761   int fastcall;         /* fastcall calling convention is used */
1762   int sse_words;                /* # sse words passed so far */
1763   int sse_nregs;                /* # sse registers available for passing */
1764   int sse_regno;                /* next available sse register number */
1765   int maybe_vaarg;              /* true for calls to possibly vardic fncts.  */
1766 } CUMULATIVE_ARGS;
1767
1768 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1769    for a call to a function whose data type is FNTYPE.
1770    For a library call, FNTYPE is 0.  */
1771
1772 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL) \
1773   init_cumulative_args (&(CUM), (FNTYPE), (LIBNAME), (FNDECL))
1774
1775 /* Update the data in CUM to advance over an argument
1776    of mode MODE and data type TYPE.
1777    (TYPE is null for libcalls where that information may not be available.)  */
1778
1779 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
1780   function_arg_advance (&(CUM), (MODE), (TYPE), (NAMED))
1781
1782 /* Define where to put the arguments to a function.
1783    Value is zero to push the argument on the stack,
1784    or a hard register in which to store the argument.
1785
1786    MODE is the argument's machine mode.
1787    TYPE is the data type of the argument (as a tree).
1788     This is null for libcalls where that information may
1789     not be available.
1790    CUM is a variable of type CUMULATIVE_ARGS which gives info about
1791     the preceding args and about the function being called.
1792    NAMED is nonzero if this argument is a named parameter
1793     (otherwise it is an extra parameter matching an ellipsis).  */
1794
1795 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
1796   function_arg (&(CUM), (MODE), (TYPE), (NAMED))
1797
1798 /* For an arg passed partly in registers and partly in memory,
1799    this is the number of registers used.
1800    For args passed entirely in registers or entirely in memory, zero.  */
1801
1802 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
1803
1804 /* A C expression that indicates when an argument must be passed by
1805    reference.  If nonzero for an argument, a copy of that argument is
1806    made in memory and a pointer to the argument is passed instead of
1807    the argument itself.  The pointer is passed in whatever way is
1808    appropriate for passing a pointer to that type.  */
1809  
1810 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
1811   function_arg_pass_by_reference(&CUM, MODE, TYPE, NAMED)
1812  
1813 /* Perform any needed actions needed for a function that is receiving a
1814    variable number of arguments.
1815
1816    CUM is as above.
1817
1818    MODE and TYPE are the mode and type of the current parameter.
1819
1820    PRETEND_SIZE is a variable that should be set to the amount of stack
1821    that must be pushed by the prolog to pretend that our caller pushed
1822    it.
1823
1824    Normally, this macro will push all remaining incoming registers on the
1825    stack and set PRETEND_SIZE to the length of the registers pushed.  */
1826
1827 #define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PRETEND_SIZE, NO_RTL)   \
1828   ix86_setup_incoming_varargs (&(CUM), (MODE), (TYPE), &(PRETEND_SIZE), \
1829                                (NO_RTL))
1830
1831 /* Define the `__builtin_va_list' type for the ABI.  */
1832 #define BUILD_VA_LIST_TYPE(VALIST) \
1833   ((VALIST) = ix86_build_va_list ())
1834
1835 /* Implement `va_start' for varargs and stdarg.  */
1836 #define EXPAND_BUILTIN_VA_START(VALIST, NEXTARG) \
1837   ix86_va_start (VALIST, NEXTARG)
1838
1839 /* Implement `va_arg'.  */
1840 #define EXPAND_BUILTIN_VA_ARG(VALIST, TYPE) \
1841   ix86_va_arg ((VALIST), (TYPE))
1842
1843 #define TARGET_ASM_FILE_END ix86_file_end
1844 #define NEED_INDICATE_EXEC_STACK 0
1845
1846 /* Output assembler code to FILE to increment profiler label # LABELNO
1847    for profiling a function entry.  */
1848
1849 #define FUNCTION_PROFILER(FILE, LABELNO) x86_function_profiler (FILE, LABELNO)
1850
1851 #define MCOUNT_NAME "_mcount"
1852
1853 #define PROFILE_COUNT_REGISTER "edx"
1854
1855 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
1856    the stack pointer does not matter.  The value is tested only in
1857    functions that have frame pointers.
1858    No definition is equivalent to always zero.  */
1859 /* Note on the 386 it might be more efficient not to define this since
1860    we have to restore it ourselves from the frame pointer, in order to
1861    use pop */
1862
1863 #define EXIT_IGNORE_STACK 1
1864
1865 /* Output assembler code for a block containing the constant parts
1866    of a trampoline, leaving space for the variable parts.  */
1867
1868 /* On the 386, the trampoline contains two instructions:
1869      mov #STATIC,ecx
1870      jmp FUNCTION
1871    The trampoline is generated entirely at runtime.  The operand of JMP
1872    is the address of FUNCTION relative to the instruction following the
1873    JMP (which is 5 bytes long).  */
1874
1875 /* Length in units of the trampoline for entering a nested function.  */
1876
1877 #define TRAMPOLINE_SIZE (TARGET_64BIT ? 23 : 10)
1878
1879 /* Emit RTL insns to initialize the variable parts of a trampoline.
1880    FNADDR is an RTX for the address of the function's pure code.
1881    CXT is an RTX for the static chain value for the function.  */
1882
1883 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
1884   x86_initialize_trampoline ((TRAMP), (FNADDR), (CXT))
1885 \f
1886 /* Definitions for register eliminations.
1887
1888    This is an array of structures.  Each structure initializes one pair
1889    of eliminable registers.  The "from" register number is given first,
1890    followed by "to".  Eliminations of the same "from" register are listed
1891    in order of preference.
1892
1893    There are two registers that can always be eliminated on the i386.
1894    The frame pointer and the arg pointer can be replaced by either the
1895    hard frame pointer or to the stack pointer, depending upon the
1896    circumstances.  The hard frame pointer is not used before reload and
1897    so it is not eligible for elimination.  */
1898
1899 #define ELIMINABLE_REGS                                 \
1900 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM},           \
1901  { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},      \
1902  { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},         \
1903  { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}}    \
1904
1905 /* Given FROM and TO register numbers, say whether this elimination is
1906    allowed.  Frame pointer elimination is automatically handled.
1907
1908    All other eliminations are valid.  */
1909
1910 #define CAN_ELIMINATE(FROM, TO) \
1911   ((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
1912
1913 /* Define the offset between two registers, one to be eliminated, and the other
1914    its replacement, at the start of a routine.  */
1915
1916 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
1917   ((OFFSET) = ix86_initial_elimination_offset ((FROM), (TO)))
1918 \f
1919 /* Addressing modes, and classification of registers for them.  */
1920
1921 /* Macros to check register numbers against specific register classes.  */
1922
1923 /* These assume that REGNO is a hard or pseudo reg number.
1924    They give nonzero only if REGNO is a hard reg of the suitable class
1925    or a pseudo reg currently allocated to a suitable hard reg.
1926    Since they use reg_renumber, they are safe only once reg_renumber
1927    has been allocated, which happens in local-alloc.c.  */
1928
1929 #define REGNO_OK_FOR_INDEX_P(REGNO)                                     \
1930   ((REGNO) < STACK_POINTER_REGNUM                                       \
1931    || (REGNO >= FIRST_REX_INT_REG                                       \
1932        && (REGNO) <= LAST_REX_INT_REG)                                  \
1933    || ((unsigned) reg_renumber[(REGNO)] >= FIRST_REX_INT_REG            \
1934        && (unsigned) reg_renumber[(REGNO)] <= LAST_REX_INT_REG)         \
1935    || (unsigned) reg_renumber[(REGNO)] < STACK_POINTER_REGNUM)
1936
1937 #define REGNO_OK_FOR_BASE_P(REGNO)                                      \
1938   ((REGNO) <= STACK_POINTER_REGNUM                                      \
1939    || (REGNO) == ARG_POINTER_REGNUM                                     \
1940    || (REGNO) == FRAME_POINTER_REGNUM                                   \
1941    || (REGNO >= FIRST_REX_INT_REG                                       \
1942        && (REGNO) <= LAST_REX_INT_REG)                                  \
1943    || ((unsigned) reg_renumber[(REGNO)] >= FIRST_REX_INT_REG            \
1944        && (unsigned) reg_renumber[(REGNO)] <= LAST_REX_INT_REG)         \
1945    || (unsigned) reg_renumber[(REGNO)] <= STACK_POINTER_REGNUM)
1946
1947 #define REGNO_OK_FOR_SIREG_P(REGNO) \
1948   ((REGNO) == 4 || reg_renumber[(REGNO)] == 4)
1949 #define REGNO_OK_FOR_DIREG_P(REGNO) \
1950   ((REGNO) == 5 || reg_renumber[(REGNO)] == 5)
1951
1952 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
1953    and check its validity for a certain class.
1954    We have two alternate definitions for each of them.
1955    The usual definition accepts all pseudo regs; the other rejects
1956    them unless they have been allocated suitable hard regs.
1957    The symbol REG_OK_STRICT causes the latter definition to be used.
1958
1959    Most source files want to accept pseudo regs in the hope that
1960    they will get allocated to the class that the insn wants them to be in.
1961    Source files for reload pass need to be strict.
1962    After reload, it makes no difference, since pseudo regs have
1963    been eliminated by then.  */
1964
1965
1966 /* Non strict versions, pseudos are ok */
1967 #define REG_OK_FOR_INDEX_NONSTRICT_P(X)                                 \
1968   (REGNO (X) < STACK_POINTER_REGNUM                                     \
1969    || (REGNO (X) >= FIRST_REX_INT_REG                                   \
1970        && REGNO (X) <= LAST_REX_INT_REG)                                \
1971    || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1972
1973 #define REG_OK_FOR_BASE_NONSTRICT_P(X)                                  \
1974   (REGNO (X) <= STACK_POINTER_REGNUM                                    \
1975    || REGNO (X) == ARG_POINTER_REGNUM                                   \
1976    || REGNO (X) == FRAME_POINTER_REGNUM                                 \
1977    || (REGNO (X) >= FIRST_REX_INT_REG                                   \
1978        && REGNO (X) <= LAST_REX_INT_REG)                                \
1979    || REGNO (X) >= FIRST_PSEUDO_REGISTER)
1980
1981 /* Strict versions, hard registers only */
1982 #define REG_OK_FOR_INDEX_STRICT_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
1983 #define REG_OK_FOR_BASE_STRICT_P(X)  REGNO_OK_FOR_BASE_P (REGNO (X))
1984
1985 #ifndef REG_OK_STRICT
1986 #define REG_OK_FOR_INDEX_P(X)  REG_OK_FOR_INDEX_NONSTRICT_P (X)
1987 #define REG_OK_FOR_BASE_P(X)   REG_OK_FOR_BASE_NONSTRICT_P (X)
1988
1989 #else
1990 #define REG_OK_FOR_INDEX_P(X)  REG_OK_FOR_INDEX_STRICT_P (X)
1991 #define REG_OK_FOR_BASE_P(X)   REG_OK_FOR_BASE_STRICT_P (X)
1992 #endif
1993
1994 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
1995    that is a valid memory address for an instruction.
1996    The MODE argument is the machine mode for the MEM expression
1997    that wants to use this address.
1998
1999    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
2000    except for CONSTANT_ADDRESS_P which is usually machine-independent.
2001
2002    See legitimize_pic_address in i386.c for details as to what
2003    constitutes a legitimate address when -fpic is used.  */
2004
2005 #define MAX_REGS_PER_ADDRESS 2
2006
2007 #define CONSTANT_ADDRESS_P(X)  constant_address_p (X)
2008
2009 /* Nonzero if the constant value X is a legitimate general operand.
2010    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
2011
2012 #define LEGITIMATE_CONSTANT_P(X)  legitimate_constant_p (X)
2013
2014 #ifdef REG_OK_STRICT
2015 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                         \
2016 do {                                                                    \
2017   if (legitimate_address_p ((MODE), (X), 1))                            \
2018     goto ADDR;                                                          \
2019 } while (0)
2020
2021 #else
2022 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                         \
2023 do {                                                                    \
2024   if (legitimate_address_p ((MODE), (X), 0))                            \
2025     goto ADDR;                                                          \
2026 } while (0)
2027
2028 #endif
2029
2030 /* If defined, a C expression to determine the base term of address X.
2031    This macro is used in only one place: `find_base_term' in alias.c.
2032
2033    It is always safe for this macro to not be defined.  It exists so
2034    that alias analysis can understand machine-dependent addresses.
2035
2036    The typical use of this macro is to handle addresses containing
2037    a label_ref or symbol_ref within an UNSPEC.  */
2038
2039 #define FIND_BASE_TERM(X) ix86_find_base_term (X)
2040
2041 /* Try machine-dependent ways of modifying an illegitimate address
2042    to be legitimate.  If we find one, return the new, valid address.
2043    This macro is used in only one place: `memory_address' in explow.c.
2044
2045    OLDX is the address as it was before break_out_memory_refs was called.
2046    In some cases it is useful to look at this to decide what needs to be done.
2047
2048    MODE and WIN are passed so that this macro can use
2049    GO_IF_LEGITIMATE_ADDRESS.
2050
2051    It is always safe for this macro to do nothing.  It exists to recognize
2052    opportunities to optimize the output.
2053
2054    For the 80386, we handle X+REG by loading X into a register R and
2055    using R+REG.  R will go in a general reg and indexing will be used.
2056    However, if REG is a broken-out memory address or multiplication,
2057    nothing needs to be done because REG can certainly go in a general reg.
2058
2059    When -fpic is used, special handling is needed for symbolic references.
2060    See comments by legitimize_pic_address in i386.c for details.  */
2061
2062 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)                          \
2063 do {                                                                    \
2064   (X) = legitimize_address ((X), (OLDX), (MODE));                       \
2065   if (memory_address_p ((MODE), (X)))                                   \
2066     goto WIN;                                                           \
2067 } while (0)
2068
2069 #define REWRITE_ADDRESS(X) rewrite_address (X)
2070
2071 /* Nonzero if the constant value X is a legitimate general operand
2072    when generating PIC code.  It is given that flag_pic is on and
2073    that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
2074
2075 #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
2076
2077 #define SYMBOLIC_CONST(X)       \
2078   (GET_CODE (X) == SYMBOL_REF                                           \
2079    || GET_CODE (X) == LABEL_REF                                         \
2080    || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
2081
2082 /* Go to LABEL if ADDR (a legitimate address expression)
2083    has an effect that depends on the machine mode it is used for.
2084    On the 80386, only postdecrement and postincrement address depend thus
2085    (the amount of decrement or increment being the length of the operand).  */
2086 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL)       \
2087 do {                                                    \
2088  if (GET_CODE (ADDR) == POST_INC                        \
2089      || GET_CODE (ADDR) == POST_DEC)                    \
2090    goto LABEL;                                          \
2091 } while (0)
2092 \f
2093 /* Codes for all the SSE/MMX builtins.  */
2094 enum ix86_builtins
2095 {
2096   IX86_BUILTIN_ADDPS,
2097   IX86_BUILTIN_ADDSS,
2098   IX86_BUILTIN_DIVPS,
2099   IX86_BUILTIN_DIVSS,
2100   IX86_BUILTIN_MULPS,
2101   IX86_BUILTIN_MULSS,
2102   IX86_BUILTIN_SUBPS,
2103   IX86_BUILTIN_SUBSS,
2104
2105   IX86_BUILTIN_CMPEQPS,
2106   IX86_BUILTIN_CMPLTPS,
2107   IX86_BUILTIN_CMPLEPS,
2108   IX86_BUILTIN_CMPGTPS,
2109   IX86_BUILTIN_CMPGEPS,
2110   IX86_BUILTIN_CMPNEQPS,
2111   IX86_BUILTIN_CMPNLTPS,
2112   IX86_BUILTIN_CMPNLEPS,
2113   IX86_BUILTIN_CMPNGTPS,
2114   IX86_BUILTIN_CMPNGEPS,
2115   IX86_BUILTIN_CMPORDPS,
2116   IX86_BUILTIN_CMPUNORDPS,
2117   IX86_BUILTIN_CMPNEPS,
2118   IX86_BUILTIN_CMPEQSS,
2119   IX86_BUILTIN_CMPLTSS,
2120   IX86_BUILTIN_CMPLESS,
2121   IX86_BUILTIN_CMPNEQSS,
2122   IX86_BUILTIN_CMPNLTSS,
2123   IX86_BUILTIN_CMPNLESS,
2124   IX86_BUILTIN_CMPORDSS,
2125   IX86_BUILTIN_CMPUNORDSS,
2126   IX86_BUILTIN_CMPNESS,
2127
2128   IX86_BUILTIN_COMIEQSS,
2129   IX86_BUILTIN_COMILTSS,
2130   IX86_BUILTIN_COMILESS,
2131   IX86_BUILTIN_COMIGTSS,
2132   IX86_BUILTIN_COMIGESS,
2133   IX86_BUILTIN_COMINEQSS,
2134   IX86_BUILTIN_UCOMIEQSS,
2135   IX86_BUILTIN_UCOMILTSS,
2136   IX86_BUILTIN_UCOMILESS,
2137   IX86_BUILTIN_UCOMIGTSS,
2138   IX86_BUILTIN_UCOMIGESS,
2139   IX86_BUILTIN_UCOMINEQSS,
2140
2141   IX86_BUILTIN_CVTPI2PS,
2142   IX86_BUILTIN_CVTPS2PI,
2143   IX86_BUILTIN_CVTSI2SS,
2144   IX86_BUILTIN_CVTSI642SS,
2145   IX86_BUILTIN_CVTSS2SI,
2146   IX86_BUILTIN_CVTSS2SI64,
2147   IX86_BUILTIN_CVTTPS2PI,
2148   IX86_BUILTIN_CVTTSS2SI,
2149   IX86_BUILTIN_CVTTSS2SI64,
2150
2151   IX86_BUILTIN_MAXPS,
2152   IX86_BUILTIN_MAXSS,
2153   IX86_BUILTIN_MINPS,
2154   IX86_BUILTIN_MINSS,
2155
2156   IX86_BUILTIN_LOADAPS,
2157   IX86_BUILTIN_LOADUPS,
2158   IX86_BUILTIN_STOREAPS,
2159   IX86_BUILTIN_STOREUPS,
2160   IX86_BUILTIN_LOADSS,
2161   IX86_BUILTIN_STORESS,
2162   IX86_BUILTIN_MOVSS,
2163
2164   IX86_BUILTIN_MOVHLPS,
2165   IX86_BUILTIN_MOVLHPS,
2166   IX86_BUILTIN_LOADHPS,
2167   IX86_BUILTIN_LOADLPS,
2168   IX86_BUILTIN_STOREHPS,
2169   IX86_BUILTIN_STORELPS,
2170
2171   IX86_BUILTIN_MASKMOVQ,
2172   IX86_BUILTIN_MOVMSKPS,
2173   IX86_BUILTIN_PMOVMSKB,
2174
2175   IX86_BUILTIN_MOVNTPS,
2176   IX86_BUILTIN_MOVNTQ,
2177
2178   IX86_BUILTIN_LOADDQA,
2179   IX86_BUILTIN_LOADDQU,
2180   IX86_BUILTIN_STOREDQA,
2181   IX86_BUILTIN_STOREDQU,
2182   IX86_BUILTIN_MOVQ,
2183   IX86_BUILTIN_LOADD,
2184   IX86_BUILTIN_STORED,
2185
2186   IX86_BUILTIN_CLRTI,
2187
2188   IX86_BUILTIN_PACKSSWB,
2189   IX86_BUILTIN_PACKSSDW,
2190   IX86_BUILTIN_PACKUSWB,
2191
2192   IX86_BUILTIN_PADDB,
2193   IX86_BUILTIN_PADDW,
2194   IX86_BUILTIN_PADDD,
2195   IX86_BUILTIN_PADDQ,
2196   IX86_BUILTIN_PADDSB,
2197   IX86_BUILTIN_PADDSW,
2198   IX86_BUILTIN_PADDUSB,
2199   IX86_BUILTIN_PADDUSW,
2200   IX86_BUILTIN_PSUBB,
2201   IX86_BUILTIN_PSUBW,
2202   IX86_BUILTIN_PSUBD,
2203   IX86_BUILTIN_PSUBQ,
2204   IX86_BUILTIN_PSUBSB,
2205   IX86_BUILTIN_PSUBSW,
2206   IX86_BUILTIN_PSUBUSB,
2207   IX86_BUILTIN_PSUBUSW,
2208
2209   IX86_BUILTIN_PAND,
2210   IX86_BUILTIN_PANDN,
2211   IX86_BUILTIN_POR,
2212   IX86_BUILTIN_PXOR,
2213
2214   IX86_BUILTIN_PAVGB,
2215   IX86_BUILTIN_PAVGW,
2216
2217   IX86_BUILTIN_PCMPEQB,
2218   IX86_BUILTIN_PCMPEQW,
2219   IX86_BUILTIN_PCMPEQD,
2220   IX86_BUILTIN_PCMPGTB,
2221   IX86_BUILTIN_PCMPGTW,
2222   IX86_BUILTIN_PCMPGTD,
2223
2224   IX86_BUILTIN_PEXTRW,
2225   IX86_BUILTIN_PINSRW,
2226
2227   IX86_BUILTIN_PMADDWD,
2228
2229   IX86_BUILTIN_PMAXSW,
2230   IX86_BUILTIN_PMAXUB,
2231   IX86_BUILTIN_PMINSW,
2232   IX86_BUILTIN_PMINUB,
2233
2234   IX86_BUILTIN_PMULHUW,
2235   IX86_BUILTIN_PMULHW,
2236   IX86_BUILTIN_PMULLW,
2237
2238   IX86_BUILTIN_PSADBW,
2239   IX86_BUILTIN_PSHUFW,
2240
2241   IX86_BUILTIN_PSLLW,
2242   IX86_BUILTIN_PSLLD,
2243   IX86_BUILTIN_PSLLQ,
2244   IX86_BUILTIN_PSRAW,
2245   IX86_BUILTIN_PSRAD,
2246   IX86_BUILTIN_PSRLW,
2247   IX86_BUILTIN_PSRLD,
2248   IX86_BUILTIN_PSRLQ,
2249   IX86_BUILTIN_PSLLWI,
2250   IX86_BUILTIN_PSLLDI,
2251   IX86_BUILTIN_PSLLQI,
2252   IX86_BUILTIN_PSRAWI,
2253   IX86_BUILTIN_PSRADI,
2254   IX86_BUILTIN_PSRLWI,
2255   IX86_BUILTIN_PSRLDI,
2256   IX86_BUILTIN_PSRLQI,
2257
2258   IX86_BUILTIN_PUNPCKHBW,
2259   IX86_BUILTIN_PUNPCKHWD,
2260   IX86_BUILTIN_PUNPCKHDQ,
2261   IX86_BUILTIN_PUNPCKLBW,
2262   IX86_BUILTIN_PUNPCKLWD,
2263   IX86_BUILTIN_PUNPCKLDQ,
2264
2265   IX86_BUILTIN_SHUFPS,
2266
2267   IX86_BUILTIN_RCPPS,
2268   IX86_BUILTIN_RCPSS,
2269   IX86_BUILTIN_RSQRTPS,
2270   IX86_BUILTIN_RSQRTSS,
2271   IX86_BUILTIN_SQRTPS,
2272   IX86_BUILTIN_SQRTSS,
2273
2274   IX86_BUILTIN_UNPCKHPS,
2275   IX86_BUILTIN_UNPCKLPS,
2276
2277   IX86_BUILTIN_ANDPS,
2278   IX86_BUILTIN_ANDNPS,
2279   IX86_BUILTIN_ORPS,
2280   IX86_BUILTIN_XORPS,
2281
2282   IX86_BUILTIN_EMMS,
2283   IX86_BUILTIN_LDMXCSR,
2284   IX86_BUILTIN_STMXCSR,
2285   IX86_BUILTIN_SFENCE,
2286
2287   /* 3DNow! Original */
2288   IX86_BUILTIN_FEMMS,
2289   IX86_BUILTIN_PAVGUSB,
2290   IX86_BUILTIN_PF2ID,
2291   IX86_BUILTIN_PFACC,
2292   IX86_BUILTIN_PFADD,
2293   IX86_BUILTIN_PFCMPEQ,
2294   IX86_BUILTIN_PFCMPGE,
2295   IX86_BUILTIN_PFCMPGT,
2296   IX86_BUILTIN_PFMAX,
2297   IX86_BUILTIN_PFMIN,
2298   IX86_BUILTIN_PFMUL,
2299   IX86_BUILTIN_PFRCP,
2300   IX86_BUILTIN_PFRCPIT1,
2301   IX86_BUILTIN_PFRCPIT2,
2302   IX86_BUILTIN_PFRSQIT1,
2303   IX86_BUILTIN_PFRSQRT,
2304   IX86_BUILTIN_PFSUB,
2305   IX86_BUILTIN_PFSUBR,
2306   IX86_BUILTIN_PI2FD,
2307   IX86_BUILTIN_PMULHRW,
2308
2309   /* 3DNow! Athlon Extensions */
2310   IX86_BUILTIN_PF2IW,
2311   IX86_BUILTIN_PFNACC,
2312   IX86_BUILTIN_PFPNACC,
2313   IX86_BUILTIN_PI2FW,
2314   IX86_BUILTIN_PSWAPDSI,
2315   IX86_BUILTIN_PSWAPDSF,
2316
2317   IX86_BUILTIN_SSE_ZERO,
2318   IX86_BUILTIN_MMX_ZERO,
2319
2320   /* SSE2 */
2321   IX86_BUILTIN_ADDPD,
2322   IX86_BUILTIN_ADDSD,
2323   IX86_BUILTIN_DIVPD,
2324   IX86_BUILTIN_DIVSD,
2325   IX86_BUILTIN_MULPD,
2326   IX86_BUILTIN_MULSD,
2327   IX86_BUILTIN_SUBPD,
2328   IX86_BUILTIN_SUBSD,
2329
2330   IX86_BUILTIN_CMPEQPD,
2331   IX86_BUILTIN_CMPLTPD,
2332   IX86_BUILTIN_CMPLEPD,
2333   IX86_BUILTIN_CMPGTPD,
2334   IX86_BUILTIN_CMPGEPD,
2335   IX86_BUILTIN_CMPNEQPD,
2336   IX86_BUILTIN_CMPNLTPD,
2337   IX86_BUILTIN_CMPNLEPD,
2338   IX86_BUILTIN_CMPNGTPD,
2339   IX86_BUILTIN_CMPNGEPD,
2340   IX86_BUILTIN_CMPORDPD,
2341   IX86_BUILTIN_CMPUNORDPD,
2342   IX86_BUILTIN_CMPNEPD,
2343   IX86_BUILTIN_CMPEQSD,
2344   IX86_BUILTIN_CMPLTSD,
2345   IX86_BUILTIN_CMPLESD,
2346   IX86_BUILTIN_CMPNEQSD,
2347   IX86_BUILTIN_CMPNLTSD,
2348   IX86_BUILTIN_CMPNLESD,
2349   IX86_BUILTIN_CMPORDSD,
2350   IX86_BUILTIN_CMPUNORDSD,
2351   IX86_BUILTIN_CMPNESD,
2352
2353   IX86_BUILTIN_COMIEQSD,
2354   IX86_BUILTIN_COMILTSD,
2355   IX86_BUILTIN_COMILESD,
2356   IX86_BUILTIN_COMIGTSD,
2357   IX86_BUILTIN_COMIGESD,
2358   IX86_BUILTIN_COMINEQSD,
2359   IX86_BUILTIN_UCOMIEQSD,
2360   IX86_BUILTIN_UCOMILTSD,
2361   IX86_BUILTIN_UCOMILESD,
2362   IX86_BUILTIN_UCOMIGTSD,
2363   IX86_BUILTIN_UCOMIGESD,
2364   IX86_BUILTIN_UCOMINEQSD,
2365
2366   IX86_BUILTIN_MAXPD,
2367   IX86_BUILTIN_MAXSD,
2368   IX86_BUILTIN_MINPD,
2369   IX86_BUILTIN_MINSD,
2370
2371   IX86_BUILTIN_ANDPD,
2372   IX86_BUILTIN_ANDNPD,
2373   IX86_BUILTIN_ORPD,
2374   IX86_BUILTIN_XORPD,
2375
2376   IX86_BUILTIN_SQRTPD,
2377   IX86_BUILTIN_SQRTSD,
2378
2379   IX86_BUILTIN_UNPCKHPD,
2380   IX86_BUILTIN_UNPCKLPD,
2381
2382   IX86_BUILTIN_SHUFPD,
2383
2384   IX86_BUILTIN_LOADAPD,
2385   IX86_BUILTIN_LOADUPD,
2386   IX86_BUILTIN_STOREAPD,
2387   IX86_BUILTIN_STOREUPD,
2388   IX86_BUILTIN_LOADSD,
2389   IX86_BUILTIN_STORESD,
2390   IX86_BUILTIN_MOVSD,
2391
2392   IX86_BUILTIN_LOADHPD,
2393   IX86_BUILTIN_LOADLPD,
2394   IX86_BUILTIN_STOREHPD,
2395   IX86_BUILTIN_STORELPD,
2396
2397   IX86_BUILTIN_CVTDQ2PD,
2398   IX86_BUILTIN_CVTDQ2PS,
2399
2400   IX86_BUILTIN_CVTPD2DQ,
2401   IX86_BUILTIN_CVTPD2PI,
2402   IX86_BUILTIN_CVTPD2PS,
2403   IX86_BUILTIN_CVTTPD2DQ,
2404   IX86_BUILTIN_CVTTPD2PI,
2405
2406   IX86_BUILTIN_CVTPI2PD,
2407   IX86_BUILTIN_CVTSI2SD,
2408   IX86_BUILTIN_CVTSI642SD,
2409
2410   IX86_BUILTIN_CVTSD2SI,
2411   IX86_BUILTIN_CVTSD2SI64,
2412   IX86_BUILTIN_CVTSD2SS,
2413   IX86_BUILTIN_CVTSS2SD,
2414   IX86_BUILTIN_CVTTSD2SI,
2415   IX86_BUILTIN_CVTTSD2SI64,
2416
2417   IX86_BUILTIN_CVTPS2DQ,
2418   IX86_BUILTIN_CVTPS2PD,
2419   IX86_BUILTIN_CVTTPS2DQ,
2420
2421   IX86_BUILTIN_MOVNTI,
2422   IX86_BUILTIN_MOVNTPD,
2423   IX86_BUILTIN_MOVNTDQ,
2424
2425   IX86_BUILTIN_SETPD1,
2426   IX86_BUILTIN_SETPD,
2427   IX86_BUILTIN_CLRPD,
2428   IX86_BUILTIN_SETRPD,
2429   IX86_BUILTIN_LOADPD1,
2430   IX86_BUILTIN_LOADRPD,
2431   IX86_BUILTIN_STOREPD1,
2432   IX86_BUILTIN_STORERPD,
2433
2434   /* SSE2 MMX */
2435   IX86_BUILTIN_MASKMOVDQU,
2436   IX86_BUILTIN_MOVMSKPD,
2437   IX86_BUILTIN_PMOVMSKB128,
2438   IX86_BUILTIN_MOVQ2DQ,
2439   IX86_BUILTIN_MOVDQ2Q,
2440
2441   IX86_BUILTIN_PACKSSWB128,
2442   IX86_BUILTIN_PACKSSDW128,
2443   IX86_BUILTIN_PACKUSWB128,
2444
2445   IX86_BUILTIN_PADDB128,
2446   IX86_BUILTIN_PADDW128,
2447   IX86_BUILTIN_PADDD128,
2448   IX86_BUILTIN_PADDQ128,
2449   IX86_BUILTIN_PADDSB128,
2450   IX86_BUILTIN_PADDSW128,
2451   IX86_BUILTIN_PADDUSB128,
2452   IX86_BUILTIN_PADDUSW128,
2453   IX86_BUILTIN_PSUBB128,
2454   IX86_BUILTIN_PSUBW128,
2455   IX86_BUILTIN_PSUBD128,
2456   IX86_BUILTIN_PSUBQ128,
2457   IX86_BUILTIN_PSUBSB128,
2458   IX86_BUILTIN_PSUBSW128,
2459   IX86_BUILTIN_PSUBUSB128,
2460   IX86_BUILTIN_PSUBUSW128,
2461
2462   IX86_BUILTIN_PAND128,
2463   IX86_BUILTIN_PANDN128,
2464   IX86_BUILTIN_POR128,
2465   IX86_BUILTIN_PXOR128,
2466
2467   IX86_BUILTIN_PAVGB128,
2468   IX86_BUILTIN_PAVGW128,
2469
2470   IX86_BUILTIN_PCMPEQB128,
2471   IX86_BUILTIN_PCMPEQW128,
2472   IX86_BUILTIN_PCMPEQD128,
2473   IX86_BUILTIN_PCMPGTB128,
2474   IX86_BUILTIN_PCMPGTW128,
2475   IX86_BUILTIN_PCMPGTD128,
2476
2477   IX86_BUILTIN_PEXTRW128,
2478   IX86_BUILTIN_PINSRW128,
2479
2480   IX86_BUILTIN_PMADDWD128,
2481
2482   IX86_BUILTIN_PMAXSW128,
2483   IX86_BUILTIN_PMAXUB128,
2484   IX86_BUILTIN_PMINSW128,
2485   IX86_BUILTIN_PMINUB128,
2486
2487   IX86_BUILTIN_PMULUDQ,
2488   IX86_BUILTIN_PMULUDQ128,
2489   IX86_BUILTIN_PMULHUW128,
2490   IX86_BUILTIN_PMULHW128,
2491   IX86_BUILTIN_PMULLW128,
2492
2493   IX86_BUILTIN_PSADBW128,
2494   IX86_BUILTIN_PSHUFHW,
2495   IX86_BUILTIN_PSHUFLW,
2496   IX86_BUILTIN_PSHUFD,
2497
2498   IX86_BUILTIN_PSLLW128,
2499   IX86_BUILTIN_PSLLD128,
2500   IX86_BUILTIN_PSLLQ128,
2501   IX86_BUILTIN_PSRAW128,
2502   IX86_BUILTIN_PSRAD128,
2503   IX86_BUILTIN_PSRLW128,
2504   IX86_BUILTIN_PSRLD128,
2505   IX86_BUILTIN_PSRLQ128,
2506   IX86_BUILTIN_PSLLDQI128,
2507   IX86_BUILTIN_PSLLWI128,
2508   IX86_BUILTIN_PSLLDI128,
2509   IX86_BUILTIN_PSLLQI128,
2510   IX86_BUILTIN_PSRAWI128,
2511   IX86_BUILTIN_PSRADI128,
2512   IX86_BUILTIN_PSRLDQI128,
2513   IX86_BUILTIN_PSRLWI128,
2514   IX86_BUILTIN_PSRLDI128,
2515   IX86_BUILTIN_PSRLQI128,
2516
2517   IX86_BUILTIN_PUNPCKHBW128,
2518   IX86_BUILTIN_PUNPCKHWD128,
2519   IX86_BUILTIN_PUNPCKHDQ128,
2520   IX86_BUILTIN_PUNPCKHQDQ128,
2521   IX86_BUILTIN_PUNPCKLBW128,
2522   IX86_BUILTIN_PUNPCKLWD128,
2523   IX86_BUILTIN_PUNPCKLDQ128,
2524   IX86_BUILTIN_PUNPCKLQDQ128,
2525
2526   IX86_BUILTIN_CLFLUSH,
2527   IX86_BUILTIN_MFENCE,
2528   IX86_BUILTIN_LFENCE,
2529
2530   /* Prescott New Instructions.  */
2531   IX86_BUILTIN_ADDSUBPS,
2532   IX86_BUILTIN_HADDPS,
2533   IX86_BUILTIN_HSUBPS,
2534   IX86_BUILTIN_MOVSHDUP,
2535   IX86_BUILTIN_MOVSLDUP,
2536   IX86_BUILTIN_ADDSUBPD,
2537   IX86_BUILTIN_HADDPD,
2538   IX86_BUILTIN_HSUBPD,
2539   IX86_BUILTIN_LOADDDUP,
2540   IX86_BUILTIN_MOVDDUP,
2541   IX86_BUILTIN_LDDQU,
2542
2543   IX86_BUILTIN_MONITOR,
2544   IX86_BUILTIN_MWAIT,
2545
2546   IX86_BUILTIN_MAX
2547 };
2548 \f
2549 /* Max number of args passed in registers.  If this is more than 3, we will
2550    have problems with ebx (register #4), since it is a caller save register and
2551    is also used as the pic register in ELF.  So for now, don't allow more than
2552    3 registers to be passed in registers.  */
2553
2554 #define REGPARM_MAX (TARGET_64BIT ? 6 : 3)
2555
2556 #define SSE_REGPARM_MAX (TARGET_64BIT ? 8 : 0)
2557
2558 \f
2559 /* Specify the machine mode that this machine uses
2560    for the index in the tablejump instruction.  */
2561 #define CASE_VECTOR_MODE (!TARGET_64BIT || flag_pic ? SImode : DImode)
2562
2563 /* Define as C expression which evaluates to nonzero if the tablejump
2564    instruction expects the table to contain offsets from the address of the
2565    table.
2566    Do not define this if the table should contain absolute addresses.  */
2567 /* #define CASE_VECTOR_PC_RELATIVE 1 */
2568
2569 /* Define this as 1 if `char' should by default be signed; else as 0.  */
2570 #define DEFAULT_SIGNED_CHAR 1
2571
2572 /* Number of bytes moved into a data cache for a single prefetch operation.  */
2573 #define PREFETCH_BLOCK ix86_cost->prefetch_block
2574
2575 /* Number of prefetch operations that can be done in parallel.  */
2576 #define SIMULTANEOUS_PREFETCHES ix86_cost->simultaneous_prefetches
2577
2578 /* Max number of bytes we can move from memory to memory
2579    in one reasonably fast instruction.  */
2580 #define MOVE_MAX 16
2581
2582 /* MOVE_MAX_PIECES is the number of bytes at a time which we can
2583    move efficiently, as opposed to  MOVE_MAX which is the maximum
2584    number of bytes we can move with a single instruction.  */
2585 #define MOVE_MAX_PIECES (TARGET_64BIT ? 8 : 4)
2586
2587 /* If a memory-to-memory move would take MOVE_RATIO or more simple
2588    move-instruction pairs, we will do a movstr or libcall instead.
2589    Increasing the value will always make code faster, but eventually
2590    incurs high cost in increased code size.
2591
2592    If you don't define this, a reasonable default is used.  */
2593
2594 #define MOVE_RATIO (optimize_size ? 3 : ix86_cost->move_ratio)
2595
2596 /* Define if shifts truncate the shift count
2597    which implies one can omit a sign-extension or zero-extension
2598    of a shift count.  */
2599 /* On i386, shifts do truncate the count.  But bit opcodes don't.  */
2600
2601 /* #define SHIFT_COUNT_TRUNCATED */
2602
2603 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
2604    is done just by pretending it is already truncated.  */
2605 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
2606
2607 /* When a prototype says `char' or `short', really pass an `int'.
2608    (The 386 can't easily push less than an int.)  */
2609
2610 #define PROMOTE_PROTOTYPES 1
2611
2612 /* A macro to update M and UNSIGNEDP when an object whose type is
2613    TYPE and which has the specified mode and signedness is to be
2614    stored in a register.  This macro is only called when TYPE is a
2615    scalar type.
2616
2617    On i386 it is sometimes useful to promote HImode and QImode
2618    quantities to SImode.  The choice depends on target type.  */
2619
2620 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE)             \
2621 do {                                                    \
2622   if (((MODE) == HImode && TARGET_PROMOTE_HI_REGS)      \
2623       || ((MODE) == QImode && TARGET_PROMOTE_QI_REGS))  \
2624     (MODE) = SImode;                                    \
2625 } while (0)
2626
2627 /* Specify the machine mode that pointers have.
2628    After generation of rtl, the compiler makes no further distinction
2629    between pointers and any other objects of this machine mode.  */
2630 #define Pmode (TARGET_64BIT ? DImode : SImode)
2631
2632 /* A function address in a call instruction
2633    is a byte address (for indexing purposes)
2634    so give the MEM rtx a byte's mode.  */
2635 #define FUNCTION_MODE QImode
2636 \f
2637 /* A C expression for the cost of moving data from a register in class FROM to
2638    one in class TO.  The classes are expressed using the enumeration values
2639    such as `GENERAL_REGS'.  A value of 2 is the default; other values are
2640    interpreted relative to that.
2641
2642    It is not required that the cost always equal 2 when FROM is the same as TO;
2643    on some machines it is expensive to move between registers if they are not
2644    general registers.  */
2645
2646 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
2647    ix86_register_move_cost ((MODE), (CLASS1), (CLASS2))
2648
2649 /* A C expression for the cost of moving data of mode M between a
2650    register and memory.  A value of 2 is the default; this cost is
2651    relative to those in `REGISTER_MOVE_COST'.
2652
2653    If moving between registers and memory is more expensive than
2654    between two registers, you should define this macro to express the
2655    relative cost.  */
2656
2657 #define MEMORY_MOVE_COST(MODE, CLASS, IN)       \
2658   ix86_memory_move_cost ((MODE), (CLASS), (IN))
2659
2660 /* A C expression for the cost of a branch instruction.  A value of 1
2661    is the default; other values are interpreted relative to that.  */
2662
2663 #define BRANCH_COST ix86_branch_cost
2664
2665 /* Define this macro as a C expression which is nonzero if accessing
2666    less than a word of memory (i.e. a `char' or a `short') is no
2667    faster than accessing a word of memory, i.e., if such access
2668    require more than one instruction or if there is no difference in
2669    cost between byte and (aligned) word loads.
2670
2671    When this macro is not defined, the compiler will access a field by
2672    finding the smallest containing object; when it is defined, a
2673    fullword load will be used if alignment permits.  Unless bytes
2674    accesses are faster than word accesses, using word accesses is
2675    preferable since it may eliminate subsequent memory access if
2676    subsequent accesses occur to other fields in the same word of the
2677    structure, but to different bytes.  */
2678
2679 #define SLOW_BYTE_ACCESS 0
2680
2681 /* Nonzero if access to memory by shorts is slow and undesirable.  */
2682 #define SLOW_SHORT_ACCESS 0
2683
2684 /* Define this macro to be the value 1 if unaligned accesses have a
2685    cost many times greater than aligned accesses, for example if they
2686    are emulated in a trap handler.
2687
2688    When this macro is nonzero, the compiler will act as if
2689    `STRICT_ALIGNMENT' were nonzero when generating code for block
2690    moves.  This can cause significantly more instructions to be
2691    produced.  Therefore, do not set this macro nonzero if unaligned
2692    accesses only add a cycle or two to the time for a memory access.
2693
2694    If the value of this macro is always zero, it need not be defined.  */
2695
2696 /* #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) 0 */
2697
2698 /* Define this macro if it is as good or better to call a constant
2699    function address than to call an address kept in a register.
2700
2701    Desirable on the 386 because a CALL with a constant address is
2702    faster than one with a register address.  */
2703
2704 #define NO_FUNCTION_CSE
2705
2706 /* Define this macro if it is as good or better for a function to call
2707    itself with an explicit address than to call an address kept in a
2708    register.  */
2709
2710 #define NO_RECURSIVE_FUNCTION_CSE
2711 \f
2712 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
2713    return the mode to be used for the comparison.
2714
2715    For floating-point equality comparisons, CCFPEQmode should be used.
2716    VOIDmode should be used in all other cases.
2717
2718    For integer comparisons against zero, reduce to CCNOmode or CCZmode if
2719    possible, to allow for more combinations.  */
2720
2721 #define SELECT_CC_MODE(OP, X, Y) ix86_cc_mode ((OP), (X), (Y))
2722
2723 /* Return nonzero if MODE implies a floating point inequality can be
2724    reversed.  */
2725
2726 #define REVERSIBLE_CC_MODE(MODE) 1
2727
2728 /* A C expression whose value is reversed condition code of the CODE for
2729    comparison done in CC_MODE mode.  */
2730 #define REVERSE_CONDITION(CODE, MODE) \
2731   ((MODE) != CCFPmode && (MODE) != CCFPUmode ? reverse_condition (CODE) \
2732    : reverse_condition_maybe_unordered (CODE))
2733
2734 \f
2735 /* Control the assembler format that we output, to the extent
2736    this does not vary between assemblers.  */
2737
2738 /* How to refer to registers in assembler output.
2739    This sequence is indexed by compiler's hard-register-number (see above).  */
2740
2741 /* In order to refer to the first 8 regs as 32 bit regs prefix an "e"
2742    For non floating point regs, the following are the HImode names.
2743
2744    For float regs, the stack top is sometimes referred to as "%st(0)"
2745    instead of just "%st".  PRINT_REG handles this with the "y" code.  */
2746
2747 #undef  HI_REGISTER_NAMES
2748 #define HI_REGISTER_NAMES                                               \
2749 {"ax","dx","cx","bx","si","di","bp","sp",                               \
2750  "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)",          \
2751  "argp", "flags", "fpsr", "dirflag", "frame",                           \
2752  "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7",               \
2753  "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" ,               \
2754  "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",                  \
2755  "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}
2756
2757 #define REGISTER_NAMES HI_REGISTER_NAMES
2758
2759 /* Table of additional register names to use in user input.  */
2760
2761 #define ADDITIONAL_REGISTER_NAMES \
2762 { { "eax", 0 }, { "edx", 1 }, { "ecx", 2 }, { "ebx", 3 },       \
2763   { "esi", 4 }, { "edi", 5 }, { "ebp", 6 }, { "esp", 7 },       \
2764   { "rax", 0 }, { "rdx", 1 }, { "rcx", 2 }, { "rbx", 3 },       \
2765   { "rsi", 4 }, { "rdi", 5 }, { "rbp", 6 }, { "rsp", 7 },       \
2766   { "al", 0 }, { "dl", 1 }, { "cl", 2 }, { "bl", 3 },           \
2767   { "ah", 0 }, { "dh", 1 }, { "ch", 2 }, { "bh", 3 },           \
2768   { "mm0", 8},  { "mm1", 9},  { "mm2", 10}, { "mm3", 11},       \
2769   { "mm4", 12}, { "mm5", 13}, { "mm6", 14}, { "mm7", 15} }
2770
2771 /* Note we are omitting these since currently I don't know how
2772 to get gcc to use these, since they want the same but different
2773 number as al, and ax.
2774 */
2775
2776 #define QI_REGISTER_NAMES \
2777 {"al", "dl", "cl", "bl", "sil", "dil", "bpl", "spl",}
2778
2779 /* These parallel the array above, and can be used to access bits 8:15
2780    of regs 0 through 3.  */
2781
2782 #define QI_HIGH_REGISTER_NAMES \
2783 {"ah", "dh", "ch", "bh", }
2784
2785 /* How to renumber registers for dbx and gdb.  */
2786
2787 #define DBX_REGISTER_NUMBER(N) \
2788   (TARGET_64BIT ? dbx64_register_map[(N)] : dbx_register_map[(N)])
2789
2790 extern int const dbx_register_map[FIRST_PSEUDO_REGISTER];
2791 extern int const dbx64_register_map[FIRST_PSEUDO_REGISTER];
2792 extern int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER];
2793
2794 /* Before the prologue, RA is at 0(%esp).  */
2795 #define INCOMING_RETURN_ADDR_RTX \
2796   gen_rtx_MEM (VOIDmode, gen_rtx_REG (VOIDmode, STACK_POINTER_REGNUM))
2797
2798 /* After the prologue, RA is at -4(AP) in the current frame.  */
2799 #define RETURN_ADDR_RTX(COUNT, FRAME)                                      \
2800   ((COUNT) == 0                                                            \
2801    ? gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, -UNITS_PER_WORD)) \
2802    : gen_rtx_MEM (Pmode, plus_constant (FRAME, UNITS_PER_WORD)))
2803
2804 /* PC is dbx register 8; let's use that column for RA.  */
2805 #define DWARF_FRAME_RETURN_COLUMN       (TARGET_64BIT ? 16 : 8)
2806
2807 /* Before the prologue, the top of the frame is at 4(%esp).  */
2808 #define INCOMING_FRAME_SP_OFFSET UNITS_PER_WORD
2809
2810 /* Describe how we implement __builtin_eh_return.  */
2811 #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) : INVALID_REGNUM)
2812 #define EH_RETURN_STACKADJ_RTX  gen_rtx_REG (Pmode, 2)
2813
2814
2815 /* Select a format to encode pointers in exception handling data.  CODE
2816    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
2817    true if the symbol may be affected by dynamic relocations.
2818
2819    ??? All x86 object file formats are capable of representing this.
2820    After all, the relocation needed is the same as for the call insn.
2821    Whether or not a particular assembler allows us to enter such, I
2822    guess we'll have to see.  */
2823 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                      \
2824   (flag_pic                                                             \
2825     ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4\
2826    : DW_EH_PE_absptr)
2827
2828 /* This is how to output an insn to push a register on the stack.
2829    It need not be very fast code.  */
2830
2831 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO)  \
2832 do {                                                                    \
2833   if (TARGET_64BIT)                                                     \
2834     asm_fprintf ((FILE), "\tpush{q}\t%%r%s\n",                          \
2835                  reg_names[(REGNO)] + (REX_INT_REGNO_P (REGNO) != 0));  \
2836   else                                                                  \
2837     asm_fprintf ((FILE), "\tpush{l}\t%%e%s\n", reg_names[(REGNO)]);     \
2838 } while (0)
2839
2840 /* This is how to output an insn to pop a register from the stack.
2841    It need not be very fast code.  */
2842
2843 #define ASM_OUTPUT_REG_POP(FILE, REGNO)  \
2844 do {                                                                    \
2845   if (TARGET_64BIT)                                                     \
2846     asm_fprintf ((FILE), "\tpop{q}\t%%r%s\n",                           \
2847                  reg_names[(REGNO)] + (REX_INT_REGNO_P (REGNO) != 0));  \
2848   else                                                                  \
2849     asm_fprintf ((FILE), "\tpop{l}\t%%e%s\n", reg_names[(REGNO)]);      \
2850 } while (0)
2851
2852 /* This is how to output an element of a case-vector that is absolute.  */
2853
2854 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE)  \
2855   ix86_output_addr_vec_elt ((FILE), (VALUE))
2856
2857 /* This is how to output an element of a case-vector that is relative.  */
2858
2859 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
2860   ix86_output_addr_diff_elt ((FILE), (VALUE), (REL))
2861
2862 /* Under some conditions we need jump tables in the text section, because
2863    the assembler cannot handle label differences between sections.  */
2864
2865 #define JUMP_TABLES_IN_TEXT_SECTION \
2866   (!TARGET_64BIT && flag_pic && !HAVE_AS_GOTOFF_IN_DATA)
2867
2868 /* A C statement that outputs an address constant appropriate to
2869    for DWARF debugging.  */
2870
2871 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE, X) \
2872   i386_dwarf_output_addr_const ((FILE), (X))
2873
2874 /* Emit a dtp-relative reference to a TLS variable.  */
2875
2876 #ifdef HAVE_AS_TLS
2877 #define ASM_OUTPUT_DWARF_DTPREL(FILE, SIZE, X) \
2878   i386_output_dwarf_dtprel (FILE, SIZE, X)
2879 #endif
2880
2881 /* Switch to init or fini section via SECTION_OP, emit a call to FUNC,
2882    and switch back.  For x86 we do this only to save a few bytes that
2883    would otherwise be unused in the text section.  */
2884 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)      \
2885    asm (SECTION_OP "\n\t"                               \
2886         "call " USER_LABEL_PREFIX #FUNC "\n"            \
2887         TEXT_SECTION_ASM_OP);
2888 \f
2889 /* Print operand X (an rtx) in assembler syntax to file FILE.
2890    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
2891    Effect of various CODE letters is described in i386.c near
2892    print_operand function.  */
2893
2894 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
2895   ((CODE) == '*' || (CODE) == '+' || (CODE) == '&')
2896
2897 /* Print the name of a register based on its machine mode and number.
2898    If CODE is 'w', pretend the mode is HImode.
2899    If CODE is 'b', pretend the mode is QImode.
2900    If CODE is 'k', pretend the mode is SImode.
2901    If CODE is 'q', pretend the mode is DImode.
2902    If CODE is 'h', pretend the reg is the `high' byte register.
2903    If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op.  */
2904
2905 #define PRINT_REG(X, CODE, FILE)  \
2906   print_reg ((X), (CODE), (FILE))
2907
2908 #define PRINT_OPERAND(FILE, X, CODE)  \
2909   print_operand ((FILE), (X), (CODE))
2910
2911 #define PRINT_OPERAND_ADDRESS(FILE, ADDR)  \
2912   print_operand_address ((FILE), (ADDR))
2913
2914 #define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL)  \
2915 do {                                            \
2916   if (! output_addr_const_extra (FILE, (X)))    \
2917     goto FAIL;                                  \
2918 } while (0);
2919
2920 /* Print the name of a register for based on its machine mode and number.
2921    This macro is used to print debugging output.
2922    This macro is different from PRINT_REG in that it may be used in
2923    programs that are not linked with aux-output.o.  */
2924
2925 #define DEBUG_PRINT_REG(X, CODE, FILE)                  \
2926   do { static const char * const hi_name[] = HI_REGISTER_NAMES; \
2927        static const char * const qi_name[] = QI_REGISTER_NAMES; \
2928        fprintf ((FILE), "%d ", REGNO (X));              \
2929        if (REGNO (X) == FLAGS_REG)                      \
2930          { fputs ("flags", (FILE)); break; }            \
2931        if (REGNO (X) == DIRFLAG_REG)                    \
2932          { fputs ("dirflag", (FILE)); break; }          \
2933        if (REGNO (X) == FPSR_REG)                       \
2934          { fputs ("fpsr", (FILE)); break; }             \
2935        if (REGNO (X) == ARG_POINTER_REGNUM)             \
2936          { fputs ("argp", (FILE)); break; }             \
2937        if (REGNO (X) == FRAME_POINTER_REGNUM)           \
2938          { fputs ("frame", (FILE)); break; }            \
2939        if (STACK_TOP_P (X))                             \
2940          { fputs ("st(0)", (FILE)); break; }            \
2941        if (FP_REG_P (X))                                \
2942          { fputs (hi_name[REGNO(X)], (FILE)); break; }  \
2943        if (REX_INT_REG_P (X))                           \
2944          {                                              \
2945            switch (GET_MODE_SIZE (GET_MODE (X)))        \
2946              {                                          \
2947              default:                                   \
2948              case 8:                                    \
2949                fprintf ((FILE), "r%i", REGNO (X)        \
2950                         - FIRST_REX_INT_REG + 8);       \
2951                break;                                   \
2952              case 4:                                    \
2953                fprintf ((FILE), "r%id", REGNO (X)       \
2954                         - FIRST_REX_INT_REG + 8);       \
2955                break;                                   \
2956              case 2:                                    \
2957                fprintf ((FILE), "r%iw", REGNO (X)       \
2958                         - FIRST_REX_INT_REG + 8);       \
2959                break;                                   \
2960              case 1:                                    \
2961                fprintf ((FILE), "r%ib", REGNO (X)       \
2962                         - FIRST_REX_INT_REG + 8);       \
2963                break;                                   \
2964              }                                          \
2965            break;                                       \
2966          }                                              \
2967        switch (GET_MODE_SIZE (GET_MODE (X)))            \
2968          {                                              \
2969          case 8:                                        \
2970            fputs ("r", (FILE));                         \
2971            fputs (hi_name[REGNO (X)], (FILE));          \
2972            break;                                       \
2973          default:                                       \
2974            fputs ("e", (FILE));                         \
2975          case 2:                                        \
2976            fputs (hi_name[REGNO (X)], (FILE));          \
2977            break;                                       \
2978          case 1:                                        \
2979            fputs (qi_name[REGNO (X)], (FILE));          \
2980            break;                                       \
2981          }                                              \
2982      } while (0)
2983
2984 /* a letter which is not needed by the normal asm syntax, which
2985    we can use for operand syntax in the extended asm */
2986
2987 #define ASM_OPERAND_LETTER '#'
2988 #define RET return ""
2989 #define AT_SP(MODE) (gen_rtx_MEM ((MODE), stack_pointer_rtx))
2990 \f
2991 /* Define the codes that are matched by predicates in i386.c.  */
2992
2993 #define PREDICATE_CODES                                                 \
2994   {"x86_64_immediate_operand", {CONST_INT, SUBREG, REG,                 \
2995                                 SYMBOL_REF, LABEL_REF, CONST}},         \
2996   {"x86_64_nonmemory_operand", {CONST_INT, SUBREG, REG,                 \
2997                                 SYMBOL_REF, LABEL_REF, CONST}},         \
2998   {"x86_64_movabs_operand", {CONST_INT, SUBREG, REG,                    \
2999                                 SYMBOL_REF, LABEL_REF, CONST}},         \
3000   {"x86_64_szext_nonmemory_operand", {CONST_INT, SUBREG, REG,           \
3001                                      SYMBOL_REF, LABEL_REF, CONST}},    \
3002   {"x86_64_general_operand", {CONST_INT, SUBREG, REG, MEM,              \
3003                               SYMBOL_REF, LABEL_REF, CONST}},           \
3004   {"x86_64_szext_general_operand", {CONST_INT, SUBREG, REG, MEM,        \
3005                                    SYMBOL_REF, LABEL_REF, CONST}},      \
3006   {"x86_64_zext_immediate_operand", {CONST_INT, CONST_DOUBLE, CONST,    \
3007                                        SYMBOL_REF, LABEL_REF}},         \
3008   {"shiftdi_operand", {SUBREG, REG, MEM}},                              \
3009   {"const_int_1_operand", {CONST_INT}},                                 \
3010   {"const_int_1_31_operand", {CONST_INT}},                              \
3011   {"symbolic_operand", {SYMBOL_REF, LABEL_REF, CONST}},                 \
3012   {"aligned_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,      \
3013                        LABEL_REF, SUBREG, REG, MEM}},                   \
3014   {"pic_symbolic_operand", {CONST}},                                    \
3015   {"call_insn_operand", {REG, SUBREG, MEM, SYMBOL_REF}},                \
3016   {"sibcall_insn_operand", {REG, SUBREG, SYMBOL_REF}},                  \
3017   {"constant_call_address_operand", {SYMBOL_REF, CONST}},               \
3018   {"const0_operand", {CONST_INT, CONST_DOUBLE}},                        \
3019   {"const1_operand", {CONST_INT}},                                      \
3020   {"const248_operand", {CONST_INT}},                                    \
3021   {"const_0_to_3_operand", {CONST_INT}},                                \
3022   {"const_0_to_7_operand", {CONST_INT}},                                \
3023   {"const_0_to_15_operand", {CONST_INT}},                               \
3024   {"const_0_to_255_operand", {CONST_INT}},                              \
3025   {"incdec_operand", {CONST_INT}},                                      \
3026   {"mmx_reg_operand", {REG}},                                           \
3027   {"reg_no_sp_operand", {SUBREG, REG}},                                 \
3028   {"general_no_elim_operand", {CONST_INT, CONST_DOUBLE, CONST,          \
3029                         SYMBOL_REF, LABEL_REF, SUBREG, REG, MEM}},      \
3030   {"nonmemory_no_elim_operand", {CONST_INT, REG, SUBREG}},              \
3031   {"index_register_operand", {SUBREG, REG}},                            \
3032   {"flags_reg_operand", {REG}},                                         \
3033   {"q_regs_operand", {SUBREG, REG}},                                    \
3034   {"non_q_regs_operand", {SUBREG, REG}},                                \
3035   {"fcmov_comparison_operator", {EQ, NE, LTU, GTU, LEU, GEU, UNORDERED, \
3036                                  ORDERED, LT, UNLT, GT, UNGT, LE, UNLE, \
3037                                  GE, UNGE, LTGT, UNEQ}},                \
3038   {"sse_comparison_operator", {EQ, LT, LE, UNORDERED, NE, UNGE, UNGT,   \
3039                                ORDERED, UNEQ, UNLT, UNLE, LTGT, GE, GT  \
3040                                }},                                      \
3041   {"ix86_comparison_operator", {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU,  \
3042                                GTU, UNORDERED, ORDERED, UNLE, UNLT,     \
3043                                UNGE, UNGT, LTGT, UNEQ }},               \
3044   {"ix86_carry_flag_operator", {LTU, LT, UNLT, GT, UNGT, LE, UNLE,      \
3045                                  GE, UNGE, LTGT, UNEQ}},                \
3046   {"cmp_fp_expander_operand", {CONST_DOUBLE, SUBREG, REG, MEM}},        \
3047   {"ext_register_operand", {SUBREG, REG}},                              \
3048   {"binary_fp_operator", {PLUS, MINUS, MULT, DIV}},                     \
3049   {"mult_operator", {MULT}},                                            \
3050   {"div_operator", {DIV}},                                              \
3051   {"arith_or_logical_operator", {PLUS, MULT, AND, IOR, XOR, SMIN, SMAX, \
3052                                  UMIN, UMAX, COMPARE, MINUS, DIV, MOD,  \
3053                                  UDIV, UMOD, ASHIFT, ROTATE, ASHIFTRT,  \
3054                                  LSHIFTRT, ROTATERT}},                  \
3055   {"promotable_binary_operator", {PLUS, MULT, AND, IOR, XOR, ASHIFT}},  \
3056   {"memory_displacement_operand", {MEM}},                               \
3057   {"cmpsi_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,        \
3058                      LABEL_REF, SUBREG, REG, MEM, AND}},                \
3059   {"long_memory_operand", {MEM}},                                       \
3060   {"tls_symbolic_operand", {SYMBOL_REF}},                               \
3061   {"global_dynamic_symbolic_operand", {SYMBOL_REF}},                    \
3062   {"local_dynamic_symbolic_operand", {SYMBOL_REF}},                     \
3063   {"initial_exec_symbolic_operand", {SYMBOL_REF}},                      \
3064   {"local_exec_symbolic_operand", {SYMBOL_REF}},                        \
3065   {"any_fp_register_operand", {REG}},                                   \
3066   {"register_and_not_any_fp_reg_operand", {REG}},                       \
3067   {"fp_register_operand", {REG}},                                       \
3068   {"register_and_not_fp_reg_operand", {REG}},                           \
3069   {"zero_extended_scalar_load_operand", {MEM}},                         \
3070   {"vector_move_operand", {CONST_VECTOR, SUBREG, REG, MEM}},            \
3071   {"no_seg_address_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF, \
3072                               LABEL_REF, SUBREG, REG, MEM, PLUS, MULT}},
3073
3074 /* A list of predicates that do special things with modes, and so
3075    should not elicit warnings for VOIDmode match_operand.  */
3076
3077 #define SPECIAL_MODE_PREDICATES \
3078   "ext_register_operand",
3079 \f
3080 /* Which processor to schedule for. The cpu attribute defines a list that
3081    mirrors this list, so changes to i386.md must be made at the same time.  */
3082
3083 enum processor_type
3084 {
3085   PROCESSOR_I386,                       /* 80386 */
3086   PROCESSOR_I486,                       /* 80486DX, 80486SX, 80486DX[24] */
3087   PROCESSOR_PENTIUM,
3088   PROCESSOR_PENTIUMPRO,
3089   PROCESSOR_K6,
3090   PROCESSOR_ATHLON,
3091   PROCESSOR_PENTIUM4,
3092   PROCESSOR_K8,
3093   PROCESSOR_max
3094 };
3095
3096 extern enum processor_type ix86_tune;
3097 extern const char *ix86_tune_string;
3098
3099 extern enum processor_type ix86_arch;
3100 extern const char *ix86_arch_string;
3101
3102 enum fpmath_unit
3103 {
3104   FPMATH_387 = 1,
3105   FPMATH_SSE = 2
3106 };
3107
3108 extern enum fpmath_unit ix86_fpmath;
3109 extern const char *ix86_fpmath_string;
3110
3111 enum tls_dialect
3112 {
3113   TLS_DIALECT_GNU,
3114   TLS_DIALECT_SUN
3115 };
3116
3117 extern enum tls_dialect ix86_tls_dialect;
3118 extern const char *ix86_tls_dialect_string;
3119
3120 enum cmodel {
3121   CM_32,        /* The traditional 32-bit ABI.  */
3122   CM_SMALL,     /* Assumes all code and data fits in the low 31 bits.  */
3123   CM_KERNEL,    /* Assumes all code and data fits in the high 31 bits.  */
3124   CM_MEDIUM,    /* Assumes code fits in the low 31 bits; data unlimited.  */
3125   CM_LARGE,     /* No assumptions.  */
3126   CM_SMALL_PIC  /* Assumes code+data+got/plt fits in a 31 bit region.  */
3127 };
3128
3129 extern enum cmodel ix86_cmodel;
3130 extern const char *ix86_cmodel_string;
3131
3132 /* Size of the RED_ZONE area.  */
3133 #define RED_ZONE_SIZE 128
3134 /* Reserved area of the red zone for temporaries.  */
3135 #define RED_ZONE_RESERVE 8
3136
3137 enum asm_dialect {
3138   ASM_ATT,
3139   ASM_INTEL
3140 };
3141
3142 extern const char *ix86_asm_string;
3143 extern enum asm_dialect ix86_asm_dialect;
3144
3145 extern int ix86_regparm;
3146 extern const char *ix86_regparm_string;
3147
3148 extern int ix86_preferred_stack_boundary;
3149 extern const char *ix86_preferred_stack_boundary_string;
3150
3151 extern int ix86_branch_cost;
3152 extern const char *ix86_branch_cost_string;
3153
3154 extern const char *ix86_debug_arg_string;
3155 extern const char *ix86_debug_addr_string;
3156
3157 /* Obsoleted by -f options.  Remove before 3.2 ships.  */
3158 extern const char *ix86_align_loops_string;
3159 extern const char *ix86_align_jumps_string;
3160 extern const char *ix86_align_funcs_string;
3161
3162 /* Smallest class containing REGNO.  */
3163 extern enum reg_class const regclass_map[FIRST_PSEUDO_REGISTER];
3164
3165 extern rtx ix86_compare_op0;    /* operand 0 for comparisons */
3166 extern rtx ix86_compare_op1;    /* operand 1 for comparisons */
3167 \f
3168 /* To properly truncate FP values into integers, we need to set i387 control
3169    word.  We can't emit proper mode switching code before reload, as spills
3170    generated by reload may truncate values incorrectly, but we still can avoid
3171    redundant computation of new control word by the mode switching pass.
3172    The fldcw instructions are still emitted redundantly, but this is probably
3173    not going to be noticeable problem, as most CPUs do have fast path for
3174    the sequence.
3175
3176    The machinery is to emit simple truncation instructions and split them
3177    before reload to instructions having USEs of two memory locations that
3178    are filled by this code to old and new control word.
3179
3180    Post-reload pass may be later used to eliminate the redundant fildcw if
3181    needed.  */
3182
3183 enum fp_cw_mode {FP_CW_STORED, FP_CW_UNINITIALIZED, FP_CW_ANY};
3184
3185 /* Define this macro if the port needs extra instructions inserted
3186    for mode switching in an optimizing compilation.  */
3187
3188 #define OPTIMIZE_MODE_SWITCHING(ENTITY) ix86_optimize_mode_switching
3189
3190 /* If you define `OPTIMIZE_MODE_SWITCHING', you have to define this as
3191    initializer for an array of integers.  Each initializer element N
3192    refers to an entity that needs mode switching, and specifies the
3193    number of different modes that might need to be set for this
3194    entity.  The position of the initializer in the initializer -
3195    starting counting at zero - determines the integer that is used to
3196    refer to the mode-switched entity in question.  */
3197
3198 #define NUM_MODES_FOR_MODE_SWITCHING { FP_CW_ANY }
3199
3200 /* ENTITY is an integer specifying a mode-switched entity.  If
3201    `OPTIMIZE_MODE_SWITCHING' is defined, you must define this macro to
3202    return an integer value not larger than the corresponding element
3203    in `NUM_MODES_FOR_MODE_SWITCHING', to denote the mode that ENTITY
3204    must be switched into prior to the execution of INSN.  */
3205
3206 #define MODE_NEEDED(ENTITY, I)                                          \
3207   (GET_CODE (I) == CALL_INSN                                            \
3208    || (GET_CODE (I) == INSN && (asm_noperands (PATTERN (I)) >= 0        \
3209                                 || GET_CODE (PATTERN (I)) == ASM_INPUT))\
3210    ? FP_CW_UNINITIALIZED                                                \
3211    : recog_memoized (I) < 0 || get_attr_type (I) != TYPE_FISTP          \
3212    ? FP_CW_ANY                                                          \
3213    : FP_CW_STORED)
3214
3215 /* This macro specifies the order in which modes for ENTITY are
3216    processed.  0 is the highest priority.  */
3217
3218 #define MODE_PRIORITY_TO_MODE(ENTITY, N) (N)
3219
3220 /* Generate one or more insns to set ENTITY to MODE.  HARD_REG_LIVE
3221    is the set of hard registers live at the point where the insn(s)
3222    are to be inserted.  */
3223
3224 #define EMIT_MODE_SET(ENTITY, MODE, HARD_REGS_LIVE)                     \
3225   ((MODE) == FP_CW_STORED                                               \
3226    ? emit_i387_cw_initialization (assign_386_stack_local (HImode, 1),   \
3227                                   assign_386_stack_local (HImode, 2)), 0\
3228    : 0)
3229 \f
3230 /* Avoid renaming of stack registers, as doing so in combination with
3231    scheduling just increases amount of live registers at time and in
3232    the turn amount of fxch instructions needed.
3233
3234    ??? Maybe Pentium chips benefits from renaming, someone can try...  */
3235
3236 #define HARD_REGNO_RENAME_OK(SRC, TARGET)  \
3237    ((SRC) < FIRST_STACK_REG || (SRC) > LAST_STACK_REG)
3238
3239 \f
3240 #define DLL_IMPORT_EXPORT_PREFIX '#'
3241
3242 #define FASTCALL_PREFIX '@'
3243 \f
3244 struct machine_function GTY(())
3245 {
3246   struct stack_local_entry *stack_locals;
3247   const char *some_ld_name;
3248   int save_varrargs_registers;
3249   int accesses_prev_frame;
3250   int optimize_mode_switching;
3251   /* Set by ix86_compute_frame_layout and used by prologue/epilogue expander to
3252      determine the style used.  */
3253   int use_fast_prologue_epilogue;
3254   /* Number of saved registers USE_FAST_PROLOGUE_EPILOGUE has been computed
3255      for.  */
3256   int use_fast_prologue_epilogue_nregs;
3257 };
3258
3259 #define ix86_stack_locals (cfun->machine->stack_locals)
3260 #define ix86_save_varrargs_registers (cfun->machine->save_varrargs_registers)
3261 #define ix86_optimize_mode_switching (cfun->machine->optimize_mode_switching)
3262
3263 /* Control behavior of x86_file_start.  */
3264 #define X86_FILE_START_VERSION_DIRECTIVE false
3265 #define X86_FILE_START_FLTUSED false
3266
3267 /*
3268 Local variables:
3269 version-control: t
3270 End:
3271 */