OSDN Git Service

2001-08-28 Dale Johannesen <dalej@apple.com>
[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 /* The "Darwin ABI" is mostly like AIX, but with some key differences.  */
23
24 #define DEFAULT_ABI ABI_DARWIN
25
26 /* The object file format is Mach-O.  */
27
28 #define TARGET_OBJECT_FORMAT OBJECT_MACHO
29
30 /* We're not ever going to do TOCs.  */
31
32 #define TARGET_TOC 0
33 #define TARGET_NO_TOC 1
34
35 #define CPP_PREDEFINES "-D__ppc__ -D__NATURAL_ALIGNMENT__ -D__MACH__ -D__BIG_ENDIAN__ -D__APPLE__"
36
37 /* We want -fPIC by default, unless we're using -static to compile for
38    the kernel or some such.  */
39
40 #define CC1_SPEC "%{!static:-fPIC}"
41
42 #define FIXED_R13 0
43
44 #undef  TARGET_DEFAULT
45 #define TARGET_DEFAULT (MASK_POWERPC | MASK_MULTIPLE | MASK_NEW_MNEMONICS \
46   | MASK_NO_FP_IN_TOC | MASK_NO_SUM_IN_TOC)
47
48 /* Base register for access to local variables of the function.  */
49
50 #undef  FRAME_POINTER_REGNUM
51 #define FRAME_POINTER_REGNUM 30
52
53 #undef  PIC_OFFSET_TABLE_REGNUM
54 #define PIC_OFFSET_TABLE_REGNUM 31
55
56 #undef STACK_BOUNDARY
57 #define STACK_BOUNDARY 128
58
59 /* Pad the outgoing args area to 16 bytes instead of the usual 8.  */
60
61 #undef STARTING_FRAME_OFFSET
62 #define STARTING_FRAME_OFFSET                                           \
63   (RS6000_ALIGN (current_function_outgoing_args_size, 16)               \
64    + RS6000_VARARGS_AREA                                                \
65    + RS6000_SAVE_AREA)
66
67 #undef STACK_DYNAMIC_OFFSET
68 #define STACK_DYNAMIC_OFFSET(FUNDECL)                                   \
69   (RS6000_ALIGN (current_function_outgoing_args_size, 16)               \
70    + (STACK_POINTER_OFFSET))
71
72 /* Define cutoff for using external functions to save floating point.
73    Currently on Darwin, always use inline stores.  */
74
75 #undef  FP_SAVE_INLINE
76 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 64)
77
78 /* Always use the "debug" register names, they're what the assembler
79    wants to see.  */
80
81 #undef REGISTER_NAMES
82 #define REGISTER_NAMES DEBUG_REGISTER_NAMES
83
84 /* This outputs NAME to FILE.  */
85
86 #undef  RS6000_OUTPUT_BASENAME
87 #define RS6000_OUTPUT_BASENAME(FILE, NAME)      \
88     assemble_name (FILE, NAME);
89
90 /* Output before instructions.  */
91 /* This is how to output the definition of a user-level label named NAME,
92    such as the label on a static function or variable NAME.  */
93
94 #define ASM_OUTPUT_LABEL(FILE,NAME)     \
95   do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
96
97 /* This is how to output a command to make the user-level label named NAME
98    defined for reference from other files.  */
99
100 #undef ASM_GLOBALIZE_LABEL
101 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
102   do { fputs ("\t.globl ", FILE);       \
103        RS6000_OUTPUT_BASENAME (FILE, NAME); putc ('\n', FILE);} while (0)
104
105 /* This is how to output an internal label prefix.  rs6000.c uses this
106    when generating traceback tables.  */
107 /* Not really used for Darwin?  */
108
109 #undef ASM_OUTPUT_INTERNAL_LABEL_PREFIX
110 #define ASM_OUTPUT_INTERNAL_LABEL_PREFIX(FILE,PREFIX)   \
111   fprintf (FILE, "%s", PREFIX)
112
113 #undef TEXT_SECTION_ASM_OP
114 #define TEXT_SECTION_ASM_OP ".text"
115
116 /* Output before writable data.  */
117
118 #undef DATA_SECTION_ASM_OP
119 #define DATA_SECTION_ASM_OP ".data"
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 #define ASM_OUTPUT_SKIP(FILE,SIZE)  \
131   fprintf (FILE, "\t.space %d\n", SIZE)
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 /* Since Darwin doesn't do TOCs, stub this out.  */
148
149 #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)  0
150
151 /* Unlike most other PowerPC targets, chars are signed, for
152    consistency with other Darwin architectures.  */
153
154 #undef DEFAULT_SIGNED_CHAR
155 #define DEFAULT_SIGNED_CHAR (1)
156
157 /* Given an rtx X being reloaded into a reg required to be      
158    in class CLASS, return the class of reg to actually use.     
159    In general this is just CLASS; but on some machines
160    in some cases it is preferable to use a more restrictive class.
161   
162    On the RS/6000, we have to return NO_REGS when we want to reload a
163    floating-point CONST_DOUBLE to force it to be copied to memory.
164
165    Don't allow R0 when loading the address of, or otherwise furtling with,
166    a SYMBOL_REF.  */
167
168 #undef PREFERRED_RELOAD_CLASS
169 #define PREFERRED_RELOAD_CLASS(X,CLASS)                 \
170   (((GET_CODE (X) == CONST_DOUBLE                       \
171     && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT)     \
172    ? NO_REGS                                            \
173    : (GET_MODE_CLASS (GET_MODE (X)) == MODE_INT         \
174       && (CLASS) == NON_SPECIAL_REGS)                   \
175    ? GENERAL_REGS                                       \
176    : (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == HIGH)       \
177    ? BASE_REGS                                          \
178    : (CLASS)))
179
180 /* Fix for emit_group_load (): force large constants to be pushed via regs.  */
181 #define ALWAYS_PUSH_CONSTS_USING_REGS_P         1
182
183 /* Darwin word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
184 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
185   (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
186               ? get_inner_array_type (FIELD) \
187               : TREE_TYPE (FIELD)) == DFmode \
188    ? MIN ((COMPUTED), 32) : (COMPUTED))
189
190 /* Darwin increases natural record alignment to doubleword if the first
191    field is an FP double while the FP fields remain word aligned.  */
192 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)   \
193   ((TREE_CODE (STRUCT) == RECORD_TYPE                   \
194     || TREE_CODE (STRUCT) == UNION_TYPE                 \
195     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)           \
196    && TYPE_FIELDS (STRUCT) != 0                         \
197    && DECL_MODE (TYPE_FIELDS (STRUCT)) == DFmode        \
198    ? MAX (MAX ((COMPUTED), (SPECIFIED)), BIGGEST_ALIGNMENT) \
199    : MAX ((COMPUTED), (SPECIFIED)))
200 /* XXX: Darwin supports neither .quad, or .llong, but it also doesn't
201    support 64 bit powerpc either, so this just keeps things happy. */
202 #define DOUBLE_INT_ASM_OP "\t.quad\t"