blob: d02a99f081a660505668b84c5c0b6175b5c51027 [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
Sanjay Patel2e753412015-08-14 15:11:42 +000047/// Classify a blockaddress reference for the current subtarget according to how
48/// we should reference it in a non-pcrel context.
Eric Christophere2fbc672013-04-02 23:06:40 +000049unsigned char X86Subtarget::ClassifyBlockAddressReference() const {
Dan Gohman7a6611792009-11-20 23:18:13 +000050 if (isPICStyleGOT()) // 32-bit ELF targets.
51 return X86II::MO_GOTOFF;
Chad Rosier24c19d22012-08-01 18:39:17 +000052
Dan Gohman7a6611792009-11-20 23:18:13 +000053 if (isPICStyleStubPIC()) // Darwin/32 in PIC mode.
54 return X86II::MO_PIC_BASE_OFFSET;
Chad Rosier24c19d22012-08-01 18:39:17 +000055
Dan Gohman7a6611792009-11-20 23:18:13 +000056 // Direct static reference to label.
57 return X86II::MO_NO_FLAG;
58}
59
Sanjay Patel2e753412015-08-14 15:11:42 +000060/// Classify a global variable reference for the current subtarget according to
61/// how we should reference it in a non-pcrel context.
Chris Lattnerdc842c02009-07-10 07:20:05 +000062unsigned char X86Subtarget::
63ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
64 // DLLImport only exists on windows, it is implemented as a load from a
65 // DLLIMPORT stub.
Nico Rieck7157bb72014-01-14 15:22:47 +000066 if (GV->hasDLLImportStorageClass())
Chris Lattnerdc842c02009-07-10 07:20:05 +000067 return X86II::MO_DLLIMPORT;
68
Peter Collingbourne6a9d1772015-07-05 20:52:35 +000069 bool isDef = GV->isStrongDefinitionForLinker();
Evan Cheng02a76522009-07-16 22:53:10 +000070
Chris Lattnerdc842c02009-07-10 07:20:05 +000071 // X86-64 in PIC mode.
72 if (isPICStyleRIPRel()) {
73 // Large model never uses stubs.
74 if (TM.getCodeModel() == CodeModel::Large)
75 return X86II::MO_NO_FLAG;
Chad Rosier24c19d22012-08-01 18:39:17 +000076
Chris Lattner7dce9912009-07-10 21:01:59 +000077 if (isTargetDarwin()) {
78 // If symbol visibility is hidden, the extra load is not needed if
79 // target is x86-64 or the symbol is definitely defined in the current
80 // translation unit.
Peter Collingbourne6a9d1772015-07-05 20:52:35 +000081 if (GV->hasDefaultVisibility() && !isDef)
Chris Lattner7dce9912009-07-10 21:01:59 +000082 return X86II::MO_GOTPCREL;
Anton Korobeynikovdb9820e2010-08-21 17:21:11 +000083 } else if (!isTargetWin64()) {
Chris Lattner7dce9912009-07-10 21:01:59 +000084 assert(isTargetELF() && "Unknown rip-relative target");
Chris Lattnerdc842c02009-07-10 07:20:05 +000085
Sriraman Tallam3cb77342016-04-22 21:41:58 +000086 // Extra load is needed for all externally visible globals except with
87 // PIE as the definition of the global in an executable is not
88 // overridden.
89
90 if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility() &&
91 !isGlobalDefinedInPIE(GV, TM))
Chris Lattner7dce9912009-07-10 21:01:59 +000092 return X86II::MO_GOTPCREL;
93 }
Chris Lattnerdc842c02009-07-10 07:20:05 +000094
95 return X86II::MO_NO_FLAG;
96 }
Chad Rosier24c19d22012-08-01 18:39:17 +000097
Chris Lattnerdc842c02009-07-10 07:20:05 +000098 if (isPICStyleGOT()) { // 32-bit ELF targets.
Sriraman Tallam3cb77342016-04-22 21:41:58 +000099 // Extra load is needed for all externally visible globals except with
100 // PIE as the definition of the global in an executable is not overridden.
101
102 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility() ||
103 isGlobalDefinedInPIE(GV, TM))
Chris Lattnerdc842c02009-07-10 07:20:05 +0000104 return X86II::MO_GOTOFF;
105 return X86II::MO_GOT;
106 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000107
Chris Lattner21c29402009-07-10 21:00:45 +0000108 if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000109 // Determine whether we have a stub reference and/or whether the reference
110 // is relative to the PIC base or not.
Chad Rosier24c19d22012-08-01 18:39:17 +0000111
Chris Lattnerdc842c02009-07-10 07:20:05 +0000112 // If this is a strong reference to a definition, it is definitely not
113 // through a stub.
Peter Collingbourne6a9d1772015-07-05 20:52:35 +0000114 if (isDef)
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000115 return X86II::MO_PIC_BASE_OFFSET;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000116
117 // Unless we have a symbol with hidden visibility, we have to go through a
118 // normal $non_lazy_ptr stub because this symbol might be resolved late.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000119 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
120 return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
Chad Rosier24c19d22012-08-01 18:39:17 +0000121
Chris Lattnerdc842c02009-07-10 07:20:05 +0000122 // If symbol visibility is hidden, we have a stub for common symbol
123 // references and external declarations.
Peter Collingbourne6a9d1772015-07-05 20:52:35 +0000124 if (GV->isDeclarationForLinker() || GV->hasCommonLinkage()) {
Chris Lattnerdc842c02009-07-10 07:20:05 +0000125 // Hidden $non_lazy_ptr reference.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000126 return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000127 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000128
Chris Lattnerdc842c02009-07-10 07:20:05 +0000129 // Otherwise, no stub.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000130 return X86II::MO_PIC_BASE_OFFSET;
131 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000132
Chris Lattner21c29402009-07-10 21:00:45 +0000133 if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode.
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000134 // Determine whether we have a stub reference.
Chad Rosier24c19d22012-08-01 18:39:17 +0000135
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000136 // If this is a strong reference to a definition, it is definitely not
137 // through a stub.
Peter Collingbourne6a9d1772015-07-05 20:52:35 +0000138 if (isDef)
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000139 return X86II::MO_NO_FLAG;
Chad Rosier24c19d22012-08-01 18:39:17 +0000140
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000141 // Unless we have a symbol with hidden visibility, we have to go through a
142 // normal $non_lazy_ptr stub because this symbol might be resolved late.
143 if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
144 return X86II::MO_DARWIN_NONLAZY;
Evan Cheng1b389522009-09-03 07:04:02 +0000145
Chris Lattnerbd3e5602009-07-10 20:53:38 +0000146 // Otherwise, no stub.
147 return X86II::MO_NO_FLAG;
Chris Lattnerdc842c02009-07-10 07:20:05 +0000148 }
Chad Rosier24c19d22012-08-01 18:39:17 +0000149
Chris Lattnerdc842c02009-07-10 07:20:05 +0000150 // Direct static reference to global.
151 return X86II::MO_NO_FLAG;
152}
153
Asaf Badouh89406d12016-04-20 08:32:57 +0000154unsigned char X86Subtarget::classifyGlobalFunctionReference(
155 const GlobalValue *GV, const TargetMachine &TM) const {
156 // On ELF targets, in both X86-64 and X86-32 mode, direct calls to
157 // external symbols most go through the PLT in PIC mode. If the symbol
158 // has hidden or protected visibility, or if it is static or local, then
159 // we don't need to use the PLT - we can directly call it.
160 // In PIE mode, calls to global functions don't need to go through PLT
161 if (isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
162 (!TM.Options.PositionIndependentExecutable ||
163 GV->isDeclarationForLinker()) &&
164 GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
165 return X86II::MO_PLT;
166 } else if (isPICStyleStubAny() && !GV->isStrongDefinitionForLinker() &&
167 (!getTargetTriple().isMacOSX() ||
168 getTargetTriple().isMacOSXVersionLT(10, 5))) {
169 // PC-relative references to external symbols should go through $stub,
170 // unless we're building with the leopard linker or later, which
171 // automatically synthesizes these stubs.
172 return X86II::MO_DARWIN_STUB;
173 } else if (isPICStyleRIPRel() && isa<Function>(GV) &&
174 cast<Function>(GV)->hasFnAttribute(Attribute::NonLazyBind)) {
175 // If the function is marked as non-lazy, generate an indirect call
176 // which loads from the GOT directly. This avoids runtime overhead
177 // at the cost of eager binding (and one extra byte of encoding).
178 return X86II::MO_GOTPCREL;
179 }
180
181 return X86II::MO_NO_FLAG;
182}
Anton Korobeynikov6dbdfe22006-11-30 22:42:55 +0000183
Sanjay Patel2e753412015-08-14 15:11:42 +0000184/// This function returns the name of a function which has an interface like
185/// the non-standard bzero function, if such a function exists on the
186/// current subtarget and it is considered preferable over memset with zero
Bill Wendlingbd092622008-09-30 21:22:07 +0000187/// passed as the second argument. Otherwise it returns null.
Bill Wendling17825842008-09-30 22:05:33 +0000188const char *X86Subtarget::getBZeroEntry() const {
Dan Gohman980d7202008-04-01 20:38:36 +0000189 // Darwin 10 has a __bzero entry point for this purpose.
Daniel Dunbarcd01ed52011-04-20 00:14:25 +0000190 if (getTargetTriple().isMacOSX() &&
191 !getTargetTriple().isMacOSXVersionLT(10, 6))
Bill Wendling17825842008-09-30 22:05:33 +0000192 return "__bzero";
Dan Gohman980d7202008-04-01 20:38:36 +0000193
Craig Topper062a2ba2014-04-25 05:30:21 +0000194 return nullptr;
Dan Gohman980d7202008-04-01 20:38:36 +0000195}
196
Evan Cheng0e88c7d2013-01-29 02:32:37 +0000197bool X86Subtarget::hasSinCos() const {
198 return getTargetTriple().isMacOSX() &&
Evan Chengd2ca4e22013-01-30 22:56:35 +0000199 !getTargetTriple().isMacOSXVersionLT(10, 9) &&
200 is64Bit();
Evan Cheng0e88c7d2013-01-29 02:32:37 +0000201}
202
Sanjay Patel2e753412015-08-14 15:11:42 +0000203/// Return true if the subtarget allows calls to immediate address.
Evan Cheng96098332009-05-20 04:53:57 +0000204bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
David Majnemer02f21882014-03-28 21:40:47 +0000205 // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
206 // but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does,
207 // the following check for Win32 should be removed.
208 if (In64BitMode || isTargetWin32())
Evan Cheng96098332009-05-20 04:53:57 +0000209 return false;
210 return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
211}
212
Eric Christopherb68e2532014-09-03 20:36:31 +0000213void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
Nadav Rotem08ab8772013-02-27 05:56:20 +0000214 std::string CPUName = CPU;
Jim Grosbach48551fb2014-04-12 01:34:29 +0000215 if (CPUName.empty())
216 CPUName = "generic";
Evan Cheng964cb5f2011-07-08 21:14:14 +0000217
Jim Grosbach48551fb2014-04-12 01:34:29 +0000218 // Make sure 64-bit features are available in 64-bit mode. (But make sure
219 // SSE2 can be turned off explicitly.)
220 std::string FullFS = FS;
221 if (In64BitMode) {
222 if (!FullFS.empty())
223 FullFS = "+64bit,+sse2," + FullFS;
224 else
225 FullFS = "+64bit,+sse2";
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000226 }
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000227
Hans Wennborg5000ce82015-12-04 23:00:33 +0000228 // LAHF/SAHF are always supported in non-64-bit mode.
229 if (!In64BitMode) {
230 if (!FullFS.empty())
231 FullFS = "+sahf," + FullFS;
232 else
233 FullFS = "+sahf";
234 }
235
236
Duncan P. N. Exon Smithbb57d732015-07-10 22:33:01 +0000237 // Parse features string and set the CPU.
Jim Grosbach48551fb2014-04-12 01:34:29 +0000238 ParseSubtargetFeatures(CPUName, FullFS);
239
Sanjay Pateldeb8f822015-08-25 16:29:21 +0000240 // All CPUs that implement SSE4.2 or SSE4A support unaligned accesses of
241 // 16-bytes and under that are reasonably fast. These features were
242 // introduced with Intel's Nehalem/Silvermont and AMD's Family10h
243 // micro-architectures respectively.
244 if (hasSSE42() || hasSSE4A())
Sanjay Patel30145672015-09-01 20:51:51 +0000245 IsUAMem16Slow = false;
Sanjay Pateldeb8f822015-08-25 16:29:21 +0000246
Andrew Tricke0c83b12012-08-07 00:25:30 +0000247 InstrItins = getInstrItineraryForCPU(CPUName);
Andrew Trick8523b162012-02-01 23:20:51 +0000248
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000249 // It's important to keep the MCSubtargetInfo feature bits in sync with
250 // target data structure which is shared with MC code emitter, etc.
251 if (In64BitMode)
252 ToggleFeature(X86::Mode64Bit);
Craig Topper3c80d622014-01-06 04:55:54 +0000253 else if (In32BitMode)
254 ToggleFeature(X86::Mode32Bit);
255 else if (In16BitMode)
256 ToggleFeature(X86::Mode16Bit);
257 else
258 llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!");
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000259
David Greene00411812010-01-05 01:29:13 +0000260 DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
Bill Wendling6eecd562009-08-03 00:11:34 +0000261 << ", 3DNowLevel " << X863DNowLevel
262 << ", 64bit " << HasX86_64 << "\n");
Evan Cheng13bcc6c2011-07-07 21:06:52 +0000263 assert((!In64BitMode || HasX86_64) &&
Dan Gohman74037512009-02-03 00:04:43 +0000264 "64-bit code requested on a subtarget that doesn't support it!");
Evan Cheng11b0a5d2006-09-08 06:48:29 +0000265
Roman Divacky22135672012-11-09 20:10:44 +0000266 // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both
Roman Divackye8a93fe82011-02-22 17:30:05 +0000267 // 32 and 64 bit) and for all 64-bit targets.
Evan Cheng3a0c5e52011-06-23 17:54:54 +0000268 if (StackAlignOverride)
269 stackAlignment = StackAlignOverride;
Roman Divacky22135672012-11-09 20:10:44 +0000270 else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
271 In64BitMode)
Nate Begemanf26625e2005-07-12 01:41:54 +0000272 stackAlignment = 16;
Dan Gohmandc53f1c2010-05-27 18:43:40 +0000273}
Andrew Trick8523b162012-02-01 23:20:51 +0000274
Bill Wendling61375d82013-02-16 01:36:26 +0000275void X86Subtarget::initializeEnvironment() {
Eric Christopher11e59832015-10-08 20:10:06 +0000276 X86SSELevel = NoSSE;
Bill Wendling61375d82013-02-16 01:36:26 +0000277 X863DNowLevel = NoThreeDNow;
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000278 HasX87 = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000279 HasCMov = false;
280 HasX86_64 = false;
281 HasPOPCNT = false;
282 HasSSE4A = false;
283 HasAES = false;
Craig Topper09b65982015-10-16 06:03:09 +0000284 HasFXSR = false;
Amjad Aboud1db6d7a2015-10-12 11:47:46 +0000285 HasXSAVE = false;
286 HasXSAVEOPT = false;
287 HasXSAVEC = false;
288 HasXSAVES = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000289 HasPCLMUL = false;
290 HasFMA = false;
291 HasFMA4 = false;
292 HasXOP = false;
Yunzhong Gaodd36e932013-09-24 18:21:52 +0000293 HasTBM = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000294 HasMOVBE = false;
295 HasRDRAND = false;
296 HasF16C = false;
297 HasFSGSBase = false;
298 HasLZCNT = false;
299 HasBMI = false;
300 HasBMI2 = false;
Michael Zuckerman97b6a6922016-01-17 13:42:12 +0000301 HasVBMI = false;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000302 HasIFMA = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000303 HasRTM = false;
Michael Liaoe344ec92013-03-26 22:46:02 +0000304 HasHLE = false;
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000305 HasERI = false;
306 HasCDI = false;
Craig Topper7a8cf012013-08-20 05:23:59 +0000307 HasPFI = false;
Robert Khasanovbfa01312014-07-21 14:54:21 +0000308 HasDQI = false;
309 HasBWI = false;
310 HasVLX = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000311 HasADX = false;
Asaf Badouh5acf66f2015-12-15 13:35:29 +0000312 HasPKU = false;
Ben Langmuir16501752013-09-12 15:51:31 +0000313 HasSHA = false;
Michael Liao5173ee02013-03-26 17:47:11 +0000314 HasPRFCHW = false;
Michael Liaoa486a112013-03-28 23:41:26 +0000315 HasRDSEED = false;
Hans Wennborg5000ce82015-12-04 23:00:33 +0000316 HasLAHFSAHF = false;
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000317 HasMPX = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000318 IsBTMemSlow = false;
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000319 IsSHLDSlow = false;
Sanjay Patel30145672015-09-01 20:51:51 +0000320 IsUAMem16Slow = false;
Sanjay Patel501890e2014-11-21 17:40:04 +0000321 IsUAMem32Slow = false;
Sanjay Patelffd039b2015-02-03 17:13:04 +0000322 HasSSEUnalignedMem = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000323 HasCmpxchg16b = false;
324 UseLeaForSP = false;
Yunzhong Gao0de36ec2016-02-12 23:37:57 +0000325 HasFastPartialYMMWrite = false;
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000326 HasSlowDivide32 = false;
327 HasSlowDivide64 = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000328 PadShortFunctions = false;
Preston Gurd663e6f92013-03-27 19:14:02 +0000329 CallRegIndirect = false;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000330 LEAUsesAG = false;
Alexey Volkov6226de62014-05-20 08:55:50 +0000331 SlowLEA = false;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000332 SlowIncDec = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000333 stackAlignment = 4;
334 // FIXME: this is a known good value for Yonah. How about others?
335 MaxInlineSizeThreshold = 128;
Eric Christopher824f42f2015-05-12 01:26:05 +0000336 UseSoftFloat = false;
Bill Wendling61375d82013-02-16 01:36:26 +0000337}
338
Eric Christopher1a212032014-06-11 00:25:19 +0000339X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,
340 StringRef FS) {
341 initializeEnvironment();
Eric Christopherb68e2532014-09-03 20:36:31 +0000342 initSubtargetFeatures(CPU, FS);
Eric Christopher1a212032014-06-11 00:25:19 +0000343 return *this;
344}
345
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000346X86Subtarget::X86Subtarget(const Triple &TT, const std::string &CPU,
Eric Christopher12f4a782014-10-01 20:38:22 +0000347 const std::string &FS, const X86TargetMachine &TM,
Eric Christophera08f30b2014-06-09 17:08:19 +0000348 unsigned StackAlignOverride)
Daniel Sanders50f17232015-09-15 16:17:27 +0000349 : X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
Eric Christopherb8f97682014-05-07 21:05:47 +0000350 PICStyle(PICStyles::None), TargetTriple(TT),
351 StackAlignOverride(StackAlignOverride),
352 In64BitMode(TargetTriple.getArch() == Triple::x86_64),
353 In32BitMode(TargetTriple.getArch() == Triple::x86 &&
354 TargetTriple.getEnvironment() != Triple::CODE16),
355 In16BitMode(TargetTriple.getArch() == Triple::x86 &&
Eric Christophera08f30b2014-06-09 17:08:19 +0000356 TargetTriple.getEnvironment() == Triple::CODE16),
Mehdi Amini157e5a62015-07-09 02:10:08 +0000357 TSInfo(), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
358 TLInfo(TM, *this), FrameLowering(*this, getStackAlignment()) {
Eric Christopher4629ed72014-08-09 01:07:25 +0000359 // Determine the PICStyle based on the target selected.
360 if (TM.getRelocationModel() == Reloc::Static) {
361 // Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
362 setPICStyle(PICStyles::None);
363 } else if (is64Bit()) {
364 // PIC in 64 bit mode is always rip-rel.
365 setPICStyle(PICStyles::RIPRel);
366 } else if (isTargetCOFF()) {
367 setPICStyle(PICStyles::None);
368 } else if (isTargetDarwin()) {
369 if (TM.getRelocationModel() == Reloc::PIC_)
370 setPICStyle(PICStyles::StubPIC);
371 else {
372 assert(TM.getRelocationModel() == Reloc::DynamicNoPIC);
373 setPICStyle(PICStyles::StubDynamicNoPIC);
374 }
375 } else if (isTargetELF()) {
376 setPICStyle(PICStyles::GOT);
377 }
378}
Bill Wendlingaef9c372013-02-15 22:31:27 +0000379
Sanjay Patela2f658d2014-07-15 22:39:58 +0000380bool X86Subtarget::enableEarlyIfConversion() const {
Eric Christopher3470bbb2014-05-21 23:51:57 +0000381 return hasCMov() && X86EarlyIfConv;
Eric Christopher6b0fcfe2014-05-21 23:40:26 +0000382}
Sanjay Patela2f658d2014-07-15 22:39:58 +0000383