blob: 1069dcb08fc82cc36896b7a19d824bc4db6fbbe5 [file] [log] [blame]
Bill Wendlingd6434862010-12-04 23:57:24 +00001//===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===//
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//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file implements the X86 specific subclass of TargetSubtargetInfo.
Nate Begemanfb5792f2005-07-12 01:41:54 +000011//
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"
Daniel Dunbar3be03402009-08-02 22:11:08 +000017#include "llvm/GlobalValue.h"
Evan Cheng5b925c02009-01-03 04:04:46 +000018#include "llvm/Support/Debug.h"
Rafael Espindolaca592212011-09-07 16:10:57 +000019#include "llvm/Support/ErrorHandling.h"
Bill Wendling0ea8bf32009-08-03 00:11:34 +000020#include "llvm/Support/raw_ostream.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000021#include "llvm/Support/Host.h"
Anton Korobeynikov2b2bc682006-12-22 22:29:05 +000022#include "llvm/Target/TargetMachine.h"
Rafael Espindolaca592212011-09-07 16:10:57 +000023#include "llvm/Target/TargetOptions.h"
David Goodwinc2e8a7e2009-11-10 00:48:55 +000024#include "llvm/ADT/SmallVector.h"
Evan Cheng94214702011-07-01 20:45:01 +000025
Evan Cheng94214702011-07-01 20:45:01 +000026#define GET_SUBTARGETINFO_TARGET_DESC
Evan Chengebdeeab2011-07-08 01:53:10 +000027#define GET_SUBTARGETINFO_CTOR
Evan Cheng385e9302011-07-01 22:36:09 +000028#include "X86GenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000029
Nate Begemanfb5792f2005-07-12 01:41:54 +000030using namespace llvm;
31
Chris Lattnerbc583222009-04-25 18:27:23 +000032#if defined(_MSC_VER)
Bill Wendling0ea8bf32009-08-03 00:11:34 +000033#include <intrin.h>
Chris Lattnerbc583222009-04-25 18:27:23 +000034#endif
35
Dan Gohman29cbade2009-11-20 23:18:13 +000036/// ClassifyBlockAddressReference - Classify a blockaddress reference for the
37/// current subtarget according to how we should reference it in a non-pcrel
38/// context.
39unsigned char X86Subtarget::
40ClassifyBlockAddressReference() const {
41 if (isPICStyleGOT()) // 32-bit ELF targets.
42 return X86II::MO_GOTOFF;
43
44 if (isPICStyleStubPIC()) // Darwin/32 in PIC mode.
45 return X86II::MO_PIC_BASE_OFFSET;
46
47 // Direct static reference to label.
48 return X86II::MO_NO_FLAG;
49}
50
Chris Lattnerd392bd92009-07-10 07:20:05 +000051/// ClassifyGlobalReference - Classify a global variable reference for the
52/// current subtarget according to how we should reference it in a non-pcrel
53/// context.
54unsigned char X86Subtarget::
55ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
56 // DLLImport only exists on windows, it is implemented as a load from a
57 // DLLIMPORT stub.
58 if (GV->hasDLLImportLinkage())
59 return X86II::MO_DLLIMPORT;
60
Chris Lattner6b601532010-06-14 20:11:56 +000061 // Determine whether this is a reference to a definition or a declaration.
62 // Materializable GVs (in JIT lazy compilation mode) do not require an extra
63 // load from stub.
64 bool isDecl = GV->hasAvailableExternallyLinkage();
65 if (GV->isDeclaration() && !GV->isMaterializable())
66 isDecl = true;
Evan Chenga82b22c2009-07-16 22:53:10 +000067
Chris Lattnerd392bd92009-07-10 07:20:05 +000068 // X86-64 in PIC mode.
69 if (isPICStyleRIPRel()) {
70 // Large model never uses stubs.
71 if (TM.getCodeModel() == CodeModel::Large)
72 return X86II::MO_NO_FLAG;
73
Chris Lattnerc7822322009-07-10 21:01:59 +000074 if (isTargetDarwin()) {
75 // If symbol visibility is hidden, the extra load is not needed if
76 // target is x86-64 or the symbol is definitely defined in the current
77 // translation unit.
78 if (GV->hasDefaultVisibility() &&
Evan Chenga82b22c2009-07-16 22:53:10 +000079 (isDecl || GV->isWeakForLinker()))
Chris Lattnerc7822322009-07-10 21:01:59 +000080 return X86II::MO_GOTPCREL;
Anton Korobeynikov699647c2010-08-21 17:21:11 +000081 } else if (!isTargetWin64()) {
Chris Lattnerc7822322009-07-10 21:01:59 +000082 assert(isTargetELF() && "Unknown rip-relative target");
Chris Lattnerd392bd92009-07-10 07:20:05 +000083
Chris Lattnerc7822322009-07-10 21:01:59 +000084 // Extra load is needed for all externally visible.
85 if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility())
86 return X86II::MO_GOTPCREL;
87 }
Chris Lattnerd392bd92009-07-10 07:20:05 +000088
89 return X86II::MO_NO_FLAG;
90 }
91
92 if (isPICStyleGOT()) { // 32-bit ELF targets.
93 // Extra load is needed for all externally visible.
94 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
95 return X86II::MO_GOTOFF;
96 return X86II::MO_GOT;
97 }
98
Chris Lattnere2c92082009-07-10 21:00:45 +000099 if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode.
Chris Lattner84853a12009-07-10 20:53:38 +0000100 // Determine whether we have a stub reference and/or whether the reference
101 // is relative to the PIC base or not.
Chris Lattnerd392bd92009-07-10 07:20:05 +0000102
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_PIC_BASE_OFFSET;
Chris Lattnerd392bd92009-07-10 07:20:05 +0000107
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.
Chris Lattner84853a12009-07-10 20:53:38 +0000110 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
111 return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
Chris Lattnerd392bd92009-07-10 07:20:05 +0000112
113 // If symbol visibility is hidden, we have a stub for common symbol
114 // references and external declarations.
Evan Chenga82b22c2009-07-16 22:53:10 +0000115 if (isDecl || GV->hasCommonLinkage()) {
Chris Lattnerd392bd92009-07-10 07:20:05 +0000116 // Hidden $non_lazy_ptr reference.
Chris Lattner84853a12009-07-10 20:53:38 +0000117 return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE;
Chris Lattnerd392bd92009-07-10 07:20:05 +0000118 }
119
120 // Otherwise, no stub.
Chris Lattner84853a12009-07-10 20:53:38 +0000121 return X86II::MO_PIC_BASE_OFFSET;
122 }
123
Chris Lattnere2c92082009-07-10 21:00:45 +0000124 if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode.
Chris Lattner84853a12009-07-10 20:53:38 +0000125 // Determine whether we have a stub reference.
126
127 // If this is a strong reference to a definition, it is definitely not
128 // through a stub.
Evan Chenga82b22c2009-07-16 22:53:10 +0000129 if (!isDecl && !GV->isWeakForLinker())
Chris Lattner84853a12009-07-10 20:53:38 +0000130 return X86II::MO_NO_FLAG;
131
132 // Unless we have a symbol with hidden visibility, we have to go through a
133 // normal $non_lazy_ptr stub because this symbol might be resolved late.
134 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
135 return X86II::MO_DARWIN_NONLAZY;
Evan Cheng63476a82009-09-03 07:04:02 +0000136
Chris Lattner84853a12009-07-10 20:53:38 +0000137 // Otherwise, no stub.
138 return X86II::MO_NO_FLAG;
Chris Lattnerd392bd92009-07-10 07:20:05 +0000139 }
140
141 // Direct static reference to global.
142 return X86II::MO_NO_FLAG;
143}
144
Anton Korobeynikov7784ebc2006-11-30 22:42:55 +0000145
Bill Wendling6f287b22008-09-30 21:22:07 +0000146/// getBZeroEntry - This function returns the name of a function which has an
147/// interface like the non-standard bzero function, if such a function exists on
148/// the current subtarget and it is considered prefereable over memset with zero
149/// passed as the second argument. Otherwise it returns null.
Bill Wendling6e087382008-09-30 22:05:33 +0000150const char *X86Subtarget::getBZeroEntry() const {
Dan Gohman68d599d2008-04-01 20:38:36 +0000151 // Darwin 10 has a __bzero entry point for this purpose.
Daniel Dunbar558692f2011-04-20 00:14:25 +0000152 if (getTargetTriple().isMacOSX() &&
153 !getTargetTriple().isMacOSXVersionLT(10, 6))
Bill Wendling6e087382008-09-30 22:05:33 +0000154 return "__bzero";
Dan Gohman68d599d2008-04-01 20:38:36 +0000155
156 return 0;
157}
158
Evan Chengd7f666a2009-05-20 04:53:57 +0000159/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
160/// to immediate address.
161bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
Evan Cheng18fb1d32011-07-07 21:06:52 +0000162 if (In64BitMode)
Evan Chengd7f666a2009-05-20 04:53:57 +0000163 return false;
164 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
165}
166
Dan Gohman8749b612008-12-16 03:35:01 +0000167/// getSpecialAddressLatency - For targets where it is beneficial to
168/// backschedule instructions that compute addresses, return a value
169/// indicating the number of scheduling cycles of backscheduling that
170/// should be attempted.
171unsigned X86Subtarget::getSpecialAddressLatency() const {
172 // For x86 out-of-order targets, back-schedule address computations so
173 // that loads and stores aren't blocked.
174 // This value was chosen arbitrarily.
175 return 200;
176}
177
Evan Chenga26eb5e2006-10-06 09:17:41 +0000178void X86Subtarget::AutoDetectSubtargetFeatures() {
Evan Chengb3a7e212006-01-27 19:30:30 +0000179 unsigned EAX = 0, EBX = 0, ECX = 0, EDX = 0;
Jeff Cohena3496402006-01-28 18:47:32 +0000180 union {
Jeff Cohen216d2812006-01-28 19:48:34 +0000181 unsigned u[3];
182 char c[12];
Jeff Cohena3496402006-01-28 18:47:32 +0000183 } text;
Chris Lattner3b6f4972006-11-20 18:16:05 +0000184
Evan Cheng18fb1d32011-07-07 21:06:52 +0000185 if (X86_MC::GetCpuIDAndInfo(0, &EAX, text.u+0, text.u+2, text.u+1))
Evan Chengabc346c2006-10-06 08:21:07 +0000186 return;
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000187
Evan Cheng18fb1d32011-07-07 21:06:52 +0000188 X86_MC::GetCpuIDAndInfo(0x1, &EAX, &EBX, &ECX, &EDX);
Chris Lattner3b6f4972006-11-20 18:16:05 +0000189
Evan Cheng59ee62d2011-07-11 03:57:24 +0000190 if ((EDX >> 15) & 1) HasCMov = true; ToggleFeature(X86::FeatureCMOV);
191 if ((EDX >> 23) & 1) X86SSELevel = MMX; ToggleFeature(X86::FeatureMMX);
192 if ((EDX >> 25) & 1) X86SSELevel = SSE1; ToggleFeature(X86::FeatureSSE1);
193 if ((EDX >> 26) & 1) X86SSELevel = SSE2; ToggleFeature(X86::FeatureSSE2);
194 if (ECX & 0x1) X86SSELevel = SSE3; ToggleFeature(X86::FeatureSSE3);
195 if ((ECX >> 9) & 1) X86SSELevel = SSSE3; ToggleFeature(X86::FeatureSSSE3);
196 if ((ECX >> 19) & 1) X86SSELevel = SSE41; ToggleFeature(X86::FeatureSSE41);
197 if ((ECX >> 20) & 1) X86SSELevel = SSE42; ToggleFeature(X86::FeatureSSE42);
Evan Chengde7f9202010-12-13 04:23:53 +0000198 // FIXME: AVX codegen support is not ready.
Evan Cheng59ee62d2011-07-11 03:57:24 +0000199 //if ((ECX >> 28) & 1) { HasAVX = true; } ToggleFeature(X86::FeatureAVX);
Anton Korobeynikov3b5ee732007-03-23 23:46:48 +0000200
Evan Chengccb69762009-01-02 05:35:45 +0000201 bool IsIntel = memcmp(text.c, "GenuineIntel", 12) == 0;
202 bool IsAMD = !IsIntel && memcmp(text.c, "AuthenticAMD", 12) == 0;
David Greene343dadb2009-06-26 22:46:54 +0000203
Evan Cheng59ee62d2011-07-11 03:57:24 +0000204 HasCLMUL = IsIntel && ((ECX >> 1) & 0x1); ToggleFeature(X86::FeatureCLMUL);
205 HasFMA3 = IsIntel && ((ECX >> 12) & 0x1); ToggleFeature(X86::FeatureFMA3);
Craig Topper581fe822011-10-03 17:28:23 +0000206 HasMOVBE = IsIntel && ((ECX >> 22) & 0x1); ToggleFeature(X86::FeatureMOVBE);
Evan Cheng59ee62d2011-07-11 03:57:24 +0000207 HasPOPCNT = IsIntel && ((ECX >> 23) & 0x1); ToggleFeature(X86::FeaturePOPCNT);
208 HasAES = IsIntel && ((ECX >> 25) & 0x1); ToggleFeature(X86::FeatureAES);
Craig Topperda394042011-10-09 07:31:39 +0000209 HasF16C = IsIntel && ((ECX >> 29) & 0x1); ToggleFeature(X86::FeatureF16C);
Craig Topper581fe822011-10-03 17:28:23 +0000210 HasRDRAND = IsIntel && ((ECX >> 30) & 0x1); ToggleFeature(X86::FeatureRDRAND);
Eli Friedman43f51ae2011-08-26 21:21:21 +0000211 HasCmpxchg16b = ((ECX >> 13) & 0x1); ToggleFeature(X86::FeatureCMPXCHG16B);
David Greene343dadb2009-06-26 22:46:54 +0000212
Evan Chengccb69762009-01-02 05:35:45 +0000213 if (IsIntel || IsAMD) {
214 // Determine if bit test memory instructions are slow.
215 unsigned Family = 0;
216 unsigned Model = 0;
Evan Cheng18fb1d32011-07-07 21:06:52 +0000217 X86_MC::DetectFamilyModel(EAX, Family, Model);
Evan Cheng59ee62d2011-07-11 03:57:24 +0000218 if (IsAMD || (Family == 6 && Model >= 13)) {
219 IsBTMemSlow = true;
220 ToggleFeature(X86::FeatureSlowBTMem);
221 }
Evan Cheng48c58bb2010-04-01 05:58:17 +0000222 // If it's Nehalem, unaligned memory access is fast.
Evan Cheng59ee62d2011-07-11 03:57:24 +0000223 if (Family == 15 && Model == 26) {
Evan Cheng48c58bb2010-04-01 05:58:17 +0000224 IsUAMemFast = true;
Evan Cheng59ee62d2011-07-11 03:57:24 +0000225 ToggleFeature(X86::FeatureFastUAMem);
226 }
Evan Chengccb69762009-01-02 05:35:45 +0000227
Evan Cheng18fb1d32011-07-07 21:06:52 +0000228 X86_MC::GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX);
Evan Cheng59ee62d2011-07-11 03:57:24 +0000229 if ((EDX >> 29) & 0x1) {
230 HasX86_64 = true;
231 ToggleFeature(X86::Feature64Bit);
232 }
233 if (IsAMD && ((ECX >> 6) & 0x1)) {
234 HasSSE4A = true;
235 ToggleFeature(X86::FeatureSSE4A);
236 }
237 if (IsAMD && ((ECX >> 16) & 0x1)) {
238 HasFMA4 = true;
239 ToggleFeature(X86::FeatureFMA4);
240 }
Jeff Cohenc3987092007-04-16 21:59:44 +0000241 }
Evan Cheng559806f2006-01-27 08:10:46 +0000242}
Evan Cheng97c7fc32006-01-26 09:53:06 +0000243
Evan Cheng276365d2011-06-30 01:53:36 +0000244X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
245 const std::string &FS,
Evan Cheng4d1a8dd2011-07-08 22:30:25 +0000246 unsigned StackAlignOverride, bool is64Bit)
Evan Cheng0ddff1b2011-07-07 07:07:08 +0000247 : X86GenSubtargetInfo(TT, CPU, FS)
Evan Cheng94214702011-07-01 20:45:01 +0000248 , PICStyle(PICStyles::None)
Evan Cheng25ab6902006-09-08 06:48:29 +0000249 , X86SSELevel(NoMMXSSE)
Evan Chengdc008582008-04-16 19:03:02 +0000250 , X863DNowLevel(NoThreeDNow)
Chris Lattner70084162009-09-02 05:53:04 +0000251 , HasCMov(false)
Evan Cheng25ab6902006-09-08 06:48:29 +0000252 , HasX86_64(false)
Bill Wendlingd6434862010-12-04 23:57:24 +0000253 , HasPOPCNT(false)
David Greene343dadb2009-06-26 22:46:54 +0000254 , HasSSE4A(false)
255 , HasAVX(false)
Eric Christopher6d1cd1c2010-04-02 21:54:27 +0000256 , HasAES(false)
Bruno Cardoso Lopescdae7e82010-07-23 01:17:51 +0000257 , HasCLMUL(false)
David Greene343dadb2009-06-26 22:46:54 +0000258 , HasFMA3(false)
259 , HasFMA4(false)
Craig Topper581fe822011-10-03 17:28:23 +0000260 , HasMOVBE(false)
261 , HasRDRAND(false)
Craig Topperda394042011-10-09 07:31:39 +0000262 , HasF16C(false)
Evan Chengccb69762009-01-02 05:35:45 +0000263 , IsBTMemSlow(false)
Evan Cheng48c58bb2010-04-01 05:58:17 +0000264 , IsUAMemFast(false)
David Greene95eb2ee2010-01-11 16:29:42 +0000265 , HasVectorUAMem(false)
Eli Friedman43f51ae2011-08-26 21:21:21 +0000266 , HasCmpxchg16b(false)
Evan Cheng25ab6902006-09-08 06:48:29 +0000267 , stackAlignment(8)
268 // FIXME: this is a known good value for Yonah. How about others?
Rafael Espindolafc05f402007-10-31 11:52:06 +0000269 , MaxInlineSizeThreshold(128)
Eric Christopher62f35a22010-07-05 19:26:33 +0000270 , TargetTriple(TT)
Nick Lewycky1fac6b52011-09-05 21:51:43 +0000271 , In64BitMode(is64Bit)
272 , InNaClMode(false) {
Evan Cheng97c7fc32006-01-26 09:53:06 +0000273 // Determine default and user specified characteristics
Evan Cheng4d1a8dd2011-07-08 22:30:25 +0000274 if (!FS.empty() || !CPU.empty()) {
Evan Chengcc0ddc72011-07-08 21:14:14 +0000275 std::string CPUName = CPU;
276 if (CPUName.empty()) {
277#if defined (__x86_64__) || defined(__i386__)
278 CPUName = sys::getHostCPUName();
279#else
280 CPUName = "generic";
281#endif
282 }
283
Eli Friedman439d05d2011-07-08 23:43:01 +0000284 // Make sure 64-bit features are available in 64-bit mode. (But make sure
285 // SSE2 can be turned off explicitly.)
286 std::string FullFS = FS;
287 if (In64BitMode) {
288 if (!FullFS.empty())
289 FullFS = "+64bit,+sse2," + FullFS;
290 else
291 FullFS = "+64bit,+sse2";
292 }
Evan Cheng4d1a8dd2011-07-08 22:30:25 +0000293
Eli Friedman439d05d2011-07-08 23:43:01 +0000294 // If feature string is not empty, parse features string.
295 ParseSubtargetFeatures(CPUName, FullFS);
Chris Lattner3b6f4972006-11-20 18:16:05 +0000296 } else {
297 // Otherwise, use CPUID to auto-detect feature set.
298 AutoDetectSubtargetFeatures();
Evan Cheng18fb1d32011-07-07 21:06:52 +0000299
Eli Friedman6dfef662011-07-08 23:07:42 +0000300 // Make sure 64-bit features are available in 64-bit mode.
301 if (In64BitMode) {
Evan Cheng59ee62d2011-07-11 03:57:24 +0000302 HasX86_64 = true; ToggleFeature(X86::Feature64Bit);
303 HasCMov = true; ToggleFeature(X86::FeatureCMOV);
Eli Friedman6dfef662011-07-08 23:07:42 +0000304
Evan Cheng59ee62d2011-07-11 03:57:24 +0000305 if (!HasAVX && X86SSELevel < SSE2) {
Eli Friedman6dfef662011-07-08 23:07:42 +0000306 X86SSELevel = SSE2;
Evan Cheng59ee62d2011-07-11 03:57:24 +0000307 ToggleFeature(X86::FeatureSSE1);
308 ToggleFeature(X86::FeatureSSE2);
309 }
Eli Friedman6dfef662011-07-08 23:07:42 +0000310 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000311 }
Evan Cheng59ee62d2011-07-11 03:57:24 +0000312
313 // It's important to keep the MCSubtargetInfo feature bits in sync with
314 // target data structure which is shared with MC code emitter, etc.
315 if (In64BitMode)
316 ToggleFeature(X86::Mode64Bit);
317
Nick Lewycky1fac6b52011-09-05 21:51:43 +0000318 if (isTargetNaCl()) {
319 InNaClMode = true;
320 ToggleFeature(X86::ModeNaCl);
321 }
322
Evan Cheng59ee62d2011-07-11 03:57:24 +0000323 if (HasAVX)
324 X86SSELevel = NoMMXSSE;
Chris Lattner1c436d02010-03-14 22:39:35 +0000325
David Greenebd7b8452010-01-05 01:29:13 +0000326 DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
Bill Wendling0ea8bf32009-08-03 00:11:34 +0000327 << ", 3DNowLevel " << X863DNowLevel
328 << ", 64bit " << HasX86_64 << "\n");
Evan Cheng18fb1d32011-07-07 21:06:52 +0000329 assert((!In64BitMode || HasX86_64) &&
Dan Gohmanf75e5b42009-02-03 00:04:43 +0000330 "64-bit code requested on a subtarget that doesn't support it!");
Evan Cheng25ab6902006-09-08 06:48:29 +0000331
Rafael Espindolaca592212011-09-07 16:10:57 +0000332 if(EnableSegmentedStacks && !isTargetELF())
333 report_fatal_error("Segmented stacks are only implemented on ELF.");
334
Roman Divacky4c3ab582011-02-22 17:30:05 +0000335 // Stack alignment is 16 bytes on Darwin, FreeBSD, Linux and Solaris (both
336 // 32 and 64 bit) and for all 64-bit targets.
Evan Chengef41ff62011-06-23 17:54:54 +0000337 if (StackAlignOverride)
338 stackAlignment = StackAlignOverride;
339 else if (isTargetDarwin() || isTargetFreeBSD() || isTargetLinux() ||
Evan Cheng18fb1d32011-07-07 21:06:52 +0000340 isTargetSolaris() || In64BitMode)
Nate Begemanfb5792f2005-07-12 01:41:54 +0000341 stackAlignment = 16;
Dan Gohman4d3d6e12010-05-27 18:43:40 +0000342}