OSDN Git Service

* config/rs6000/darwin.h (DARWIN_MINVERSION_SPEC): Add
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / darwin.h
1 /* Target definitions for x86 running Darwin.
2    Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
3    Contributed by Apple Computer Inc.
4
5 This file is part of GCC.
6
7 GCC 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 GCC 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 GCC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.  */
21
22 /* Enable Mach-O bits in generic x86 code.  */
23 #undef TARGET_MACHO
24 #define TARGET_MACHO 1
25
26 #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)");
27
28 #undef  TARGET_64BIT
29 #define TARGET_64BIT (target_flags & MASK_64BIT)
30
31 #ifdef IN_LIBGCC2
32 #undef TARGET_64BIT
33 #ifdef __x86_64__
34 #define TARGET_64BIT 1
35 #else
36 #define TARGET_64BIT 0
37 #endif
38 #endif
39
40 /* Size of the Obj-C jump buffer.  */
41 #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18))
42
43 #undef TARGET_FPMATH_DEFAULT
44 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387)
45
46 #define TARGET_OS_CPP_BUILTINS()                \
47   do                                            \
48     {                                           \
49       builtin_define ("__LITTLE_ENDIAN__");     \
50       darwin_cpp_builtins (pfile);              \
51     }                                           \
52   while (0)
53
54 #undef PTRDIFF_TYPE
55 #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
56
57 #undef WCHAR_TYPE
58 #define WCHAR_TYPE "int"
59
60 #undef WCHAR_TYPE_SIZE
61 #define WCHAR_TYPE_SIZE 32
62
63 #undef MAX_BITS_PER_WORD
64 #define MAX_BITS_PER_WORD 64
65
66 #undef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
67 #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN (0)
68
69 #undef TARGET_KEEPS_VECTOR_ALIGNED_STACK
70 #define TARGET_KEEPS_VECTOR_ALIGNED_STACK 1
71
72 /* We want -fPIC by default, unless we're using -static to compile for
73    the kernel or some such.  */
74
75 #undef CC1_SPEC
76 #define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
77   %{!mmacosx-version-min=*:-mmacosx-version-min=%(darwin_minversion)} \
78   %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}"
79
80 #undef ASM_SPEC
81 #define ASM_SPEC "-arch %(darwin_arch) -force_cpusubtype_ALL"
82
83 #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
84 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
85
86 /* Determine a minimum version based on compiler options.  */
87 #define DARWIN_MINVERSION_SPEC                          \
88  "%{!m64|fgnu-runtime:10.4;                             \
89     ,objective-c|,objc-cpp-output:10.5;                 \
90     ,objective-c-header:10.5;                           \
91     ,objective-c++|,objective-c++-cpp-output:10.5;      \
92     ,objective-c++-header|,objc++-cpp-output:10.5;      \
93     :10.4}"
94
95 #undef SUBTARGET_EXTRA_SPECS
96 #define SUBTARGET_EXTRA_SPECS                                   \
97   DARWIN_EXTRA_SPECS                                            \
98   { "darwin_arch", DARWIN_ARCH_SPEC },                          \
99   { "darwin_crt2", "" },                                        \
100   { "darwin_subarch", DARWIN_SUBARCH_SPEC },
101
102 /* Use the following macro for any Darwin/x86-specific command-line option
103    translation.  */
104 #define SUBTARGET_OPTION_TRANSLATE_TABLE \
105   { "", "" }
106
107 /* The Darwin assembler mostly follows AT&T syntax.  */
108 #undef ASSEMBLER_DIALECT
109 #define ASSEMBLER_DIALECT ASM_ATT
110
111 /* Define macro used to output shift-double opcodes when the shift
112    count is in %cl.  Some assemblers require %cl as an argument;
113    some don't.  This macro controls what to do: by default, don't
114    print %cl.  */
115
116 #define SHIFT_DOUBLE_OMITS_COUNT 0
117
118 extern void darwin_x86_file_end (void);
119 #undef TARGET_ASM_FILE_END
120 #define TARGET_ASM_FILE_END darwin_x86_file_end
121
122 /* Define the syntax of pseudo-ops, labels and comments.  */
123
124 /* String containing the assembler's comment-starter.  */
125
126 #define ASM_COMMENT_START "#"
127
128 /* By default, target has a 80387, uses IEEE compatible arithmetic,
129    and returns float values in the 387.  */
130
131 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE)
132
133 /* For now, disable dynamic-no-pic.  We'll need to go through i386.c
134    with a fine-tooth comb looking for refs to flag_pic!  */
135 #define MASK_MACHO_DYNAMIC_NO_PIC 0
136 #define TARGET_DYNAMIC_NO_PIC     (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
137
138 #undef GOT_SYMBOL_NAME
139 #define GOT_SYMBOL_NAME (machopic_function_base_name ())
140
141 /* Define the syntax of pseudo-ops, labels and comments.  */
142
143 #define LPREFIX "L"
144
145 /* These are used by -fbranch-probabilities */
146 #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
147 #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
148                               "__TEXT,__unlikely,regular,pure_instructions"
149
150 /* Assembler pseudos to introduce constants of various size.  */
151
152 #define ASM_BYTE_OP "\t.byte\t"
153 #define ASM_SHORT "\t.word\t"
154 #define ASM_LONG "\t.long\t"
155 #define ASM_QUAD "\t.quad\t"
156
157 #define SUBTARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
158
159 #undef ASM_OUTPUT_ALIGN
160 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
161  do { if ((LOG) != 0)                   \
162         {                               \
163           if (in_section == text_section) \
164             fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
165           else                          \
166             fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
167         }                               \
168     } while (0)
169
170 /* This says how to output an assembler line
171    to define a global common symbol.  */
172
173 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
174 ( fputs (".comm ", (FILE)),                     \
175   assemble_name ((FILE), (NAME)),               \
176   fprintf ((FILE), ",%lu\n", (unsigned long)(ROUNDED)))
177
178 /* This says how to output an assembler line
179    to define a local common symbol.  */
180
181 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
182 ( fputs (".lcomm ", (FILE)),                    \
183   assemble_name ((FILE), (NAME)),               \
184   fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
185
186 /* Darwin profiling -- call mcount.  */
187 #undef FUNCTION_PROFILER
188 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
189     do {                                                                \
190       if (MACHOPIC_INDIRECT && !TARGET_64BIT)                           \
191         {                                                               \
192           const char *name = machopic_mcount_stub_name ();              \
193           fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */      \
194           machopic_validate_stub_or_non_lazy_ptr (name);                \
195         }                                                               \
196       else fprintf (FILE, "\tcall mcount\n");                           \
197     } while (0)
198
199 #define C_COMMON_OVERRIDE_OPTIONS                                       \
200   do {                                                                  \
201     SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;                                \
202   } while (0)
203
204 /* Darwin on x86_64 uses dwarf-2 by default.  Pre-darwin9 32-bit
205    compiles default to stabs+.  darwin9+ defaults to dwarf-2.  */
206 #ifndef DARWIN_PREFER_DWARF
207 #undef PREFERRED_DEBUGGING_TYPE
208 #define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG)
209 #endif
210
211 /* Darwin uses the standard DWARF register numbers but the default
212    register numbers for STABS.  Fortunately for 64-bit code the
213    default and the standard are the same.  */
214 #undef DBX_REGISTER_NUMBER
215 #define DBX_REGISTER_NUMBER(n)                                  \
216   (TARGET_64BIT ? dbx64_register_map[n]                         \
217    : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n]   \
218    : dbx_register_map[n])
219
220 /* Unfortunately, the 32-bit EH information also doesn't use the standard
221    DWARF register numbers.  */
222 #define DWARF2_FRAME_REG_OUT(n, for_eh)                                 \
223   (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n)    \
224    : (n) == 5 ? 4                                                       \
225    : (n) == 4 ? 5                                                       \
226    : (n) >= 11 && (n) <= 18 ? (n) + 1                                   \
227    : (n))
228
229 #undef REGISTER_TARGET_PRAGMAS
230 #define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS()
231
232 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
233 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes
234
235 /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the
236    end of the instruction, but without the 4 we'd only have the right
237    address for the start of the instruction.  */
238 #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
239 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE)     \
240   if (TARGET_64BIT)                                                             \
241     {                                                                           \
242       if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel)                 \
243         {                                                                       \
244            fputs (ASM_LONG, FILE);                                              \
245            assemble_name (FILE, XSTR (ADDR, 0));                                \
246            fputs ("+4@GOTPCREL", FILE);                                         \
247            goto DONE;                                                           \
248         }                                                                       \
249     }                                                                           \
250   else                                                                          \
251     {                                                                           \
252       if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1))                      \
253         {                                                                       \
254           darwin_non_lazy_pcrel (FILE, ADDR);                                   \
255           goto DONE;                                                            \
256         }                                                                       \
257     }
258
259 /* This needs to move since i386 uses the first flag and other flags are
260    used in Mach-O.  */
261 #undef MACHO_SYMBOL_FLAG_VARIABLE
262 #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3)