blob: 6eb0235e15dadc304ee06b32aea02053e7412903 [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"
16#include "X86GenSubtarget.inc"
17#include "llvm/Module.h"
18#include "llvm/Support/CommandLine.h"
Evan Cheng5211b422009-01-03 04:04:46 +000019#include "llvm/Support/Debug.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020#include "llvm/Target/TargetMachine.h"
Anton Korobeynikovb214a522008-04-23 18:18:10 +000021#include "llvm/Target/TargetOptions.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000022using namespace llvm;
23
Chris Lattner1d8091f2009-04-25 18:27:23 +000024#if defined(_MSC_VER)
25 #include <intrin.h>
26#endif
27
Dan Gohman089efff2008-05-13 00:00:25 +000028static cl::opt<X86Subtarget::AsmWriterFlavorTy>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset),
30 cl::desc("Choose style of code to emit from X86 backend:"),
31 cl::values(
Dan Gohman669b9bf2008-10-14 20:25:08 +000032 clEnumValN(X86Subtarget::ATT, "att", "Emit AT&T-style assembly"),
33 clEnumValN(X86Subtarget::Intel, "intel", "Emit Intel-style assembly"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034 clEnumValEnd));
35
36
37/// True if accessing the GV requires an extra load. For Windows, dllimported
38/// symbols are indirect, loading the value at address GV rather then the
39/// value of GV itself. This means that the GlobalAddress must be in the base
40/// or index register of the address, not the GV offset field.
Chris Lattner08323962009-07-10 05:45:15 +000041bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue *GV,
42 const TargetMachine &TM,
Chris Lattner6d45da02009-07-09 03:27:27 +000043 bool isDirectCall) const {
44 // Windows targets only require an extra load for DLLImport linkage values,
45 // and they need these regardless of whether we're in PIC mode or not.
46 if (isTargetCygMing() || isTargetWindows())
47 return GV->hasDLLImportLinkage();
48
49 if (TM.getRelocationModel() == Reloc::Static ||
50 TM.getCodeModel() == CodeModel::Large)
51 return false;
52
53 if (isTargetDarwin()) {
54 if (isDirectCall)
55 return false;
56 bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode();
57 if (GV->hasHiddenVisibility() &&
58 (Is64Bit || (!isDecl && !GV->hasCommonLinkage())))
59 // If symbol visibility is hidden, the extra load is not needed if
60 // target is x86-64 or the symbol is definitely defined in the current
61 // translation unit.
62 return false;
63 return !isDirectCall && (isDecl || GV->isWeakForLinker());
64 } else if (isTargetELF()) {
65 // Extra load is needed for all externally visible.
66 if (isDirectCall)
67 return false;
68 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
69 return false;
70 return true;
Anton Korobeynikov8c90d2a2008-02-20 11:22:39 +000071 }
Dale Johannesen64660e92008-12-05 21:47:27 +000072 return false;
73}
74
Chris Lattner08323962009-07-10 05:45:15 +000075/// PCRelGVRequiresExtraLoad - True if accessing the GV from a PC-relative
76/// operand like a call target requires an extra load.
77bool X86Subtarget::PCRelGVRequiresExtraLoad(const GlobalValue *GV,
78 const TargetMachine &TM) const {
79 // Windows targets only require an extra load for DLLImport linkage values,
80 // and they need these regardless of whether we're in PIC mode or not.
81 if (isTargetCygMing() || isTargetWindows())
82 return GV->hasDLLImportLinkage();
83
84 return false;
85}
86
87
Dale Johannesen64660e92008-12-05 21:47:27 +000088/// True if accessing the GV requires a register. This is a superset of the
89/// cases where GVRequiresExtraLoad is true. Some variations of PIC require
90/// a register, but not an extra load.
91bool X86Subtarget::GVRequiresRegister(const GlobalValue *GV,
Chris Lattnera35337f2009-07-10 05:37:11 +000092 const TargetMachine &TM) const {
93 if (GVRequiresExtraLoad(GV, TM, false))
Dale Johannesen64660e92008-12-05 21:47:27 +000094 return true;
Chris Lattnera35337f2009-07-10 05:37:11 +000095
Dale Johannesen64660e92008-12-05 21:47:27 +000096 // Code below here need only consider cases where GVRequiresExtraLoad
97 // returns false.
98 if (TM.getRelocationModel() == Reloc::PIC_)
Chris Lattnera35337f2009-07-10 05:37:11 +000099 return GV->hasLocalLinkage() || GV->hasExternalLinkage();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100 return false;
101}
102
Bill Wendling5db7ffb2008-09-30 21:22:07 +0000103/// getBZeroEntry - This function returns the name of a function which has an
104/// interface like the non-standard bzero function, if such a function exists on
105/// the current subtarget and it is considered prefereable over memset with zero
106/// passed as the second argument. Otherwise it returns null.
Bill Wendlingd3752032008-09-30 22:05:33 +0000107const char *X86Subtarget::getBZeroEntry() const {
Dan Gohmanf95c2bf2008-04-01 20:38:36 +0000108 // Darwin 10 has a __bzero entry point for this purpose.
109 if (getDarwinVers() >= 10)
Bill Wendlingd3752032008-09-30 22:05:33 +0000110 return "__bzero";
Dan Gohmanf95c2bf2008-04-01 20:38:36 +0000111
112 return 0;
113}
114
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000115/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
116/// to immediate address.
117bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
118 if (Is64Bit)
119 return false;
120 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
121}
122
Dan Gohman47170992008-12-16 03:35:01 +0000123/// getSpecialAddressLatency - For targets where it is beneficial to
124/// backschedule instructions that compute addresses, return a value
125/// indicating the number of scheduling cycles of backscheduling that
126/// should be attempted.
127unsigned X86Subtarget::getSpecialAddressLatency() const {
128 // For x86 out-of-order targets, back-schedule address computations so
129 // that loads and stores aren't blocked.
130 // This value was chosen arbitrarily.
131 return 200;
132}
133
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
135/// specified arguments. If we can't run cpuid on the host, return true.
136bool X86::GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
137 unsigned *rECX, unsigned *rEDX) {
Chris Lattner1d8091f2009-04-25 18:27:23 +0000138#if defined(__x86_64__) || defined(_M_AMD64)
139 #if defined(__GNUC__)
140 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
141 asm ("movq\t%%rbx, %%rsi\n\t"
142 "cpuid\n\t"
143 "xchgq\t%%rbx, %%rsi\n\t"
144 : "=a" (*rEAX),
145 "=S" (*rEBX),
146 "=c" (*rECX),
147 "=d" (*rEDX)
148 : "a" (value));
149 return false;
150 #elif defined(_MSC_VER)
151 int registers[4];
152 __cpuid(registers, value);
153 *rEAX = registers[0];
154 *rEBX = registers[1];
155 *rECX = registers[2];
156 *rEDX = registers[3];
157 return false;
158 #endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Chris Lattner1d8091f2009-04-25 18:27:23 +0000160 #if defined(__GNUC__)
161 asm ("movl\t%%ebx, %%esi\n\t"
162 "cpuid\n\t"
163 "xchgl\t%%ebx, %%esi\n\t"
164 : "=a" (*rEAX),
165 "=S" (*rEBX),
166 "=c" (*rECX),
167 "=d" (*rEDX)
168 : "a" (value));
169 return false;
170 #elif defined(_MSC_VER)
171 __asm {
172 mov eax,value
173 cpuid
174 mov esi,rEAX
175 mov dword ptr [esi],eax
176 mov esi,rEBX
177 mov dword ptr [esi],ebx
178 mov esi,rECX
179 mov dword ptr [esi],ecx
180 mov esi,rEDX
181 mov dword ptr [esi],edx
182 }
183 return false;
184 #endif
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185#endif
186 return true;
187}
188
Evan Cheng95a77fd2009-01-02 05:35:45 +0000189static void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
190 Family = (EAX >> 8) & 0xf; // Bits 8 - 11
191 Model = (EAX >> 4) & 0xf; // Bits 4 - 7
192 if (Family == 6 || Family == 0xf) {
193 if (Family == 0xf)
194 // Examine extended family ID if family ID is F.
195 Family += (EAX >> 20) & 0xff; // Bits 20 - 27
196 // Examine extended model ID if family ID is 6 or F.
197 Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
198 }
199}
200
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201void X86Subtarget::AutoDetectSubtargetFeatures() {
202 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
203 union {
204 unsigned u[3];
205 char c[12];
206 } text;
207
208 if (X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1))
209 return;
210
211 X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
212
213 if ((EDX >> 23) & 0x1) X86SSELevel = MMX;
214 if ((EDX >> 25) & 0x1) X86SSELevel = SSE1;
215 if ((EDX >> 26) & 0x1) X86SSELevel = SSE2;
216 if (ECX & 0x1) X86SSELevel = SSE3;
217 if ((ECX >> 9) & 0x1) X86SSELevel = SSSE3;
Nate Begemanb2975562008-02-03 07:18:54 +0000218 if ((ECX >> 19) & 0x1) X86SSELevel = SSE41;
219 if ((ECX >> 20) & 0x1) X86SSELevel = SSE42;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
Evan Cheng95a77fd2009-01-02 05:35:45 +0000221 bool IsIntel = memcmp(text.c, "GenuineIntel", 12) == 0;
222 bool IsAMD = !IsIntel && memcmp(text.c, "AuthenticAMD", 12) == 0;
David Greene8bf22bc2009-06-26 22:46:54 +0000223
224 HasFMA3 = IsIntel && ((ECX >> 12) & 0x1);
225 HasAVX = ((ECX >> 28) & 0x1);
226
Evan Cheng95a77fd2009-01-02 05:35:45 +0000227 if (IsIntel || IsAMD) {
228 // Determine if bit test memory instructions are slow.
229 unsigned Family = 0;
230 unsigned Model = 0;
231 DetectFamilyModel(EAX, Family, Model);
232 IsBTMemSlow = IsAMD || (Family == 6 && Model >= 13);
233
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000234 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
235 HasX86_64 = (EDX >> 29) & 0x1;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000236 HasSSE4A = IsAMD && ((ECX >> 6) & 0x1);
David Greene8bf22bc2009-06-26 22:46:54 +0000237 HasFMA4 = IsAMD && ((ECX >> 16) & 0x1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238 }
239}
240
241static const char *GetCurrentX86CPU() {
242 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
243 if (X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
244 return "generic";
Evan Cheng95a77fd2009-01-02 05:35:45 +0000245 unsigned Family = 0;
246 unsigned Model = 0;
247 DetectFamilyModel(EAX, Family, Model);
Evan Chengedde6842009-01-02 05:29:20 +0000248
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
250 bool Em64T = (EDX >> 29) & 0x1;
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000251 bool HasSSE3 = (ECX & 0x1);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252
253 union {
254 unsigned u[3];
255 char c[12];
256 } text;
257
258 X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1);
259 if (memcmp(text.c, "GenuineIntel", 12) == 0) {
260 switch (Family) {
261 case 3:
262 return "i386";
263 case 4:
264 return "i486";
265 case 5:
266 switch (Model) {
267 case 4: return "pentium-mmx";
268 default: return "pentium";
269 }
270 case 6:
271 switch (Model) {
272 case 1: return "pentiumpro";
273 case 3:
274 case 5:
275 case 6: return "pentium2";
276 case 7:
277 case 8:
278 case 10:
279 case 11: return "pentium3";
280 case 9:
281 case 13: return "pentium-m";
282 case 14: return "yonah";
Evan Cheng5211b422009-01-03 04:04:46 +0000283 case 15:
284 case 22: // Celeron M 540
285 return "core2";
286 case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE)
287 return "penryn";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288 default: return "i686";
289 }
290 case 15: {
291 switch (Model) {
292 case 3:
293 case 4:
Evan Cheng5211b422009-01-03 04:04:46 +0000294 case 6: // same as 4, but 65nm
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295 return (Em64T) ? "nocona" : "prescott";
Evan Chengcfadd3b2009-01-05 08:45:01 +0000296 case 26:
297 return "corei7";
Evan Cheng5211b422009-01-03 04:04:46 +0000298 case 28:
Evan Chengcfadd3b2009-01-05 08:45:01 +0000299 return "atom";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300 default:
301 return (Em64T) ? "x86-64" : "pentium4";
302 }
303 }
304
305 default:
306 return "generic";
307 }
308 } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) {
309 // FIXME: this poorly matches the generated SubtargetFeatureKV table. There
310 // appears to be no way to generate the wide variety of AMD-specific targets
311 // from the information returned from CPUID.
312 switch (Family) {
313 case 4:
314 return "i486";
315 case 5:
316 switch (Model) {
317 case 6:
318 case 7: return "k6";
319 case 8: return "k6-2";
320 case 9:
321 case 13: return "k6-3";
322 default: return "pentium";
323 }
324 case 6:
325 switch (Model) {
326 case 4: return "athlon-tbird";
327 case 6:
328 case 7:
329 case 8: return "athlon-mp";
330 case 10: return "athlon-xp";
331 default: return "athlon";
332 }
333 case 15:
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000334 if (HasSSE3) {
335 switch (Model) {
336 default: return "k8-sse3";
337 }
338 } else {
339 switch (Model) {
340 case 1: return "opteron";
341 case 5: return "athlon-fx"; // also opteron
342 default: return "athlon64";
343 }
344 }
345 case 16:
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 switch (Model) {
Stefanus Du Toitfe086e62009-05-26 21:04:35 +0000347 default: return "amdfam10";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348 }
349 default:
350 return "generic";
351 }
352 } else {
353 return "generic";
354 }
355}
356
357X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
358 : AsmFlavor(AsmWriterFlavor)
Duncan Sandsde5f95f2008-11-28 09:29:37 +0000359 , PICStyle(PICStyles::None)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 , X86SSELevel(NoMMXSSE)
Evan Chengb6992de2008-04-16 19:03:02 +0000361 , X863DNowLevel(NoThreeDNow)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362 , HasX86_64(false)
David Greene8bf22bc2009-06-26 22:46:54 +0000363 , HasSSE4A(false)
364 , HasAVX(false)
365 , HasFMA3(false)
366 , HasFMA4(false)
Evan Cheng95a77fd2009-01-02 05:35:45 +0000367 , IsBTMemSlow(false)
Chris Lattner93a2d432008-01-02 19:44:55 +0000368 , DarwinVers(0)
Dan Gohmande22f242008-05-05 18:43:07 +0000369 , IsLinux(false)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370 , stackAlignment(8)
371 // FIXME: this is a known good value for Yonah. How about others?
Rafael Espindola7afa9b12007-10-31 11:52:06 +0000372 , MaxInlineSizeThreshold(128)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373 , Is64Bit(is64Bit)
374 , TargetType(isELF) { // Default to ELF unless otherwise specified.
Anton Korobeynikov11713322009-06-08 22:53:56 +0000375
376 // default to hard float ABI
377 if (FloatABIType == FloatABI::Default)
378 FloatABIType = FloatABI::Hard;
Mon P Wang078a62d2008-05-05 19:05:59 +0000379
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380 // Determine default and user specified characteristics
381 if (!FS.empty()) {
382 // If feature string is not empty, parse features string.
383 std::string CPU = GetCurrentX86CPU();
384 ParseSubtargetFeatures(FS, CPU);
Edwin Török4031b792009-02-02 21:57:34 +0000385 // All X86-64 CPUs also have SSE2, however user might request no SSE via
386 // -mattr, so don't force SSELevel here.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387 } else {
388 // Otherwise, use CPUID to auto-detect feature set.
389 AutoDetectSubtargetFeatures();
Dan Gohman4092bbc2009-02-03 00:04:43 +0000390 // Make sure SSE2 is enabled; it is available on all X86-64 CPUs.
391 if (Is64Bit && X86SSELevel < SSE2)
392 X86SSELevel = SSE2;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393 }
Dan Gohman4092bbc2009-02-03 00:04:43 +0000394
Dan Gohmand3ef6c92009-02-03 18:53:21 +0000395 // If requesting codegen for X86-64, make sure that 64-bit features
396 // are enabled.
397 if (Is64Bit)
398 HasX86_64 = true;
399
Evan Cheng5211b422009-01-03 04:04:46 +0000400 DOUT << "Subtarget features: SSELevel " << X86SSELevel
401 << ", 3DNowLevel " << X863DNowLevel
402 << ", 64bit " << HasX86_64 << "\n";
Dan Gohman4092bbc2009-02-03 00:04:43 +0000403 assert((!Is64Bit || HasX86_64) &&
404 "64-bit code requested on a subtarget that doesn't support it!");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
406 // Set the boolean corresponding to the current target triple, or the default
407 // if one cannot be determined, to true.
408 const std::string& TT = M.getTargetTriple();
409 if (TT.length() > 5) {
Duncan Sandsdfd94582008-01-08 10:06:15 +0000410 size_t Pos;
Chris Lattner93a2d432008-01-02 19:44:55 +0000411 if ((Pos = TT.find("-darwin")) != std::string::npos) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 TargetType = isDarwin;
Chris Lattner93a2d432008-01-02 19:44:55 +0000413
414 // Compute the darwin version number.
415 if (isdigit(TT[Pos+7]))
416 DarwinVers = atoi(&TT[Pos+7]);
417 else
418 DarwinVers = 8; // Minimum supported darwin is Tiger.
Dan Gohmana65530a2008-05-05 00:28:39 +0000419 } else if (TT.find("linux") != std::string::npos) {
Dan Gohman2593e2b2008-05-05 16:11:31 +0000420 // Linux doesn't imply ELF, but we don't currently support anything else.
421 TargetType = isELF;
422 IsLinux = true;
Chris Lattner93a2d432008-01-02 19:44:55 +0000423 } else if (TT.find("cygwin") != std::string::npos) {
424 TargetType = isCygwin;
425 } else if (TT.find("mingw") != std::string::npos) {
426 TargetType = isMingw;
427 } else if (TT.find("win32") != std::string::npos) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428 TargetType = isWindows;
Anton Korobeynikovf0ce64b2008-03-22 21:12:53 +0000429 } else if (TT.find("windows") != std::string::npos) {
430 TargetType = isWindows;
Chris Lattner93a2d432008-01-02 19:44:55 +0000431 }
Mon P Wang23bbfc32009-02-28 00:25:30 +0000432 else if (TT.find("-cl") != std::string::npos) {
433 TargetType = isDarwin;
434 DarwinVers = 9;
435 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436 } else if (TT.empty()) {
437#if defined(__CYGWIN__)
438 TargetType = isCygwin;
Anton Korobeynikov62a51e42008-03-22 21:18:22 +0000439#elif defined(__MINGW32__) || defined(__MINGW64__)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440 TargetType = isMingw;
441#elif defined(__APPLE__)
442 TargetType = isDarwin;
Chris Lattner93a2d432008-01-02 19:44:55 +0000443#if __APPLE_CC__ > 5400
444 DarwinVers = 9; // GCC 5400+ is Leopard.
445#else
446 DarwinVers = 8; // Minimum supported darwin is Tiger.
447#endif
448
Anton Korobeynikov62a51e42008-03-22 21:18:22 +0000449#elif defined(_WIN32) || defined(_WIN64)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 TargetType = isWindows;
Dan Gohmana65530a2008-05-05 00:28:39 +0000451#elif defined(__linux__)
452 // Linux doesn't imply ELF, but we don't currently support anything else.
Dan Gohman2593e2b2008-05-05 16:11:31 +0000453 TargetType = isELF;
454 IsLinux = true;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000455#endif
456 }
457
458 // If the asm syntax hasn't been overridden on the command line, use whatever
459 // the target wants.
460 if (AsmFlavor == X86Subtarget::Unset) {
Chris Lattner93a2d432008-01-02 19:44:55 +0000461 AsmFlavor = (TargetType == isWindows)
462 ? X86Subtarget::Intel : X86Subtarget::ATT;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 }
464
Anton Korobeynikovcdd93812008-04-23 18:16:16 +0000465 // Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
466 // bit targets.
467 if (TargetType == isDarwin || Is64Bit)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468 stackAlignment = 16;
Anton Korobeynikov06c42402008-04-12 22:12:22 +0000469
470 if (StackAlignment)
471 stackAlignment = StackAlignment;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472}