blob: afa0173fb10c1dbd138980c6bb7af888c41ed1ab [file] [log] [blame]
Bill Wendling2bce78e2010-12-04 23:57:24 +00001//===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===//
Nate Begemanf26625e2005-07-12 01:41:54 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Begemanf26625e2005-07-12 01:41:54 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng0d639a22011-07-01 21:01:15 +000010// This file implements the X86 specific subclass of TargetSubtargetInfo.
Nate Begemanf26625e2005-07-12 01:41:54 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "X86Subtarget.h"
Chris Lattnerdc842c02009-07-10 07:20:05 +000015#include "X86InstrInfo.h"
Eric Christopher4629ed72014-08-09 01:07:25 +000016#include "X86TargetMachine.h"
Bill Wendlingaef9c372013-02-15 22:31:27 +000017#include "llvm/IR/Attributes.h"
18#include "llvm/IR/Function.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000019#include "llvm/IR/GlobalValue.h"
Eric Christopher3470bbb2014-05-21 23:51:57 +000020#include "llvm/Support/CommandLine.h"
Evan Cheng9a3ec1b2009-01-03 04:04:46 +000021#include "llvm/Support/Debug.h"
Rafael Espindola65596562011-09-07 16:10:57 +000022#include "llvm/Support/ErrorHandling.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000023#include "llvm/Support/Host.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000024#include "llvm/Support/raw_ostream.h"
Anton Korobeynikov430e68a12006-12-22 22:29:05 +000025#include "llvm/Target/TargetMachine.h"
Rafael Espindola65596562011-09-07 16:10:57 +000026#include "llvm/Target/TargetOptions.h"
Evan Cheng54b68e32011-07-01 20:45:01 +000027
Chris Lattner3ad60b12009-04-25 18:27:23 +000028#if defined(_MSC_VER)
Bill Wendling6eecd562009-08-03 00:11:34 +000029#include <intrin.h>
Chris Lattner3ad60b12009-04-25 18:27:23 +000030#endif
31
Chandler Carruth84e68b22014-04-22 02:41:26 +000032using namespace llvm;
33
34#define DEBUG_TYPE "subtarget"
35
Chandler Carruthd174b722014-04-22 02:03:14 +000036#define GET_SUBTARGETINFO_TARGET_DESC
37#define GET_SUBTARGETINFO_CTOR
38#include "X86GenSubtargetInfo.inc"
39
Eric Christopher6b0fcfe2014-05-21 23:40:26 +000040// Temporary option to control early if-conversion for x86 while adding machine
41// models.
42static cl::opt<bool>
43X86EarlyIfConv("x86-early-ifcvt", cl::Hidden,
44 cl::desc("Enable early if-conversion on X86"));
45
46
Dan Gohman7a6611792009-11-20 23:18:13 +000047/// ClassifyBlockAddressReference - Classify a blockaddress reference for the
48/// current subtarget according to how we should reference it in a non-pcrel
49/// context.
Eric Christophere2fbc672013-04-02 23:06:40 +000050unsigned char X86Subtarget::ClassifyBlockAddressReference() const {
Dan Gohman7a6611792009-11-20 23:18:13 +000051 if (isPICStyleGOT()) // 32-bit ELF targets.
52 return X86II::MO_GOTOFF;
Chad Rosier24c19d22012-08-01 18:39:17 +000053
Dan Gohman7a6611792009-11-20 23:18:13 +000054 if (isPICStyleStubPIC()) // Darwin/32 in PIC mode.
55 return X86II::MO_PIC_BASE_OFFSET;
Chad Rosier24c19d22012-08-01 18:39:17 +000056
Dan Gohman7a6611792009-11-20 23:18:13 +000057 // Direct static reference to label.
58 return X86II::MO_NO_FLAG;
59}
60
Chris Lattnerdc842c02009-07-10 07:20:05 +000061/// ClassifyGlobalReference - Classify a global variable reference for the
62/// current subtarget according to how we should reference it in a non-pcrel
63/// context.
64unsigned char X86Subtarget::
65ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
66 // DLLImport only exists on windows, it is implemented as a load from a
67 // DLLIMPORT stub.
Nico Rieck7157bb72014-01-14 15:22:47 +000068 if (GV->hasDLLImportStorageClass())
Chris Lattnerdc842c02009-07-10 07:20:05 +000069 return X86II::MO_DLLIMPORT;
70
Rafael Espindola246c4fb2014-11-01 16:46:18 +000071 bool isDecl = GV->isDeclarationForLinker();
Evan Cheng02a76522009-07-16 22:53:10 +000072
Chris Lattnerdc842c02009-07-10 07:20:05 +000073 // X86-64 in PIC mode.
74 if (isPICStyleRIPRel()) {
75 // Large model never uses stubs.
76 if (TM.getCodeModel() == CodeModel::Large)
77 return X86II::MO_NO_FLAG;
Chad Rosier24c19d22012-08-01 18:39:17 +000078
Chris Lattner7dce9912009-07-10 21:01:59 +000079 if (isTargetDarwin()) {
80 // If symbol visibility is hidden, the extra load is not needed if
81 // target is x86-64 or the symbol is definitely defined in the current
82 // translation unit.
83 if (GV->hasDefaultVisibility() &&
Evan Cheng02a76522009-07-16 22:53:10 +000084 (isDecl || GV->isWeakForLinker()))
Chris Lattner7dce9912009-07-10 21:01:59 +000085 return X86II::MO_GOTPCREL;
Anton Korobeynikovdb9820e2010-08-21 17:21:11 +000086 } else if (!isTargetWin64()) {
Chris Lattner7dce9912009-07-10 21:01:59 +000087 assert(isTargetELF() && "Unknown rip-relative target");
Chris Lattnerdc842c02009-07-10 07:20:05 +000088
Chris Lattner7dce9912009-07-10 21:01:59 +000089 // Extra load is needed for all externally visible.
90 if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility())
91 return X86II::MO_GOTPCREL;
92 }
Chris Lattnerdc842c02009-07-10 07:20:05 +000093
94 return X86II::MO_NO_FLAG;
95 }
Chad Rosier24c19d22012-08-01 18:39:17 +000096
Chris Lattnerdc842c02009-07-10 07:20:05 +000097 if (isPICStyleGOT()) { // 32-bit ELF targets.
98 // Extra load is needed for all externally visible.
99 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
100 return X86II::MO_GOTOFF;
101 return X86II::MO_GOT;
102 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000103
Chris Lattner21c29402009-07-10 21:00:45 +0000104 if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000105 // Determine whether we have a stub reference and/or whether the reference
106 // is relative to the PIC base or not.
Chad Rosier24c19d22012-08-01 18:39:17 +0000107
Chris Lattnerdc842c02009-07-10 07:20:05 +0000108 // If this is a strong reference to a definition, it is definitely not
109 // through a stub.
Evan Cheng02a76522009-07-16 22:53:10 +0000110 if (!isDecl && !GV->isWeakForLinker())
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000111 return X86II::MO_PIC_BASE_OFFSET;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000112
113 // Unless we have a symbol with hidden visibility, we have to go through a
114 // normal $non_lazy_ptr stub because this symbol might be resolved late.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000115 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
116 return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
Chad Rosier24c19d22012-08-01 18:39:17 +0000117
Chris Lattnerdc842c02009-07-10 07:20:05 +0000118 // If symbol visibility is hidden, we have a stub for common symbol
119 // references and external declarations.
Evan Cheng02a76522009-07-16 22:53:10 +0000120 if (isDecl || GV->hasCommonLinkage()) {
Chris Lattnerdc842c02009-07-10 07:20:05 +0000121 // Hidden $non_lazy_ptr reference.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000122 return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000123 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000124
Chris Lattnerdc842c02009-07-10 07:20:05 +0000125 // Otherwise, no stub.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000126 return X86II::MO_PIC_BASE_OFFSET;
127 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000128
Chris Lattner21c29402009-07-10 21:00:45 +0000129 if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000130 // Determine whether we have a stub reference.
Chad Rosier24c19d22012-08-01 18:39:17 +0000131
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000132 // If this is a strong reference to a definition, it is definitely not
133 // through a stub.
Evan Cheng02a76522009-07-16 22:53:10 +0000134 if (!isDecl && !GV->isWeakForLinker())
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000135 return X86II::MO_NO_FLAG;
Chad Rosier24c19d22012-08-01 18:39:17 +0000136
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000137 // Unless we have a symbol with hidden visibility, we have to go through a
138 // normal $non_lazy_ptr stub because this symbol might be resolved late.
139 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
140 return X86II::MO_DARWIN_NONLAZY;
Evan Cheng1b389522009-09-03 07:04:02 +0000141
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000142 // Otherwise, no stub.
143 return X86II::MO_NO_FLAG;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000144 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000145
Chris Lattnerdc842c02009-07-10 07:20:05 +0000146 // Direct static reference to global.
147 return X86II::MO_NO_FLAG;
148}
149
Anton Korobeynikov6dbdfe22006-11-30 22:42:55 +0000150
Bill Wendlingbd092622008-09-30 21:22:07 +0000151/// getBZeroEntry - This function returns the name of a function which has an
152/// interface like the non-standard bzero function, if such a function exists on
153/// the current subtarget and it is considered prefereable over memset with zero
154/// passed as the second argument. Otherwise it returns null.
Bill Wendling17825842008-09-30 22:05:33 +0000155const char *X86Subtarget::getBZeroEntry() const {
Dan Gohman980d7202008-04-01 20:38:36 +0000156 // Darwin 10 has a __bzero entry point for this purpose.
Daniel Dunbarcd01ed52011-04-20 00:14:25 +0000157 if (getTargetTriple().isMacOSX() &&
158 !getTargetTriple().isMacOSXVersionLT(10, 6))
Bill Wendling17825842008-09-30 22:05:33 +0000159 return "__bzero";
Dan Gohman980d7202008-04-01 20:38:36 +0000160
Craig Topper062a2ba2014-04-25 05:30:21 +0000161 return nullptr;
Dan Gohman980d7202008-04-01 20:38:36 +0000162}
163
Evan Cheng0e88c7d2013-01-29 02:32:37 +0000164bool X86Subtarget::hasSinCos() const {
165 return getTargetTriple().isMacOSX() &&
Evan Chengd2ca4e22013-01-30 22:56:35 +0000166 !getTargetTriple().isMacOSXVersionLT(10, 9) &&
167 is64Bit();
Evan Cheng0e88c7d2013-01-29 02:32:37 +0000168}
169
Evan Cheng96098332009-05-20 04:53:57 +0000170/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
171/// to immediate address.
172bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
David Majnemer02f21882014-03-28 21:40:47 +0000173 // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
174 // but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does,
175 // the following check for Win32 should be removed.
176 if (In64BitMode || isTargetWin32())
Evan Cheng96098332009-05-20 04:53:57 +0000177 return false;
178 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
179}
180
Eric Christopherb68e2532014-09-03 20:36:31 +0000181void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
Nadav Rotem08ab8772013-02-27 05:56:20 +0000182 std::string CPUName = CPU;
Jim Grosbach48551fb2014-04-12 01:34:29 +0000183 if (CPUName.empty())
184 CPUName = "generic";
Evan Cheng964cb5f2011-07-08 21:14:14 +0000185
Jim Grosbach48551fb2014-04-12 01:34:29 +0000186 // Make sure 64-bit features are available in 64-bit mode. (But make sure
187 // SSE2 can be turned off explicitly.)
188 std::string FullFS = FS;
189 if (In64BitMode) {
190 if (!FullFS.empty())
191 FullFS = "+64bit,+sse2," + FullFS;
192 else
193 FullFS = "+64bit,+sse2";
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000194 }
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000195
Jim Grosbach48551fb2014-04-12 01:34:29 +0000196 // If feature string is not empty, parse features string.
197 ParseSubtargetFeatures(CPUName, FullFS);
198
199 // Make sure the right MCSchedModel is used.
Craig Toppera8442342013-09-18 05:54:09 +0000200 InitCPUSchedModel(CPUName);
Preston Gurd35fcb542012-10-03 15:55:13 +0000201
Andrew Tricke0c83b12012-08-07 00:25:30 +0000202 InstrItins = getInstrItineraryForCPU(CPUName);
Andrew Trick8523b162012-02-01 23:20:51 +0000203
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000204 // It's important to keep the MCSubtargetInfo feature bits in sync with
205 // target data structure which is shared with MC code emitter, etc.
206 if (In64BitMode)
207 ToggleFeature(X86::Mode64Bit);
Craig Topper3c80d622014-01-06 04:55:54 +0000208 else if (In32BitMode)
209 ToggleFeature(X86::Mode32Bit);
210 else if (In16BitMode)
211 ToggleFeature(X86::Mode16Bit);
212 else
213 llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!");
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000214
David Greene00411812010-01-05 01:29:13 +0000215 DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
Bill Wendling6eecd562009-08-03 00:11:34 +0000216 << ", 3DNowLevel " << X863DNowLevel
217 << ", 64bit " << HasX86_64 << "\n");
Evan Cheng13bcc6c2011-07-07 21:06:52 +0000218 assert((!In64BitMode || HasX86_64) &&
Dan Gohman74037512009-02-03 00:04:43 +0000219 "64-bit code requested on a subtarget that doesn't support it!");
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000220
Roman Divacky22135672012-11-09 20:10:44 +0000221 // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both
Roman Divackye8a93fe82011-02-22 17:30:05 +0000222 // 32 and 64 bit) and for all 64-bit targets.
Evan Cheng3a0c5e52011-06-23 17:54:54 +0000223 if (StackAlignOverride)
224 stackAlignment = StackAlignOverride;
Roman Divacky22135672012-11-09 20:10:44 +0000225 else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
226 In64BitMode)
Nate Begemanf26625e2005-07-12 01:41:54 +0000227 stackAlignment = 16;
Dan Gohmandc53f1c2010-05-27 18:43:40 +0000228}
Andrew Trick8523b162012-02-01 23:20:51 +0000229
Bill Wendling61375d82013-02-16 01:36:26 +0000230void X86Subtarget::initializeEnvironment() {
231 X86SSELevel = NoMMXSSE;
232 X863DNowLevel = NoThreeDNow;
233 HasCMov = false;
234 HasX86_64 = false;
235 HasPOPCNT = false;
236 HasSSE4A = false;
237 HasAES = false;
238 HasPCLMUL = false;
239 HasFMA = false;
240 HasFMA4 = false;
241 HasXOP = false;
Yunzhong Gaodd36e932013-09-24 18:21:52 +0000242 HasTBM = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000243 HasMOVBE = false;
244 HasRDRAND = false;
245 HasF16C = false;
246 HasFSGSBase = false;
247 HasLZCNT = false;
248 HasBMI = false;
249 HasBMI2 = false;
250 HasRTM = false;
Michael Liaoe344ec92013-03-26 22:46:02 +0000251 HasHLE = false;
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000252 HasERI = false;
253 HasCDI = false;
Craig Topper7a8cf012013-08-20 05:23:59 +0000254 HasPFI = false;
Robert Khasanovbfa01312014-07-21 14:54:21 +0000255 HasDQI = false;
256 HasBWI = false;
257 HasVLX = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000258 HasADX = false;
Ben Langmuir16501752013-09-12 15:51:31 +0000259 HasSHA = false;
Kevin Enderby0d928a12014-07-31 23:57:38 +0000260 HasSGX = false;
Michael Liao5173ee02013-03-26 17:47:11 +0000261 HasPRFCHW = false;
Michael Liaoa486a112013-03-28 23:41:26 +0000262 HasRDSEED = false;
Robert Khasanov98441b62014-08-21 09:16:12 +0000263 HasSMAP = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000264 IsBTMemSlow = false;
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000265 IsSHLDSlow = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000266 IsUAMemFast = false;
267 HasVectorUAMem = false;
268 HasCmpxchg16b = false;
269 UseLeaForSP = false;
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000270 HasSlowDivide32 = false;
271 HasSlowDivide64 = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000272 PadShortFunctions = false;
Preston Gurd663e6f92013-03-27 19:14:02 +0000273 CallRegIndirect = false;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000274 LEAUsesAG = false;
Alexey Volkov6226de62014-05-20 08:55:50 +0000275 SlowLEA = false;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000276 SlowIncDec = false;
Sanjay Patel957efc232014-10-24 17:02:16 +0000277 UseSqrtEst = false;
Sanjay Patel50fc6ff2014-11-11 23:13:15 +0000278 UseReciprocalEst = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000279 stackAlignment = 4;
280 // FIXME: this is a known good value for Yonah. How about others?
281 MaxInlineSizeThreshold = 128;
282}
283
Eric Christophere950b672014-08-09 04:38:53 +0000284static std::string computeDataLayout(const Triple &TT) {
Eric Christophera08f30b2014-06-09 17:08:19 +0000285 // X86 is little endian
286 std::string Ret = "e";
287
Eric Christophere950b672014-08-09 04:38:53 +0000288 Ret += DataLayout::getManglingComponent(TT);
Eric Christophera08f30b2014-06-09 17:08:19 +0000289 // X86 and x32 have 32 bit pointers.
Eric Christophere950b672014-08-09 04:38:53 +0000290 if ((TT.isArch64Bit() &&
291 (TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
292 !TT.isArch64Bit())
Eric Christophera08f30b2014-06-09 17:08:19 +0000293 Ret += "-p:32:32";
294
295 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
Eric Christophere950b672014-08-09 04:38:53 +0000296 if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
Eric Christophera08f30b2014-06-09 17:08:19 +0000297 Ret += "-i64:64";
298 else
299 Ret += "-f64:32:64";
300
301 // Some ABIs align long double to 128 bits, others to 32.
Eric Christophere950b672014-08-09 04:38:53 +0000302 if (TT.isOSNaCl())
Eric Christophera08f30b2014-06-09 17:08:19 +0000303 ; // No f80
Eric Christophere950b672014-08-09 04:38:53 +0000304 else if (TT.isArch64Bit() || TT.isOSDarwin())
Eric Christophera08f30b2014-06-09 17:08:19 +0000305 Ret += "-f80:128";
306 else
307 Ret += "-f80:32";
308
309 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
Eric Christophere950b672014-08-09 04:38:53 +0000310 if (TT.isArch64Bit())
Eric Christophera08f30b2014-06-09 17:08:19 +0000311 Ret += "-n8:16:32:64";
312 else
313 Ret += "-n8:16:32";
314
315 // The stack is aligned to 32 bits on some ABIs and 128 bits on others.
Duncan P. N. Exon Smithe85df162014-08-14 17:18:26 +0000316 if (!TT.isArch64Bit() && TT.isOSWindows())
Eric Christophera08f30b2014-06-09 17:08:19 +0000317 Ret += "-S32";
318 else
319 Ret += "-S128";
320
321 return Ret;
322}
323
Eric Christopher1a212032014-06-11 00:25:19 +0000324X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,
325 StringRef FS) {
326 initializeEnvironment();
Eric Christopherb68e2532014-09-03 20:36:31 +0000327 initSubtargetFeatures(CPU, FS);
Eric Christopher1a212032014-06-11 00:25:19 +0000328 return *this;
329}
330
Bill Wendlingaef9c372013-02-15 22:31:27 +0000331X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
Eric Christopher12f4a782014-10-01 20:38:22 +0000332 const std::string &FS, const X86TargetMachine &TM,
Eric Christophera08f30b2014-06-09 17:08:19 +0000333 unsigned StackAlignOverride)
Eric Christopherb8f97682014-05-07 21:05:47 +0000334 : X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
335 PICStyle(PICStyles::None), TargetTriple(TT),
Eric Christophere950b672014-08-09 04:38:53 +0000336 DL(computeDataLayout(TargetTriple)),
Eric Christopherb8f97682014-05-07 21:05:47 +0000337 StackAlignOverride(StackAlignOverride),
338 In64BitMode(TargetTriple.getArch() == Triple::x86_64),
339 In32BitMode(TargetTriple.getArch() == Triple::x86 &&
340 TargetTriple.getEnvironment() != Triple::CODE16),
341 In16BitMode(TargetTriple.getArch() == Triple::x86 &&
Eric Christophera08f30b2014-06-09 17:08:19 +0000342 TargetTriple.getEnvironment() == Triple::CODE16),
Eric Christophere950b672014-08-09 04:38:53 +0000343 TSInfo(DL), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
344 TLInfo(TM), FrameLowering(TargetFrameLowering::StackGrowsDown,
Eric Christopher79cc1e32014-09-02 22:28:02 +0000345 getStackAlignment(), is64Bit() ? -8 : -4) {
Eric Christopher4629ed72014-08-09 01:07:25 +0000346 // Determine the PICStyle based on the target selected.
347 if (TM.getRelocationModel() == Reloc::Static) {
348 // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
349 setPICStyle(PICStyles::None);
350 } else if (is64Bit()) {
351 // PIC in 64 bit mode is always rip-rel.
352 setPICStyle(PICStyles::RIPRel);
353 } else if (isTargetCOFF()) {
354 setPICStyle(PICStyles::None);
355 } else if (isTargetDarwin()) {
356 if (TM.getRelocationModel() == Reloc::PIC_)
357 setPICStyle(PICStyles::StubPIC);
358 else {
359 assert(TM.getRelocationModel() == Reloc::DynamicNoPIC);
360 setPICStyle(PICStyles::StubDynamicNoPIC);
361 }
362 } else if (isTargetELF()) {
363 setPICStyle(PICStyles::GOT);
364 }
365}
Bill Wendlingaef9c372013-02-15 22:31:27 +0000366
Sanjay Patela2f658d2014-07-15 22:39:58 +0000367bool X86Subtarget::enableEarlyIfConversion() const {
Eric Christopher3470bbb2014-05-21 23:51:57 +0000368 return hasCMov() && X86EarlyIfConv;
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000369}
Sanjay Patela2f658d2014-07-15 22:39:58 +0000370