2010-12-04 23:57:24 +00:00
|
|
|
//===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===//
|
2005-07-12 01:41:54 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-07-12 01:41:54 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-01 21:01:15 +00:00
|
|
|
// This file implements the X86 specific subclass of TargetSubtargetInfo.
|
2005-07-12 01:41:54 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "X86Subtarget.h"
|
2009-07-10 07:20:05 +00:00
|
|
|
#include "X86InstrInfo.h"
|
2014-08-09 01:07:25 +00:00
|
|
|
#include "X86TargetMachine.h"
|
2013-02-15 22:31:27 +00:00
|
|
|
#include "llvm/IR/Attributes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/GlobalValue.h"
|
2014-05-21 23:51:57 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-01-03 04:04:46 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2011-09-07 16:10:57 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/Host.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2006-12-22 22:29:05 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2011-09-07 16:10:57 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2011-07-01 20:45:01 +00:00
|
|
|
|
2009-04-25 18:27:23 +00:00
|
|
|
#if defined(_MSC_VER)
|
2009-08-03 00:11:34 +00:00
|
|
|
#include <intrin.h>
|
2009-04-25 18:27:23 +00:00
|
|
|
#endif
|
|
|
|
|
2014-04-22 02:41:26 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "subtarget"
|
|
|
|
|
2014-04-22 02:03:14 +00:00
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
|
|
|
#include "X86GenSubtargetInfo.inc"
|
|
|
|
|
2014-05-21 23:40:26 +00:00
|
|
|
// Temporary option to control early if-conversion for x86 while adding machine
|
|
|
|
// models.
|
|
|
|
static cl::opt<bool>
|
|
|
|
X86EarlyIfConv("x86-early-ifcvt", cl::Hidden,
|
|
|
|
cl::desc("Enable early if-conversion on X86"));
|
|
|
|
|
|
|
|
|
2009-11-20 23:18:13 +00:00
|
|
|
/// ClassifyBlockAddressReference - Classify a blockaddress reference for the
|
|
|
|
/// current subtarget according to how we should reference it in a non-pcrel
|
|
|
|
/// context.
|
2013-04-02 23:06:40 +00:00
|
|
|
unsigned char X86Subtarget::ClassifyBlockAddressReference() const {
|
2009-11-20 23:18:13 +00:00
|
|
|
if (isPICStyleGOT()) // 32-bit ELF targets.
|
|
|
|
return X86II::MO_GOTOFF;
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-11-20 23:18:13 +00:00
|
|
|
if (isPICStyleStubPIC()) // Darwin/32 in PIC mode.
|
|
|
|
return X86II::MO_PIC_BASE_OFFSET;
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-11-20 23:18:13 +00:00
|
|
|
// Direct static reference to label.
|
|
|
|
return X86II::MO_NO_FLAG;
|
|
|
|
}
|
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
/// ClassifyGlobalReference - Classify a global variable reference for the
|
|
|
|
/// current subtarget according to how we should reference it in a non-pcrel
|
|
|
|
/// context.
|
|
|
|
unsigned char X86Subtarget::
|
|
|
|
ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const {
|
|
|
|
// DLLImport only exists on windows, it is implemented as a load from a
|
|
|
|
// DLLIMPORT stub.
|
2014-01-14 15:22:47 +00:00
|
|
|
if (GV->hasDLLImportStorageClass())
|
2009-07-10 07:20:05 +00:00
|
|
|
return X86II::MO_DLLIMPORT;
|
|
|
|
|
2010-06-14 20:11:56 +00:00
|
|
|
// Determine whether this is a reference to a definition or a declaration.
|
|
|
|
// Materializable GVs (in JIT lazy compilation mode) do not require an extra
|
|
|
|
// load from stub.
|
|
|
|
bool isDecl = GV->hasAvailableExternallyLinkage();
|
|
|
|
if (GV->isDeclaration() && !GV->isMaterializable())
|
|
|
|
isDecl = true;
|
2009-07-16 22:53:10 +00:00
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
// X86-64 in PIC mode.
|
|
|
|
if (isPICStyleRIPRel()) {
|
|
|
|
// Large model never uses stubs.
|
|
|
|
if (TM.getCodeModel() == CodeModel::Large)
|
|
|
|
return X86II::MO_NO_FLAG;
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 21:01:59 +00:00
|
|
|
if (isTargetDarwin()) {
|
|
|
|
// If symbol visibility is hidden, the extra load is not needed if
|
|
|
|
// target is x86-64 or the symbol is definitely defined in the current
|
|
|
|
// translation unit.
|
|
|
|
if (GV->hasDefaultVisibility() &&
|
2009-07-16 22:53:10 +00:00
|
|
|
(isDecl || GV->isWeakForLinker()))
|
2009-07-10 21:01:59 +00:00
|
|
|
return X86II::MO_GOTPCREL;
|
2010-08-21 17:21:11 +00:00
|
|
|
} else if (!isTargetWin64()) {
|
2009-07-10 21:01:59 +00:00
|
|
|
assert(isTargetELF() && "Unknown rip-relative target");
|
2009-07-10 07:20:05 +00:00
|
|
|
|
2009-07-10 21:01:59 +00:00
|
|
|
// Extra load is needed for all externally visible.
|
|
|
|
if (!GV->hasLocalLinkage() && GV->hasDefaultVisibility())
|
|
|
|
return X86II::MO_GOTPCREL;
|
|
|
|
}
|
2009-07-10 07:20:05 +00:00
|
|
|
|
|
|
|
return X86II::MO_NO_FLAG;
|
|
|
|
}
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
if (isPICStyleGOT()) { // 32-bit ELF targets.
|
|
|
|
// Extra load is needed for all externally visible.
|
|
|
|
if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
|
|
|
|
return X86II::MO_GOTOFF;
|
|
|
|
return X86II::MO_GOT;
|
|
|
|
}
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 21:00:45 +00:00
|
|
|
if (isPICStyleStubPIC()) { // Darwin/32 in PIC mode.
|
2009-07-10 20:53:38 +00:00
|
|
|
// Determine whether we have a stub reference and/or whether the reference
|
|
|
|
// is relative to the PIC base or not.
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
2009-07-16 22:53:10 +00:00
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
2009-07-10 20:53:38 +00:00
|
|
|
return X86II::MO_PIC_BASE_OFFSET;
|
2009-07-10 07:20:05 +00:00
|
|
|
|
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
2009-07-10 20:53:38 +00:00
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return X86II::MO_DARWIN_NONLAZY_PIC_BASE;
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 20:53:38 +00:00
|
|
|
// If symbol visibility is hidden, we have a stub for common symbol
|
|
|
|
// references and external declarations.
|
2009-07-16 22:53:10 +00:00
|
|
|
if (isDecl || GV->hasCommonLinkage()) {
|
2009-07-10 20:53:38 +00:00
|
|
|
// Hidden $non_lazy_ptr reference.
|
|
|
|
return X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE;
|
2009-07-10 07:20:05 +00:00
|
|
|
}
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 20:53:38 +00:00
|
|
|
// Otherwise, no stub.
|
|
|
|
return X86II::MO_PIC_BASE_OFFSET;
|
|
|
|
}
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 21:00:45 +00:00
|
|
|
if (isPICStyleStubNoDynamic()) { // Darwin/32 in -mdynamic-no-pic mode.
|
2009-07-10 20:53:38 +00:00
|
|
|
// Determine whether we have a stub reference.
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 20:53:38 +00:00
|
|
|
// If this is a strong reference to a definition, it is definitely not
|
|
|
|
// through a stub.
|
2009-07-16 22:53:10 +00:00
|
|
|
if (!isDecl && !GV->isWeakForLinker())
|
2009-07-10 20:53:38 +00:00
|
|
|
return X86II::MO_NO_FLAG;
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 20:53:38 +00:00
|
|
|
// Unless we have a symbol with hidden visibility, we have to go through a
|
|
|
|
// normal $non_lazy_ptr stub because this symbol might be resolved late.
|
|
|
|
if (!GV->hasHiddenVisibility()) // Non-hidden $non_lazy_ptr reference.
|
|
|
|
return X86II::MO_DARWIN_NONLAZY;
|
2009-09-03 07:04:02 +00:00
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
// Otherwise, no stub.
|
2009-07-10 20:53:38 +00:00
|
|
|
return X86II::MO_NO_FLAG;
|
2009-07-10 07:20:05 +00:00
|
|
|
}
|
2012-08-01 18:39:17 +00:00
|
|
|
|
2009-07-10 07:20:05 +00:00
|
|
|
// Direct static reference to global.
|
|
|
|
return X86II::MO_NO_FLAG;
|
|
|
|
}
|
|
|
|
|
2006-11-30 22:42:55 +00:00
|
|
|
|
2008-09-30 21:22:07 +00:00
|
|
|
/// getBZeroEntry - This function returns the name of a function which has an
|
|
|
|
/// interface like the non-standard bzero function, if such a function exists on
|
|
|
|
/// the current subtarget and it is considered prefereable over memset with zero
|
|
|
|
/// passed as the second argument. Otherwise it returns null.
|
2008-09-30 22:05:33 +00:00
|
|
|
const char *X86Subtarget::getBZeroEntry() const {
|
2008-04-01 20:38:36 +00:00
|
|
|
// Darwin 10 has a __bzero entry point for this purpose.
|
2011-04-20 00:14:25 +00:00
|
|
|
if (getTargetTriple().isMacOSX() &&
|
|
|
|
!getTargetTriple().isMacOSXVersionLT(10, 6))
|
2008-09-30 22:05:33 +00:00
|
|
|
return "__bzero";
|
2008-04-01 20:38:36 +00:00
|
|
|
|
2014-04-25 05:30:21 +00:00
|
|
|
return nullptr;
|
2008-04-01 20:38:36 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 02:32:37 +00:00
|
|
|
bool X86Subtarget::hasSinCos() const {
|
|
|
|
return getTargetTriple().isMacOSX() &&
|
2013-01-30 22:56:35 +00:00
|
|
|
!getTargetTriple().isMacOSXVersionLT(10, 9) &&
|
|
|
|
is64Bit();
|
2013-01-29 02:32:37 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 04:53:57 +00:00
|
|
|
/// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
|
|
|
|
/// to immediate address.
|
|
|
|
bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
|
2014-03-28 21:40:47 +00:00
|
|
|
// FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
|
|
|
|
// but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does,
|
|
|
|
// the following check for Win32 should be removed.
|
|
|
|
if (In64BitMode || isTargetWin32())
|
2009-05-20 04:53:57 +00:00
|
|
|
return false;
|
|
|
|
return isTargetELF() || TM.getRelocationModel() == Reloc::Static;
|
|
|
|
}
|
|
|
|
|
2014-09-03 20:36:31 +00:00
|
|
|
void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
2013-02-27 05:56:20 +00:00
|
|
|
std::string CPUName = CPU;
|
2014-04-12 01:34:29 +00:00
|
|
|
if (CPUName.empty())
|
|
|
|
CPUName = "generic";
|
2011-07-08 23:43:01 +00:00
|
|
|
|
2014-04-12 01:34:29 +00:00
|
|
|
// Make sure 64-bit features are available in 64-bit mode. (But make sure
|
|
|
|
// SSE2 can be turned off explicitly.)
|
|
|
|
std::string FullFS = FS;
|
|
|
|
if (In64BitMode) {
|
|
|
|
if (!FullFS.empty())
|
|
|
|
FullFS = "+64bit,+sse2," + FullFS;
|
|
|
|
else
|
|
|
|
FullFS = "+64bit,+sse2";
|
2006-09-08 06:48:29 +00:00
|
|
|
}
|
2011-07-11 03:57:24 +00:00
|
|
|
|
2014-04-12 01:34:29 +00:00
|
|
|
// If feature string is not empty, parse features string.
|
|
|
|
ParseSubtargetFeatures(CPUName, FullFS);
|
|
|
|
|
|
|
|
// Make sure the right MCSchedModel is used.
|
2013-09-18 05:54:09 +00:00
|
|
|
InitCPUSchedModel(CPUName);
|
2012-10-03 15:55:13 +00:00
|
|
|
|
2012-08-07 00:25:30 +00:00
|
|
|
InstrItins = getInstrItineraryForCPU(CPUName);
|
2012-02-01 23:20:51 +00:00
|
|
|
|
2011-07-11 03:57:24 +00:00
|
|
|
// It's important to keep the MCSubtargetInfo feature bits in sync with
|
|
|
|
// target data structure which is shared with MC code emitter, etc.
|
|
|
|
if (In64BitMode)
|
|
|
|
ToggleFeature(X86::Mode64Bit);
|
2014-01-06 04:55:54 +00:00
|
|
|
else if (In32BitMode)
|
|
|
|
ToggleFeature(X86::Mode32Bit);
|
|
|
|
else if (In16BitMode)
|
|
|
|
ToggleFeature(X86::Mode16Bit);
|
|
|
|
else
|
|
|
|
llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!");
|
2011-07-11 03:57:24 +00:00
|
|
|
|
2010-01-05 01:29:13 +00:00
|
|
|
DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
|
2009-08-03 00:11:34 +00:00
|
|
|
<< ", 3DNowLevel " << X863DNowLevel
|
|
|
|
<< ", 64bit " << HasX86_64 << "\n");
|
2011-07-07 21:06:52 +00:00
|
|
|
assert((!In64BitMode || HasX86_64) &&
|
2009-02-03 00:04:43 +00:00
|
|
|
"64-bit code requested on a subtarget that doesn't support it!");
|
2006-09-08 06:48:29 +00:00
|
|
|
|
2012-11-09 20:10:44 +00:00
|
|
|
// Stack alignment is 16 bytes on Darwin, Linux and Solaris (both
|
2011-02-22 17:30:05 +00:00
|
|
|
// 32 and 64 bit) and for all 64-bit targets.
|
2011-06-23 17:54:54 +00:00
|
|
|
if (StackAlignOverride)
|
|
|
|
stackAlignment = StackAlignOverride;
|
2012-11-09 20:10:44 +00:00
|
|
|
else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
|
|
|
|
In64BitMode)
|
2005-07-12 01:41:54 +00:00
|
|
|
stackAlignment = 16;
|
2010-05-27 18:43:40 +00:00
|
|
|
}
|
2012-02-01 23:20:51 +00:00
|
|
|
|
2013-02-16 01:36:26 +00:00
|
|
|
void X86Subtarget::initializeEnvironment() {
|
|
|
|
X86SSELevel = NoMMXSSE;
|
|
|
|
X863DNowLevel = NoThreeDNow;
|
|
|
|
HasCMov = false;
|
|
|
|
HasX86_64 = false;
|
|
|
|
HasPOPCNT = false;
|
|
|
|
HasSSE4A = false;
|
|
|
|
HasAES = false;
|
|
|
|
HasPCLMUL = false;
|
|
|
|
HasFMA = false;
|
|
|
|
HasFMA4 = false;
|
|
|
|
HasXOP = false;
|
2013-09-24 18:21:52 +00:00
|
|
|
HasTBM = false;
|
2013-02-16 01:36:26 +00:00
|
|
|
HasMOVBE = false;
|
|
|
|
HasRDRAND = false;
|
|
|
|
HasF16C = false;
|
|
|
|
HasFSGSBase = false;
|
|
|
|
HasLZCNT = false;
|
|
|
|
HasBMI = false;
|
|
|
|
HasBMI2 = false;
|
|
|
|
HasRTM = false;
|
2013-03-26 22:46:02 +00:00
|
|
|
HasHLE = false;
|
2013-07-28 08:28:38 +00:00
|
|
|
HasERI = false;
|
|
|
|
HasCDI = false;
|
2013-08-20 05:23:59 +00:00
|
|
|
HasPFI = false;
|
2014-07-21 14:54:21 +00:00
|
|
|
HasDQI = false;
|
|
|
|
HasBWI = false;
|
|
|
|
HasVLX = false;
|
2013-02-16 01:36:26 +00:00
|
|
|
HasADX = false;
|
2013-09-12 15:51:31 +00:00
|
|
|
HasSHA = false;
|
2014-07-31 23:57:38 +00:00
|
|
|
HasSGX = false;
|
2013-03-26 17:47:11 +00:00
|
|
|
HasPRFCHW = false;
|
2013-03-28 23:41:26 +00:00
|
|
|
HasRDSEED = false;
|
2014-08-21 09:16:12 +00:00
|
|
|
HasSMAP = false;
|
2013-02-16 01:36:26 +00:00
|
|
|
IsBTMemSlow = false;
|
SHLD/SHRD are VectorPath (microcode) instructions known to have poor latency on certain architectures. While generating SHLD/SHRD instructions is acceptable when optimizing for size, optimizing for speed on these platforms should be implemented using alternative sequences of instructions composed of add, adc, shr, shl, or and lea which are directPath instructions. These alternative instructions not only have a lower latency but they also increase the decode bandwidth by allowing simultaneous decoding of a third directPath instruction.
AMD's processors family K7, K8, K10, K12, K15 and K16 are known to have SHLD/SHRD instructions with very poor latency. Optimization guides for these processors recommend using an alternative sequence of instructions. For these AMD's processors, I disabled folding (or (x << c) | (y >> (64 - c))) when we are not optimizing for size.
It might be beneficial to disable this folding for some of the Intel's processors. However, since I couldn't find specific recommendations regarding using SHLD/SHRD instructions on Intel's processors, I haven't disabled this peephole for Intel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195383 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-21 23:21:26 +00:00
|
|
|
IsSHLDSlow = false;
|
2013-02-16 01:36:26 +00:00
|
|
|
IsUAMemFast = false;
|
|
|
|
HasVectorUAMem = false;
|
|
|
|
HasCmpxchg16b = false;
|
|
|
|
UseLeaForSP = false;
|
|
|
|
HasSlowDivide = false;
|
|
|
|
PadShortFunctions = false;
|
2013-03-27 19:14:02 +00:00
|
|
|
CallRegIndirect = false;
|
2013-04-25 20:29:37 +00:00
|
|
|
LEAUsesAG = false;
|
2014-05-20 08:55:50 +00:00
|
|
|
SlowLEA = false;
|
2014-06-09 11:40:41 +00:00
|
|
|
SlowIncDec = false;
|
2013-02-16 01:36:26 +00:00
|
|
|
stackAlignment = 4;
|
|
|
|
// FIXME: this is a known good value for Yonah. How about others?
|
|
|
|
MaxInlineSizeThreshold = 128;
|
|
|
|
}
|
|
|
|
|
2014-08-09 04:38:53 +00:00
|
|
|
static std::string computeDataLayout(const Triple &TT) {
|
2014-06-09 17:08:19 +00:00
|
|
|
// X86 is little endian
|
|
|
|
std::string Ret = "e";
|
|
|
|
|
2014-08-09 04:38:53 +00:00
|
|
|
Ret += DataLayout::getManglingComponent(TT);
|
2014-06-09 17:08:19 +00:00
|
|
|
// X86 and x32 have 32 bit pointers.
|
2014-08-09 04:38:53 +00:00
|
|
|
if ((TT.isArch64Bit() &&
|
|
|
|
(TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
|
|
|
|
!TT.isArch64Bit())
|
2014-06-09 17:08:19 +00:00
|
|
|
Ret += "-p:32:32";
|
|
|
|
|
|
|
|
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
2014-08-09 04:38:53 +00:00
|
|
|
if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
|
2014-06-09 17:08:19 +00:00
|
|
|
Ret += "-i64:64";
|
|
|
|
else
|
|
|
|
Ret += "-f64:32:64";
|
|
|
|
|
|
|
|
// Some ABIs align long double to 128 bits, others to 32.
|
2014-08-09 04:38:53 +00:00
|
|
|
if (TT.isOSNaCl())
|
2014-06-09 17:08:19 +00:00
|
|
|
; // No f80
|
2014-08-09 04:38:53 +00:00
|
|
|
else if (TT.isArch64Bit() || TT.isOSDarwin())
|
2014-06-09 17:08:19 +00:00
|
|
|
Ret += "-f80:128";
|
|
|
|
else
|
|
|
|
Ret += "-f80:32";
|
|
|
|
|
|
|
|
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
2014-08-09 04:38:53 +00:00
|
|
|
if (TT.isArch64Bit())
|
2014-06-09 17:08:19 +00:00
|
|
|
Ret += "-n8:16:32:64";
|
|
|
|
else
|
|
|
|
Ret += "-n8:16:32";
|
|
|
|
|
|
|
|
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
2014-08-14 17:18:26 +00:00
|
|
|
if (!TT.isArch64Bit() && TT.isOSWindows())
|
2014-06-09 17:08:19 +00:00
|
|
|
Ret += "-S32";
|
|
|
|
else
|
|
|
|
Ret += "-S128";
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2014-06-11 00:25:19 +00:00
|
|
|
X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
StringRef FS) {
|
|
|
|
initializeEnvironment();
|
2014-09-03 20:36:31 +00:00
|
|
|
initSubtargetFeatures(CPU, FS);
|
2014-06-11 00:25:19 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:31:27 +00:00
|
|
|
X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
2014-06-09 17:08:19 +00:00
|
|
|
const std::string &FS, X86TargetMachine &TM,
|
|
|
|
unsigned StackAlignOverride)
|
2014-05-07 21:05:47 +00:00
|
|
|
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
|
|
|
|
PICStyle(PICStyles::None), TargetTriple(TT),
|
2014-08-09 04:38:53 +00:00
|
|
|
DL(computeDataLayout(TargetTriple)),
|
2014-05-07 21:05:47 +00:00
|
|
|
StackAlignOverride(StackAlignOverride),
|
|
|
|
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
|
|
|
|
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
|
|
|
|
TargetTriple.getEnvironment() != Triple::CODE16),
|
|
|
|
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
2014-06-09 17:08:19 +00:00
|
|
|
TargetTriple.getEnvironment() == Triple::CODE16),
|
2014-08-09 04:38:53 +00:00
|
|
|
TSInfo(DL), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
|
|
|
TLInfo(TM), FrameLowering(TargetFrameLowering::StackGrowsDown,
|
2014-09-02 22:28:02 +00:00
|
|
|
getStackAlignment(), is64Bit() ? -8 : -4) {
|
2014-08-09 01:07:25 +00:00
|
|
|
// Determine the PICStyle based on the target selected.
|
|
|
|
if (TM.getRelocationModel() == Reloc::Static) {
|
|
|
|
// Unless we're in PIC or DynamicNoPIC mode, set the PIC style to None.
|
|
|
|
setPICStyle(PICStyles::None);
|
|
|
|
} else if (is64Bit()) {
|
|
|
|
// PIC in 64 bit mode is always rip-rel.
|
|
|
|
setPICStyle(PICStyles::RIPRel);
|
|
|
|
} else if (isTargetCOFF()) {
|
|
|
|
setPICStyle(PICStyles::None);
|
|
|
|
} else if (isTargetDarwin()) {
|
|
|
|
if (TM.getRelocationModel() == Reloc::PIC_)
|
|
|
|
setPICStyle(PICStyles::StubPIC);
|
|
|
|
else {
|
|
|
|
assert(TM.getRelocationModel() == Reloc::DynamicNoPIC);
|
|
|
|
setPICStyle(PICStyles::StubDynamicNoPIC);
|
|
|
|
}
|
|
|
|
} else if (isTargetELF()) {
|
|
|
|
setPICStyle(PICStyles::GOT);
|
|
|
|
}
|
|
|
|
}
|
2013-02-15 22:31:27 +00:00
|
|
|
|
2014-07-15 22:39:58 +00:00
|
|
|
bool X86Subtarget::enableEarlyIfConversion() const {
|
2014-05-21 23:51:57 +00:00
|
|
|
return hasCMov() && X86EarlyIfConv;
|
2014-05-21 23:40:26 +00:00
|
|
|
}
|
2014-07-15 22:39:58 +00:00
|
|
|
|