OSDN Git Service

Add support for darwin linker option -dynamic.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / darwin.h
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.
4
5 This file is part of GNU CC.
6
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)
10 any later version.
11
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.
16
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.  */
21
22 #undef  TARGET_VERSION
23 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
24
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
38 /* Handle #pragma weak and #pragma pack.  */
39 #define HANDLE_SYSV_PRAGMA 1
40
41 /* The Darwin ABI always includes AltiVec, can't be (validly) turned
42    off.  */
43
44 #define SUBTARGET_OVERRIDE_OPTIONS  \
45   rs6000_altivec_abi = 1;
46
47 #define TARGET_OS_CPP_BUILTINS()                \
48   do                                            \
49     {                                           \
50       builtin_define ("__ppc__");               \
51       builtin_define ("__POWERPC__");           \
52       builtin_define ("__NATURAL_ALIGNMENT__"); \
53       builtin_define ("__MACH__");              \
54       builtin_define ("__APPLE__");             \
55     }                                           \
56   while (0)
57
58 /* We want -fPIC by default, unless we're using -static to compile for
59    the kernel or some such.  */
60
61 #define CC1_SPEC "\
62 %{static: %{Zdynamic: %e conflicting code gen style switches are used}}\
63 %{!static:-fPIC}"
64
65 /* Make both r2 and r3 available for allocation.  */
66 #define FIXED_R2 0
67 #define FIXED_R13 0
68
69 /* Base register for access to local variables of the function.  */
70
71 #undef  FRAME_POINTER_REGNUM
72 #define FRAME_POINTER_REGNUM 30
73
74 #undef  RS6000_PIC_OFFSET_TABLE_REGNUM
75 #define RS6000_PIC_OFFSET_TABLE_REGNUM 31
76
77 /* Pad the outgoing args area to 16 bytes instead of the usual 8.  */
78
79 #undef STARTING_FRAME_OFFSET
80 #define STARTING_FRAME_OFFSET                                           \
81   (RS6000_ALIGN (current_function_outgoing_args_size, 16)               \
82    + RS6000_VARARGS_AREA                                                \
83    + RS6000_SAVE_AREA)
84
85 #undef STACK_DYNAMIC_OFFSET
86 #define STACK_DYNAMIC_OFFSET(FUNDECL)                                   \
87   (RS6000_ALIGN (current_function_outgoing_args_size, 16)               \
88    + (STACK_POINTER_OFFSET))
89
90 /* Define cutoff for using external functions to save floating point.
91    Currently on Darwin, always use inline stores.  */
92
93 #undef  FP_SAVE_INLINE
94 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
95
96 /* Always use the "debug" register names, they're what the assembler
97    wants to see.  */
98
99 #undef REGISTER_NAMES
100 #define REGISTER_NAMES DEBUG_REGISTER_NAMES
101
102 /* This outputs NAME to FILE.  */
103
104 #undef  RS6000_OUTPUT_BASENAME
105 #define RS6000_OUTPUT_BASENAME(FILE, NAME)      \
106     assemble_name (FILE, NAME);
107
108 /* Globalizing directive for a label.  */
109 #undef GLOBAL_ASM_OP
110 #define GLOBAL_ASM_OP "\t.globl "
111 #undef TARGET_ASM_GLOBALIZE_LABEL
112
113 /* This is how to output an internal label prefix.  rs6000.c uses this
114    when generating traceback tables.  */
115 /* Not really used for Darwin?  */
116
117 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
118 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
119   fprintf (FILE, "%s", PREFIX)
120
121 /* This says how to output an assembler line to define a global common
122    symbol.  */
123 /* ? */
124 #undef  ASM_OUTPUT_ALIGNED_COMMON
125 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)    \
126   do { fputs (".comm ", (FILE));                        \
127        RS6000_OUTPUT_BASENAME ((FILE), (NAME));         \
128        fprintf ((FILE), ",%d\n", (SIZE)); } while (0)
129
130 /* Override the standard rs6000 definition.  */
131
132 #undef ASM_COMMENT_START
133 #define ASM_COMMENT_START ";"
134
135 /* FP save and restore routines.  */
136 #define SAVE_FP_PREFIX "._savef"
137 #define SAVE_FP_SUFFIX ""
138 #define RESTORE_FP_PREFIX "._restf"
139 #define RESTORE_FP_SUFFIX ""
140
141 /* This is how to output an assembler line that says to advance
142    the location counter to a multiple of 2**LOG bytes using the
143    "nop" instruction as padding.  */
144
145 #define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG)                   \
146   do                                                          \
147     {                                                         \
148       if ((LOG) < 3)                                          \
149         {                                                     \
150           ASM_OUTPUT_ALIGN (FILE,LOG);                        \
151         }                                                     \
152       else /* nop == ori r0,r0,0 */                           \
153         fprintf (FILE, "\t.align32 %d,0x60000000\n", (LOG));  \
154     } while (0)
155
156 /* Generate insns to call the profiler.  */
157
158 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
159
160 /* Function name to call to do profiling.  */
161
162 #define RS6000_MCOUNT "*mcount"
163
164 /* Default processor: a G4.  */
165
166 #undef PROCESSOR_DEFAULT
167 #define PROCESSOR_DEFAULT  PROCESSOR_PPC7400
168
169 /* Default target flag settings.  Despite the fact that STMW/LMW
170    serializes, it's still a big codesize win to use them.  Use FSEL by
171    default as well.  */
172
173 #undef  TARGET_DEFAULT
174 #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \
175                       | MASK_PPC_GFXOPT)
176
177 /* Since Darwin doesn't do TOCs, stub this out.  */
178
179 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)  0
180
181 /* Unlike most other PowerPC targets, chars are signed, for
182    consistency with other Darwin architectures.  */
183
184 #undef DEFAULT_SIGNED_CHAR
185 #define DEFAULT_SIGNED_CHAR (1)
186
187 /* Given an rtx X being reloaded into a reg required to be      
188    in class CLASS, return the class of reg to actually use.     
189    In general this is just CLASS; but on some machines
190    in some cases it is preferable to use a more restrictive class.
191   
192    On the RS/6000, we have to return NO_REGS when we want to reload a
193    floating-point CONST_DOUBLE to force it to be copied to memory.
194
195    Don't allow R0 when loading the address of, or otherwise furtling with,
196    a SYMBOL_REF.  */
197
198 #undef PREFERRED_RELOAD_CLASS
199 #define PREFERRED_RELOAD_CLASS(X,CLASS)                 \
200   (((GET_CODE (X) == CONST_DOUBLE                       \
201     && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT)     \
202    ? NO_REGS                                            \
203    : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT         \
204       && (CLASS) == NON_SPECIAL_REGS)                   \
205    ? GENERAL_REGS                                       \
206    : (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH)       \
207    ? BASE_REGS                                          \
208    : (CLASS)))
209
210 /* Fix for emit_group_load (): force large constants to be pushed via regs.  */
211 #define ALWAYS_PUSH_CONSTS_USING_REGS_P         1
212
213 /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
214 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
215   (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
216               ? get_inner_array_type (FIELD) \
217               : TREE_TYPE (FIELD)) == DFmode \
218    ? MIN ((COMPUTED), 32) : (COMPUTED))
219
220 /* Darwin increases natural record alignment to doubleword if the first
221    field is an FP double while the FP fields remain word aligned.  */
222 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)   \
223   ((TREE_CODE (STRUCT) == RECORD_TYPE                   \
224     || TREE_CODE (STRUCT) == UNION_TYPE                 \
225     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)           \
226    && TYPE_FIELDS (STRUCT) != 0                         \
227    && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode        \
228    ? MAX (MAX ((COMPUTED), (SPECIFIED)), 64)            \
229    : (TARGET_ALTIVEC && TREE_CODE (STRUCT) == VECTOR_TYPE) \
230    ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128)           \
231    : MAX ((COMPUTED), (SPECIFIED)))
232
233 /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
234    support 64 bit PowerPC either, so this just keeps things happy.  */
235 #define DOUBLE_INT_ASM_OP "\t.quad\t"
236
237 /* Get HOST_WIDE_INT and CONST_INT to be 32 bits, for compile time
238    space/speed.  */
239 #undef MAX_LONG_TYPE_SIZE
240 #define MAX_LONG_TYPE_SIZE 32
241
242 /* For binary compatibility with 2.95; Darwin C APIs use bool from
243    stdbool.h, which was an int-sized enum in 2.95.  */
244 #define BOOL_TYPE_SIZE INT_TYPE_SIZE
245
246 #undef REGISTER_TARGET_PRAGMAS
247 #define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS