* arm.md (compare_scc): Use shorter sequence for EQ case.
[official-gcc.git] / gcc / config / rs6000 / darwin.h
blob20f1ca229fc9d5c225ad688aa51133803faa3314
1 /* Target definitions for PowerPC running Darwin (Mac OS X).
2 Copyright (C) 1997, 2000, 2001, 2003 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 /* Darwin switches. */
39 /* Use dynamic-no-pic codegen (no picbase reg; not suitable for shlibs.) */
40 #define MASK_MACHO_DYNAMIC_NO_PIC 0x00800000
42 #define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
44 /* Handle #pragma weak and #pragma pack. */
45 #define HANDLE_SYSV_PRAGMA 1
48 #define TARGET_OS_CPP_BUILTINS() \
49 do \
50 { \
51 builtin_define ("__ppc__"); \
52 builtin_define ("__POWERPC__"); \
53 builtin_define ("__NATURAL_ALIGNMENT__"); \
54 builtin_define ("__MACH__"); \
55 builtin_define ("__APPLE__"); \
56 } \
57 while (0)
60 /* */
61 #undef SUBTARGET_SWITCHES
62 #define SUBTARGET_SWITCHES \
63 {"dynamic-no-pic", MASK_MACHO_DYNAMIC_NO_PIC, \
64 N_("Generate code suitable for executables (NOT shared libs)")}, \
65 {"no-dynamic-no-pic", -MASK_MACHO_DYNAMIC_NO_PIC, ""},
68 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
69 off. */
71 #define SUBTARGET_OVERRIDE_OPTIONS \
72 do { \
73 rs6000_altivec_abi = 1; \
74 if (DEFAULT_ABI == ABI_DARWIN) \
75 { \
76 if (MACHO_DYNAMIC_NO_PIC_P) \
77 { \
78 if (flag_pic) \
79 warning ("-mdynamic-no-pic overrides -fpic or -fPIC"); \
80 flag_pic = 0; \
81 } \
82 else if (flag_pic == 1) \
83 { \
84 /* Darwin doesn't support -fpic. */ \
85 warning ("-fpic is not supported; -fPIC assumed"); \
86 flag_pic = 2; \
87 } \
88 } \
89 }while(0)
91 /* We want -fPIC by default, unless we're using -static to compile for
92 the kernel or some such. */
95 #define CC1_SPEC "\
96 %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
97 %{!static:%{!mdynamic-no-pic:-fPIC}}"
99 /* Make both r2 and r3 available for allocation. */
100 #define FIXED_R2 0
101 #define FIXED_R13 0
103 /* Base register for access to local variables of the function. */
105 #undef FRAME_POINTER_REGNUM
106 #define FRAME_POINTER_REGNUM 30
108 #undef RS6000_PIC_OFFSET_TABLE_REGNUM
109 #define RS6000_PIC_OFFSET_TABLE_REGNUM 31
111 /* Pad the outgoing args area to 16 bytes instead of the usual 8. */
113 #undef STARTING_FRAME_OFFSET
114 #define STARTING_FRAME_OFFSET \
115 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
116 + RS6000_VARARGS_AREA \
117 + RS6000_SAVE_AREA)
119 #undef STACK_DYNAMIC_OFFSET
120 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
121 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
122 + (STACK_POINTER_OFFSET))
124 /* These are used by -fbranch-probabilities */
125 #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
126 #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
127 "__TEXT,__text2,regular,pure_instructions"
129 /* Define cutoff for using external functions to save floating point.
130 Currently on Darwin, always use inline stores. */
132 #undef FP_SAVE_INLINE
133 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
135 /* Always use the "debug" register names, they're what the assembler
136 wants to see. */
138 #undef REGISTER_NAMES
139 #define REGISTER_NAMES DEBUG_REGISTER_NAMES
141 /* This outputs NAME to FILE. */
143 #undef RS6000_OUTPUT_BASENAME
144 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
145 assemble_name (FILE, NAME);
147 /* Globalizing directive for a label. */
148 #undef GLOBAL_ASM_OP
149 #define GLOBAL_ASM_OP "\t.globl "
150 #undef TARGET_ASM_GLOBALIZE_LABEL
152 /* This is how to output an internal label prefix. rs6000.c uses this
153 when generating traceback tables. */
154 /* Not really used for Darwin? */
156 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
157 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
158 fprintf (FILE, "%s", PREFIX)
160 /* This says how to output an assembler line to define a global common
161 symbol. */
162 /* ? */
163 #undef ASM_OUTPUT_ALIGNED_COMMON
164 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
165 do { fputs (".comm ", (FILE)); \
166 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
167 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
168 (SIZE)); } while (0)
170 /* Override the standard rs6000 definition. */
172 #undef ASM_COMMENT_START
173 #define ASM_COMMENT_START ";"
175 /* FP save and restore routines. */
176 #define SAVE_FP_PREFIX "._savef"
177 #define SAVE_FP_SUFFIX ""
178 #define RESTORE_FP_PREFIX "._restf"
179 #define RESTORE_FP_SUFFIX ""
181 /* This is how to output an assembler line that says to advance
182 the location counter to a multiple of 2**LOG bytes using the
183 "nop" instruction as padding. */
185 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \
186 do \
188 if ((LOG) < 3) \
190 ASM_OUTPUT_ALIGN (FILE,LOG); \
192 else /* nop == ori r0,r0,0 */ \
193 fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG)); \
194 } while (0)
196 /* Generate insns to call the profiler. */
198 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
200 /* Function name to call to do profiling. */
202 #define RS6000_MCOUNT "*mcount"
204 /* Default processor: a G4. */
206 #undef PROCESSOR_DEFAULT
207 #define PROCESSOR_DEFAULT PROCESSOR_PPC7400
209 /* Default target flag settings. Despite the fact that STMW/LMW
210 serializes, it's still a big codesize win to use them. Use FSEL by
211 default as well. */
213 #undef TARGET_DEFAULT
214 #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \
215 | MASK_PPC_GFXOPT)
217 /* Since Darwin doesn't do TOCs, stub this out. */
219 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) 0
221 /* Unlike most other PowerPC targets, chars are signed, for
222 consistency with other Darwin architectures. */
224 #undef DEFAULT_SIGNED_CHAR
225 #define DEFAULT_SIGNED_CHAR (1)
227 /* Given an rtx X being reloaded into a reg required to be
228 in class CLASS, return the class of reg to actually use.
229 In general this is just CLASS; but on some machines
230 in some cases it is preferable to use a more restrictive class.
232 On the RS/6000, we have to return NO_REGS when we want to reload a
233 floating-point CONST_DOUBLE to force it to be copied to memory.
235 Don't allow R0 when loading the address of, or otherwise furtling with,
236 a SYMBOL_REF. */
238 #undef PREFERRED_RELOAD_CLASS
239 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
240 (((GET_CODE (X) == CONST_DOUBLE \
241 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
242 ? NO_REGS \
243 : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \
244 && (CLASS) == NON_SPECIAL_REGS) \
245 ? GENERAL_REGS \
246 : (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH) \
247 ? BASE_REGS \
248 : (CLASS)))
250 /* Fix for emit_group_load (): force large constants to be pushed via regs. */
251 #define ALWAYS_PUSH_CONSTS_USING_REGS_P 1
253 /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints. */
254 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
255 (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
256 ? get_inner_array_type (FIELD) \
257 : TREE_TYPE (FIELD)) == DFmode \
258 ? MIN ((COMPUTED), 32) : (COMPUTED))
260 /* Darwin increases natural record alignment to doubleword if the first
261 field is an FP double while the FP fields remain word aligned. */
262 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
263 ((TREE_CODE (STRUCT) == RECORD_TYPE \
264 || TREE_CODE (STRUCT) == UNION_TYPE \
265 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
266 && TYPE_FIELDS (STRUCT) != 0 \
267 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \
268 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
269 : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
270 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
271 : MAX ((COMPUTED), (SPECIFIED)))
273 /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
274 support 64 bit PowerPC either, so this just keeps things happy. */
275 #define DOUBLE_INT_ASM_OP "\t.quad\t"
277 /* Get HOST_WIDE_INT and CONST_INT to be 32 bits, for compile time
278 space/speed. */
279 #undef MAX_LONG_TYPE_SIZE
280 #define MAX_LONG_TYPE_SIZE 32
282 /* For binary compatibility with 2.95; Darwin C APIs use bool from
283 stdbool.h, which was an int-sized enum in 2.95. */
284 #define BOOL_TYPE_SIZE INT_TYPE_SIZE
286 #undef REGISTER_TARGET_PRAGMAS
287 #define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS