mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 23:18:51 +00:00
Have the X86 backend use Triple instead of a string and some enums.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107625 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5cb97d16f8
commit
62f35a2c13
@ -62,21 +62,19 @@ static SDValue getMOVL(SelectionDAG &DAG, DebugLoc dl, EVT VT, SDValue V1,
|
||||
SDValue V2);
|
||||
|
||||
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
||||
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
||||
default: llvm_unreachable("unknown subtarget type");
|
||||
case X86Subtarget::isDarwin:
|
||||
if (TM.getSubtarget<X86Subtarget>().is64Bit())
|
||||
return new X8664_MachoTargetObjectFile();
|
||||
|
||||
bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
|
||||
|
||||
if (TM.getSubtarget<X86Subtarget>().isTargetDarwin()) {
|
||||
if (is64Bit) return new X8664_MachoTargetObjectFile();
|
||||
return new TargetLoweringObjectFileMachO();
|
||||
case X86Subtarget::isELF:
|
||||
if (TM.getSubtarget<X86Subtarget>().is64Bit())
|
||||
return new X8664_ELFTargetObjectFile(TM);
|
||||
} else if (TM.getSubtarget<X86Subtarget>().isTargetELF() ){
|
||||
if (is64Bit) return new X8664_ELFTargetObjectFile(TM);
|
||||
return new X8632_ELFTargetObjectFile(TM);
|
||||
case X86Subtarget::isMingw:
|
||||
case X86Subtarget::isCygwin:
|
||||
case X86Subtarget::isWindows:
|
||||
} else if (TM.getSubtarget<X86Subtarget>().isTargetCOFF()) {
|
||||
return new TargetLoweringObjectFileCOFF();
|
||||
}
|
||||
}
|
||||
llvm_unreachable("unknown subtarget type");
|
||||
}
|
||||
|
||||
X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
||||
|
@ -296,12 +296,11 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS,
|
||||
, IsBTMemSlow(false)
|
||||
, IsUAMemFast(false)
|
||||
, HasVectorUAMem(false)
|
||||
, DarwinVers(0)
|
||||
, stackAlignment(8)
|
||||
// FIXME: this is a known good value for Yonah. How about others?
|
||||
, MaxInlineSizeThreshold(128)
|
||||
, Is64Bit(is64Bit)
|
||||
, TargetType(isELF) { // Default to ELF unless otherwise specified.
|
||||
, TargetTriple(TT)
|
||||
, Is64Bit(is64Bit) {
|
||||
|
||||
// default to hard float ABI
|
||||
if (FloatABIType == FloatABI::Default)
|
||||
@ -331,45 +330,15 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS,
|
||||
HasCMov = true;
|
||||
}
|
||||
|
||||
|
||||
DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
|
||||
<< ", 3DNowLevel " << X863DNowLevel
|
||||
<< ", 64bit " << HasX86_64 << "\n");
|
||||
assert((!Is64Bit || HasX86_64) &&
|
||||
"64-bit code requested on a subtarget that doesn't support it!");
|
||||
|
||||
// Set the boolean corresponding to the current target triple, or the default
|
||||
// if one cannot be determined, to true.
|
||||
if (TT.length() > 5) {
|
||||
size_t Pos;
|
||||
if ((Pos = TT.find("-darwin")) != std::string::npos) {
|
||||
TargetType = isDarwin;
|
||||
|
||||
// Compute the darwin version number.
|
||||
if (isdigit(TT[Pos+7]))
|
||||
DarwinVers = atoi(&TT[Pos+7]);
|
||||
else
|
||||
DarwinVers = 8; // Minimum supported darwin is Tiger.
|
||||
} else if (TT.find("linux") != std::string::npos) {
|
||||
// Linux doesn't imply ELF, but we don't currently support anything else.
|
||||
TargetType = isELF;
|
||||
} else if (TT.find("cygwin") != std::string::npos) {
|
||||
TargetType = isCygwin;
|
||||
} else if (TT.find("mingw") != std::string::npos) {
|
||||
TargetType = isMingw;
|
||||
} else if (TT.find("win32") != std::string::npos) {
|
||||
TargetType = isWindows;
|
||||
} else if (TT.find("windows") != std::string::npos) {
|
||||
TargetType = isWindows;
|
||||
} else if (TT.find("-cl") != std::string::npos) {
|
||||
TargetType = isDarwin;
|
||||
DarwinVers = 9;
|
||||
}
|
||||
}
|
||||
|
||||
// Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
|
||||
// bit targets.
|
||||
if (TargetType == isDarwin || Is64Bit)
|
||||
if (isTargetDarwin() || Is64Bit)
|
||||
stackAlignment = 16;
|
||||
|
||||
if (StackAlignment)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef X86SUBTARGET_H
|
||||
#define X86SUBTARGET_H
|
||||
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Target/TargetSubtarget.h"
|
||||
#include "llvm/CallingConv.h"
|
||||
#include <string>
|
||||
@ -89,10 +90,6 @@ protected:
|
||||
/// operands. This may require setting a feature bit in the processor.
|
||||
bool HasVectorUAMem;
|
||||
|
||||
/// DarwinVers - Nonzero if this is a darwin platform: the numeric
|
||||
/// version of the platform, e.g. 8 = 10.4 (Tiger), 9 = 10.5 (Leopard), etc.
|
||||
unsigned char DarwinVers; // Is any darwin-x86 platform.
|
||||
|
||||
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
||||
/// entry to the function and which must be maintained by every function.
|
||||
unsigned stackAlignment;
|
||||
@ -100,6 +97,9 @@ protected:
|
||||
/// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
|
||||
///
|
||||
unsigned MaxInlineSizeThreshold;
|
||||
|
||||
/// TargetTriple - What processor and OS we're targeting.
|
||||
Triple TargetTriple;
|
||||
|
||||
private:
|
||||
/// Is64Bit - True if the processor supports 64-bit instructions and
|
||||
@ -107,9 +107,6 @@ private:
|
||||
bool Is64Bit;
|
||||
|
||||
public:
|
||||
enum {
|
||||
isELF, isCygwin, isDarwin, isWindows, isMingw
|
||||
} TargetType;
|
||||
|
||||
/// This constructor initializes the data members to match that
|
||||
/// of the specified triple.
|
||||
@ -158,24 +155,31 @@ public:
|
||||
bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
|
||||
bool hasVectorUAMem() const { return HasVectorUAMem; }
|
||||
|
||||
bool isTargetDarwin() const { return TargetType == isDarwin; }
|
||||
bool isTargetELF() const { return TargetType == isELF; }
|
||||
|
||||
bool isTargetWindows() const { return TargetType == isWindows; }
|
||||
bool isTargetMingw() const { return TargetType == isMingw; }
|
||||
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
||||
bool isTargetCygMing() const {
|
||||
return TargetType == isMingw || TargetType == isCygwin;
|
||||
bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
|
||||
|
||||
// ELF is a reasonably sane default and the only other X86 targets we
|
||||
// support are Darwin and Windows. Just use "not those".
|
||||
bool isTargetELF() const {
|
||||
return !isTargetDarwin() && !isTargetWindows() && !isTargetCygMing();
|
||||
}
|
||||
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
|
||||
|
||||
bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
|
||||
bool isTargetMingw() const {
|
||||
return TargetTriple.getOS() == Triple::MinGW32 ||
|
||||
TargetTriple.getOS() == Triple::MinGW64; }
|
||||
bool isTargetCygwin() const { return TargetTriple.getOS() == Triple::Cygwin; }
|
||||
bool isTargetCygMing() const {
|
||||
return isTargetMingw() || isTargetCygwin();
|
||||
}
|
||||
|
||||
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
||||
bool isTargetCOFF() const {
|
||||
return TargetType == isMingw || TargetType == isCygwin ||
|
||||
TargetType == isWindows;
|
||||
return isTargetMingw() || isTargetCygwin() || isTargetWindows();
|
||||
}
|
||||
|
||||
bool isTargetWin64() const {
|
||||
return Is64Bit && (TargetType == isMingw || TargetType == isWindows);
|
||||
return Is64Bit && (isTargetMingw() || isTargetWindows());
|
||||
}
|
||||
|
||||
std::string getDataLayout() const {
|
||||
@ -209,7 +213,10 @@ public:
|
||||
|
||||
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
||||
/// 10 = Snow Leopard, etc.
|
||||
unsigned getDarwinVers() const { return DarwinVers; }
|
||||
unsigned getDarwinVers() const {
|
||||
if (isTargetDarwin()) return TargetTriple.getDarwinMajorNumber();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// ClassifyGlobalReference - Classify a global variable reference for the
|
||||
/// current subtarget according to how we should reference it in a non-pcrel
|
||||
|
Loading…
Reference in New Issue
Block a user