comparison gcc/config/i386/darwin.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Target definitions for x86 running Darwin. 1 /* Target definitions for x86 running Darwin.
2 Copyright (C) 2001-2018 Free Software Foundation, Inc. 2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
3 Contributed by Apple Computer Inc. 3 Contributed by Apple Computer Inc.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
23 #define TARGET_MACHO 1 23 #define TARGET_MACHO 1
24 24
25 #undef DARWIN_X86 25 #undef DARWIN_X86
26 #define DARWIN_X86 1 26 #define DARWIN_X86 1
27 27
28 #undef TARGET_64BIT 28 #undef TARGET_64BIT
29 #undef TARGET_64BIT_P
30 #define TARGET_64BIT TARGET_ISA_64BIT 29 #define TARGET_64BIT TARGET_ISA_64BIT
31 #define TARGET_64BIT_P(x) TARGET_ISA_64BIT_P(x) 30 #undef TARGET_64BIT_P
31 #define TARGET_64BIT_P(x) TARGET_ISA_64BIT_P(x)
32 32
33 #ifdef IN_LIBGCC2 33 #ifdef IN_LIBGCC2
34 #undef TARGET_64BIT 34 #undef TARGET_64BIT
35 #ifdef __x86_64__ 35 #ifdef __x86_64__
36 #define TARGET_64BIT 1 36 #define TARGET_64BIT 1
45 the calls that libgcc makes to obtain the KEYMGR_GCC3_DW2_OBJ_LIST are not 45 the calls that libgcc makes to obtain the KEYMGR_GCC3_DW2_OBJ_LIST are not
46 updated to include new images, and might not even be valid for a single 46 updated to include new images, and might not even be valid for a single
47 image. 47 image.
48 Therefore, for 64b exes at least, we must use the libunwind implementation, 48 Therefore, for 64b exes at least, we must use the libunwind implementation,
49 even when static-libgcc is specified. We put libSystem first so that 49 even when static-libgcc is specified. We put libSystem first so that
50 unwinder symbols are satisfied from there. */ 50 unwinder symbols are satisfied from there.
51 We default to 64b for single-arch builds, so apply this unconditionally. */
51 #undef REAL_LIBGCC_SPEC 52 #undef REAL_LIBGCC_SPEC
52 #define REAL_LIBGCC_SPEC \ 53 #define REAL_LIBGCC_SPEC \
53 "%{static-libgcc|static: \ 54 "%{static-libgcc|static: \
54 %{m64:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)} \ 55 %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) \
55 -lgcc_eh -lgcc; \ 56 -lgcc_eh -lgcc; \
56 shared-libgcc|fexceptions|fgnu-runtime: \ 57 shared-libgcc|fexceptions|fgnu-runtime: \
57 %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4) \ 58 %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4) \
58 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ 59 %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \
59 %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4) \ 60 %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4) \
60 %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5) \ 61 %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5) \
68 /* Size of the Obj-C jump buffer. */ 69 /* Size of the Obj-C jump buffer. */
69 #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18)) 70 #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18))
70 71
71 #undef TARGET_FPMATH_DEFAULT 72 #undef TARGET_FPMATH_DEFAULT
72 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387) 73 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387)
74 #undef TARGET_FPMATH_DEFAULT_P
75 #define TARGET_FPMATH_DEFAULT_P(x) \
76 (TARGET_SSE_P(x) ? FPMATH_SSE : FPMATH_387)
73 77
74 #define TARGET_OS_CPP_BUILTINS() \ 78 #define TARGET_OS_CPP_BUILTINS() \
75 do \ 79 do { \
76 { \ 80 builtin_define ("__LITTLE_ENDIAN__"); \
77 builtin_define ("__LITTLE_ENDIAN__"); \ 81 darwin_cpp_builtins (pfile); \
78 darwin_cpp_builtins (pfile); \ 82 } while (0)
79 } \
80 while (0)
81 83
82 #undef PTRDIFF_TYPE 84 #undef PTRDIFF_TYPE
83 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") 85 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
84 86
85 #undef WCHAR_TYPE 87 #undef WCHAR_TYPE
86 #define WCHAR_TYPE "int" 88 #define WCHAR_TYPE "int"
87 89
88 #undef WCHAR_TYPE_SIZE 90 #undef WCHAR_TYPE_SIZE
89 #define WCHAR_TYPE_SIZE 32 91 #define WCHAR_TYPE_SIZE 32
90 92
91 /* Generate branch islands stubs if this is true. */ 93 /* Generate pic symbol indirection stubs if this is true. */
92 extern int darwin_emit_branch_islands; 94 #undef TARGET_MACHO_SYMBOL_STUBS
93 95 #define TARGET_MACHO_SYMBOL_STUBS (darwin_symbol_stubs)
94 #undef TARGET_MACHO_BRANCH_ISLANDS
95 #define TARGET_MACHO_BRANCH_ISLANDS darwin_emit_branch_islands
96 96
97 /* For compatibility with OSX system tools, use the new style of pic stub 97 /* For compatibility with OSX system tools, use the new style of pic stub
98 if this is set. */ 98 if this is set (default). */
99 #undef MACHOPIC_ATT_STUB 99 #undef MACHOPIC_ATT_STUB
100 #define MACHOPIC_ATT_STUB (darwin_macho_att_stub) 100 #define MACHOPIC_ATT_STUB (darwin_macho_att_stub)
101 101
102 #undef MAX_BITS_PER_WORD 102 #undef MAX_BITS_PER_WORD
103 #define MAX_BITS_PER_WORD 64 103 #define MAX_BITS_PER_WORD 64
109 #define TARGET_KEEPS_VECTOR_ALIGNED_STACK 1 109 #define TARGET_KEEPS_VECTOR_ALIGNED_STACK 1
110 110
111 /* On Darwin, the stack is 128-bit aligned at the point of every call. 111 /* On Darwin, the stack is 128-bit aligned at the point of every call.
112 Failure to ensure this will lead to a crash in the system libraries 112 Failure to ensure this will lead to a crash in the system libraries
113 or dynamic loader. */ 113 or dynamic loader. */
114 #undef STACK_BOUNDARY
115 #define STACK_BOUNDARY \
116 ((profile_flag || (TARGET_64BIT && ix86_abi == MS_ABI)) \
117 ? 128 : BITS_PER_WORD)
118 114
119 #undef MAIN_STACK_BOUNDARY 115 #undef MAIN_STACK_BOUNDARY
120 #define MAIN_STACK_BOUNDARY 128 116 #define MAIN_STACK_BOUNDARY 128
121 117
122 /* Since we'll never want a stack boundary less aligned than 128 bits 118 /* Since we'll never want a stack boundary less aligned than 128 bits
123 we need the extra work here otherwise bits of gcc get very grumpy 119 we need the extra work here otherwise bits of gcc get very grumpy
124 when we ask for lower alignment. We could just reject values less 120 when we ask for lower alignment. We could just reject values less
125 than 128 bits for Darwin, but it's easier to up the alignment if 121 than 128 bits for Darwin, but it's easier to up the alignment if
126 it's below the minimum. */ 122 it's below the minimum. */
127 #undef PREFERRED_STACK_BOUNDARY 123 #undef PREFERRED_STACK_BOUNDARY
128 #define PREFERRED_STACK_BOUNDARY \ 124 #define PREFERRED_STACK_BOUNDARY \
129 MAX (128, ix86_preferred_stack_boundary) 125 MAX (128, ix86_preferred_stack_boundary)
130 126
131 /* We want -fPIC by default, unless we're using -static to compile for 127 /* We want -fPIC by default, unless we're using -static to compile for
132 the kernel or some such. */ 128 the kernel or some such. */
133 129
134 #undef CC1_SPEC 130 #undef CC1_SPEC
135 #define CC1_SPEC "%(cc1_cpu) \ 131 #define CC1_SPEC "%(cc1_cpu) \
136 %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \ 132 %{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
137 %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} " \ 133 %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }} \
134 %{mx32:%eDarwin is not an mx32 platform} \
135 %{mfentry*:%eDarwin does not support -mfentry or associated options}" \
138 DARWIN_CC1_SPEC 136 DARWIN_CC1_SPEC
139 137
140 #undef ASM_SPEC 138 #undef ASM_SPEC
141 #define ASM_SPEC "-arch %(darwin_arch) \ 139 #define ASM_SPEC "-arch %(darwin_arch) \
142 " ASM_OPTIONS " -force_cpusubtype_ALL \ 140 " ASM_OPTIONS " -force_cpusubtype_ALL \
143 %{static}" ASM_MMACOSX_VERSION_MIN_SPEC 141 %{static}" ASM_MMACOSX_VERSION_MIN_SPEC
144
145 #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
146 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
147 142
148 #undef ENDFILE_SPEC 143 #undef ENDFILE_SPEC
149 #define ENDFILE_SPEC \ 144 #define ENDFILE_SPEC \
150 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 145 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
151 %{mpc32:crtprec32.o%s} \ 146 %{mpc32:crtprec32.o%s} \
152 %{mpc64:crtprec64.o%s} \ 147 %{mpc64:crtprec64.o%s} \
153 %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR 148 %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR
154 149
150 /* We default to x86_64 for single-arch builds, bi-arch overrides. */
151 #define DARWIN_ARCH_SPEC "x86_64"
152
155 #undef SUBTARGET_EXTRA_SPECS 153 #undef SUBTARGET_EXTRA_SPECS
156 #define SUBTARGET_EXTRA_SPECS \ 154 #define SUBTARGET_EXTRA_SPECS \
157 DARWIN_EXTRA_SPECS \ 155 DARWIN_EXTRA_SPECS \
158 { "darwin_arch", DARWIN_ARCH_SPEC }, \ 156 { "darwin_arch", DARWIN_ARCH_SPEC }, \
159 { "darwin_crt2", "" }, \ 157 { "darwin_crt2", "" }, \
160 { "darwin_subarch", DARWIN_SUBARCH_SPEC }, 158 { "darwin_subarch", DARWIN_ARCH_SPEC },
161 159
162 /* The Darwin assembler mostly follows AT&T syntax. */ 160 /* The Darwin assembler mostly follows AT&T syntax. */
163 #undef ASSEMBLER_DIALECT 161 #undef ASSEMBLER_DIALECT
164 #define ASSEMBLER_DIALECT ASM_ATT 162 #define ASSEMBLER_DIALECT ASM_ATT
165 163
181 179
182 /* By default, target has a 80387, uses IEEE compatible arithmetic, 180 /* By default, target has a 80387, uses IEEE compatible arithmetic,
183 and returns float values in the 387. */ 181 and returns float values in the 387. */
184 182
185 #undef TARGET_SUBTARGET_DEFAULT 183 #undef TARGET_SUBTARGET_DEFAULT
186 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE) 184 #define TARGET_SUBTARGET_DEFAULT \
185 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE)
187 186
188 /* For darwin we want to target specific processor features as a minimum, 187 /* For darwin we want to target specific processor features as a minimum,
189 but these unfortunately don't correspond to a specific processor. */ 188 but these unfortunately don't correspond to a specific processor. */
190 #undef TARGET_SUBTARGET32_ISA_DEFAULT 189 #undef TARGET_SUBTARGET32_ISA_DEFAULT
191 #define TARGET_SUBTARGET32_ISA_DEFAULT (OPTION_MASK_ISA_MMX \ 190 #define TARGET_SUBTARGET32_ISA_DEFAULT \
192 | OPTION_MASK_ISA_SSE \ 191 (OPTION_MASK_ISA_MMX | OPTION_MASK_ISA_SSE \
193 | OPTION_MASK_ISA_SSE2 \ 192 | OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE3)
194 | OPTION_MASK_ISA_SSE3)
195 193
196 #undef TARGET_SUBTARGET64_ISA_DEFAULT 194 #undef TARGET_SUBTARGET64_ISA_DEFAULT
197 #define TARGET_SUBTARGET64_ISA_DEFAULT TARGET_SUBTARGET32_ISA_DEFAULT 195 #define TARGET_SUBTARGET64_ISA_DEFAULT TARGET_SUBTARGET32_ISA_DEFAULT
198 196
199 #undef GOT_SYMBOL_NAME 197 #undef GOT_SYMBOL_NAME
211 #define ASM_QUAD "\t.quad\t" 209 #define ASM_QUAD "\t.quad\t"
212 210
213 #define SUBTARGET_ENCODE_SECTION_INFO darwin_encode_section_info 211 #define SUBTARGET_ENCODE_SECTION_INFO darwin_encode_section_info
214 212
215 #undef ASM_OUTPUT_ALIGN 213 #undef ASM_OUTPUT_ALIGN
216 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 214 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
217 do { if ((LOG) != 0) \ 215 do { \
218 { \ 216 if ((LOG) != 0) \
219 if (in_section == text_section) \ 217 { \
220 fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \ 218 if (in_section == text_section) \
221 else \ 219 fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
222 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \ 220 else \
223 } \ 221 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
224 } while (0) 222 } \
225 223 } while (0)
226 /* Darwin profiling -- call mcount. */ 224
225 #ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
226 #define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \
227 do { \
228 if ((LOG) != 0) { \
229 if ((MAX_SKIP) == 0 || (MAX_SKIP) >= (1 << (LOG)) - 1) \
230 fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
231 else \
232 fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
233 } \
234 } while (0)
235 #endif
236
237 /* Darwin x86 assemblers support the .ident directive. */
238
239 #undef TARGET_ASM_OUTPUT_IDENT
240 #define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
241
242 /* Darwin profiling -- call mcount.
243 If we need a stub, then we unconditionally mark it as used. */
227 #undef FUNCTION_PROFILER 244 #undef FUNCTION_PROFILER
228 #define FUNCTION_PROFILER(FILE, LABELNO) \ 245 #define FUNCTION_PROFILER(FILE, LABELNO) \
229 do { \ 246 do { \
230 if (TARGET_MACHO_BRANCH_ISLANDS \ 247 if (TARGET_MACHO_SYMBOL_STUBS \
231 && MACHOPIC_INDIRECT && !TARGET_64BIT) \ 248 && MACHOPIC_INDIRECT && !TARGET_64BIT) \
232 { \ 249 { \
233 const char *name = machopic_mcount_stub_name (); \ 250 const char *name = machopic_mcount_stub_name (); \
234 fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \ 251 fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \
235 machopic_validate_stub_or_non_lazy_ptr (name); \ 252 } \
236 } \ 253 else fprintf (FILE, "\tcall mcount\n"); \
237 else fprintf (FILE, "\tcall mcount\n"); \ 254 } while (0)
238 } while (0)
239 255
240 #define C_COMMON_OVERRIDE_OPTIONS \ 256 #define C_COMMON_OVERRIDE_OPTIONS \
241 do { \ 257 do { \
242 SUBTARGET_C_COMMON_OVERRIDE_OPTIONS; \ 258 SUBTARGET_C_COMMON_OVERRIDE_OPTIONS; \
243 } while (0) 259 } while (0)
244 260
245 #undef SUBTARGET_OVERRIDE_OPTIONS 261 #undef SUBTARGET_OVERRIDE_OPTIONS
246 #define SUBTARGET_OVERRIDE_OPTIONS \ 262 #define SUBTARGET_OVERRIDE_OPTIONS \
247 do { \ 263 do { \
248 if (TARGET_64BIT && MACHO_DYNAMIC_NO_PIC_P) \ 264 if (TARGET_64BIT && MACHO_DYNAMIC_NO_PIC_P) \
249 target_flags &= ~MASK_MACHO_DYNAMIC_NO_PIC; \ 265 target_flags &= ~MASK_MACHO_DYNAMIC_NO_PIC; \
250 } while (0) 266 } while (0)
251 267
252 /* Darwin on x86_64 uses dwarf-2 by default. Pre-darwin9 32-bit 268 /* Darwin on x86_64 uses dwarf-2 by default. Pre-darwin9 32-bit
253 compiles default to stabs+. darwin9+ defaults to dwarf-2. */ 269 compiles default to stabs+. darwin9+ defaults to dwarf-2. */
254 #ifndef DARWIN_PREFER_DWARF 270 #ifndef DARWIN_PREFER_DWARF
255 #undef PREFERRED_DEBUGGING_TYPE 271 #undef PREFERRED_DEBUGGING_TYPE
286 302
287 /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the 303 /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the
288 end of the instruction, but without the 4 we'd only have the right 304 end of the instruction, but without the 4 we'd only have the right
289 address for the start of the instruction. */ 305 address for the start of the instruction. */
290 #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX 306 #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
291 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \ 307 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
292 if (TARGET_64BIT) \ 308 if (TARGET_64BIT) \
293 { \ 309 { \
294 if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel) \ 310 if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel) \
295 { \ 311 { \
296 fputs (ASM_LONG, FILE); \ 312 fputs (ASM_LONG, FILE); \
297 assemble_name (FILE, XSTR (ADDR, 0)); \ 313 assemble_name (FILE, XSTR (ADDR, 0)); \
298 fputs ("+4@GOTPCREL", FILE); \ 314 fputs ("+4@GOTPCREL", FILE); \
299 goto DONE; \ 315 goto DONE; \
300 } \ 316 } \
301 } \ 317 } \
302 else \ 318 else \
303 { \ 319 { \
304 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) \ 320 if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) \
305 { \ 321 { \
306 darwin_non_lazy_pcrel (FILE, ADDR); \ 322 darwin_non_lazy_pcrel (FILE, ADDR); \
307 goto DONE; \ 323 goto DONE; \
308 } \ 324 } \
309 } 325 }
310 326
311 /* This needs to move since i386 uses the first flag and other flags are 327 /* First available SYMBOL flag bit for use by subtargets. */
312 used in Mach-O. */ 328 #define SYMBOL_FLAG_SUBT_DEP (SYMBOL_FLAG_MACH_DEP << 5)
313 #undef MACHO_SYMBOL_FLAG_VARIABLE
314 #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3)
315 329
316 #undef MACHOPIC_NL_SYMBOL_PTR_SECTION 330 #undef MACHOPIC_NL_SYMBOL_PTR_SECTION
317 #define MACHOPIC_NL_SYMBOL_PTR_SECTION \ 331 #define MACHOPIC_NL_SYMBOL_PTR_SECTION \
318 ".section __IMPORT,__pointers,non_lazy_symbol_pointers" 332 ".section __IMPORT,__pointers,non_lazy_symbol_pointers"
319 333
320 #define SUBTARGET32_DEFAULT_CPU "i686" 334 #define SUBTARGET32_DEFAULT_CPU "i686"
321 335
322 #undef SUBTARGET_INIT_BUILTINS 336 #undef SUBTARGET_INIT_BUILTINS
323 #define SUBTARGET_INIT_BUILTINS \ 337 #define SUBTARGET_INIT_BUILTINS \
324 do { \ 338 do { \
325 ix86_builtins[(int) IX86_BUILTIN_CFSTRING] \ 339 ix86_builtins[(int) IX86_BUILTIN_CFSTRING] \
326 = darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_CFSTRING)); \ 340 = darwin_init_cfstring_builtins ((unsigned) (IX86_BUILTIN_CFSTRING)); \
327 darwin_rename_builtins (); \ 341 darwin_rename_builtins (); \
328 } while(0) 342 } while(0)