1 /* Target definitions for PowerPC running Darwin (Mac OS X).
2 Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Apple Computer Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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. */
36 #define TARGET_NO_TOC 1
38 /* Handle #pragma weak and #pragma pack. */
39 #define HANDLE_SYSV_PRAGMA
41 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
44 #define SUBTARGET_OVERRIDE_OPTIONS \
45 rs6000_altivec_abi = 1;
47 #define CPP_PREDEFINES "-D__ppc__ -D__POWERPC__ -D__NATURAL_ALIGNMENT__ -D__MACH__ -D__BIG_ENDIAN__ -D__APPLE__"
49 /* We want -fPIC by default, unless we're using -static to compile for
50 the kernel or some such. */
52 #define CC1_SPEC "%{!static:-fPIC}"
54 /* Make both r2 and r3 available for allocation. */
58 /* Base register for access to local variables of the function. */
60 #undef FRAME_POINTER_REGNUM
61 #define FRAME_POINTER_REGNUM 30
63 #undef RS6000_PIC_OFFSET_TABLE_REGNUM
64 #define RS6000_PIC_OFFSET_TABLE_REGNUM 31
66 /* Pad the outgoing args area to 16 bytes instead of the usual 8. */
68 #undef STARTING_FRAME_OFFSET
69 #define STARTING_FRAME_OFFSET \
70 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
71 + RS6000_VARARGS_AREA \
74 #undef STACK_DYNAMIC_OFFSET
75 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
76 (RS6000_ALIGN (current_function_outgoing_args_size, 16) \
77 + (STACK_POINTER_OFFSET))
79 /* Define cutoff for using external functions to save floating point.
80 Currently on Darwin, always use inline stores. */
83 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
85 /* Always use the "debug" register names, they're what the assembler
89 #define REGISTER_NAMES DEBUG_REGISTER_NAMES
91 /* This outputs NAME to FILE. */
93 #undef RS6000_OUTPUT_BASENAME
94 #define RS6000_OUTPUT_BASENAME(FILE, NAME) \
95 assemble_name (FILE, NAME);
97 /* Output before instructions. */
98 /* This is how to output the definition of a user-level label named NAME,
99 such as the label on a static function or variable NAME. */
101 #define ASM_OUTPUT_LABEL(FILE,NAME) \
102 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
104 /* This is how to output a command to make the user-level label named NAME
105 defined for reference from other files. */
107 #undef ASM_GLOBALIZE_LABEL
108 #define ASM_GLOBALIZE_LABEL(FILE,NAME) \
109 do { fputs ("\t.globl ", FILE); \
110 RS6000_OUTPUT_BASENAME (FILE, NAME); putc ('\n', FILE);} while (0)
112 /* This is how to output an internal label prefix. rs6000.c uses this
113 when generating traceback tables. */
114 /* Not really used for Darwin? */
116 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
117 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX) \
118 fprintf (FILE, "%s", PREFIX)
120 #undef TEXT_SECTION_ASM_OP
121 #define TEXT_SECTION_ASM_OP ".text"
123 /* Output before writable data. */
125 #undef DATA_SECTION_ASM_OP
126 #define DATA_SECTION_ASM_OP ".data"
128 /* This says how to output an assembler line to define a global common
131 #undef ASM_OUTPUT_ALIGNED_COMMON
132 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
133 do { fputs (".comm ", (FILE)); \
134 RS6000_OUTPUT_BASENAME ((FILE), (NAME)); \
135 fprintf ((FILE), ",%d\n", (SIZE)); } while (0)
137 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
138 fprintf (FILE, "\t.space %d\n", SIZE)
140 /* Override the standard rs6000 definition. */
142 #undef ASM_COMMENT_START
143 #define ASM_COMMENT_START ";"
145 /* FP save and restore routines. */
146 #define SAVE_FP_PREFIX "._savef"
147 #define SAVE_FP_SUFFIX ""
148 #define RESTORE_FP_PREFIX "._restf"
149 #define RESTORE_FP_SUFFIX ""
151 /* Generate insns to call the profiler. */
153 #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL)
155 /* Function name to call to do profiling. */
157 #define RS6000_MCOUNT "*mcount"
159 /* Default processor: a G4. */
161 #undef PROCESSOR_DEFAULT
162 #define PROCESSOR_DEFAULT PROCESSOR_PPC7400
164 /* Default target flag settings. Despite the fact that STMW/LMW
165 serializes, it's still a big codesize win to use them. Use FSEL by
168 #undef TARGET_DEFAULT
169 #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \
172 /* Since Darwin doesn't do TOCs, stub this out. */
174 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) 0
176 /* Unlike most other PowerPC targets, chars are signed, for
177 consistency with other Darwin architectures. */
179 #undef DEFAULT_SIGNED_CHAR
180 #define DEFAULT_SIGNED_CHAR (1)
182 /* Given an rtx X being reloaded into a reg required to be
183 in class CLASS, return the class of reg to actually use.
184 In general this is just CLASS; but on some machines
185 in some cases it is preferable to use a more restrictive class.
187 On the RS/6000, we have to return NO_REGS when we want to reload a
188 floating-point CONST_DOUBLE to force it to be copied to memory.
190 Don't allow R0 when loading the address of, or otherwise furtling with,
193 #undef PREFERRED_RELOAD_CLASS
194 #define PREFERRED_RELOAD_CLASS(X,CLASS) \
195 (((GET_CODE (X) == CONST_DOUBLE \
196 && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) \
198 : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT \
199 && (CLASS) == NON_SPECIAL_REGS) \
201 : (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH) \
205 /* Fix for emit_group_load (): force large constants to be pushed via regs. */
206 #define ALWAYS_PUSH_CONSTS_USING_REGS_P 1
208 /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints. */
209 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
210 (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
211 ? get_inner_array_type (FIELD) \
212 : TREE_TYPE (FIELD)) == DFmode \
213 ? MIN ((COMPUTED), 32) : (COMPUTED))
215 /* Darwin increases natural record alignment to doubleword if the first
216 field is an FP double while the FP fields remain word aligned. */
217 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
218 ((TREE_CODE (STRUCT) == RECORD_TYPE \
219 || TREE_CODE (STRUCT) == UNION_TYPE \
220 || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
221 && TYPE_FIELDS (STRUCT) != 0 \
222 && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode \
223 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64) \
224 : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
225 ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
226 : MAX ((COMPUTED), (SPECIFIED)))
228 /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
229 support 64 bit powerpc either, so this just keeps things happy. */
230 #define DOUBLE_INT_ASM_OP "\t.quad\t"
232 /* Get HOST_WIDE_INT and CONST_INT to be 32 bits, for compile time
234 #undef MAX_LONG_TYPE_SIZE
235 #define MAX_LONG_TYPE_SIZE 32
237 /* For binary compatibility with 2.95; Darwin C APIs use bool from
238 stdbool.h, which was an int-sized enum in 2.95. */
239 #define BOOL_TYPE_SIZE INT_TYPE_SIZE