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