aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/i386/darwin.h
blob: f20c9d896b5d8a399b187dfb29e254bb6578e0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/* Target definitions for x86 running Darwin.
   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
   Contributed by Apple Computer Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

/* Enable Mach-O bits in generic x86 code.  */
#undef TARGET_MACHO
#define TARGET_MACHO 1

/* APPLE LOCAL begin default to ppro */
/* Default to -mcpu=pentiumpro instead of i386 (radar 2730299)  ilr */
#undef TARGET_CPU_DEFAULT
#define TARGET_CPU_DEFAULT 4
/* APPLE LOCAL end default to ppro */

#define TARGET_VERSION fprintf (stderr, " (i386 Darwin)");

#define TARGET_OS_CPP_BUILTINS()                \
  do                                            \
    {                                           \
      builtin_define ("__i386__");              \
      builtin_define ("__LITTLE_ENDIAN__");     \
      /* APPLE LOCAL constant cfstrings */	\
      SUBTARGET_OS_CPP_BUILTINS ();		\
    }                                           \
  while (0)

/* We want -fPIC by default, unless we're using -static to compile for
   the kernel or some such.  */

#undef CC1_SPEC
/* APPLE LOCAL dynamic-no-pic */
/* APPLE LOCAL ignore -mcpu=G4 -mcpu=G5 */
/* When -mdynamic-no-pic finally works, remove the "xx" below.  FIXME!!  */
#define CC1_SPEC "%{!static:%{!mxxdynamic-no-pic:-fPIC}} %<faltivec %<mlong-branch %<mlongcall %<mcpu=G4 %<mcpu=G5"

/* APPLE LOCAL AltiVec */
#define CPP_ALTIVEC_SPEC "%<faltivec"

/* APPLE LOCAL begin 3492132 */

#define ASM_SPEC "%(darwin_arch_asm_spec)\
  -force_cpusubtype_ALL \
  %{Zforce_cpusubtype_ALL:-force_cpusubtype_ALL} \
  %{!Zforce_cpusubtype_ALL:%{mmmx:-force_cpusubtype_ALL}\
			   %{msse:-force_cpusubtype_ALL}\
			   %{msse2:-force_cpusubtype_ALL}}"

#define DARWIN_ARCH_LD_SPEC                                                    \
"%{march=i386: %{!Zdynamiclib:-arch i386} %{Zdynamiclib:-arch_only i386}}      \
 %{march=i486: %{!Zdynamiclib:-arch i486} %{Zdynamiclib:-arch_only i486}}      \
 %{march=i586: %{!Zdynamiclib:-arch i586} %{Zdynamiclib:-arch_only i586}}      \
 %{march=pentium: %{!Zdynamiclib:-arch pentium} %{Zdynamiclib:-arch_only pentium}}    \
 %{march=pentiumpro: %{!Zdynamiclib:-arch pentpro} %{Zdynamiclib:-arch_only pentpro}} \
 %{march=i686: %{!Zdynamiclib:-arch i686} %{Zdynamiclib:-arch_only i686}}             \
 %{march=pentium3: %{!Zdynamiclib:-arch pentIIm3} %{Zdynamiclib:-arch_only pentIIm3}} \
 %{!mcpu*:%{!march*:%{!Zdynamiclib:-arch i686} %{Zdynamiclib:-arch_only i686}}} "

#define DARWIN_ARCH_ASM_SPEC        \
"%{march=i386: -arch i386}          \
 %{march=i486: -arch i486}          \
 %{march=i586: -arch i586}          \
 %{march=pentium: -arch pentium}    \
 %{march=pentiumpro: -arch pentpro} \
 %{march=i686: -arch i686}          \
 %{march=pentium3: -arch pentIIm3}  \
 %{!mcpu*:%{!march*: -arch i686}} "

#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS			      \
  { "darwin_arch_asm_spec", DARWIN_ARCH_ASM_SPEC },   \
  { "darwin_arch_ld_spec", DARWIN_ARCH_LD_SPEC },     \
  { "darwin_arch", "i686" },

/* APPLE LOCAL end 3492132 */

/* Use the following macro for any Darwin/x86-specific command-line option
   translation.  */
#define SUBTARGET_OPTION_TRANSLATE_TABLE \
  { "", "" }

/* The Darwin assembler mostly follows AT&T syntax.  */
#undef ASSEMBLER_DIALECT
#define ASSEMBLER_DIALECT ASM_ATT

/* Define macro used to output shift-double opcodes when the shift
   count is in %cl.  Some assemblers require %cl as an argument;
   some don't.  This macro controls what to do: by default, don't
   print %cl.  */

#define SHIFT_DOUBLE_OMITS_COUNT 0

/* Define the syntax of pseudo-ops, labels and comments.  */

/* String containing the assembler's comment-starter.  */

#define ASM_COMMENT_START "#"

/* By default, target has a 80387, uses IEEE compatible arithmetic,
   and returns float values in the 387.  */

#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS)

/* TARGET_DEEP_BRANCH_PREDICTION is incompatible with Mach-O PIC.  */

#undef TARGET_DEEP_BRANCH_PREDICTION
#define TARGET_DEEP_BRANCH_PREDICTION   0

/* For now, disable dynamic-no-pic.  We'll need to go through i386.c
   with a fine-tooth comb looking for refs to flag_pic!  */
#define MASK_MACHO_DYNAMIC_NO_PIC 0
#define TARGET_DYNAMIC_NO_PIC	  (target_flags & MASK_MACHO_DYNAMIC_NO_PIC)

/* Define the syntax of pseudo-ops, labels and comments.  */

#define LPREFIX "L"

/* Assembler pseudos to introduce constants of various size.  */

#define ASM_BYTE_OP "\t.byte\t"
#define ASM_SHORT "\t.word\t"
#define ASM_LONG "\t.long\t"
/* Darwin as doesn't do ".quad".  */

#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG)	\
 do { if ((LOG) != 0)			\
        {				\
          /* APPLE LOCAL coalescing */  \
          if (in_text_section ()	\
              || in_unlikely_text_section () \
              || darwin_named_section_is ("__TEXT,__textcoal,coalesced") \
              || darwin_named_section_is ("__TEXT,__textcoal_nt,coalesced,no_toc") \
              || darwin_named_section_is (STATIC_INIT_SECTION)) \
            fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \
          else				\
            fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \
        }				\
    } while (0)

/* This says how to output an assembler line
   to define a global common symbol.  */

#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
( fputs (".comm ", (FILE)),			\
  assemble_name ((FILE), (NAME)),		\
  fprintf ((FILE), ",%lu\n", (unsigned long)(ROUNDED)))

/* This says how to output an assembler line
   to define a local common symbol.  */

#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
( fputs (".lcomm ", (FILE)),			\
  assemble_name ((FILE), (NAME)),		\
  fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n", (ROUNDED)))


/* APPLE LOCAL begin Macintosh alignment 2002-2-19 ff */
#define MASK_ALIGN_NATURAL	0x40000000
#define TARGET_ALIGN_NATURAL	(target_flags & MASK_ALIGN_NATURAL)
#define rs6000_alignment_flags target_flags
#define MASK_ALIGN_MAC68K	0x20000000
#define TARGET_ALIGN_MAC68K	(target_flags & MASK_ALIGN_MAC68K)

#undef SUBTARGET_SWITCHES
#define SUBTARGET_SWITCHES						\
  {"align-mac68k",      MASK_ALIGN_MAC68K,				\
	N_("Align structs and unions according to mac68k rules")},	\
  {"align-power",       - (MASK_ALIGN_MAC68K | MASK_ALIGN_NATURAL),	\
	N_("Align structs and unions according to PowerPC rules")},	\
  {"align-natural",     MASK_ALIGN_NATURAL,				\
	N_("Align structs and unions according to natural rules")},	\
  {"dynamic-no-pic",    MASK_MACHO_DYNAMIC_NO_PIC,			\
	N_("Generate code suitable for executables (NOT shared libs)")},\
  {"no-dynamic-no-pic", -MASK_MACHO_DYNAMIC_NO_PIC,  ""},
/* APPLE LOCAL end Macintosh alignment 2002-2-19 ff */

/* Darwin profiling -- call mcount.  */
#undef FUNCTION_PROFILER
#define FUNCTION_PROFILER(FILE, LABELNO)				\
    do {								\
      if (MACHOPIC_INDIRECT)						\
	{								\
	  const char *name = machopic_stub_name ("*mcount");		\
	  fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */	\
	  machopic_validate_stub_or_non_lazy_ptr (name, /*stub:*/1);	\
	}								\
      else fprintf (FILE, "\tcall mcount\n");				\
    } while (0)

/* APPLE LOCAL SSE stack alignment */
#define BASIC_STACK_BOUNDARY (128)

#undef SUBTARGET_OVERRIDE_OPTIONS
/* Force Darwin/x86 to default as "-march=i686 -mcpu=pentium4".  */
#define SUBTARGET_OVERRIDE_OPTIONS \
  do { \
    if (!ix86_arch_string) ix86_arch_string = "pentiumpro"; \
    if (!ix86_tune_string) ix86_tune_string = "pentium4"; \
  } while (0)