blob: c6cda56f7dd357308790b6e62626dab16487a027 [file] [log] [blame]
Nate Begeman8c00f8c2005-08-04 07:12:09 +00001//===-- X86Subtarget.cpp - X86 Subtarget Information ------------*- C++ -*-===//
Nate Begemanfb5792f2005-07-12 01:41:54 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Nate Begemanfb5792f2005-07-12 01:41:54 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the X86 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
Evan Cheng5b925c02009-01-03 04:04:46 +000014#define DEBUG_TYPE "subtarget"
Nate Begemanfb5792f2005-07-12 01:41:54 +000015#include "X86Subtarget.h"
Evan Chenga26eb5e2006-10-06 09:17:41 +000016#include "X86GenSubtarget.inc"
Nate Begemanfb5792f2005-07-12 01:41:54 +000017#include "llvm/Module.h"
Jim Laskey05a059d2006-09-07 12:23:47 +000018#include "llvm/Support/CommandLine.h"
Evan Cheng5b925c02009-01-03 04:04:46 +000019#include "llvm/Support/Debug.h"
Anton Korobeynikov2b2bc682006-12-22 22:29:05 +000020#include "llvm/Target/TargetMachine.h"
Anton Korobeynikov45709ae2008-04-23 18:18:10 +000021#include "llvm/Target/TargetOptions.h"
Nate Begemanfb5792f2005-07-12 01:41:54 +000022using namespace llvm;
23
Dan Gohman844731a2008-05-13 00:00:25 +000024static cl::opt<X86Subtarget::AsmWriterFlavorTy>
Anton Korobeynikov7f705592007-01-12 19:20:47 +000025AsmWriterFlavor("x86-asm-syntax", cl::init(X86Subtarget::Unset),
Jim Laskey05a059d2006-09-07 12:23:47 +000026 cl::desc("Choose style of code to emit from X86 backend:"),
27 cl::values(
Dan Gohmanb8cab922008-10-14 20:25:08 +000028 clEnumValN(X86Subtarget::ATT, "att", "Emit AT&T-style assembly"),
29 clEnumValN(X86Subtarget::Intel, "intel", "Emit Intel-style assembly"),
Chris Lattnercdb341d2006-09-07 22:29:41 +000030 clEnumValEnd));
Jim Laskey05a059d2006-09-07 12:23:47 +000031
Evan Cheng751c0e12006-10-16 21:00:37 +000032
Anton Korobeynikov7784ebc2006-11-30 22:42:55 +000033/// True if accessing the GV requires an extra load. For Windows, dllimported
34/// symbols are indirect, loading the value at address GV rather then the
35/// value of GV itself. This means that the GlobalAddress must be in the base
36/// or index register of the address, not the GV offset field.
Anton Korobeynikov48c8e3d2006-12-20 20:40:30 +000037bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
Anton Korobeynikov2b2bc682006-12-22 22:29:05 +000038 const TargetMachine& TM,
Anton Korobeynikov48c8e3d2006-12-20 20:40:30 +000039 bool isDirectCall) const
Anton Korobeynikov7784ebc2006-11-30 22:42:55 +000040{
Anton Korobeynikovb10308e2007-01-28 13:31:35 +000041 // FIXME: PIC
Evan Cheng817a6a92008-07-16 01:34:02 +000042 if (TM.getRelocationModel() != Reloc::Static &&
43 TM.getCodeModel() != CodeModel::Large) {
Anton Korobeynikov5032e5a2007-01-17 10:33:08 +000044 if (isTargetDarwin()) {
Evan Chenge4d10822008-12-08 19:29:03 +000045 if (isDirectCall)
46 return false;
Evan Chengae94e592008-12-05 01:06:39 +000047 bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode();
48 if (GV->hasHiddenVisibility() &&
49 (Is64Bit || (!isDecl && !GV->hasCommonLinkage())))
50 // If symbol visibility is hidden, the extra load is not needed if
51 // target is x86-64 or the symbol is definitely defined in the current
52 // translation unit.
53 return false;
Dan Gohman2d4e9bc2008-12-08 17:38:02 +000054 return !isDirectCall && (isDecl || GV->mayBeOverridden());
Anton Korobeynikov49964d62008-01-20 13:58:16 +000055 } else if (isTargetELF()) {
Rafael Espindolada5860f2008-06-02 07:52:43 +000056 // Extra load is needed for all externally visible.
57 if (isDirectCall)
58 return false;
Anton Korobeynikov3b485912008-07-09 13:29:08 +000059 if (GV->hasInternalLinkage() || GV->hasHiddenVisibility())
Rafael Espindolada5860f2008-06-02 07:52:43 +000060 return false;
61 return true;
Anton Korobeynikov317848f2007-01-03 11:43:14 +000062 } else if (isTargetCygMing() || isTargetWindows()) {
Anton Korobeynikov15fccf12006-12-20 01:03:20 +000063 return (GV->hasDLLImportLinkage());
64 }
Anton Korobeynikov7c1c2612008-02-20 11:22:39 +000065 }
Dale Johannesen203af582008-12-05 21:47:27 +000066 return false;
67}
68
69/// True if accessing the GV requires a register. This is a superset of the
70/// cases where GVRequiresExtraLoad is true. Some variations of PIC require
71/// a register, but not an extra load.
72bool X86Subtarget::GVRequiresRegister(const GlobalValue *GV,
73 const TargetMachine& TM,
74 bool isDirectCall) const
75{
76 if (GVRequiresExtraLoad(GV, TM, isDirectCall))
77 return true;
78 // Code below here need only consider cases where GVRequiresExtraLoad
79 // returns false.
80 if (TM.getRelocationModel() == Reloc::PIC_)
81 return !isDirectCall &&
82 (GV->hasInternalLinkage() || GV->hasExternalLinkage());
Anton Korobeynikov7784ebc2006-11-30 22:42:55 +000083 return false;
84}
85
Bill Wendling6f287b22008-09-30 21:22:07 +000086/// getBZeroEntry - This function returns the name of a function which has an
87/// interface like the non-standard bzero function, if such a function exists on
88/// the current subtarget and it is considered prefereable over memset with zero
89/// passed as the second argument. Otherwise it returns null.
Bill Wendling6e087382008-09-30 22:05:33 +000090const char *X86Subtarget::getBZeroEntry() const {
Dan Gohman68d599d2008-04-01 20:38:36 +000091 // Darwin 10 has a __bzero entry point for this purpose.
92 if (getDarwinVers() >= 10)
Bill Wendling6e087382008-09-30 22:05:33 +000093 return "__bzero";
Dan Gohman68d599d2008-04-01 20:38:36 +000094
95 return 0;
96}
97
Dan Gohman8749b612008-12-16 03:35:01 +000098/// getSpecialAddressLatency - For targets where it is beneficial to
99/// backschedule instructions that compute addresses, return a value
100/// indicating the number of scheduling cycles of backscheduling that
101/// should be attempted.
102unsigned X86Subtarget::getSpecialAddressLatency() const {
103 // For x86 out-of-order targets, back-schedule address computations so
104 // that loads and stores aren't blocked.
105 // This value was chosen arbitrarily.
106 return 200;
107}
108
Chris Lattner1e39a152006-01-28 06:05:41 +0000109/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
110/// specified arguments. If we can't run cpuid on the host, return true.
Evan Cheng751c0e12006-10-16 21:00:37 +0000111bool X86::GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
112 unsigned *rECX, unsigned *rEDX) {
Evan Cheng25ab6902006-09-08 06:48:29 +0000113#if defined(__x86_64__)
Evan Chengf896d1e2006-10-17 00:24:49 +0000114 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
115 asm ("movq\t%%rbx, %%rsi\n\t"
116 "cpuid\n\t"
117 "xchgq\t%%rbx, %%rsi\n\t"
Evan Cheng25ab6902006-09-08 06:48:29 +0000118 : "=a" (*rEAX),
119 "=S" (*rEBX),
120 "=c" (*rECX),
121 "=d" (*rEDX)
122 : "a" (value));
123 return false;
124#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Evan Cheng559806f2006-01-27 08:10:46 +0000125#if defined(__GNUC__)
Evan Chengaacf9992006-11-08 20:35:37 +0000126 asm ("movl\t%%ebx, %%esi\n\t"
Evan Cheng559806f2006-01-27 08:10:46 +0000127 "cpuid\n\t"
Evan Chengaacf9992006-11-08 20:35:37 +0000128 "xchgl\t%%ebx, %%esi\n\t"
Jeff Cohen41adb0d2006-01-28 18:09:06 +0000129 : "=a" (*rEAX),
130 "=S" (*rEBX),
131 "=c" (*rECX),
132 "=d" (*rEDX)
Evan Cheng559806f2006-01-27 08:10:46 +0000133 : "a" (value));
Chris Lattner1e39a152006-01-28 06:05:41 +0000134 return false;
Jeff Cohen41adb0d2006-01-28 18:09:06 +0000135#elif defined(_MSC_VER)
136 __asm {
137 mov eax,value
138 cpuid
139 mov esi,rEAX
140 mov dword ptr [esi],eax
141 mov esi,rEBX
142 mov dword ptr [esi],ebx
143 mov esi,rECX
144 mov dword ptr [esi],ecx
145 mov esi,rEDX
146 mov dword ptr [esi],edx
147 }
148 return false;
Evan Cheng559806f2006-01-27 08:10:46 +0000149#endif
150#endif
Chris Lattner1e39a152006-01-28 06:05:41 +0000151 return true;
Evan Cheng559806f2006-01-27 08:10:46 +0000152}
153
Evan Chengccb69762009-01-02 05:35:45 +0000154static void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
155 Family = (EAX >> 8) & 0xf; // Bits 8 - 11
156 Model = (EAX >> 4) & 0xf; // Bits 4 - 7
157 if (Family == 6 || Family == 0xf) {
158 if (Family == 0xf)
159 // Examine extended family ID if family ID is F.
160 Family += (EAX >> 20) & 0xff; // Bits 20 - 27
161 // Examine extended model ID if family ID is 6 or F.
162 Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
163 }
164}
165
Evan Chenga26eb5e2006-10-06 09:17:41 +0000166void X86Subtarget::AutoDetectSubtargetFeatures() {
Evan Chengb3a7e212006-01-27 19:30:30 +0000167 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
Jeff Cohena3496402006-01-28 18:47:32 +0000168 union {
Jeff Cohen216d2812006-01-28 19:48:34 +0000169 unsigned u[3];
170 char c[12];
Jeff Cohena3496402006-01-28 18:47:32 +0000171 } text;
Chris Lattner3b6f4972006-11-20 18:16:05 +0000172
Evan Cheng751c0e12006-10-16 21:00:37 +0000173 if (X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1))
Evan Chengabc346c2006-10-06 08:21:07 +0000174 return;
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000175
176 X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
Chris Lattner3b6f4972006-11-20 18:16:05 +0000177
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000178 if ((EDX >> 23) & 0x1) X86SSELevel = MMX;
179 if ((EDX >> 25) & 0x1) X86SSELevel = SSE1;
180 if ((EDX >> 26) & 0x1) X86SSELevel = SSE2;
181 if (ECX & 0x1) X86SSELevel = SSE3;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000182 if ((ECX >> 9) & 0x1) X86SSELevel = SSSE3;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000183 if ((ECX >> 19) & 0x1) X86SSELevel = SSE41;
184 if ((ECX >> 20) & 0x1) X86SSELevel = SSE42;
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000185
Evan Chengccb69762009-01-02 05:35:45 +0000186 bool IsIntel = memcmp(text.c, "GenuineIntel", 12) == 0;
187 bool IsAMD = !IsIntel && memcmp(text.c, "AuthenticAMD", 12) == 0;
188 if (IsIntel || IsAMD) {
189 // Determine if bit test memory instructions are slow.
190 unsigned Family = 0;
191 unsigned Model = 0;
192 DetectFamilyModel(EAX, Family, Model);
193 IsBTMemSlow = IsAMD || (Family == 6 && Model >= 13);
194
Jeff Cohenc3987092007-04-16 21:59:44 +0000195 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
196 HasX86_64 = (EDX >> 29) & 0x1;
197 }
Evan Cheng559806f2006-01-27 08:10:46 +0000198}
Evan Cheng97c7fc32006-01-26 09:53:06 +0000199
Evan Chenga26eb5e2006-10-06 09:17:41 +0000200static const char *GetCurrentX86CPU() {
201 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
Evan Cheng751c0e12006-10-16 21:00:37 +0000202 if (X86::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
Evan Chenga26eb5e2006-10-06 09:17:41 +0000203 return "generic";
Evan Chengccb69762009-01-02 05:35:45 +0000204 unsigned Family = 0;
205 unsigned Model = 0;
206 DetectFamilyModel(EAX, Family, Model);
Evan Cheng0be6d3f2009-01-03 04:24:44 +0000207 bool HasSSE42 = (ECX >> 19) & 0x1;
Evan Cheng018b7ee2009-01-02 05:29:20 +0000208
Evan Cheng751c0e12006-10-16 21:00:37 +0000209 X86::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
Evan Cheng3cff9f82006-10-06 18:57:51 +0000210 bool Em64T = (EDX >> 29) & 0x1;
Evan Chenga26eb5e2006-10-06 09:17:41 +0000211
212 union {
213 unsigned u[3];
214 char c[12];
215 } text;
216
Evan Cheng751c0e12006-10-16 21:00:37 +0000217 X86::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1);
Evan Chenga26eb5e2006-10-06 09:17:41 +0000218 if (memcmp(text.c, "GenuineIntel", 12) == 0) {
219 switch (Family) {
220 case 3:
221 return "i386";
222 case 4:
223 return "i486";
224 case 5:
225 switch (Model) {
226 case 4: return "pentium-mmx";
227 default: return "pentium";
228 }
229 case 6:
230 switch (Model) {
231 case 1: return "pentiumpro";
232 case 3:
233 case 5:
234 case 6: return "pentium2";
235 case 7:
236 case 8:
237 case 10:
238 case 11: return "pentium3";
239 case 9:
240 case 13: return "pentium-m";
241 case 14: return "yonah";
Evan Cheng5b925c02009-01-03 04:04:46 +0000242 case 15:
243 case 22: // Celeron M 540
244 return "core2";
245 case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE)
246 return "penryn";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000247 default: return "i686";
248 }
249 case 15: {
250 switch (Model) {
251 case 3:
252 case 4:
Evan Cheng5b925c02009-01-03 04:04:46 +0000253 case 6: // same as 4, but 65nm
Evan Chenga26eb5e2006-10-06 09:17:41 +0000254 return (Em64T) ? "nocona" : "prescott";
Evan Cheng5b925c02009-01-03 04:04:46 +0000255 case 28:
256 // Intel Atom, and Core i7 both have this model.
257 // Atom has SSSE3, Core i7 has SSE4.2
Evan Cheng0be6d3f2009-01-03 04:24:44 +0000258 return (HasSSE42) ? "corei7" : "atom";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000259 default:
260 return (Em64T) ? "x86-64" : "pentium4";
261 }
262 }
263
264 default:
265 return "generic";
266 }
267 } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) {
268 // FIXME: this poorly matches the generated SubtargetFeatureKV table. There
269 // appears to be no way to generate the wide variety of AMD-specific targets
270 // from the information returned from CPUID.
271 switch (Family) {
272 case 4:
273 return "i486";
274 case 5:
275 switch (Model) {
276 case 6:
277 case 7: return "k6";
278 case 8: return "k6-2";
279 case 9:
280 case 13: return "k6-3";
281 default: return "pentium";
282 }
283 case 6:
284 switch (Model) {
285 case 4: return "athlon-tbird";
286 case 6:
287 case 7:
288 case 8: return "athlon-mp";
289 case 10: return "athlon-xp";
290 default: return "athlon";
291 }
292 case 15:
293 switch (Model) {
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000294 case 1: return "opteron";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000295 case 5: return "athlon-fx"; // also opteron
296 default: return "athlon64";
297 }
Evan Chenga26eb5e2006-10-06 09:17:41 +0000298 default:
299 return "generic";
300 }
301 } else {
302 return "generic";
303 }
304}
305
Evan Cheng25ab6902006-09-08 06:48:29 +0000306X86Subtarget::X86Subtarget(const Module &M, const std::string &FS, bool is64Bit)
Evan Cheng8e0055d2006-10-04 18:33:00 +0000307 : AsmFlavor(AsmWriterFlavor)
Duncan Sandsf9a67a82008-11-28 09:29:37 +0000308 , PICStyle(PICStyles::None)
Evan Cheng25ab6902006-09-08 06:48:29 +0000309 , X86SSELevel(NoMMXSSE)
Evan Chengdc008582008-04-16 19:03:02 +0000310 , X863DNowLevel(NoThreeDNow)
Evan Cheng25ab6902006-09-08 06:48:29 +0000311 , HasX86_64(false)
Evan Chengccb69762009-01-02 05:35:45 +0000312 , IsBTMemSlow(false)
Chris Lattner7ad92d82008-01-02 19:44:55 +0000313 , DarwinVers(0)
Dan Gohman94bbdc82008-05-05 18:43:07 +0000314 , IsLinux(false)
Evan Cheng25ab6902006-09-08 06:48:29 +0000315 , stackAlignment(8)
316 // FIXME: this is a known good value for Yonah. How about others?
Rafael Espindolafc05f402007-10-31 11:52:06 +0000317 , MaxInlineSizeThreshold(128)
Evan Cheng25ab6902006-09-08 06:48:29 +0000318 , Is64Bit(is64Bit)
319 , TargetType(isELF) { // Default to ELF unless otherwise specified.
Mon P Wang63307c32008-05-05 19:05:59 +0000320
Evan Cheng97c7fc32006-01-26 09:53:06 +0000321 // Determine default and user specified characteristics
Evan Chenga26eb5e2006-10-06 09:17:41 +0000322 if (!FS.empty()) {
323 // If feature string is not empty, parse features string.
324 std::string CPU = GetCurrentX86CPU();
325 ParseSubtargetFeatures(FS, CPU);
Chris Lattner3b6f4972006-11-20 18:16:05 +0000326 } else {
327 // Otherwise, use CPUID to auto-detect feature set.
328 AutoDetectSubtargetFeatures();
329 }
330
331 // If requesting codegen for X86-64, make sure that 64-bit and SSE2 features
332 // are enabled. These are available on all x86-64 CPUs.
333 if (Is64Bit) {
334 HasX86_64 = true;
335 if (X86SSELevel < SSE2)
336 X86SSELevel = SSE2;
Evan Cheng25ab6902006-09-08 06:48:29 +0000337 }
Evan Cheng5b925c02009-01-03 04:04:46 +0000338 DOUT << "Subtarget features: SSELevel " << X86SSELevel
339 << ", 3DNowLevel " << X863DNowLevel
340 << ", 64bit " << HasX86_64 << "\n";
Evan Cheng25ab6902006-09-08 06:48:29 +0000341
Nate Begemanfb5792f2005-07-12 01:41:54 +0000342 // Set the boolean corresponding to the current target triple, or the default
343 // if one cannot be determined, to true.
344 const std::string& TT = M.getTargetTriple();
345 if (TT.length() > 5) {
Duncan Sandse51775d2008-01-08 10:06:15 +0000346 size_t Pos;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000347 if ((Pos = TT.find("-darwin")) != std::string::npos) {
Chris Lattnere5600e52005-11-21 22:31:58 +0000348 TargetType = isDarwin;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000349
350 // Compute the darwin version number.
351 if (isdigit(TT[Pos+7]))
352 DarwinVers = atoi(&TT[Pos+7]);
353 else
354 DarwinVers = 8; // Minimum supported darwin is Tiger.
Dan Gohmana779a982008-05-05 00:28:39 +0000355 } else if (TT.find("linux") != std::string::npos) {
Dan Gohman600bf162008-05-05 16:11:31 +0000356 // Linux doesn't imply ELF, but we don't currently support anything else.
357 TargetType = isELF;
358 IsLinux = true;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000359 } else if (TT.find("cygwin") != std::string::npos) {
360 TargetType = isCygwin;
361 } else if (TT.find("mingw") != std::string::npos) {
362 TargetType = isMingw;
363 } else if (TT.find("win32") != std::string::npos) {
Chris Lattnere5600e52005-11-21 22:31:58 +0000364 TargetType = isWindows;
Anton Korobeynikov508f0fd2008-03-22 21:12:53 +0000365 } else if (TT.find("windows") != std::string::npos) {
366 TargetType = isWindows;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000367 }
Nate Begemanfb5792f2005-07-12 01:41:54 +0000368 } else if (TT.empty()) {
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000369#if defined(__CYGWIN__)
Chris Lattnere5600e52005-11-21 22:31:58 +0000370 TargetType = isCygwin;
Anton Korobeynikov2b4f7802008-03-22 21:18:22 +0000371#elif defined(__MINGW32__) || defined(__MINGW64__)
Anton Korobeynikov317848f2007-01-03 11:43:14 +0000372 TargetType = isMingw;
Nate Begemanfb5792f2005-07-12 01:41:54 +0000373#elif defined(__APPLE__)
Chris Lattnere5600e52005-11-21 22:31:58 +0000374 TargetType = isDarwin;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000375#if __APPLE_CC__ > 5400
376 DarwinVers = 9; // GCC 5400+ is Leopard.
377#else
378 DarwinVers = 8; // Minimum supported darwin is Tiger.
379#endif
380
Anton Korobeynikov2b4f7802008-03-22 21:18:22 +0000381#elif defined(_WIN32) || defined(_WIN64)
Chris Lattnere5600e52005-11-21 22:31:58 +0000382 TargetType = isWindows;
Dan Gohmana779a982008-05-05 00:28:39 +0000383#elif defined(__linux__)
384 // Linux doesn't imply ELF, but we don't currently support anything else.
Dan Gohman600bf162008-05-05 16:11:31 +0000385 TargetType = isELF;
386 IsLinux = true;
Nate Begemanfb5792f2005-07-12 01:41:54 +0000387#endif
388 }
389
Chris Lattnercdb341d2006-09-07 22:29:41 +0000390 // If the asm syntax hasn't been overridden on the command line, use whatever
391 // the target wants.
Anton Korobeynikov7f705592007-01-12 19:20:47 +0000392 if (AsmFlavor == X86Subtarget::Unset) {
Chris Lattner7ad92d82008-01-02 19:44:55 +0000393 AsmFlavor = (TargetType == isWindows)
394 ? X86Subtarget::Intel : X86Subtarget::ATT;
Chris Lattnercdb341d2006-09-07 22:29:41 +0000395 }
396
Anton Korobeynikov890fe882008-04-23 18:16:16 +0000397 // Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
398 // bit targets.
399 if (TargetType == isDarwin || Is64Bit)
Nate Begemanfb5792f2005-07-12 01:41:54 +0000400 stackAlignment = 16;
Anton Korobeynikov78c80fd2008-04-12 22:12:22 +0000401
402 if (StackAlignment)
403 stackAlignment = StackAlignment;
Nate Begemanfb5792f2005-07-12 01:41:54 +0000404}