blob: c68b29b00bb906a37474a0ca7142d8cc9429bed7 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the X86 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
Evan Cheng5211b422009-01-03 04:04:46 +000014#define DEBUG_TYPE "subtarget"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015#include "X86Subtarget.h"
Chris Lattner505aa6c2009-07-10 07:20:05 +000016#include "X86InstrInfo.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017#include "X86GenSubtarget.inc"
18#include "llvm/Module.h"
19#include "llvm/Support/CommandLine.h"
Evan Cheng5211b422009-01-03 04:04:46 +000020#include "llvm/Support/Debug.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021#include "llvm/Target/TargetMachine.h"
Anton Korobeynikovb214a522008-04-23 18:18:10 +000022#include "llvm/Target/TargetOptions.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023using namespace llvm;
24
Chris Lattner1d8091f2009-04-25 18:27:23 +000025#if defined(_MSC_VER)
26 #include <intrin.h>
27#endif
28
Dan Gohman089efff2008-05-13 00:00:25 +000029static cl::opt<X86Subtarget::AsmWriterFlavorTy>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset),
31 cl::desc("Choose style of code to emit from X86 backend:"),
32 cl::values(
Dan Gohman669b9bf2008-10-14 20:25:08 +000033 clEnumValN(X86Subtarget::ATT, "att", "Emit AT&T-style assembly"),
34 clEnumValN(X86Subtarget::Intel, "intel", "Emit Intel-style assembly"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035 clEnumValEnd));
36
Chris Lattner4a948932009-07-10 20:47:30 +000037bool X86Subtarget::isPICStyleStubPIC(const TargetMachine &TM) const {
38 return PICStyle == PICStyles::Stub &&
39 TM.getRelocationModel() == Reloc::PIC_;
40}
41
42bool X86Subtarget::isPICStyleStubNoDynamic(const TargetMachine &TM) const {
43 return PICStyle == PICStyles::Stub &&
44 TM.getRelocationModel() == Reloc::DynamicNoPIC;
45}
46
47
Dan Gohmanf17a25c2007-07-18 16:29:46 +000048
Chris Lattner505aa6c2009-07-10 07:20:05 +000049/// ClassifyGlobalReference - Classify a global variable reference for the
50/// current subtarget according to how we should reference it in a non-pcrel
51/// context.
52unsigned char X86Subtarget::
53ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
54 // DLLImport only exists on windows, it is implemented as a load from a
55 // DLLIMPORT stub.
56 if (GV->hasDLLImportLinkage())
57 return X86II::MO_DLLIMPORT;
58
59 // X86-64 in PIC mode.
60 if (isPICStyleRIPRel()) {
61 // Large model never uses stubs.
62 if (TM.getCodeModel() == CodeModel::Large)
63 return X86II::MO_NO_FLAG;
64
65 if (isTargetDarwin()) {
66 // If symbol visibility is hidden, the extra load is not needed if
67 // target is x86-64 or the symbol is definitely defined in the current
68 // translation unit.
69 if (GV->hasDefaultVisibility() &&
70 (GV->isDeclaration() || GV->isWeakForLinker()))
71 return X86II::MO_GOTPCREL;
72 } else {
73 assert(isTargetELF() && "Unknown rip-relative target");
74
75 // Extra load is needed for all externally visible.
76 if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility())
77 return X86II::MO_GOTPCREL;
78 }
79
80 return X86II::MO_NO_FLAG;
81 }
82
83 if (isPICStyleGOT()) { // 32-bit ELF targets.
84 // Extra load is needed for all externally visible.
85 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
86 return X86II::MO_GOTOFF;
87 return X86II::MO_GOT;
88 }
89
Chris Lattner4a948932009-07-10 20:47:30 +000090 if (isPICStyleStubAny()) {
Chris Lattner505aa6c2009-07-10 07:20:05 +000091 // In Darwin/32, we have multiple different stub types, and we have both PIC
92 // and -mdynamic-no-pic. Determine whether we have a stub reference
93 // and/or whether the reference is relative to the PIC base or not.
94 bool IsPIC = TM.getRelocationModel() == Reloc::PIC_;
95
96 // If this is a strong reference to a definition, it is definitely not
97 // through a stub.
98 if (!GV->isDeclaration() && !GV->isWeakForLinker())
99 return IsPIC ? X86II::MO_PIC_BASE_OFFSET : 0;
100
101 // Unless we have a symbol with hidden visibility, we have to go through a
102 // normal $non_lazy_ptr stub because this symbol might be resolved late.
103 if (!GV->hasHiddenVisibility()) {
104 // Non-hidden $non_lazy_ptr reference.
105 return IsPIC ? X86II::MO_DARWIN_NONLAZY_PIC_BASE :
106 X86II::MO_DARWIN_NONLAZY;
107 }
108
109 // If symbol visibility is hidden, we have a stub for common symbol
110 // references and external declarations.
111 if (GV->isDeclaration() || GV->hasCommonLinkage()) {
112 // Hidden $non_lazy_ptr reference.
113 return IsPIC ? X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE :
114 X86II::MO_DARWIN_HIDDEN_NONLAZY;
115 }
116
117 // Otherwise, no stub.
118 return IsPIC ? X86II::MO_PIC_BASE_OFFSET : 0;
119 }
120
121 // Direct static reference to global.
122 return X86II::MO_NO_FLAG;
123}
124
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125
Bill Wendling5db7ffb2008-09-30 21:22:07 +0000126/// getBZeroEntry - This function returns the name of a function which has an
127/// interface like the non-standard bzero function, if such a function exists on
128/// the current subtarget and it is considered prefereable over memset with zero
129/// passed as the second argument. Otherwise it returns null.
Bill Wendlingd3752032008-09-30 22:05:33 +0000130const char *X86Subtarget::getBZeroEntry() const {
Dan Gohmanf95c2bf2008-04-01 20:38:36 +0000131 // Darwin 10 has a __bzero entry point for this purpose.
132 if (getDarwinVers() >= 10)
Bill Wendlingd3752032008-09-30 22:05:33 +0000133 return "__bzero";
Dan Gohmanf95c2bf2008-04-01 20:38:36 +0000134
135 return 0;
136}
137
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000138/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
139/// to immediate address.
140bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
141 if (Is64Bit)
142 return false;
143 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
144}
145
Dan Gohman47170992008-12-16 03:35:01 +0000146/// getSpecialAddressLatency - For targets where it is beneficial to
147/// backschedule instructions that compute addresses, return a value
148/// indicating the number of scheduling cycles of backscheduling that
149/// should be attempted.
150unsigned X86Subtarget::getSpecialAddressLatency() const {
151 // For x86 out-of-order targets, back-schedule address computations so
152 // that loads and stores aren't blocked.
153 // This value was chosen arbitrarily.
154 return 200;
155}
156
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
158/// specified arguments. If we can't run cpuid on the host, return true.
159bool X86::GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
160 unsigned *rECX, unsigned *rEDX) {
Chris Lattner1d8091f2009-04-25 18:27:23 +0000161#if defined(__x86_64__) || defined(_M_AMD64)
162 #if defined(__GNUC__)
163 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
164 asm ("movq\t%%rbx, %%rsi\n\t"
165 "cpuid\n\t"
166 "xchgq\t%%rbx, %%rsi\n\t"
167 : "=a" (*rEAX),
168 "=S" (*rEBX),
169 "=c" (*rECX),
170 "=d" (*rEDX)
171 : "a" (value));
172 return false;
173 #elif defined(_MSC_VER)
174 int registers[4];
175 __cpuid(registers, value);
176 *rEAX = registers[0];
177 *rEBX = registers[1];
178 *rECX = registers[2];
179 *rEDX = registers[3];
180 return false;
181 #endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Chris Lattner1d8091f2009-04-25 18:27:23 +0000183 #if defined(__GNUC__)
184 asm ("movl\t%%ebx, %%esi\n\t"
185 "cpuid\n\t"
186 "xchgl\t%%ebx, %%esi\n\t"
187 : "=a" (*rEAX),
188 "=S" (*rEBX),
189 "=c" (*rECX),
190 "=d" (*rEDX)
191 : "a" (value));
192 return false;
193 #elif defined(_MSC_VER)
194 __asm {
195 mov eax,value
196 cpuid
197 mov esi,rEAX
198 mov dword ptr [esi],eax
199 mov esi,rEBX
200 mov dword ptr [esi],ebx
201 mov esi,rECX
202 mov dword ptr [esi],ecx
203 mov esi,rEDX
204 mov dword ptr [esi],edx
205 }
206 return false;
207 #endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208#endif
209 return true;
210}
211
Evan Cheng95a77fd2009-01-02 05:35:45 +0000212static void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
213 Family = (EAX >> 8) & 0xf; // Bits 8 - 11
214 Model = (EAX >> 4) & 0xf; // Bits 4 - 7
215 if (Family == 6 || Family == 0xf) {
216 if (Family == 0xf)
217 // Examine extended family ID if family ID is F.
218 Family += (EAX >> 20) & 0xff; // Bits 20 - 27
219 // Examine extended model ID if family ID is 6 or F.
220 Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
221 }
222}
223
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224void X86Subtarget::AutoDetectSubtargetFeatures() {
225 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
226 union {
227 unsigned u[3];
228 char c[12];
229 } text;
230
231 if (X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1))
232 return;
233
234 X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
235
236 if ((EDX >> 23) & 0x1) X86SSELevel = MMX;
237 if ((EDX >> 25) & 0x1) X86SSELevel = SSE1;
238 if ((EDX >> 26) & 0x1) X86SSELevel = SSE2;
239 if (ECX & 0x1) X86SSELevel = SSE3;
240 if ((ECX >> 9) & 0x1) X86SSELevel = SSSE3;
Nate Begemanb2975562008-02-03 07:18:54 +0000241 if ((ECX >> 19) & 0x1) X86SSELevel = SSE41;
242 if ((ECX >> 20) & 0x1) X86SSELevel = SSE42;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243
Evan Cheng95a77fd2009-01-02 05:35:45 +0000244 bool IsIntel = memcmp(text.c, "GenuineIntel", 12) == 0;
245 bool IsAMD = !IsIntel && memcmp(text.c, "AuthenticAMD", 12) == 0;
David Greene8bf22bc2009-06-26 22:46:54 +0000246
247 HasFMA3 = IsIntel && ((ECX >> 12) & 0x1);
248 HasAVX = ((ECX >> 28) & 0x1);
249
Evan Cheng95a77fd2009-01-02 05:35:45 +0000250 if (IsIntel || IsAMD) {
251 // Determine if bit test memory instructions are slow.
252 unsigned Family = 0;
253 unsigned Model = 0;
254 DetectFamilyModel(EAX, Family, Model);
255 IsBTMemSlow = IsAMD || (Family == 6 && Model >= 13);
256
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
258 HasX86_64 = (EDX >> 29) & 0x1;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000259 HasSSE4A = IsAMD && ((ECX >> 6) & 0x1);
David Greene8bf22bc2009-06-26 22:46:54 +0000260 HasFMA4 = IsAMD && ((ECX >> 16) & 0x1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 }
262}
263
264static const char *GetCurrentX86CPU() {
265 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
266 if (X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
267 return "generic";
Evan Cheng95a77fd2009-01-02 05:35:45 +0000268 unsigned Family = 0;
269 unsigned Model = 0;
270 DetectFamilyModel(EAX, Family, Model);
Evan Chengedde6842009-01-02 05:29:20 +0000271
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
273 bool Em64T = (EDX >> 29) & 0x1;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000274 bool HasSSE3 = (ECX & 0x1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275
276 union {
277 unsigned u[3];
278 char c[12];
279 } text;
280
281 X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1);
282 if (memcmp(text.c, "GenuineIntel", 12) == 0) {
283 switch (Family) {
284 case 3:
285 return "i386";
286 case 4:
287 return "i486";
288 case 5:
289 switch (Model) {
290 case 4: return "pentium-mmx";
291 default: return "pentium";
292 }
293 case 6:
294 switch (Model) {
295 case 1: return "pentiumpro";
296 case 3:
297 case 5:
298 case 6: return "pentium2";
299 case 7:
300 case 8:
301 case 10:
302 case 11: return "pentium3";
303 case 9:
304 case 13: return "pentium-m";
305 case 14: return "yonah";
Evan Cheng5211b422009-01-03 04:04:46 +0000306 case 15:
307 case 22: // Celeron M 540
308 return "core2";
309 case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE)
310 return "penryn";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 default: return "i686";
312 }
313 case 15: {
314 switch (Model) {
315 case 3:
316 case 4:
Evan Cheng5211b422009-01-03 04:04:46 +0000317 case 6: // same as 4, but 65nm
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 return (Em64T) ? "nocona" : "prescott";
Evan Chengcfadd3b2009-01-05 08:45:01 +0000319 case 26:
320 return "corei7";
Evan Cheng5211b422009-01-03 04:04:46 +0000321 case 28:
Evan Chengcfadd3b2009-01-05 08:45:01 +0000322 return "atom";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 default:
324 return (Em64T) ? "x86-64" : "pentium4";
325 }
326 }
327
328 default:
329 return "generic";
330 }
331 } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) {
332 // FIXME: this poorly matches the generated SubtargetFeatureKV table. There
333 // appears to be no way to generate the wide variety of AMD-specific targets
334 // from the information returned from CPUID.
335 switch (Family) {
336 case 4:
337 return "i486";
338 case 5:
339 switch (Model) {
340 case 6:
341 case 7: return "k6";
342 case 8: return "k6-2";
343 case 9:
344 case 13: return "k6-3";
345 default: return "pentium";
346 }
347 case 6:
348 switch (Model) {
349 case 4: return "athlon-tbird";
350 case 6:
351 case 7:
352 case 8: return "athlon-mp";
353 case 10: return "athlon-xp";
354 default: return "athlon";
355 }
356 case 15:
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000357 if (HasSSE3) {
358 switch (Model) {
359 default: return "k8-sse3";
360 }
361 } else {
362 switch (Model) {
363 case 1: return "opteron";
364 case 5: return "athlon-fx"; // also opteron
365 default: return "athlon64";
366 }
367 }
368 case 16:
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 switch (Model) {
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000370 default: return "amdfam10";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371 }
372 default:
373 return "generic";
374 }
375 } else {
376 return "generic";
377 }
378}
379
380X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
381 : AsmFlavor(AsmWriterFlavor)
Duncan Sandsde5f95f2008-11-28 09:29:37 +0000382 , PICStyle(PICStyles::None)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383 , X86SSELevel(NoMMXSSE)
Evan Chengb6992de2008-04-16 19:03:02 +0000384 , X863DNowLevel(NoThreeDNow)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 , HasX86_64(false)
David Greene8bf22bc2009-06-26 22:46:54 +0000386 , HasSSE4A(false)
387 , HasAVX(false)
388 , HasFMA3(false)
389 , HasFMA4(false)
Evan Cheng95a77fd2009-01-02 05:35:45 +0000390 , IsBTMemSlow(false)
Chris Lattner93a2d432008-01-02 19:44:55 +0000391 , DarwinVers(0)
Dan Gohmande22f242008-05-05 18:43:07 +0000392 , IsLinux(false)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393 , stackAlignment(8)
394 // FIXME: this is a known good value for Yonah. How about others?
Rafael Espindola7afa9b12007-10-31 11:52:06 +0000395 , MaxInlineSizeThreshold(128)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396 , Is64Bit(is64Bit)
397 , TargetType(isELF) { // Default to ELF unless otherwise specified.
Anton Korobeynikov11713322009-06-08 22:53:56 +0000398
399 // default to hard float ABI
400 if (FloatABIType == FloatABI::Default)
401 FloatABIType = FloatABI::Hard;
Mon P Wang078a62d2008-05-05 19:05:59 +0000402
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403 // Determine default and user specified characteristics
404 if (!FS.empty()) {
405 // If feature string is not empty, parse features string.
406 std::string CPU = GetCurrentX86CPU();
407 ParseSubtargetFeatures(FS, CPU);
Edwin Török4031b792009-02-02 21:57:34 +0000408 // All X86-64 CPUs also have SSE2, however user might request no SSE via
409 // -mattr, so don't force SSELevel here.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 } else {
411 // Otherwise, use CPUID to auto-detect feature set.
412 AutoDetectSubtargetFeatures();
Dan Gohman4092bbc2009-02-03 00:04:43 +0000413 // Make sure SSE2 is enabled; it is available on all X86-64 CPUs.
414 if (Is64Bit && X86SSELevel < SSE2)
415 X86SSELevel = SSE2;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 }
Dan Gohman4092bbc2009-02-03 00:04:43 +0000417
Dan Gohmand3ef6c92009-02-03 18:53:21 +0000418 // If requesting codegen for X86-64, make sure that 64-bit features
419 // are enabled.
420 if (Is64Bit)
421 HasX86_64 = true;
422
Evan Cheng5211b422009-01-03 04:04:46 +0000423 DOUT << "Subtarget features: SSELevel " << X86SSELevel
424 << ", 3DNowLevel " << X863DNowLevel
425 << ", 64bit " << HasX86_64 << "\n";
Dan Gohman4092bbc2009-02-03 00:04:43 +0000426 assert((!Is64Bit || HasX86_64) &&
427 "64-bit code requested on a subtarget that doesn't support it!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428
429 // Set the boolean corresponding to the current target triple, or the default
430 // if one cannot be determined, to true.
431 const std::string& TT = M.getTargetTriple();
432 if (TT.length() > 5) {
Duncan Sandsdfd94582008-01-08 10:06:15 +0000433 size_t Pos;
Chris Lattner93a2d432008-01-02 19:44:55 +0000434 if ((Pos = TT.find("-darwin")) != std::string::npos) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435 TargetType = isDarwin;
Chris Lattner93a2d432008-01-02 19:44:55 +0000436
437 // Compute the darwin version number.
438 if (isdigit(TT[Pos+7]))
439 DarwinVers = atoi(&TT[Pos+7]);
440 else
441 DarwinVers = 8; // Minimum supported darwin is Tiger.
Dan Gohmana65530a2008-05-05 00:28:39 +0000442 } else if (TT.find("linux") != std::string::npos) {
Dan Gohman2593e2b2008-05-05 16:11:31 +0000443 // Linux doesn't imply ELF, but we don't currently support anything else.
444 TargetType = isELF;
445 IsLinux = true;
Chris Lattner93a2d432008-01-02 19:44:55 +0000446 } else if (TT.find("cygwin") != std::string::npos) {
447 TargetType = isCygwin;
448 } else if (TT.find("mingw") != std::string::npos) {
449 TargetType = isMingw;
450 } else if (TT.find("win32") != std::string::npos) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451 TargetType = isWindows;
Anton Korobeynikovf0ce64b2008-03-22 21:12:53 +0000452 } else if (TT.find("windows") != std::string::npos) {
453 TargetType = isWindows;
Chris Lattner93a2d432008-01-02 19:44:55 +0000454 }
Mon P Wang23bbfc32009-02-28 00:25:30 +0000455 else if (TT.find("-cl") != std::string::npos) {
456 TargetType = isDarwin;
457 DarwinVers = 9;
458 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459 } else if (TT.empty()) {
460#if defined(__CYGWIN__)
461 TargetType = isCygwin;
Anton Korobeynikov62a51e42008-03-22 21:18:22 +0000462#elif defined(__MINGW32__) || defined(__MINGW64__)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 TargetType = isMingw;
464#elif defined(__APPLE__)
465 TargetType = isDarwin;
Chris Lattner93a2d432008-01-02 19:44:55 +0000466#if __APPLE_CC__ > 5400
467 DarwinVers = 9; // GCC 5400+ is Leopard.
468#else
469 DarwinVers = 8; // Minimum supported darwin is Tiger.
470#endif
471
Anton Korobeynikov62a51e42008-03-22 21:18:22 +0000472#elif defined(_WIN32) || defined(_WIN64)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 TargetType = isWindows;
Dan Gohmana65530a2008-05-05 00:28:39 +0000474#elif defined(__linux__)
475 // Linux doesn't imply ELF, but we don't currently support anything else.
Dan Gohman2593e2b2008-05-05 16:11:31 +0000476 TargetType = isELF;
477 IsLinux = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478#endif
479 }
480
481 // If the asm syntax hasn't been overridden on the command line, use whatever
482 // the target wants.
483 if (AsmFlavor == X86Subtarget::Unset) {
Chris Lattner93a2d432008-01-02 19:44:55 +0000484 AsmFlavor = (TargetType == isWindows)
485 ? X86Subtarget::Intel : X86Subtarget::ATT;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 }
487
Anton Korobeynikovcdd93812008-04-23 18:16:16 +0000488 // Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
489 // bit targets.
490 if (TargetType == isDarwin || Is64Bit)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 stackAlignment = 16;
Anton Korobeynikov06c42402008-04-12 22:12:22 +0000492
493 if (StackAlignment)
494 stackAlignment = StackAlignment;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495}