OSDN Git Service

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