Initialize X86 DataLayout based on the Triple only.
llvm-svn: 215279
This commit is contained in:
parent
a0101074fd
commit
e950b6776b
|
@ -298,37 +298,39 @@ void X86Subtarget::initializeEnvironment() {
|
||||||
MaxInlineSizeThreshold = 128;
|
MaxInlineSizeThreshold = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string computeDataLayout(const X86Subtarget &ST) {
|
static std::string computeDataLayout(const Triple &TT) {
|
||||||
// X86 is little endian
|
// X86 is little endian
|
||||||
std::string Ret = "e";
|
std::string Ret = "e";
|
||||||
|
|
||||||
Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
|
Ret += DataLayout::getManglingComponent(TT);
|
||||||
// X86 and x32 have 32 bit pointers.
|
// X86 and x32 have 32 bit pointers.
|
||||||
if (ST.isTarget64BitILP32() || !ST.is64Bit())
|
if ((TT.isArch64Bit() &&
|
||||||
|
(TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
|
||||||
|
!TT.isArch64Bit())
|
||||||
Ret += "-p:32:32";
|
Ret += "-p:32:32";
|
||||||
|
|
||||||
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
|
||||||
if (ST.is64Bit() || ST.isOSWindows() || ST.isTargetNaCl())
|
if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl())
|
||||||
Ret += "-i64:64";
|
Ret += "-i64:64";
|
||||||
else
|
else
|
||||||
Ret += "-f64:32:64";
|
Ret += "-f64:32:64";
|
||||||
|
|
||||||
// Some ABIs align long double to 128 bits, others to 32.
|
// Some ABIs align long double to 128 bits, others to 32.
|
||||||
if (ST.isTargetNaCl())
|
if (TT.isOSNaCl())
|
||||||
; // No f80
|
; // No f80
|
||||||
else if (ST.is64Bit() || ST.isTargetDarwin())
|
else if (TT.isArch64Bit() || TT.isOSDarwin())
|
||||||
Ret += "-f80:128";
|
Ret += "-f80:128";
|
||||||
else
|
else
|
||||||
Ret += "-f80:32";
|
Ret += "-f80:32";
|
||||||
|
|
||||||
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
|
||||||
if (ST.is64Bit())
|
if (TT.isArch64Bit())
|
||||||
Ret += "-n8:16:32:64";
|
Ret += "-n8:16:32:64";
|
||||||
else
|
else
|
||||||
Ret += "-n8:16:32";
|
Ret += "-n8:16:32";
|
||||||
|
|
||||||
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
|
||||||
if (!ST.is64Bit() && ST.isOSWindows())
|
if (!TT.isArch64Bit() && TT.isOSWindows())
|
||||||
Ret += "-S32";
|
Ret += "-S32";
|
||||||
else
|
else
|
||||||
Ret += "-S128";
|
Ret += "-S128";
|
||||||
|
@ -348,16 +350,16 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
||||||
unsigned StackAlignOverride)
|
unsigned StackAlignOverride)
|
||||||
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
|
: X86GenSubtargetInfo(TT, CPU, FS), X86ProcFamily(Others),
|
||||||
PICStyle(PICStyles::None), TargetTriple(TT),
|
PICStyle(PICStyles::None), TargetTriple(TT),
|
||||||
|
DL(computeDataLayout(TargetTriple)),
|
||||||
StackAlignOverride(StackAlignOverride),
|
StackAlignOverride(StackAlignOverride),
|
||||||
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
|
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
|
||||||
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
|
In32BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||||
TargetTriple.getEnvironment() != Triple::CODE16),
|
TargetTriple.getEnvironment() != Triple::CODE16),
|
||||||
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
In16BitMode(TargetTriple.getArch() == Triple::x86 &&
|
||||||
TargetTriple.getEnvironment() == Triple::CODE16),
|
TargetTriple.getEnvironment() == Triple::CODE16),
|
||||||
DL(computeDataLayout(*this)), TSInfo(DL),
|
TSInfo(DL), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
|
||||||
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
|
TLInfo(TM), FrameLowering(TargetFrameLowering::StackGrowsDown,
|
||||||
FrameLowering(TargetFrameLowering::StackGrowsDown, getStackAlignment(),
|
getStackAlignment(), is64Bit() ? -8 : -4),
|
||||||
is64Bit() ? -8 : -4),
|
|
||||||
JITInfo(hasSSE1()) {
|
JITInfo(hasSSE1()) {
|
||||||
// Determine the PICStyle based on the target selected.
|
// Determine the PICStyle based on the target selected.
|
||||||
if (TM.getRelocationModel() == Reloc::Static) {
|
if (TM.getRelocationModel() == Reloc::Static) {
|
||||||
|
|
|
@ -223,6 +223,9 @@ protected:
|
||||||
InstrItineraryData InstrItins;
|
InstrItineraryData InstrItins;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Calculates type size & alignment
|
||||||
|
const DataLayout DL;
|
||||||
|
|
||||||
/// StackAlignOverride - Override the stack alignment.
|
/// StackAlignOverride - Override the stack alignment.
|
||||||
unsigned StackAlignOverride;
|
unsigned StackAlignOverride;
|
||||||
|
|
||||||
|
@ -235,8 +238,6 @@ private:
|
||||||
/// In16BitMode - True if compiling for 16-bit, false for 32-bit or 64-bit.
|
/// In16BitMode - True if compiling for 16-bit, false for 32-bit or 64-bit.
|
||||||
bool In16BitMode;
|
bool In16BitMode;
|
||||||
|
|
||||||
// Calculates type size & alignment
|
|
||||||
const DataLayout DL;
|
|
||||||
X86SelectionDAGInfo TSInfo;
|
X86SelectionDAGInfo TSInfo;
|
||||||
// Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
|
// Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
|
||||||
// X86TargetLowering needs.
|
// X86TargetLowering needs.
|
||||||
|
|
Loading…
Reference in New Issue