Fix size of generic vectors with -maltivec.
[official-gcc.git] / gcc / config / rs6000 / darwin.h
blob1e92d5fe2bfc2fcfdf91febc0842dbfea9dacb20
1 /* Target definitions for PowerPC running Darwin (Mac OS X).
2 Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
3 Contributed by Apple Computer Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published
9 by the Free Software Foundation; either version 2, or (at your
10 option) any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
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 the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
22 #undef TARGET_VERSION
23 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
25 /* The "Darwin ABI" is mostly like AIX, but with some key differences. */
27 #define DEFAULT_ABI ABI_DARWIN
29 /* The object file format is Mach-O. */
31 #define TARGET_OBJECT_FORMAT OBJECT_MACHO
33 /* We're not ever going to do TOCs. */
35 #define TARGET_TOC 0
36 #define TARGET_NO_TOC 1
38 /* Override the default rs6000 definition. */
39 #undef PTRDIFF_TYPE
40 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
42 /* Darwin switches. */
43 /* Use dynamic-no-pic codegen (no picbase reg; not suitable for shlibs.) */
44 #define MASK_MACHO_DYNAMIC_NO_PIC 0x00800000
46 #define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
48 /* Handle #pragma weak and #pragma pack. */
49 #define HANDLE_SYSV_PRAGMA 1
52 #define TARGET_OS_CPP_BUILTINS() \
53 do \
54 { \
55 if (!TARGET_64BIT) builtin_define ("__ppc__"); \
56 if (TARGET_64BIT) builtin_define ("__ppc64__"); \
57 builtin_define ("__POWERPC__"); \
58 builtin_define ("__NATURAL_ALIGNMENT__"); \
59 builtin_define ("__MACH__"); \
60 builtin_define ("__APPLE__"); \
61 } \
62 while (0)
65 /* */
66 #undef SUBTARGET_SWITCHES
67 #define SUBTARGET_SWITCHES \
68 { "64", MASK_64BIT | MASK_POWERPC64, \
69 N_("Generate 64-bit code") }, \
70 { "32", - (MASK_64BIT | MASK_POWERPC64), \
71 N_("Generate 32-bit code") }, \
72 {"dynamic-no-pic", MASK_MACHO_DYNAMIC_NO_PIC, \
73 N_("Generate code suitable for executables (NOT shared libs)")}, \
74 {"no-dynamic-no-pic", -MASK_MACHO_DYNAMIC_NO_PIC, ""},
77 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
78 off. */
80 #define SUBTARGET_OVERRIDE_OPTIONS \
81 do { \
82 rs6000_altivec_abi = 1; \
83 rs6000_altivec_vrsave = 1; \
84 if (DEFAULT_ABI == ABI_DARWIN) \
85 { \
86 if (MACHO_DYNAMIC_NO_PIC_P) \
87 { \
88 if (flag_pic) \
89 warning ("-mdynamic-no-pic overrides -fpic or -fPIC"); \
90 flag_pic = 0; \
91 } \
92 else if (flag_pic == 1) \
93 { \
94 /* Darwin doesn't support -fpic. */ \
95 warning ("-fpic is not supported; -fPIC assumed"); \
96 flag_pic = 2; \
97 } \
99 /* Handle -mfix-and-continue. */ \
100 if (darwin_fix_and_continue_switch) \
102 const char *base = darwin_fix_and_continue_switch; \
103 while (base[-1] != 'm') base--; \
105 if (*darwin_fix_and_continue_switch != '\0') \
106 error ("invalid option `%s'", base); \
107 darwin_fix_and_continue = (base[0] != 'n'); \
110 if (TARGET_64BIT && ! TARGET_POWERPC64) \
112 target_flags |= MASK_POWERPC64; \
113 warning ("-m64 requires PowerPC64 architecture, enabling"); \
115 } while(0)
117 /* Darwin has 128-bit long double support in libc in 10.4 and later.
118 Default to 128-bit long doubles even on earlier platforms for ABI
119 consistency; arithmetic will work even if libc and libm support is
120 not available. */
122 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
125 /* We want -fPIC by default, unless we're using -static to compile for
126 the kernel or some such. */
128 #define CC1_SPEC "\
129 %{gused: -g -feliminate-unused-debug-symbols %<gused }\
130 %{gfull: -g -fno-eliminate-unused-debug-symbols %<gfull }\
131 %{g: %{!gfull: -feliminate-unused-debug-symbols %<gfull }}\
132 %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
133 %{!static:%{!mdynamic-no-pic:-fPIC}}"
135 /* It's virtually impossible to predict all the possible combinations
136 of -mcpu and -maltivec and whatnot, so just supply
137 -force_cpusubtype_ALL if any are seen. Radar 3492132 against the
138 assembler is asking for a .machine directive so we could get this
139 really right. */
140 #define ASM_SPEC "-arch ppc \
141 %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
142 %{!Zforce_cpusubtype_ALL:%{maltivec|mcpu=*|mpowerpc64:-force_cpusubtype_ALL}}"
144 #undef SUBTARGET_EXTRA_SPECS
145 #define SUBTARGET_EXTRA_SPECS \
146 { "darwin_arch", "ppc" },
148 /* The "-faltivec" option should have been called "-maltivec" all
149 along. -ffix-and-continue and -findirect-data is for compatibility
150 for old compilers. */
152 #define SUBTARGET_OPTION_TRANSLATE_TABLE \
153 { "-ffix-and-continue", "-mfix-and-continue" }, \
154 { "-findirect-data", "-mfix-and-continue" }, \
155 { "-faltivec", "-maltivec -include altivec.h" }, \
156 { "-fno-altivec", "-mno-altivec" }, \
157 { "-Waltivec-long-deprecated", "-mwarn-altivec-long" }, \
158 { "-Wno-altivec-long-deprecated", "-mno-warn-altivec-long" }
160 /* Make both r2 and r3 available for allocation. */
161 #define FIXED_R2 0
162 #define FIXED_R13 0
164 /* Base register for access to local variables of the function. */
166 #undef FRAME_POINTER_REGNUM
167 #define FRAME_POINTER_REGNUM 30
169 #undef RS6000_PIC_OFFSET_TABLE_REGNUM
170 #define RS6000_PIC_OFFSET_TABLE_REGNUM 31
172 /* Pad the outgoing args area to 16 bytes instead of the usual 8. */
174 #undef STARTING_FRAME_OFFSET
175 #define STARTING_FRAME_OFFSET \
176 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
177 + RS6000_VARARGS_AREA \
178 + RS6000_SAVE_AREA)
180 #undef STACK_DYNAMIC_OFFSET
181 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
182 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
183 + (STACK_POINTER_OFFSET))
185 /* These are used by -fbranch-probabilities */
186 #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
187 #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
188 "__TEXT,__unlikely,regular,pure_instructions"
190 /* Define cutoff for using external functions to save floating point.
191 Currently on Darwin, always use inline stores. */
193 #undef FP_SAVE_INLINE
194 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
196 /* The assembler wants the alternate register names, but without
197 leading percent sign. */
198 #undef REGISTER_NAMES
199 #define REGISTER_NAMES \
201 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
202 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
203 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
204 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
205 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
206 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
207 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
208 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
209 "mq", "lr", "ctr", "ap", \
210 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \
211 "xer", \
212 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
213 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
214 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
215 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \
216 "vrsave", "vscr", \
217 "spe_acc", "spefscr" \
220 /* This outputs NAME to FILE. */
222 #undef RS6000_OUTPUT_BASENAME
223 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
224 assemble_name (FILE, NAME)
226 /* Globalizing directive for a label. */
227 #undef GLOBAL_ASM_OP
228 #define GLOBAL_ASM_OP "\t.globl "
229 #undef TARGET_ASM_GLOBALIZE_LABEL
231 /* This is how to output an internal label prefix. rs6000.c uses this
232 when generating traceback tables. */
233 /* Not really used for Darwin? */
235 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
236 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
237 fprintf (FILE, "%s", PREFIX)
239 /* This says how to output an assembler line to define a global common
240 symbol. */
241 /* ? */
242 #undef ASM_OUTPUT_ALIGNED_COMMON
243 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
244 do { fputs (".comm ", (FILE)); \
245 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
246 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
247 (SIZE)); } while (0)
249 /* Override the standard rs6000 definition. */
251 #undef ASM_COMMENT_START
252 #define ASM_COMMENT_START ";"
254 /* FP save and restore routines. */
255 #define SAVE_FP_PREFIX "._savef"
256 #define SAVE_FP_SUFFIX ""
257 #define RESTORE_FP_PREFIX "._restf"
258 #define RESTORE_FP_SUFFIX ""
260 /* This is how to output an assembler line that says to advance
261 the location counter to a multiple of 2**LOG bytes using the
262 "nop" instruction as padding. */
264 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
265 do \
267 if ((LOG) < 3) \
269 ASM_OUTPUT_ALIGN (FILE,LOG); \
271 else /* nop == ori r0,r0,0 */ \
272 fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG)); \
273 } while (0)
275 /* Generate insns to call the profiler. */
277 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
279 /* Function name to call to do profiling. */
281 #define RS6000_MCOUNT "*mcount"
283 /* Default processor: G4, and G5 for 64-bit. */
285 #undef PROCESSOR_DEFAULT
286 #define PROCESSOR_DEFAULT PROCESSOR_PPC7400
287 #undef PROCESSOR_DEFAULT64
288 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
290 /* Default target flag settings. Despite the fact that STMW/LMW
291 serializes, it's still a big code size win to use them. Use FSEL by
292 default as well. */
294 #undef TARGET_DEFAULT
295 #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \
296 | MASK_PPC_GFXOPT)
298 /* Since Darwin doesn't do TOCs, stub this out. */
300 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) 0
302 /* Unlike most other PowerPC targets, chars are signed, for
303 consistency with other Darwin architectures. */
305 #undef DEFAULT_SIGNED_CHAR
306 #define DEFAULT_SIGNED_CHAR (1)
308 /* Given an rtx X being reloaded into a reg required to be
309 in class CLASS, return the class of reg to actually use.
310 In general this is just CLASS; but on some machines
311 in some cases it is preferable to use a more restrictive class.
313 On the RS/6000, we have to return NO_REGS when we want to reload a
314 floating-point CONST_DOUBLE to force it to be copied to memory.
316 Don't allow R0 when loading the address of, or otherwise furtling with,
317 a SYMBOL_REF. */
319 #undef PREFERRED_RELOAD_CLASS
320 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
321 ((GET_CODE (X) == CONST_DOUBLE \
322 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
323 ? NO_REGS \
324 : ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH) \
325 && reg_class_subset_p (BASE_REGS, (CLASS))) \
326 ? BASE_REGS \
327 : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \
328 && (CLASS) == NON_SPECIAL_REGS) \
329 ? GENERAL_REGS \
330 : (CLASS))
332 /* Fix for emit_group_load (): force large constants to be pushed via regs. */
333 #define ALWAYS_PUSH_CONSTS_USING_REGS_P 1
335 /* This now supports a natural alignment mode */
336 /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints. */
337 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
338 (TARGET_ALIGN_NATURAL ? (COMPUTED) : \
339 (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
340 ? get_inner_array_type (FIELD) \
341 : TREE_TYPE (FIELD)) == DFmode \
342 ? MIN ((COMPUTED), 32) : (COMPUTED)))
344 /* Darwin increases natural record alignment to doubleword if the first
345 field is an FP double while the FP fields remain word aligned. */
346 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
347 ((TREE_CODE (STRUCT) == RECORD_TYPE \
348 || TREE_CODE (STRUCT) == UNION_TYPE \
349 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
350 && TARGET_ALIGN_NATURAL == 0 \
351 ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
352 : (TREE_CODE (STRUCT) == VECTOR_TYPE \
353 && ALTIVEC_VECTOR_MODE (TYPE_MODE (STRUCT))) \
354 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
355 : MAX ((COMPUTED), (SPECIFIED)))
357 /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
358 support 64 bit PowerPC either, so this just keeps things happy. */
359 #define DOUBLE_INT_ASM_OP "\t.quad\t"
361 /* For binary compatibility with 2.95; Darwin C APIs use bool from
362 stdbool.h, which was an int-sized enum in 2.95. Users can explicitly
363 choose to have sizeof(bool)==1 with the -mone-byte-bool switch. */
364 extern const char *darwin_one_byte_bool;
365 #define BOOL_TYPE_SIZE (darwin_one_byte_bool ? CHAR_TYPE_SIZE : INT_TYPE_SIZE)
367 #undef REGISTER_TARGET_PRAGMAS
368 #define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS
370 #ifdef IN_LIBGCC2
371 #include <stdbool.h>
372 #endif
374 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
376 extern bool _Unwind_fallback_frame_state_for \
377 (struct _Unwind_Context *context, _Unwind_FrameState *fs); \
379 if (_Unwind_fallback_frame_state_for (CONTEXT, FS)) \
380 goto SUCCESS; \
383 #define HAS_MD_FALLBACK_FRAME_STATE_FOR 1
385 /* True, iff we're generating fast turn around debugging code. When
386 true, we arrange for function prologues to start with 4 nops so
387 that gdb may insert code to redirect them, and for data to accessed
388 indirectly. The runtime uses this indirection to forward
389 references for data to the original instance of that data. */
391 #define TARGET_FIX_AND_CONTINUE (darwin_fix_and_continue)