]>
Commit | Line | Data |
---|---|---|
ee890fe2 | 1 | /* Target definitions for PowerPC running Darwin (Mac OS X). |
5de601cf | 2 | Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc. |
ee890fe2 SS |
3 | Contributed by Apple Computer Inc. |
4 | ||
5de601cf | 5 | This file is part of GCC. |
ee890fe2 | 6 | |
5de601cf NC |
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. | |
ee890fe2 | 11 | |
5de601cf NC |
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. | |
ee890fe2 | 16 | |
5de601cf NC |
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. */ | |
ee890fe2 | 21 | |
b91da81f DB |
22 | #undef TARGET_VERSION |
23 | #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)"); | |
24 | ||
ee890fe2 SS |
25 | /* The "Darwin ABI" is mostly like AIX, but with some key differences. */ |
26 | ||
27 | #define DEFAULT_ABI ABI_DARWIN | |
28 | ||
29 | /* The object file format is Mach-O. */ | |
30 | ||
31 | #define TARGET_OBJECT_FORMAT OBJECT_MACHO | |
32 | ||
33 | /* We're not ever going to do TOCs. */ | |
34 | ||
35 | #define TARGET_TOC 0 | |
36 | #define TARGET_NO_TOC 1 | |
37 | ||
ab82a49f AP |
38 | /* Darwin switches. */ |
39 | /* Use dynamic-no-pic codegen (no picbase reg; not suitable for shlibs.) */ | |
40 | #define MASK_MACHO_DYNAMIC_NO_PIC 0x00800000 | |
41 | ||
42 | #define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC) | |
43 | ||
9429c84c | 44 | /* Handle #pragma weak and #pragma pack. */ |
32f0ffb3 | 45 | #define HANDLE_SYSV_PRAGMA 1 |
9429c84c | 46 | |
00a8c0b4 | 47 | |
7990b46f MK |
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) | |
ee890fe2 | 58 | |
ab82a49f AP |
59 | |
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, ""}, | |
66 | ||
67 | ||
68 | /* The Darwin ABI always includes AltiVec, can't be (validly) turned | |
69 | off. */ | |
70 | ||
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) | |
90 | ||
ee890fe2 SS |
91 | /* We want -fPIC by default, unless we're using -static to compile for |
92 | the kernel or some such. */ | |
93 | ||
ab82a49f | 94 | |
3ab68120 DP |
95 | #define CC1_SPEC "\ |
96 | %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\ | |
ab82a49f | 97 | %{!static:%{!mdynamic-no-pic:-fPIC}}" |
ee890fe2 | 98 | |
5dead3e5 DJ |
99 | /* Make both r2 and r3 available for allocation. */ |
100 | #define FIXED_R2 0 | |
ee890fe2 SS |
101 | #define FIXED_R13 0 |
102 | ||
ee890fe2 SS |
103 | /* Base register for access to local variables of the function. */ |
104 | ||
105 | #undef FRAME_POINTER_REGNUM | |
106 | #define FRAME_POINTER_REGNUM 30 | |
107 | ||
1db02437 FS |
108 | #undef RS6000_PIC_OFFSET_TABLE_REGNUM |
109 | #define RS6000_PIC_OFFSET_TABLE_REGNUM 31 | |
ee890fe2 | 110 | |
ee890fe2 SS |
111 | /* Pad the outgoing args area to 16 bytes instead of the usual 8. */ |
112 | ||
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) | |
118 | ||
119 | #undef STACK_DYNAMIC_OFFSET | |
120 | #define STACK_DYNAMIC_OFFSET(FUNDECL) \ | |
121 | (RS6000_ALIGN (current_function_outgoing_args_size, 16) \ | |
122 | + (STACK_POINTER_OFFSET)) | |
123 | ||
d58f6584 DJ |
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" | |
128 | ||
ee890fe2 SS |
129 | /* Define cutoff for using external functions to save floating point. |
130 | Currently on Darwin, always use inline stores. */ | |
131 | ||
132 | #undef FP_SAVE_INLINE | |
133 | #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64) | |
134 | ||
135 | /* Always use the "debug" register names, they're what the assembler | |
136 | wants to see. */ | |
137 | ||
138 | #undef REGISTER_NAMES | |
139 | #define REGISTER_NAMES DEBUG_REGISTER_NAMES | |
140 | ||
54ee9799 DE |
141 | /* This outputs NAME to FILE. */ |
142 | ||
143 | #undef RS6000_OUTPUT_BASENAME | |
144 | #define RS6000_OUTPUT_BASENAME(FILE, NAME) \ | |
145 | assemble_name (FILE, NAME); | |
146 | ||
5eb99654 KG |
147 | /* Globalizing directive for a label. */ |
148 | #undef GLOBAL_ASM_OP | |
149 | #define GLOBAL_ASM_OP "\t.globl " | |
150 | #undef TARGET_ASM_GLOBALIZE_LABEL | |
ee890fe2 SS |
151 | |
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? */ | |
155 | ||
156 | #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX | |
157 | #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \ | |
158 | fprintf (FILE, "%s", PREFIX) | |
159 | ||
ee890fe2 SS |
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)); \ | |
54ee9799 | 166 | RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \ |
ee890fe2 SS |
167 | fprintf ((FILE), ",%d\n", (SIZE)); } while (0) |
168 | ||
deb5bfcc SS |
169 | /* Override the standard rs6000 definition. */ |
170 | ||
171 | #undef ASM_COMMENT_START | |
172 | #define ASM_COMMENT_START ";" | |
173 | ||
ee890fe2 SS |
174 | /* FP save and restore routines. */ |
175 | #define SAVE_FP_PREFIX "._savef" | |
176 | #define SAVE_FP_SUFFIX "" | |
177 | #define RESTORE_FP_PREFIX "._restf" | |
178 | #define RESTORE_FP_SUFFIX "" | |
179 | ||
e381c27a DJ |
180 | /* This is how to output an assembler line that says to advance |
181 | the location counter to a multiple of 2**LOG bytes using the | |
182 | "nop" instruction as padding. */ | |
183 | ||
cdc58a82 DJ |
184 | #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG) \ |
185 | do \ | |
186 | { \ | |
187 | if ((LOG) < 3) \ | |
188 | { \ | |
189 | ASM_OUTPUT_ALIGN (FILE,LOG); \ | |
190 | } \ | |
191 | else /* nop == ori r0,r0,0 */ \ | |
192 | fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG)); \ | |
193 | } while (0) | |
e381c27a | 194 | |
ee890fe2 SS |
195 | /* Generate insns to call the profiler. */ |
196 | ||
197 | #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) | |
198 | ||
199 | /* Function name to call to do profiling. */ | |
200 | ||
201 | #define RS6000_MCOUNT "*mcount" | |
202 | ||
ed947a96 DJ |
203 | /* Default processor: a G4. */ |
204 | ||
205 | #undef PROCESSOR_DEFAULT | |
206 | #define PROCESSOR_DEFAULT PROCESSOR_PPC7400 | |
207 | ||
208 | /* Default target flag settings. Despite the fact that STMW/LMW | |
209 | serializes, it's still a big codesize win to use them. Use FSEL by | |
210 | default as well. */ | |
211 | ||
212 | #undef TARGET_DEFAULT | |
213 | #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \ | |
214 | | MASK_PPC_GFXOPT) | |
215 | ||
ee890fe2 SS |
216 | /* Since Darwin doesn't do TOCs, stub this out. */ |
217 | ||
218 | #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) 0 | |
219 | ||
4f400cf6 DJ |
220 | /* Unlike most other PowerPC targets, chars are signed, for |
221 | consistency with other Darwin architectures. */ | |
222 | ||
223 | #undef DEFAULT_SIGNED_CHAR | |
224 | #define DEFAULT_SIGNED_CHAR (1) | |
225 | ||
ee890fe2 SS |
226 | /* Given an rtx X being reloaded into a reg required to be |
227 | in class CLASS, return the class of reg to actually use. | |
228 | In general this is just CLASS; but on some machines | |
229 | in some cases it is preferable to use a more restrictive class. | |
230 | ||
231 | On the RS/6000, we have to return NO_REGS when we want to reload a | |
232 | floating-point CONST_DOUBLE to force it to be copied to memory. | |
233 | ||
234 | Don't allow R0 when loading the address of, or otherwise furtling with, | |
235 | a SYMBOL_REF. */ | |
236 | ||
237 | #undef PREFERRED_RELOAD_CLASS | |
238 | #define PREFERRED_RELOAD_CLASS(X,CLASS) \ | |
239 | (((GET_CODE (X) == CONST_DOUBLE \ | |
240 | && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \ | |
241 | ? NO_REGS \ | |
242 | : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \ | |
243 | && (CLASS) == NON_SPECIAL_REGS) \ | |
244 | ? GENERAL_REGS \ | |
245 | : (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH) \ | |
246 | ? BASE_REGS \ | |
247 | : (CLASS))) | |
248 | ||
249 | /* Fix for emit_group_load (): force large constants to be pushed via regs. */ | |
250 | #define ALWAYS_PUSH_CONSTS_USING_REGS_P 1 | |
2bfcf297 | 251 | |
3b85fe5f JJ |
252 | /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints. */ |
253 | #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ | |
254 | (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ | |
255 | ? get_inner_array_type (FIELD) \ | |
256 | : TREE_TYPE (FIELD)) == DFmode \ | |
257 | ? MIN ((COMPUTED), 32) : (COMPUTED)) | |
258 | ||
2bfcf297 DB |
259 | /* Darwin increases natural record alignment to doubleword if the first |
260 | field is an FP double while the FP fields remain word aligned. */ | |
261 | #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ | |
262 | ((TREE_CODE (STRUCT) == RECORD_TYPE \ | |
263 | || TREE_CODE (STRUCT) == UNION_TYPE \ | |
264 | || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ | |
265 | && TYPE_FIELDS (STRUCT) != 0 \ | |
266 | && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \ | |
216caa2b | 267 | ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \ |
b8513691 AH |
268 | : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \ |
269 | ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \ | |
2bfcf297 | 270 | : MAX ((COMPUTED), (SPECIFIED))) |
9429c84c | 271 | |
f984d8df | 272 | /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't |
88cad84b | 273 | support 64 bit PowerPC either, so this just keeps things happy. */ |
362b68a8 | 274 | #define DOUBLE_INT_ASM_OP "\t.quad\t" |
c859cda6 DJ |
275 | |
276 | /* Get HOST_WIDE_INT and CONST_INT to be 32 bits, for compile time | |
277 | space/speed. */ | |
278 | #undef MAX_LONG_TYPE_SIZE | |
279 | #define MAX_LONG_TYPE_SIZE 32 | |
609688f3 JM |
280 | |
281 | /* For binary compatibility with 2.95; Darwin C APIs use bool from | |
282 | stdbool.h, which was an int-sized enum in 2.95. */ | |
283 | #define BOOL_TYPE_SIZE INT_TYPE_SIZE | |
9fe08fd0 RH |
284 | |
285 | #undef REGISTER_TARGET_PRAGMAS | |
286 | #define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS |