blob: a7233b52b244a60c11d686369bfa5f2b8fec8589 [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"
Chris Lattnerd392bd92009-07-10 07:20:05 +000016#include "X86InstrInfo.h"
Evan Chenga26eb5e2006-10-06 09:17:41 +000017#include "X86GenSubtarget.inc"
Daniel Dunbar3be03402009-08-02 22:11:08 +000018#include "llvm/GlobalValue.h"
Evan Cheng5b925c02009-01-03 04:04:46 +000019#include "llvm/Support/Debug.h"
Bill Wendling0ea8bf32009-08-03 00:11:34 +000020#include "llvm/Support/raw_ostream.h"
Anton Korobeynikov2b2bc682006-12-22 22:29:05 +000021#include "llvm/Target/TargetMachine.h"
Anton Korobeynikov45709ae2008-04-23 18:18:10 +000022#include "llvm/Target/TargetOptions.h"
David Goodwinc2e8a7e2009-11-10 00:48:55 +000023#include "llvm/ADT/SmallVector.h"
Nate Begemanfb5792f2005-07-12 01:41:54 +000024using namespace llvm;
25
Chris Lattnerbc583222009-04-25 18:27:23 +000026#if defined(_MSC_VER)
Bill Wendling0ea8bf32009-08-03 00:11:34 +000027#include <intrin.h>
Chris Lattnerbc583222009-04-25 18:27:23 +000028#endif
29
Chris Lattnerd392bd92009-07-10 07:20:05 +000030/// ClassifyGlobalReference - Classify a global variable reference for the
31/// current subtarget according to how we should reference it in a non-pcrel
32/// context.
33unsigned char X86Subtarget::
34ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
35 // DLLImport only exists on windows, it is implemented as a load from a
36 // DLLIMPORT stub.
37 if (GV->hasDLLImportLinkage())
38 return X86II::MO_DLLIMPORT;
39
Evan Chenga82b22c2009-07-16 22:53:10 +000040 // GV with ghost linkage (in JIT lazy compilation mode) do not require an
41 // extra load from stub.
42 bool isDecl = GV->isDeclaration() && !GV->hasNotBeenReadFromBitcode();
43
Chris Lattnerd392bd92009-07-10 07:20:05 +000044 // X86-64 in PIC mode.
45 if (isPICStyleRIPRel()) {
46 // Large model never uses stubs.
47 if (TM.getCodeModel() == CodeModel::Large)
48 return X86II::MO_NO_FLAG;
49
Chris Lattnerc7822322009-07-10 21:01:59 +000050 if (isTargetDarwin()) {
51 // If symbol visibility is hidden, the extra load is not needed if
52 // target is x86-64 or the symbol is definitely defined in the current
53 // translation unit.
54 if (GV->hasDefaultVisibility() &&
Evan Chenga82b22c2009-07-16 22:53:10 +000055 (isDecl || GV->isWeakForLinker()))
Chris Lattnerc7822322009-07-10 21:01:59 +000056 return X86II::MO_GOTPCREL;
57 } else {
58 assert(isTargetELF() && "Unknown rip-relative target");
Chris Lattnerd392bd92009-07-10 07:20:05 +000059
Chris Lattnerc7822322009-07-10 21:01:59 +000060 // Extra load is needed for all externally visible.
61 if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility())
62 return X86II::MO_GOTPCREL;
63 }
Chris Lattnerd392bd92009-07-10 07:20:05 +000064
65 return X86II::MO_NO_FLAG;
66 }
67
68 if (isPICStyleGOT()) { // 32-bit ELF targets.
69 // Extra load is needed for all externally visible.
70 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
71 return X86II::MO_GOTOFF;
72 return X86II::MO_GOT;
73 }
74
Chris Lattnere2c92082009-07-10 21:00:45 +000075 if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode.
Chris Lattner84853a12009-07-10 20:53:38 +000076 // Determine whether we have a stub reference and/or whether the reference
77 // is relative to the PIC base or not.
Chris Lattnerd392bd92009-07-10 07:20:05 +000078
79 // If this is a strong reference to a definition, it is definitely not
80 // through a stub.
Evan Chenga82b22c2009-07-16 22:53:10 +000081 if (!isDecl && !GV->isWeakForLinker())
Chris Lattner84853a12009-07-10 20:53:38 +000082 return X86II::MO_PIC_BASE_OFFSET;
Chris Lattnerd392bd92009-07-10 07:20:05 +000083
84 // Unless we have a symbol with hidden visibility, we have to go through a
85 // normal $non_lazy_ptr stub because this symbol might be resolved late.
Chris Lattner84853a12009-07-10 20:53:38 +000086 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
87 return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
Chris Lattnerd392bd92009-07-10 07:20:05 +000088
89 // If symbol visibility is hidden, we have a stub for common symbol
90 // references and external declarations.
Evan Chenga82b22c2009-07-16 22:53:10 +000091 if (isDecl || GV->hasCommonLinkage()) {
Chris Lattnerd392bd92009-07-10 07:20:05 +000092 // Hidden $non_lazy_ptr reference.
Chris Lattner84853a12009-07-10 20:53:38 +000093 return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE;
Chris Lattnerd392bd92009-07-10 07:20:05 +000094 }
95
96 // Otherwise, no stub.
Chris Lattner84853a12009-07-10 20:53:38 +000097 return X86II::MO_PIC_BASE_OFFSET;
98 }
99
Chris Lattnere2c92082009-07-10 21:00:45 +0000100 if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode.
Chris Lattner84853a12009-07-10 20:53:38 +0000101 // Determine whether we have a stub reference.
102
103 // If this is a strong reference to a definition, it is definitely not
104 // through a stub.
Evan Chenga82b22c2009-07-16 22:53:10 +0000105 if (!isDecl && !GV->isWeakForLinker())
Chris Lattner84853a12009-07-10 20:53:38 +0000106 return X86II::MO_NO_FLAG;
107
108 // Unless we have a symbol with hidden visibility, we have to go through a
109 // normal $non_lazy_ptr stub because this symbol might be resolved late.
110 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
111 return X86II::MO_DARWIN_NONLAZY;
Evan Cheng63476a82009-09-03 07:04:02 +0000112
Chris Lattner84853a12009-07-10 20:53:38 +0000113 // Otherwise, no stub.
114 return X86II::MO_NO_FLAG;
Chris Lattnerd392bd92009-07-10 07:20:05 +0000115 }
116
117 // Direct static reference to global.
118 return X86II::MO_NO_FLAG;
119}
120
Anton Korobeynikov7784ebc2006-11-30 22:42:55 +0000121
Bill Wendling6f287b22008-09-30 21:22:07 +0000122/// getBZeroEntry - This function returns the name of a function which has an
123/// interface like the non-standard bzero function, if such a function exists on
124/// the current subtarget and it is considered prefereable over memset with zero
125/// passed as the second argument. Otherwise it returns null.
Bill Wendling6e087382008-09-30 22:05:33 +0000126const char *X86Subtarget::getBZeroEntry() const {
Dan Gohman68d599d2008-04-01 20:38:36 +0000127 // Darwin 10 has a __bzero entry point for this purpose.
128 if (getDarwinVers() >= 10)
Bill Wendling6e087382008-09-30 22:05:33 +0000129 return "__bzero";
Dan Gohman68d599d2008-04-01 20:38:36 +0000130
131 return 0;
132}
133
Evan Chengd7f666a2009-05-20 04:53:57 +0000134/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
135/// to immediate address.
136bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
137 if (Is64Bit)
138 return false;
139 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
140}
141
Dan Gohman8749b612008-12-16 03:35:01 +0000142/// getSpecialAddressLatency - For targets where it is beneficial to
143/// backschedule instructions that compute addresses, return a value
144/// indicating the number of scheduling cycles of backscheduling that
145/// should be attempted.
146unsigned X86Subtarget::getSpecialAddressLatency() const {
147 // For x86 out-of-order targets, back-schedule address computations so
148 // that loads and stores aren't blocked.
149 // This value was chosen arbitrarily.
150 return 200;
151}
152
Chris Lattner1e39a152006-01-28 06:05:41 +0000153/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
154/// specified arguments. If we can't run cpuid on the host, return true.
Daniel Dunbar84811382009-09-03 05:47:34 +0000155static bool GetCpuIDAndInfo(unsigned value, unsigned *rEAX,
156 unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
Anton Korobeynikov6f9bb6f2009-08-28 16:06:41 +0000157#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
Chris Lattnerbc583222009-04-25 18:27:23 +0000158 #if defined(__GNUC__)
159 // gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
160 asm ("movq\t%%rbx, %%rsi\n\t"
161 "cpuid\n\t"
162 "xchgq\t%%rbx, %%rsi\n\t"
163 : "=a" (*rEAX),
164 "=S" (*rEBX),
165 "=c" (*rECX),
166 "=d" (*rEDX)
167 : "a" (value));
168 return false;
169 #elif defined(_MSC_VER)
170 int registers[4];
171 __cpuid(registers, value);
172 *rEAX = registers[0];
173 *rEBX = registers[1];
174 *rECX = registers[2];
175 *rEDX = registers[3];
176 return false;
177 #endif
Evan Cheng25ab6902006-09-08 06:48:29 +0000178#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
Chris Lattnerbc583222009-04-25 18:27:23 +0000179 #if defined(__GNUC__)
180 asm ("movl\t%%ebx, %%esi\n\t"
181 "cpuid\n\t"
182 "xchgl\t%%ebx, %%esi\n\t"
183 : "=a" (*rEAX),
184 "=S" (*rEBX),
185 "=c" (*rECX),
186 "=d" (*rEDX)
187 : "a" (value));
188 return false;
189 #elif defined(_MSC_VER)
190 __asm {
191 mov eax,value
192 cpuid
193 mov esi,rEAX
194 mov dword ptr [esi],eax
195 mov esi,rEBX
196 mov dword ptr [esi],ebx
197 mov esi,rECX
198 mov dword ptr [esi],ecx
199 mov esi,rEDX
200 mov dword ptr [esi],edx
201 }
202 return false;
203 #endif
Evan Cheng559806f2006-01-27 08:10:46 +0000204#endif
Chris Lattner1e39a152006-01-28 06:05:41 +0000205 return true;
Evan Cheng559806f2006-01-27 08:10:46 +0000206}
207
Evan Chengccb69762009-01-02 05:35:45 +0000208static void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model) {
209 Family = (EAX >> 8) & 0xf; // Bits 8 - 11
210 Model = (EAX >> 4) & 0xf; // Bits 4 - 7
211 if (Family == 6 || Family == 0xf) {
212 if (Family == 0xf)
213 // Examine extended family ID if family ID is F.
214 Family += (EAX >> 20) & 0xff; // Bits 20 - 27
215 // Examine extended model ID if family ID is 6 or F.
216 Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
217 }
218}
219
Evan Chenga26eb5e2006-10-06 09:17:41 +0000220void X86Subtarget::AutoDetectSubtargetFeatures() {
Evan Chengb3a7e212006-01-27 19:30:30 +0000221 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
Jeff Cohena3496402006-01-28 18:47:32 +0000222 union {
Jeff Cohen216d2812006-01-28 19:48:34 +0000223 unsigned u[3];
224 char c[12];
Jeff Cohena3496402006-01-28 18:47:32 +0000225 } text;
Chris Lattner3b6f4972006-11-20 18:16:05 +0000226
Evan Chengd0da6ff2009-09-03 04:37:05 +0000227 if (GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1))
Evan Chengabc346c2006-10-06 08:21:07 +0000228 return;
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000229
Evan Chengd0da6ff2009-09-03 04:37:05 +0000230 GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
Chris Lattner3b6f4972006-11-20 18:16:05 +0000231
Chris Lattner70084162009-09-02 05:53:04 +0000232 if ((EDX >> 15) & 1) HasCMov = true;
233 if ((EDX >> 23) & 1) X86SSELevel = MMX;
234 if ((EDX >> 25) & 1) X86SSELevel = SSE1;
235 if ((EDX >> 26) & 1) X86SSELevel = SSE2;
Daniel Dunbar84811382009-09-03 05:47:34 +0000236 if (ECX & 0x1) X86SSELevel = SSE3;
Chris Lattner70084162009-09-02 05:53:04 +0000237 if ((ECX >> 9) & 1) X86SSELevel = SSSE3;
238 if ((ECX >> 19) & 1) X86SSELevel = SSE41;
239 if ((ECX >> 20) & 1) X86SSELevel = SSE42;
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000240
Evan Chengccb69762009-01-02 05:35:45 +0000241 bool IsIntel = memcmp(text.c, "GenuineIntel", 12) == 0;
242 bool IsAMD = !IsIntel && memcmp(text.c, "AuthenticAMD", 12) == 0;
David Greene343dadb2009-06-26 22:46:54 +0000243
244 HasFMA3 = IsIntel && ((ECX >> 12) & 0x1);
245 HasAVX = ((ECX >> 28) & 0x1);
246
Evan Chengccb69762009-01-02 05:35:45 +0000247 if (IsIntel || IsAMD) {
248 // Determine if bit test memory instructions are slow.
249 unsigned Family = 0;
250 unsigned Model = 0;
251 DetectFamilyModel(EAX, Family, Model);
252 IsBTMemSlow = IsAMD || (Family == 6 && Model >= 13);
253
Evan Chengd0da6ff2009-09-03 04:37:05 +0000254 GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
Jeff Cohenc3987092007-04-16 21:59:44 +0000255 HasX86_64 = (EDX >> 29) & 0x1;
Stefanus Du Toit8cf5ab12009-05-26 21:04:35 +0000256 HasSSE4A = IsAMD && ((ECX >> 6) & 0x1);
David Greene343dadb2009-06-26 22:46:54 +0000257 HasFMA4 = IsAMD && ((ECX >> 16) & 0x1);
Jeff Cohenc3987092007-04-16 21:59:44 +0000258 }
Evan Cheng559806f2006-01-27 08:10:46 +0000259}
Evan Cheng97c7fc32006-01-26 09:53:06 +0000260
Daniel Dunbar84811382009-09-03 05:47:34 +0000261static const char *GetCurrentX86CPU() {
Evan Chenga26eb5e2006-10-06 09:17:41 +0000262 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
Evan Chengd0da6ff2009-09-03 04:37:05 +0000263 if (GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX))
Evan Chenga26eb5e2006-10-06 09:17:41 +0000264 return "generic";
Evan Chengccb69762009-01-02 05:35:45 +0000265 unsigned Family = 0;
266 unsigned Model = 0;
267 DetectFamilyModel(EAX, Family, Model);
Evan Cheng018b7ee2009-01-02 05:29:20 +0000268
Evan Chengd0da6ff2009-09-03 04:37:05 +0000269 GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
Evan Cheng3cff9f82006-10-06 18:57:51 +0000270 bool Em64T = (EDX >> 29) & 0x1;
Stefanus Du Toit8cf5ab12009-05-26 21:04:35 +0000271 bool HasSSE3 = (ECX & 0x1);
Evan Chenga26eb5e2006-10-06 09:17:41 +0000272
273 union {
274 unsigned u[3];
275 char c[12];
276 } text;
277
Evan Chengd0da6ff2009-09-03 04:37:05 +0000278 GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1);
Evan Chenga26eb5e2006-10-06 09:17:41 +0000279 if (memcmp(text.c, "GenuineIntel", 12) == 0) {
280 switch (Family) {
281 case 3:
282 return "i386";
283 case 4:
284 return "i486";
285 case 5:
286 switch (Model) {
287 case 4: return "pentium-mmx";
288 default: return "pentium";
289 }
290 case 6:
291 switch (Model) {
292 case 1: return "pentiumpro";
293 case 3:
294 case 5:
295 case 6: return "pentium2";
296 case 7:
297 case 8:
298 case 10:
299 case 11: return "pentium3";
300 case 9:
301 case 13: return "pentium-m";
302 case 14: return "yonah";
Evan Cheng5b925c02009-01-03 04:04:46 +0000303 case 15:
304 case 22: // Celeron M 540
305 return "core2";
306 case 23: // 45nm: Penryn , Wolfdale, Yorkfield (XE)
307 return "penryn";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000308 default: return "i686";
309 }
310 case 15: {
311 switch (Model) {
312 case 3:
313 case 4:
Evan Cheng5b925c02009-01-03 04:04:46 +0000314 case 6: // same as 4, but 65nm
Evan Chenga26eb5e2006-10-06 09:17:41 +0000315 return (Em64T) ? "nocona" : "prescott";
Evan Cheng78771122009-01-05 08:45:01 +0000316 case 26:
317 return "corei7";
Evan Cheng5b925c02009-01-03 04:04:46 +0000318 case 28:
Evan Cheng78771122009-01-05 08:45:01 +0000319 return "atom";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000320 default:
321 return (Em64T) ? "x86-64" : "pentium4";
322 }
323 }
324
325 default:
326 return "generic";
327 }
328 } else if (memcmp(text.c, "AuthenticAMD", 12) == 0) {
329 // FIXME: this poorly matches the generated SubtargetFeatureKV table. There
330 // appears to be no way to generate the wide variety of AMD-specific targets
331 // from the information returned from CPUID.
332 switch (Family) {
333 case 4:
334 return "i486";
335 case 5:
336 switch (Model) {
337 case 6:
338 case 7: return "k6";
339 case 8: return "k6-2";
340 case 9:
341 case 13: return "k6-3";
342 default: return "pentium";
343 }
344 case 6:
345 switch (Model) {
346 case 4: return "athlon-tbird";
347 case 6:
348 case 7:
349 case 8: return "athlon-mp";
350 case 10: return "athlon-xp";
351 default: return "athlon";
352 }
353 case 15:
Stefanus Du Toit8cf5ab12009-05-26 21:04:35 +0000354 if (HasSSE3) {
Daniel Dunbarcfb8a1b2009-07-19 01:38:38 +0000355 return "k8-sse3";
Stefanus Du Toit8cf5ab12009-05-26 21:04:35 +0000356 } else {
357 switch (Model) {
358 case 1: return "opteron";
359 case 5: return "athlon-fx"; // also opteron
360 default: return "athlon64";
361 }
362 }
363 case 16:
Daniel Dunbarcfb8a1b2009-07-19 01:38:38 +0000364 return "amdfam10";
Evan Chenga26eb5e2006-10-06 09:17:41 +0000365 default:
366 return "generic";
367 }
368 } else {
369 return "generic";
370 }
371}
372
Daniel Dunbar3be03402009-08-02 22:11:08 +0000373X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS,
374 bool is64Bit)
Chris Lattnerce914b82009-08-11 23:01:09 +0000375 : PICStyle(PICStyles::None)
Evan Cheng25ab6902006-09-08 06:48:29 +0000376 , X86SSELevel(NoMMXSSE)
Evan Chengdc008582008-04-16 19:03:02 +0000377 , X863DNowLevel(NoThreeDNow)
Chris Lattner70084162009-09-02 05:53:04 +0000378 , HasCMov(false)
Evan Cheng25ab6902006-09-08 06:48:29 +0000379 , HasX86_64(false)
David Greene343dadb2009-06-26 22:46:54 +0000380 , HasSSE4A(false)
381 , HasAVX(false)
382 , HasFMA3(false)
383 , HasFMA4(false)
Evan Chengccb69762009-01-02 05:35:45 +0000384 , IsBTMemSlow(false)
Chris Lattner7ad92d82008-01-02 19:44:55 +0000385 , DarwinVers(0)
Evan Cheng25ab6902006-09-08 06:48:29 +0000386 , stackAlignment(8)
387 // FIXME: this is a known good value for Yonah. How about others?
Rafael Espindolafc05f402007-10-31 11:52:06 +0000388 , MaxInlineSizeThreshold(128)
Evan Cheng25ab6902006-09-08 06:48:29 +0000389 , Is64Bit(is64Bit)
390 , TargetType(isELF) { // Default to ELF unless otherwise specified.
Anton Korobeynikov0eebf652009-06-08 22:53:56 +0000391
392 // default to hard float ABI
393 if (FloatABIType == FloatABI::Default)
394 FloatABIType = FloatABI::Hard;
Mon P Wang63307c32008-05-05 19:05:59 +0000395
Evan Cheng97c7fc32006-01-26 09:53:06 +0000396 // Determine default and user specified characteristics
Evan Chenga26eb5e2006-10-06 09:17:41 +0000397 if (!FS.empty()) {
398 // If feature string is not empty, parse features string.
399 std::string CPU = GetCurrentX86CPU();
400 ParseSubtargetFeatures(FS, CPU);
Torok Edwinb68a88b2009-02-02 21:57:34 +0000401 // All X86-64 CPUs also have SSE2, however user might request no SSE via
402 // -mattr, so don't force SSELevel here.
Chris Lattner3b6f4972006-11-20 18:16:05 +0000403 } else {
404 // Otherwise, use CPUID to auto-detect feature set.
405 AutoDetectSubtargetFeatures();
Dan Gohmanf75e5b42009-02-03 00:04:43 +0000406 // Make sure SSE2 is enabled; it is available on all X86-64 CPUs.
407 if (Is64Bit && X86SSELevel < SSE2)
408 X86SSELevel = SSE2;
Evan Cheng25ab6902006-09-08 06:48:29 +0000409 }
Dan Gohmanf75e5b42009-02-03 00:04:43 +0000410
Dan Gohman605679f2009-02-03 18:53:21 +0000411 // If requesting codegen for X86-64, make sure that 64-bit features
412 // are enabled.
413 if (Is64Bit)
414 HasX86_64 = true;
415
Bill Wendling0ea8bf32009-08-03 00:11:34 +0000416 DEBUG(errs() << "Subtarget features: SSELevel " << X86SSELevel
417 << ", 3DNowLevel " << X863DNowLevel
418 << ", 64bit " << HasX86_64 << "\n");
Dan Gohmanf75e5b42009-02-03 00:04:43 +0000419 assert((!Is64Bit || HasX86_64) &&
420 "64-bit code requested on a subtarget that doesn't support it!");
Evan Cheng25ab6902006-09-08 06:48:29 +0000421
Nate Begemanfb5792f2005-07-12 01:41:54 +0000422 // Set the boolean corresponding to the current target triple, or the default
423 // if one cannot be determined, to true.
Nate Begemanfb5792f2005-07-12 01:41:54 +0000424 if (TT.length() > 5) {
Duncan Sandse51775d2008-01-08 10:06:15 +0000425 size_t Pos;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000426 if ((Pos = TT.find("-darwin")) != std::string::npos) {
Chris Lattnere5600e52005-11-21 22:31:58 +0000427 TargetType = isDarwin;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000428
429 // Compute the darwin version number.
430 if (isdigit(TT[Pos+7]))
431 DarwinVers = atoi(&TT[Pos+7]);
432 else
433 DarwinVers = 8; // Minimum supported darwin is Tiger.
Dan Gohmana779a982008-05-05 00:28:39 +0000434 } else if (TT.find("linux") != std::string::npos) {
Dan Gohman600bf162008-05-05 16:11:31 +0000435 // Linux doesn't imply ELF, but we don't currently support anything else.
436 TargetType = isELF;
Chris Lattner7ad92d82008-01-02 19:44:55 +0000437 } else if (TT.find("cygwin") != std::string::npos) {
438 TargetType = isCygwin;
439 } else if (TT.find("mingw") != std::string::npos) {
440 TargetType = isMingw;
441 } else if (TT.find("win32") != std::string::npos) {
Chris Lattnere5600e52005-11-21 22:31:58 +0000442 TargetType = isWindows;
Anton Korobeynikov508f0fd2008-03-22 21:12:53 +0000443 } else if (TT.find("windows") != std::string::npos) {
444 TargetType = isWindows;
Daniel Dunbare22f4da2009-08-05 18:12:37 +0000445 } else if (TT.find("-cl") != std::string::npos) {
Mon P Wang9feb5dd2009-02-28 00:25:30 +0000446 TargetType = isDarwin;
447 DarwinVers = 9;
448 }
Nate Begemanfb5792f2005-07-12 01:41:54 +0000449 }
450
Anton Korobeynikov890fe882008-04-23 18:16:16 +0000451 // Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
452 // bit targets.
453 if (TargetType == isDarwin || Is64Bit)
Nate Begemanfb5792f2005-07-12 01:41:54 +0000454 stackAlignment = 16;
Anton Korobeynikov78c80fd2008-04-12 22:12:22 +0000455
456 if (StackAlignment)
457 stackAlignment = StackAlignment;
Nate Begemanfb5792f2005-07-12 01:41:54 +0000458}
David Goodwinc2e8a7e2009-11-10 00:48:55 +0000459
460bool X86Subtarget::enablePostRAScheduler(
461 CodeGenOpt::Level OptLevel,
462 TargetSubtarget::AntiDepBreakMode& Mode,
463 ExcludedRCVector& ExcludedRCs) const {
464 Mode = TargetSubtarget::ANTIDEP_CRITICAL;
465 ExcludedRCs.clear();
466 return OptLevel >= CodeGenOpt::Default;
467}