]>
Commit | Line | Data |
---|---|---|
b069de3b | 1 | /* Target definitions for x86 running Darwin. |
2f83c7d6 NC |
2 | Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007 |
3 | Free Software Foundation, Inc. | |
b069de3b SS |
4 | Contributed by Apple Computer Inc. |
5 | ||
7ec022b2 | 6 | This file is part of GCC. |
b069de3b | 7 | |
7ec022b2 | 8 | GCC is free software; you can redistribute it and/or modify |
b069de3b | 9 | it under the terms of the GNU General Public License as published by |
2f83c7d6 | 10 | the Free Software Foundation; either version 3, or (at your option) |
b069de3b SS |
11 | any later version. |
12 | ||
7ec022b2 | 13 | GCC is distributed in the hope that it will be useful, |
b069de3b SS |
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 | |
2f83c7d6 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
b069de3b SS |
21 | |
22 | /* Enable Mach-O bits in generic x86 code. */ | |
23 | #undef TARGET_MACHO | |
24 | #define TARGET_MACHO 1 | |
25 | ||
2e5d2af9 | 26 | #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)"); |
b069de3b | 27 | |
f7288899 | 28 | #undef TARGET_64BIT |
0a1c5e55 | 29 | #define TARGET_64BIT OPTION_ISA_64BIT |
f7288899 EC |
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 | ||
64ee9490 EC |
40 | /* Size of the Obj-C jump buffer. */ |
41 | #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18)) | |
42 | ||
004d3859 GK |
43 | #undef TARGET_FPMATH_DEFAULT |
44 | #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387) | |
45 | ||
b069de3b SS |
46 | #define TARGET_OS_CPP_BUILTINS() \ |
47 | do \ | |
48 | { \ | |
b069de3b | 49 | builtin_define ("__LITTLE_ENDIAN__"); \ |
ed5b9f96 | 50 | darwin_cpp_builtins (pfile); \ |
b069de3b SS |
51 | } \ |
52 | while (0) | |
53 | ||
f7288899 EC |
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 | #undef MAX_BITS_PER_WORD | |
64 | #define MAX_BITS_PER_WORD 64 | |
65 | ||
7d072037 SH |
66 | #undef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN |
67 | #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN (0) | |
68 | ||
ebff937c SH |
69 | #undef TARGET_KEEPS_VECTOR_ALIGNED_STACK |
70 | #define TARGET_KEEPS_VECTOR_ALIGNED_STACK 1 | |
71 | ||
2734e1c3 GK |
72 | /* On Darwin, the stack is 128-bit aligned at the point of every call. |
73 | Failure to ensure this will lead to a crash in the system libraries | |
74 | or dynamic loader. */ | |
75 | #undef STACK_BOUNDARY | |
76 | #define STACK_BOUNDARY 128 | |
77 | ||
ab47d43e EC |
78 | /* Since we'll never want a stack boundary less aligned than 128 bits |
79 | we need the extra work here otherwise bits of gcc get very grumpy | |
80 | when we ask for lower alignment. We could just reject values less | |
81 | than 128 bits for Darwin, but it's easier to up the alignment if | |
82 | it's below the minimum. */ | |
83 | #undef PREFERRED_STACK_BOUNDARY | |
84 | #define PREFERRED_STACK_BOUNDARY (ix86_preferred_stack_boundary > 128 \ | |
85 | ? ix86_preferred_stack_boundary \ | |
86 | : 128) | |
87 | ||
b069de3b SS |
88 | /* We want -fPIC by default, unless we're using -static to compile for |
89 | the kernel or some such. */ | |
90 | ||
91 | #undef CC1_SPEC | |
f475fd3c | 92 | #define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ |
32ec6542 | 93 | %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \ |
910fbc16 | 94 | %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}" |
b069de3b | 95 | |
a56cd1a9 | 96 | #undef ASM_SPEC |
f7288899 EC |
97 | #define ASM_SPEC "-arch %(darwin_arch) -force_cpusubtype_ALL" |
98 | ||
99 | #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}" | |
100 | #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC | |
3a7e8b87 | 101 | |
e4cad568 | 102 | /* Determine a minimum version based on compiler options. */ |
48137d59 GK |
103 | #define DARWIN_MINVERSION_SPEC \ |
104 | "%{!m64|fgnu-runtime:10.4; \ | |
105 | ,objective-c|,objc-cpp-output:10.5; \ | |
6b692a83 | 106 | ,objective-c-header:10.5; \ |
48137d59 | 107 | ,objective-c++|,objective-c++-cpp-output:10.5; \ |
6b692a83 | 108 | ,objective-c++-header|,objc++-cpp-output:10.5; \ |
4f648002 | 109 | :10.4}" |
e4cad568 | 110 | |
1d2b1d91 EC |
111 | #undef ENDFILE_SPEC |
112 | #define ENDFILE_SPEC \ | |
113 | "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ | |
114 | %{mpc32:crtprec32.o%s} \ | |
115 | %{mpc64:crtprec64.o%s} \ | |
116 | %{mpc80:crtprec80.o%s}" | |
117 | ||
3a7e8b87 | 118 | #undef SUBTARGET_EXTRA_SPECS |
f7288899 | 119 | #define SUBTARGET_EXTRA_SPECS \ |
742163c0 | 120 | DARWIN_EXTRA_SPECS \ |
f7288899 EC |
121 | { "darwin_arch", DARWIN_ARCH_SPEC }, \ |
122 | { "darwin_crt2", "" }, \ | |
123 | { "darwin_subarch", DARWIN_SUBARCH_SPEC }, | |
3a7e8b87 | 124 | |
8bb418a3 ZL |
125 | /* Use the following macro for any Darwin/x86-specific command-line option |
126 | translation. */ | |
2e5d2af9 SH |
127 | #define SUBTARGET_OPTION_TRANSLATE_TABLE \ |
128 | { "", "" } | |
8bb418a3 | 129 | |
b069de3b SS |
130 | /* The Darwin assembler mostly follows AT&T syntax. */ |
131 | #undef ASSEMBLER_DIALECT | |
132 | #define ASSEMBLER_DIALECT ASM_ATT | |
133 | ||
134 | /* Define macro used to output shift-double opcodes when the shift | |
135 | count is in %cl. Some assemblers require %cl as an argument; | |
136 | some don't. This macro controls what to do: by default, don't | |
137 | print %cl. */ | |
138 | ||
139 | #define SHIFT_DOUBLE_OMITS_COUNT 0 | |
140 | ||
7d072037 SH |
141 | extern void darwin_x86_file_end (void); |
142 | #undef TARGET_ASM_FILE_END | |
143 | #define TARGET_ASM_FILE_END darwin_x86_file_end | |
144 | ||
b069de3b SS |
145 | /* Define the syntax of pseudo-ops, labels and comments. */ |
146 | ||
147 | /* String containing the assembler's comment-starter. */ | |
148 | ||
149 | #define ASM_COMMENT_START "#" | |
150 | ||
151 | /* By default, target has a 80387, uses IEEE compatible arithmetic, | |
152 | and returns float values in the 387. */ | |
153 | ||
b42f4d62 | 154 | #undef TARGET_SUBTARGET_DEFAULT |
f7288899 | 155 | #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE) |
b069de3b | 156 | |
7a1eca83 EC |
157 | /* For darwin we want to target specific processor features as a minimum, |
158 | but these unfortunately don't correspond to a specific processor. */ | |
159 | #undef TARGET_SUBTARGET32_ISA_DEFAULT | |
160 | #define TARGET_SUBTARGET32_ISA_DEFAULT (OPTION_MASK_ISA_MMX \ | |
161 | | OPTION_MASK_ISA_SSE \ | |
162 | | OPTION_MASK_ISA_SSE2) | |
163 | ||
164 | #undef TARGET_SUBTARGET64_ISA_DEFAULT | |
165 | #define TARGET_SUBTARGET64_ISA_DEFAULT (OPTION_MASK_ISA_MMX \ | |
166 | | OPTION_MASK_ISA_SSE \ | |
167 | | OPTION_MASK_ISA_SSE2 \ | |
168 | | OPTION_MASK_ISA_SSE3) | |
169 | ||
ab82a49f AP |
170 | /* For now, disable dynamic-no-pic. We'll need to go through i386.c |
171 | with a fine-tooth comb looking for refs to flag_pic! */ | |
172 | #define MASK_MACHO_DYNAMIC_NO_PIC 0 | |
173 | #define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC) | |
174 | ||
7d072037 SH |
175 | #undef GOT_SYMBOL_NAME |
176 | #define GOT_SYMBOL_NAME (machopic_function_base_name ()) | |
177 | ||
b069de3b SS |
178 | /* Define the syntax of pseudo-ops, labels and comments. */ |
179 | ||
180 | #define LPREFIX "L" | |
181 | ||
a9042bb4 AP |
182 | /* These are used by -fbranch-probabilities */ |
183 | #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions" | |
ac83f770 | 184 | #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \ |
a9042bb4 | 185 | "__TEXT,__unlikely,regular,pure_instructions" |
a9042bb4 | 186 | |
b069de3b SS |
187 | /* Assembler pseudos to introduce constants of various size. */ |
188 | ||
189 | #define ASM_BYTE_OP "\t.byte\t" | |
190 | #define ASM_SHORT "\t.word\t" | |
191 | #define ASM_LONG "\t.long\t" | |
f7288899 | 192 | #define ASM_QUAD "\t.quad\t" |
b069de3b | 193 | |
5a2d4de0 AP |
194 | #define SUBTARGET_ENCODE_SECTION_INFO darwin_encode_section_info |
195 | ||
b069de3b SS |
196 | #undef ASM_OUTPUT_ALIGN |
197 | #define ASM_OUTPUT_ALIGN(FILE,LOG) \ | |
198 | do { if ((LOG) != 0) \ | |
7ae8cf75 | 199 | { \ |
d6b5193b | 200 | if (in_section == text_section) \ |
7ae8cf75 KG |
201 | fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \ |
202 | else \ | |
203 | fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \ | |
204 | } \ | |
b069de3b SS |
205 | } while (0) |
206 | ||
207 | /* This says how to output an assembler line | |
208 | to define a global common symbol. */ | |
209 | ||
210 | #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ | |
211 | ( fputs (".comm ", (FILE)), \ | |
212 | assemble_name ((FILE), (NAME)), \ | |
1c5ae962 | 213 | fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED))) |
b069de3b SS |
214 | |
215 | /* This says how to output an assembler line | |
216 | to define a local common symbol. */ | |
217 | ||
218 | #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ | |
219 | ( fputs (".lcomm ", (FILE)), \ | |
220 | assemble_name ((FILE), (NAME)), \ | |
58e15542 | 221 | fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED))) |
b069de3b SS |
222 | |
223 | /* Darwin profiling -- call mcount. */ | |
224 | #undef FUNCTION_PROFILER | |
225 | #define FUNCTION_PROFILER(FILE, LABELNO) \ | |
226 | do { \ | |
f7288899 | 227 | if (MACHOPIC_INDIRECT && !TARGET_64BIT) \ |
b069de3b | 228 | { \ |
11abc112 | 229 | const char *name = machopic_mcount_stub_name (); \ |
b069de3b | 230 | fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \ |
11abc112 | 231 | machopic_validate_stub_or_non_lazy_ptr (name); \ |
b069de3b SS |
232 | } \ |
233 | else fprintf (FILE, "\tcall mcount\n"); \ | |
234 | } while (0) | |
7405f03c | 235 | |
f475fd3c MS |
236 | #define C_COMMON_OVERRIDE_OPTIONS \ |
237 | do { \ | |
238 | SUBTARGET_C_COMMON_OVERRIDE_OPTIONS; \ | |
239 | } while (0) | |
240 | ||
80c85ca2 | 241 | /* Darwin on x86_64 uses dwarf-2 by default. Pre-darwin9 32-bit |
9fc4da9d | 242 | compiles default to stabs+. darwin9+ defaults to dwarf-2. */ |
80c85ca2 MS |
243 | #ifndef DARWIN_PREFER_DWARF |
244 | #undef PREFERRED_DEBUGGING_TYPE | |
245 | #define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG) | |
246 | #endif | |
247 | ||
7405f03c GK |
248 | /* Darwin uses the standard DWARF register numbers but the default |
249 | register numbers for STABS. Fortunately for 64-bit code the | |
250 | default and the standard are the same. */ | |
251 | #undef DBX_REGISTER_NUMBER | |
6070e8e5 GK |
252 | #define DBX_REGISTER_NUMBER(n) \ |
253 | (TARGET_64BIT ? dbx64_register_map[n] \ | |
254 | : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n] \ | |
255 | : dbx_register_map[n]) | |
256 | ||
257 | /* Unfortunately, the 32-bit EH information also doesn't use the standard | |
258 | DWARF register numbers. */ | |
259 | #define DWARF2_FRAME_REG_OUT(n, for_eh) \ | |
260 | (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n) \ | |
261 | : (n) == 5 ? 4 \ | |
262 | : (n) == 4 ? 5 \ | |
263 | : (n) >= 11 && (n) <= 18 ? (n) + 1 \ | |
264 | : (n)) | |
31abac07 | 265 | |
16d6f994 EC |
266 | #undef REGISTER_TARGET_PRAGMAS |
267 | #define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS() | |
268 | ||
269 | #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES | |
270 | #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes | |
2e71a7a3 | 271 | |
f7288899 EC |
272 | /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the |
273 | end of the instruction, but without the 4 we'd only have the right | |
274 | address for the start of the instruction. */ | |
275 | #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX | |
276 | #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \ | |
277 | if (TARGET_64BIT) \ | |
278 | { \ | |
279 | if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel) \ | |
280 | { \ | |
281 | fputs (ASM_LONG, FILE); \ | |
282 | assemble_name (FILE, XSTR (ADDR, 0)); \ | |
283 | fputs ("+4@GOTPCREL", FILE); \ | |
284 | goto DONE; \ | |
285 | } \ | |
286 | } \ | |
287 | else \ | |
288 | { \ | |
289 | if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) \ | |
290 | { \ | |
291 | darwin_non_lazy_pcrel (FILE, ADDR); \ | |
292 | goto DONE; \ | |
293 | } \ | |
294 | } | |
295 | ||
2e71a7a3 EC |
296 | /* This needs to move since i386 uses the first flag and other flags are |
297 | used in Mach-O. */ | |
298 | #undef MACHO_SYMBOL_FLAG_VARIABLE | |
299 | #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3) |