mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +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);
|
SDValue V2);
|
||||||
|
|
||||||
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
||||||
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
|
||||||
default: llvm_unreachable("unknown subtarget type");
|
bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
|
||||||
case X86Subtarget::isDarwin:
|
|
||||||
if (TM.getSubtarget<X86Subtarget>().is64Bit())
|
if (TM.getSubtarget<X86Subtarget>().isTargetDarwin()) {
|
||||||
return new X8664_MachoTargetObjectFile();
|
if (is64Bit) return new X8664_MachoTargetObjectFile();
|
||||||
return new TargetLoweringObjectFileMachO();
|
return new TargetLoweringObjectFileMachO();
|
||||||
case X86Subtarget::isELF:
|
} else if (TM.getSubtarget<X86Subtarget>().isTargetELF() ){
|
||||||
if (TM.getSubtarget<X86Subtarget>().is64Bit())
|
if (is64Bit) return new X8664_ELFTargetObjectFile(TM);
|
||||||
return new X8664_ELFTargetObjectFile(TM);
|
|
||||||
return new X8632_ELFTargetObjectFile(TM);
|
return new X8632_ELFTargetObjectFile(TM);
|
||||||
case X86Subtarget::isMingw:
|
} else if (TM.getSubtarget<X86Subtarget>().isTargetCOFF()) {
|
||||||
case X86Subtarget::isCygwin:
|
|
||||||
case X86Subtarget::isWindows:
|
|
||||||
return new TargetLoweringObjectFileCOFF();
|
return new TargetLoweringObjectFileCOFF();
|
||||||
}
|
}
|
||||||
|
llvm_unreachable("unknown subtarget type");
|
||||||
}
|
}
|
||||||
|
|
||||||
X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
X86TargetLowering::X86TargetLowering(X86TargetMachine &TM)
|
||||||
|
@ -296,12 +296,11 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS,
|
|||||||
, IsBTMemSlow(false)
|
, IsBTMemSlow(false)
|
||||||
, IsUAMemFast(false)
|
, IsUAMemFast(false)
|
||||||
, HasVectorUAMem(false)
|
, HasVectorUAMem(false)
|
||||||
, DarwinVers(0)
|
|
||||||
, stackAlignment(8)
|
, stackAlignment(8)
|
||||||
// FIXME: this is a known good value for Yonah. How about others?
|
// FIXME: this is a known good value for Yonah. How about others?
|
||||||
, MaxInlineSizeThreshold(128)
|
, MaxInlineSizeThreshold(128)
|
||||||
, Is64Bit(is64Bit)
|
, TargetTriple(TT)
|
||||||
, TargetType(isELF) { // Default to ELF unless otherwise specified.
|
, Is64Bit(is64Bit) {
|
||||||
|
|
||||||
// default to hard float ABI
|
// default to hard float ABI
|
||||||
if (FloatABIType == FloatABI::Default)
|
if (FloatABIType == FloatABI::Default)
|
||||||
@ -331,45 +330,15 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &FS,
|
|||||||
HasCMov = true;
|
HasCMov = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
|
DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
|
||||||
<< ", 3DNowLevel " << X863DNowLevel
|
<< ", 3DNowLevel " << X863DNowLevel
|
||||||
<< ", 64bit " << HasX86_64 << "\n");
|
<< ", 64bit " << HasX86_64 << "\n");
|
||||||
assert((!Is64Bit || HasX86_64) &&
|
assert((!Is64Bit || HasX86_64) &&
|
||||||
"64-bit code requested on a subtarget that doesn't support it!");
|
"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
|
// Stack alignment is 16 bytes on Darwin (both 32 and 64 bit) and for all 64
|
||||||
// bit targets.
|
// bit targets.
|
||||||
if (TargetType == isDarwin || Is64Bit)
|
if (isTargetDarwin() || Is64Bit)
|
||||||
stackAlignment = 16;
|
stackAlignment = 16;
|
||||||
|
|
||||||
if (StackAlignment)
|
if (StackAlignment)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef X86SUBTARGET_H
|
#ifndef X86SUBTARGET_H
|
||||||
#define X86SUBTARGET_H
|
#define X86SUBTARGET_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/Target/TargetSubtarget.h"
|
#include "llvm/Target/TargetSubtarget.h"
|
||||||
#include "llvm/CallingConv.h"
|
#include "llvm/CallingConv.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -89,10 +90,6 @@ protected:
|
|||||||
/// operands. This may require setting a feature bit in the processor.
|
/// operands. This may require setting a feature bit in the processor.
|
||||||
bool HasVectorUAMem;
|
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
|
/// stackAlignment - The minimum alignment known to hold of the stack frame on
|
||||||
/// entry to the function and which must be maintained by every function.
|
/// entry to the function and which must be maintained by every function.
|
||||||
unsigned stackAlignment;
|
unsigned stackAlignment;
|
||||||
@ -101,15 +98,15 @@ protected:
|
|||||||
///
|
///
|
||||||
unsigned MaxInlineSizeThreshold;
|
unsigned MaxInlineSizeThreshold;
|
||||||
|
|
||||||
|
/// TargetTriple - What processor and OS we're targeting.
|
||||||
|
Triple TargetTriple;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Is64Bit - True if the processor supports 64-bit instructions and
|
/// Is64Bit - True if the processor supports 64-bit instructions and
|
||||||
/// pointer size is 64 bit.
|
/// pointer size is 64 bit.
|
||||||
bool Is64Bit;
|
bool Is64Bit;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum {
|
|
||||||
isELF, isCygwin, isDarwin, isWindows, isMingw
|
|
||||||
} TargetType;
|
|
||||||
|
|
||||||
/// This constructor initializes the data members to match that
|
/// This constructor initializes the data members to match that
|
||||||
/// of the specified triple.
|
/// of the specified triple.
|
||||||
@ -158,24 +155,31 @@ public:
|
|||||||
bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
|
bool isUnalignedMemAccessFast() const { return IsUAMemFast; }
|
||||||
bool hasVectorUAMem() const { return HasVectorUAMem; }
|
bool hasVectorUAMem() const { return HasVectorUAMem; }
|
||||||
|
|
||||||
bool isTargetDarwin() const { return TargetType == isDarwin; }
|
bool isTargetDarwin() const { return TargetTriple.getOS() == Triple::Darwin; }
|
||||||
bool isTargetELF() const { return TargetType == isELF; }
|
|
||||||
|
|
||||||
bool isTargetWindows() const { return TargetType == isWindows; }
|
// ELF is a reasonably sane default and the only other X86 targets we
|
||||||
bool isTargetMingw() const { return TargetType == isMingw; }
|
// support are Darwin and Windows. Just use "not those".
|
||||||
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
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 {
|
bool isTargetCygMing() const {
|
||||||
return TargetType == isMingw || TargetType == isCygwin;
|
return isTargetMingw() || isTargetCygwin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
/// isTargetCOFF - Return true if this is any COFF/Windows target variant.
|
||||||
bool isTargetCOFF() const {
|
bool isTargetCOFF() const {
|
||||||
return TargetType == isMingw || TargetType == isCygwin ||
|
return isTargetMingw() || isTargetCygwin() || isTargetWindows();
|
||||||
TargetType == isWindows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTargetWin64() const {
|
bool isTargetWin64() const {
|
||||||
return Is64Bit && (TargetType == isMingw || TargetType == isWindows);
|
return Is64Bit && (isTargetMingw() || isTargetWindows());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getDataLayout() const {
|
std::string getDataLayout() const {
|
||||||
@ -209,7 +213,10 @@ public:
|
|||||||
|
|
||||||
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
/// getDarwinVers - Return the darwin version number, 8 = Tiger, 9 = Leopard,
|
||||||
/// 10 = Snow Leopard, etc.
|
/// 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
|
/// ClassifyGlobalReference - Classify a global variable reference for the
|
||||||
/// current subtarget according to how we should reference it in a non-pcrel
|
/// current subtarget according to how we should reference it in a non-pcrel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user