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