OSDN Git Service

* doc/tm.texi.in (TARGET_OPTION_TRANSLATE_TABLE): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / darwin.h
1 /* Target definitions for x86 running Darwin.
2    Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2010
3    Free Software Foundation, Inc.
4    Contributed by Apple Computer Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3.  If not see
20 <http://www.gnu.org/licenses/>.  */
21
22 /* Enable Mach-O bits in generic x86 code.  */
23 #undef TARGET_MACHO
24 #define TARGET_MACHO 1
25
26 #undef DARWIN_X86
27 #define DARWIN_X86 1
28
29 #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)");
30
31 #undef  TARGET_64BIT
32 #define TARGET_64BIT OPTION_ISA_64BIT
33
34 #ifdef IN_LIBGCC2
35 #undef TARGET_64BIT
36 #ifdef __x86_64__
37 #define TARGET_64BIT 1
38 #else
39 #define TARGET_64BIT 0
40 #endif
41 #endif
42
43 /* Size of the Obj-C jump buffer.  */
44 #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18))
45
46 #undef TARGET_FPMATH_DEFAULT
47 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387)
48
49 #define TARGET_OS_CPP_BUILTINS()                \
50   do                                            \
51     {                                           \
52       builtin_define ("__LITTLE_ENDIAN__");     \
53       darwin_cpp_builtins (pfile);              \
54     }                                           \
55   while (0)
56
57 #undef PTRDIFF_TYPE
58 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
59
60 #undef WCHAR_TYPE
61 #define WCHAR_TYPE "int"
62
63 #undef WCHAR_TYPE_SIZE
64 #define WCHAR_TYPE_SIZE 32
65
66 /* Generate branch islands stubs if this is true.  */
67 extern int darwin_emit_branch_islands;
68
69 #undef TARGET_MACHO_BRANCH_ISLANDS
70 #define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands
71
72 /* For compatibility with OSX system tools, use the new style of pic stub
73    if this is set.  */
74 #undef  MACHOPIC_ATT_STUB
75 #define MACHOPIC_ATT_STUB (darwin_macho_att_stub)
76
77 #undef MAX_BITS_PER_WORD
78 #define MAX_BITS_PER_WORD 64
79
80 #undef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
81 #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN (0)
82
83 #undef TARGET_KEEPS_VECTOR_ALIGNED_STACK
84 #define TARGET_KEEPS_VECTOR_ALIGNED_STACK 1
85
86 /* On Darwin, the stack is 128-bit aligned at the point of every call.
87    Failure to ensure this will lead to a crash in the system libraries
88    or dynamic loader.  */
89 #undef STACK_BOUNDARY
90 #define STACK_BOUNDARY \
91  ((profile_flag || (TARGET_64BIT && ix86_abi == MS_ABI)) \
92   ? 128 : BITS_PER_WORD)
93
94 #undef MAIN_STACK_BOUNDARY
95 #define MAIN_STACK_BOUNDARY 128
96
97 /* Since we'll never want a stack boundary less aligned than 128 bits
98    we need the extra work here otherwise bits of gcc get very grumpy
99    when we ask for lower alignment.  We could just reject values less
100    than 128 bits for Darwin, but it's easier to up the alignment if
101    it's below the minimum.  */
102 #undef PREFERRED_STACK_BOUNDARY
103 #define PREFERRED_STACK_BOUNDARY                        \
104   MAX (128, ix86_preferred_stack_boundary)
105
106 /* We want -fPIC by default, unless we're using -static to compile for
107    the kernel or some such.  */
108
109 #undef CC1_SPEC
110 #define CC1_SPEC "%(cc1_cpu) \
111   %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
112   %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
113   %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} " \
114   DARWIN_CC1_SPEC
115
116 #undef ASM_SPEC
117 #define ASM_SPEC "-arch %(darwin_arch) -force_cpusubtype_ALL \
118   %{static}"
119
120 #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
121 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
122
123 /* Determine a minimum version based on compiler options.  */
124 #define DARWIN_MINVERSION_SPEC                          \
125  "%{!m64|fgnu-runtime:10.4;                             \
126     ,objective-c|,objc-cpp-output:10.5;                 \
127     ,objective-c-header:10.5;                           \
128     ,objective-c++|,objective-c++-cpp-output:10.5;      \
129     ,objective-c++-header|,objc++-cpp-output:10.5;      \
130     :10.4}"
131
132 #undef ENDFILE_SPEC
133 #define ENDFILE_SPEC \
134   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
135    %{mpc32:crtprec32.o%s} \
136    %{mpc64:crtprec64.o%s} \
137    %{mpc80:crtprec80.o%s}"
138
139 #undef SUBTARGET_EXTRA_SPECS
140 #define SUBTARGET_EXTRA_SPECS                                   \
141   DARWIN_EXTRA_SPECS                                            \
142   { "darwin_arch", DARWIN_ARCH_SPEC },                          \
143   { "darwin_crt2", "" },                                        \
144   { "darwin_subarch", DARWIN_SUBARCH_SPEC },
145
146 /* The Darwin assembler mostly follows AT&T syntax.  */
147 #undef ASSEMBLER_DIALECT
148 #define ASSEMBLER_DIALECT ASM_ATT
149
150 /* Define macro used to output shift-double opcodes when the shift
151    count is in %cl.  Some assemblers require %cl as an argument;
152    some don't.  This macro controls what to do: by default, don't
153    print %cl.  */
154
155 #define SHIFT_DOUBLE_OMITS_COUNT 0
156
157 /* Put all *tf routines in libgcc.  */
158 #undef LIBGCC2_HAS_TF_MODE
159 #define LIBGCC2_HAS_TF_MODE 1
160 #define LIBGCC2_TF_CEXT q
161 #define TF_SIZE 113
162
163 #undef TARGET_ASM_FILE_END
164 #define TARGET_ASM_FILE_END darwin_file_end
165
166 /* Define the syntax of pseudo-ops, labels and comments.  */
167
168 /* String containing the assembler's comment-starter.  */
169
170 #define ASM_COMMENT_START "#"
171
172 /* By default, target has a 80387, uses IEEE compatible arithmetic,
173    and returns float values in the 387.  */
174
175 #undef TARGET_SUBTARGET_DEFAULT
176 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE)
177
178 /* For darwin we want to target specific processor features as a minimum,
179    but these unfortunately don't correspond to a specific processor.  */
180 #undef TARGET_SUBTARGET32_ISA_DEFAULT
181 #define TARGET_SUBTARGET32_ISA_DEFAULT (OPTION_MASK_ISA_MMX             \
182                                         | OPTION_MASK_ISA_SSE           \
183                                         | OPTION_MASK_ISA_SSE2          \
184                                         | OPTION_MASK_ISA_SSE3)
185
186 #undef TARGET_SUBTARGET64_ISA_DEFAULT
187 #define TARGET_SUBTARGET64_ISA_DEFAULT TARGET_SUBTARGET32_ISA_DEFAULT
188
189 #undef GOT_SYMBOL_NAME
190 #define GOT_SYMBOL_NAME MACHOPIC_FUNCTION_BASE_NAME
191
192 /* Define the syntax of pseudo-ops, labels and comments.  */
193
194 #define LPREFIX "L"
195
196 /* Assembler pseudos to introduce constants of various size.  */
197
198 #define ASM_BYTE "\t.byte\t"
199 #define ASM_SHORT "\t.word\t"
200 #define ASM_LONG "\t.long\t"
201 #define ASM_QUAD "\t.quad\t"
202
203 #define SUBTARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
204
205 #undef ASM_OUTPUT_ALIGN
206 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
207  do { if ((LOG) != 0)                   \
208         {                               \
209           if (in_section == text_section) \
210             fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
211           else                          \
212             fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
213         }                               \
214     } while (0)
215
216 /* This says how to output an assembler line
217    to define a global common symbol.  */
218
219 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
220 ( fputs ("\t.comm ", (FILE)),                   \
221   assemble_name ((FILE), (NAME)),               \
222   fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
223
224 /* This says how to output an assembler line
225    to define a local common symbol.  */
226
227 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
228 ( fputs ("\t.lcomm ", (FILE)),                  \
229   assemble_name ((FILE), (NAME)),               \
230   fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
231
232 /* Darwin profiling -- call mcount.  */
233 #undef FUNCTION_PROFILER
234 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
235     do {                                                                \
236       if (TARGET_MACHO_BRANCH_ISLANDS                                   \
237            && MACHOPIC_INDIRECT && !TARGET_64BIT)                       \
238         {                                                               \
239           const char *name = machopic_mcount_stub_name ();              \
240           fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */      \
241           machopic_validate_stub_or_non_lazy_ptr (name);                \
242         }                                                               \
243       else fprintf (FILE, "\tcall mcount\n");                           \
244     } while (0)
245
246 #define C_COMMON_OVERRIDE_OPTIONS                                       \
247   do {                                                                  \
248     SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;                                \
249   } while (0)
250
251 #undef SUBTARGET_OVERRIDE_OPTIONS
252 #define SUBTARGET_OVERRIDE_OPTIONS \
253 do {                                                                    \
254   if (TARGET_64BIT && MACHO_DYNAMIC_NO_PIC_P)                           \
255     target_flags &= ~MASK_MACHO_DYNAMIC_NO_PIC;                         \
256 } while (0)
257
258 /* Darwin on x86_64 uses dwarf-2 by default.  Pre-darwin9 32-bit
259    compiles default to stabs+.  darwin9+ defaults to dwarf-2.  */
260 #ifndef DARWIN_PREFER_DWARF
261 #undef PREFERRED_DEBUGGING_TYPE
262 #define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG)
263 #endif
264
265 /* Darwin uses the standard DWARF register numbers but the default
266    register numbers for STABS.  Fortunately for 64-bit code the
267    default and the standard are the same.  */
268 #undef DBX_REGISTER_NUMBER
269 #define DBX_REGISTER_NUMBER(n)                                  \
270   (TARGET_64BIT ? dbx64_register_map[n]                         \
271    : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n]   \
272    : dbx_register_map[n])
273
274 /* Unfortunately, the 32-bit EH information also doesn't use the standard
275    DWARF register numbers.  */
276 #define DWARF2_FRAME_REG_OUT(n, for_eh)                                 \
277   (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n)    \
278    : (n) == 5 ? 4                                                       \
279    : (n) == 4 ? 5                                                       \
280    : (n) >= 11 && (n) <= 18 ? (n) + 1                                   \
281    : (n))
282
283 #undef REGISTER_SUBTARGET_PRAGMAS
284 #define REGISTER_SUBTARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS()
285
286 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
287 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes
288
289 /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the
290    end of the instruction, but without the 4 we'd only have the right
291    address for the start of the instruction.  */
292 #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
293 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE)     \
294   if (TARGET_64BIT)                                                             \
295     {                                                                           \
296       if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel)                 \
297         {                                                                       \
298            fputs (ASM_LONG, FILE);                                              \
299            assemble_name (FILE, XSTR (ADDR, 0));                                \
300            fputs ("+4@GOTPCREL", FILE);                                         \
301            goto DONE;                                                           \
302         }                                                                       \
303     }                                                                           \
304   else                                                                          \
305     {                                                                           \
306       if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1))                      \
307         {                                                                       \
308           darwin_non_lazy_pcrel (FILE, ADDR);                                   \
309           goto DONE;                                                            \
310         }                                                                       \
311     }
312
313 /* This needs to move since i386 uses the first flag and other flags are
314    used in Mach-O.  */
315 #undef MACHO_SYMBOL_FLAG_VARIABLE
316 #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3)
317
318 #undef MACHOPIC_NL_SYMBOL_PTR_SECTION
319 #define MACHOPIC_NL_SYMBOL_PTR_SECTION \
320                 ".section __IMPORT,__pointers,non_lazy_symbol_pointers"
321
322 #define SUBTARGET32_DEFAULT_CPU "i686"
323
324 #undef  SUBTARGET_INIT_BUILTINS
325 #define SUBTARGET_INIT_BUILTINS                                 \
326 do {                                                            \
327   darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_MAX));\
328 } while(0)
329