mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 02:32:11 +00:00
First baby step towards ppc64 support. This adds a new -march=ppc64 backend
that is currently just like ppc32 :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28813 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1127315562
commit
94de9a8951
@ -69,7 +69,7 @@ static const char *GetCurrentPowerPCCPU() {
|
||||
#endif
|
||||
|
||||
|
||||
PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
|
||||
PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit)
|
||||
: StackAlignment(16)
|
||||
, InstrItins()
|
||||
, IsGigaProcessor(false)
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
/// This constructor initializes the data members to match that
|
||||
/// of the specified module.
|
||||
///
|
||||
PPCSubtarget(const Module &M, const std::string &FS);
|
||||
PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit);
|
||||
|
||||
/// ParseSubtargetFeatures - Parses features string setting specified
|
||||
/// subtarget options. Definition of function is auto generated by tblgen.
|
||||
@ -59,6 +59,10 @@ public:
|
||||
/// selection.
|
||||
const InstrItineraryData getInstrItineraryData() const { return InstrItins; }
|
||||
|
||||
const char *getTargetDataString() const {
|
||||
// FIXME: Make is64Bit be for the processor, not the target.
|
||||
return true ? "E-p:32:32-d:32-l:32" : "E-p:64:64-d:32-l:32";
|
||||
}
|
||||
|
||||
bool hasFSQRT() const { return HasFSQRT; }
|
||||
bool hasSTFIWX() const { return HasSTFIWX; }
|
||||
|
@ -29,19 +29,29 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
// Register the targets
|
||||
RegisterTarget<PPCTargetMachine>
|
||||
X("ppc32", " PowerPC");
|
||||
RegisterTarget<PPC32TargetMachine>
|
||||
X("ppc32", " PowerPC 32");
|
||||
RegisterTarget<PPC64TargetMachine>
|
||||
Y("ppc64", " PowerPC 64");
|
||||
}
|
||||
|
||||
unsigned PPCTargetMachine::getJITMatchQuality() {
|
||||
unsigned PPC32TargetMachine::getJITMatchQuality() {
|
||||
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
|
||||
return 10;
|
||||
if (sizeof(void*) == 4)
|
||||
return 10;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
unsigned PPC64TargetMachine::getJITMatchQuality() {
|
||||
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
|
||||
if (sizeof(void*) == 8)
|
||||
return 10 * 0/*FIXME: not PPC64-JIT support yet! */;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned PPCTargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
// We strongly match "powerpc-*".
|
||||
std::string TT = M.getTargetTriple();
|
||||
if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
|
||||
@ -57,11 +67,31 @@ unsigned PPCTargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
return getJITMatchQuality()/2;
|
||||
}
|
||||
|
||||
PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
|
||||
: TargetMachine("PowerPC"),
|
||||
DataLayout(std::string("PowerPC"), std::string("E-p:32:32-d:32-l:32")),
|
||||
Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
|
||||
TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
|
||||
unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
|
||||
// We strongly match "powerpc64-*".
|
||||
std::string TT = M.getTargetTriple();
|
||||
if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
|
||||
return 20;
|
||||
|
||||
if (M.getEndianness() == Module::BigEndian &&
|
||||
M.getPointerSize() == Module::Pointer64)
|
||||
return 10; // Weak match
|
||||
else if (M.getEndianness() != Module::AnyEndianness ||
|
||||
M.getPointerSize() != Module::AnyPointerSize)
|
||||
return 0; // Match for some other target
|
||||
|
||||
return getJITMatchQuality()/2;
|
||||
}
|
||||
|
||||
|
||||
PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
|
||||
bool is64Bit)
|
||||
: TargetMachine("PowerPC"), Subtarget(M, FS, is64Bit),
|
||||
DataLayout(std::string("PowerPC"),
|
||||
std::string(Subtarget.getTargetDataString())),
|
||||
FrameInfo(*this, false), JITInfo(*this), TLInfo(*this),
|
||||
InstrItins(Subtarget.getInstrItineraryData()) {
|
||||
|
||||
if (TargetDefault == PPCTarget) {
|
||||
if (Subtarget.isAIX()) PPCTarget = TargetAIX;
|
||||
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
|
||||
@ -73,6 +103,15 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
|
||||
setRelocationModel(Reloc::PIC);
|
||||
}
|
||||
|
||||
PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS)
|
||||
: PPCTargetMachine(M, FS, false) {
|
||||
}
|
||||
|
||||
|
||||
PPC64TargetMachine::PPC64TargetMachine(const Module &M, const std::string &FS)
|
||||
: PPCTargetMachine(M, FS, true) {
|
||||
}
|
||||
|
||||
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
|
||||
/// a static compiler for this target.
|
||||
///
|
||||
|
@ -26,44 +26,63 @@ namespace llvm {
|
||||
class PassManager;
|
||||
class GlobalValue;
|
||||
|
||||
/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
|
||||
///
|
||||
class PPCTargetMachine : public TargetMachine {
|
||||
const TargetData DataLayout; // Calculates type size & alignment
|
||||
PPCInstrInfo InstrInfo;
|
||||
PPCSubtarget Subtarget;
|
||||
PPCFrameInfo FrameInfo;
|
||||
PPCJITInfo JITInfo;
|
||||
PPCTargetLowering TLInfo;
|
||||
InstrItineraryData InstrItins;
|
||||
PPCSubtarget Subtarget;
|
||||
const TargetData DataLayout; // Calculates type size & alignment
|
||||
PPCInstrInfo InstrInfo;
|
||||
PPCFrameInfo FrameInfo;
|
||||
PPCJITInfo JITInfo;
|
||||
PPCTargetLowering TLInfo;
|
||||
InstrItineraryData InstrItins;
|
||||
public:
|
||||
PPCTargetMachine(const Module &M, const std::string &FS);
|
||||
PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
|
||||
|
||||
virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
|
||||
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
|
||||
virtual TargetJITInfo *getJITInfo() { return &JITInfo; }
|
||||
virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; }
|
||||
virtual PPCTargetLowering *getTargetLowering() const {
|
||||
return const_cast<PPCTargetLowering*>(&TLInfo);
|
||||
}
|
||||
virtual const MRegisterInfo *getRegisterInfo() const {
|
||||
return &InstrInfo.getRegisterInfo();
|
||||
}
|
||||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
|
||||
virtual const TargetData *getTargetData() const { return &DataLayout; }
|
||||
virtual const PPCSubtarget *getSubtargetImpl() const { return &Subtarget; }
|
||||
virtual const InstrItineraryData getInstrItineraryData() const {
|
||||
return InstrItins;
|
||||
}
|
||||
|
||||
|
||||
static unsigned getJITMatchQuality();
|
||||
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
|
||||
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
|
||||
CodeGenFileType FileType, bool Fast);
|
||||
|
||||
bool addPassesToEmitMachineCode(FunctionPassManager &PM,
|
||||
MachineCodeEmitter &MCE);
|
||||
};
|
||||
|
||||
/// PPC32TargetMachine - PowerPC 32-bit target machine.
|
||||
///
|
||||
class PPC32TargetMachine : public PPCTargetMachine {
|
||||
public:
|
||||
PPC32TargetMachine(const Module &M, const std::string &FS);
|
||||
|
||||
static unsigned getJITMatchQuality();
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
};
|
||||
|
||||
/// PPC64TargetMachine - PowerPC 64-bit target machine.
|
||||
///
|
||||
class PPC64TargetMachine : public PPCTargetMachine {
|
||||
public:
|
||||
PPC64TargetMachine(const Module &M, const std::string &FS);
|
||||
|
||||
static unsigned getJITMatchQuality();
|
||||
static unsigned getModuleMatchQuality(const Module &M);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user