]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/gcc/config/i386/darwin.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / gcc / config / i386 / darwin.h
1 /* Target definitions for x86 running Darwin.
2    Copyright (C) 2001, 2002, 2004, 2005 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 /* We want -fPIC by default, unless we're using -static to compile for
70    the kernel or some such.  */
71
72 #undef CC1_SPEC
73 #define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}} \
74   %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}"
75
76 #undef ASM_SPEC
77 #define ASM_SPEC "-arch %(darwin_arch) -force_cpusubtype_ALL"
78
79 #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
80 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
81
82 #undef SUBTARGET_EXTRA_SPECS
83 #define SUBTARGET_EXTRA_SPECS                                   \
84   { "darwin_arch", DARWIN_ARCH_SPEC },                          \
85   { "darwin_crt2", "" },                                        \
86   { "darwin_subarch", DARWIN_SUBARCH_SPEC },
87
88 /* Use the following macro for any Darwin/x86-specific command-line option
89    translation.  */
90 #define SUBTARGET_OPTION_TRANSLATE_TABLE \
91   { "", "" }
92
93 /* The Darwin assembler mostly follows AT&T syntax.  */
94 #undef ASSEMBLER_DIALECT
95 #define ASSEMBLER_DIALECT ASM_ATT
96
97 /* Define macro used to output shift-double opcodes when the shift
98    count is in %cl.  Some assemblers require %cl as an argument;
99    some don't.  This macro controls what to do: by default, don't
100    print %cl.  */
101
102 #define SHIFT_DOUBLE_OMITS_COUNT 0
103
104 extern void darwin_x86_file_end (void);
105 #undef TARGET_ASM_FILE_END
106 #define TARGET_ASM_FILE_END darwin_x86_file_end
107
108 /* Define the syntax of pseudo-ops, labels and comments.  */
109
110 /* String containing the assembler's comment-starter.  */
111
112 #define ASM_COMMENT_START "#"
113
114 /* By default, target has a 80387, uses IEEE compatible arithmetic,
115    and returns float values in the 387.  */
116
117 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE)
118
119 /* For now, disable dynamic-no-pic.  We'll need to go through i386.c
120    with a fine-tooth comb looking for refs to flag_pic!  */
121 #define MASK_MACHO_DYNAMIC_NO_PIC 0
122 #define TARGET_DYNAMIC_NO_PIC     (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
123
124 #undef GOT_SYMBOL_NAME
125 #define GOT_SYMBOL_NAME (machopic_function_base_name ())
126
127 /* Define the syntax of pseudo-ops, labels and comments.  */
128
129 #define LPREFIX "L"
130
131 /* These are used by -fbranch-probabilities */
132 #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
133 #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
134                               "__TEXT,__unlikely,regular,pure_instructions"
135
136 /* Assembler pseudos to introduce constants of various size.  */
137
138 #define ASM_BYTE_OP "\t.byte\t"
139 #define ASM_SHORT "\t.word\t"
140 #define ASM_LONG "\t.long\t"
141 #define ASM_QUAD "\t.quad\t"
142
143 #define SUBTARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
144
145 #undef ASM_OUTPUT_ALIGN
146 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
147  do { if ((LOG) != 0)                   \
148         {                               \
149           if (in_section == text_section) \
150             fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
151           else                          \
152             fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
153         }                               \
154     } while (0)
155
156 /* This says how to output an assembler line
157    to define a global common symbol.  */
158
159 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
160 ( fputs (".comm ", (FILE)),                     \
161   assemble_name ((FILE), (NAME)),               \
162   fprintf ((FILE), ",%lu\n", (unsigned long)(ROUNDED)))
163
164 /* This says how to output an assembler line
165    to define a local common symbol.  */
166
167 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
168 ( fputs (".lcomm ", (FILE)),                    \
169   assemble_name ((FILE), (NAME)),               \
170   fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
171
172 /* Darwin profiling -- call mcount.  */
173 #undef FUNCTION_PROFILER
174 #define FUNCTION_PROFILER(FILE, LABELNO)                                \
175     do {                                                                \
176       if (MACHOPIC_INDIRECT && !TARGET_64BIT)                           \
177         {                                                               \
178           const char *name = machopic_mcount_stub_name ();              \
179           fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */      \
180           machopic_validate_stub_or_non_lazy_ptr (name);                \
181         }                                                               \
182       else fprintf (FILE, "\tcall mcount\n");                           \
183     } while (0)
184
185 #define C_COMMON_OVERRIDE_OPTIONS                                       \
186   do {                                                                  \
187     SUBTARGET_C_COMMON_OVERRIDE_OPTIONS;                                \
188   } while (0)
189
190 /* Darwin on x86_64 uses dwarf-2 by default.  */
191 #undef PREFERRED_DEBUGGING_TYPE
192 #define PREFERRED_DEBUGGING_TYPE (TARGET_64BIT ? DWARF2_DEBUG : DBX_DEBUG)
193
194 /* Darwin uses the standard DWARF register numbers but the default
195    register numbers for STABS.  Fortunately for 64-bit code the
196    default and the standard are the same.  */
197 #undef DBX_REGISTER_NUMBER
198 #define DBX_REGISTER_NUMBER(n)                                  \
199   (TARGET_64BIT ? dbx64_register_map[n]                         \
200    : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n]   \
201    : dbx_register_map[n])
202
203 /* Unfortunately, the 32-bit EH information also doesn't use the standard
204    DWARF register numbers.  */
205 #define DWARF2_FRAME_REG_OUT(n, for_eh)                                 \
206   (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n)    \
207    : (n) == 5 ? 4                                                       \
208    : (n) == 4 ? 5                                                       \
209    : (n) >= 11 && (n) <= 18 ? (n) + 1                                   \
210    : (n))
211
212 #undef REGISTER_TARGET_PRAGMAS
213 #define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS()
214
215 #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
216 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes
217
218 /* For 64-bit, we need to add 4 because @GOTPCREL is relative to the
219    end of the instruction, but without the 4 we'd only have the right
220    address for the start of the instruction.  */
221 #undef ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX
222 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE)     \
223   if (TARGET_64BIT)                                                             \
224     {                                                                           \
225       if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_pcrel)                 \
226         {                                                                       \
227            fputs (ASM_LONG, FILE);                                              \
228            assemble_name (FILE, XSTR (ADDR, 0));                                \
229            fputs ("+4@GOTPCREL", FILE);                                         \
230            goto DONE;                                                           \
231         }                                                                       \
232     }                                                                           \
233   else                                                                          \
234     {                                                                           \
235       if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1))                      \
236         {                                                                       \
237           darwin_non_lazy_pcrel (FILE, ADDR);                                   \
238           goto DONE;                                                            \
239         }                                                                       \
240     }
241
242 /* This needs to move since i386 uses the first flag and other flags are
243    used in Mach-O.  */
244 #undef MACHO_SYMBOL_FLAG_VARIABLE
245 #define MACHO_SYMBOL_FLAG_VARIABLE ((SYMBOL_FLAG_MACH_DEP) << 3)