1 /* Target definitions for x86 running Darwin.
2 Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
3 Contributed by Apple Computer Inc.
5 This file is part of GCC.
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)
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.
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. */
22 /* Enable Mach-O bits in generic x86 code. */
24 #define TARGET_MACHO 1
26 #define TARGET_VERSION fprintf (stderr, " (i686 Darwin)");
28 #undef TARGET_FPMATH_DEFAULT
29 #define TARGET_FPMATH_DEFAULT (TARGET_SSE ? FPMATH_SSE : FPMATH_387)
31 #define TARGET_OS_CPP_BUILTINS() \
34 builtin_define ("__i386__"); \
35 builtin_define ("__LITTLE_ENDIAN__"); \
36 darwin_cpp_builtins (pfile); \
40 #undef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
41 #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN (0)
43 /* We want -fPIC by default, unless we're using -static to compile for
44 the kernel or some such. */
47 #define CC1_SPEC "%{!static:-fPIC}\
48 %{g: %{!fno-eliminate-unused-debug-symbols: -feliminate-unused-debug-symbols }}"
51 #define ASM_SPEC "-arch i386 -force_cpusubtype_ALL"
53 #undef SUBTARGET_EXTRA_SPECS
54 #define SUBTARGET_EXTRA_SPECS \
55 { "darwin_arch", "i386" }, \
56 { "darwin_crt2", "" }, \
57 { "darwin_subarch", "i386" },
59 /* Use the following macro for any Darwin/x86-specific command-line option
61 #define SUBTARGET_OPTION_TRANSLATE_TABLE \
64 /* The Darwin assembler mostly follows AT&T syntax. */
65 #undef ASSEMBLER_DIALECT
66 #define ASSEMBLER_DIALECT ASM_ATT
68 /* Define macro used to output shift-double opcodes when the shift
69 count is in %cl. Some assemblers require %cl as an argument;
70 some don't. This macro controls what to do: by default, don't
73 #define SHIFT_DOUBLE_OMITS_COUNT 0
75 extern void darwin_x86_file_end (void);
76 #undef TARGET_ASM_FILE_END
77 #define TARGET_ASM_FILE_END darwin_x86_file_end
79 /* Define the syntax of pseudo-ops, labels and comments. */
81 /* String containing the assembler's comment-starter. */
83 #define ASM_COMMENT_START "#"
85 /* By default, target has a 80387, uses IEEE compatible arithmetic,
86 and returns float values in the 387. */
88 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_128BIT_LONG_DOUBLE | MASK_ALIGN_DOUBLE)
90 /* For now, disable dynamic-no-pic. We'll need to go through i386.c
91 with a fine-tooth comb looking for refs to flag_pic! */
92 #define MASK_MACHO_DYNAMIC_NO_PIC 0
93 #define TARGET_DYNAMIC_NO_PIC (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)
95 #undef GOT_SYMBOL_NAME
96 #define GOT_SYMBOL_NAME (machopic_function_base_name ())
98 /* Define the syntax of pseudo-ops, labels and comments. */
102 /* These are used by -fbranch-probabilities */
103 #define HOT_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
104 #define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
105 "__TEXT,__unlikely,regular,pure_instructions"
107 /* Assembler pseudos to introduce constants of various size. */
109 #define ASM_BYTE_OP "\t.byte\t"
110 #define ASM_SHORT "\t.word\t"
111 #define ASM_LONG "\t.long\t"
112 /* Darwin as doesn't do ".quad". */
114 #define SUBTARGET_ENCODE_SECTION_INFO darwin_encode_section_info
116 #undef ASM_OUTPUT_ALIGN
117 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
118 do { if ((LOG) != 0) \
120 if (in_section == text_section) \
121 fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
123 fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
127 /* This says how to output an assembler line
128 to define a global common symbol. */
130 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
131 ( fputs (".comm ", (FILE)), \
132 assemble_name ((FILE), (NAME)), \
133 fprintf ((FILE), ",%lu\n", (unsigned long)(ROUNDED)))
135 /* This says how to output an assembler line
136 to define a local common symbol. */
138 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
139 ( fputs (".lcomm ", (FILE)), \
140 assemble_name ((FILE), (NAME)), \
141 fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))
143 /* Darwin profiling -- call mcount. */
144 #undef FUNCTION_PROFILER
145 #define FUNCTION_PROFILER(FILE, LABELNO) \
147 if (MACHOPIC_INDIRECT) \
149 const char *name = machopic_mcount_stub_name (); \
150 fprintf (FILE, "\tcall %s\n", name+1); /* skip '&' */ \
151 machopic_validate_stub_or_non_lazy_ptr (name); \
153 else fprintf (FILE, "\tcall mcount\n"); \