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:
Chris Lattner 2006-06-16 01:37:27 +00:00
parent 1127315562
commit 94de9a8951
4 changed files with 88 additions and 26 deletions

View File

@ -69,7 +69,7 @@ static const char *GetCurrentPowerPCCPU() {
#endif #endif
PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS) PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS, bool is64Bit)
: StackAlignment(16) : StackAlignment(16)
, InstrItins() , InstrItins()
, IsGigaProcessor(false) , IsGigaProcessor(false)

View File

@ -44,7 +44,7 @@ public:
/// This constructor initializes the data members to match that /// This constructor initializes the data members to match that
/// of the specified module. /// 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 /// ParseSubtargetFeatures - Parses features string setting specified
/// subtarget options. Definition of function is auto generated by tblgen. /// subtarget options. Definition of function is auto generated by tblgen.
@ -59,6 +59,10 @@ public:
/// selection. /// selection.
const InstrItineraryData getInstrItineraryData() const { return InstrItins; } 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 hasFSQRT() const { return HasFSQRT; }
bool hasSTFIWX() const { return HasSTFIWX; } bool hasSTFIWX() const { return HasSTFIWX; }

View File

@ -29,19 +29,29 @@ using namespace llvm;
namespace { namespace {
// Register the targets // Register the targets
RegisterTarget<PPCTargetMachine> RegisterTarget<PPC32TargetMachine>
X("ppc32", " PowerPC"); X("ppc32", " PowerPC 32");
RegisterTarget<PPC64TargetMachine>
Y("ppc64", " PowerPC 64");
} }
unsigned PPCTargetMachine::getJITMatchQuality() { unsigned PPC32TargetMachine::getJITMatchQuality() {
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
return 10; if (sizeof(void*) == 4)
return 10;
#else #else
return 0; return 0;
#endif #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-*". // We strongly match "powerpc-*".
std::string TT = M.getTargetTriple(); std::string TT = M.getTargetTriple();
if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-") 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; return getJITMatchQuality()/2;
} }
PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS) unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
: TargetMachine("PowerPC"), // We strongly match "powerpc64-*".
DataLayout(std::string("PowerPC"), std::string("E-p:32:32-d:32-l:32")), std::string TT = M.getTargetTriple();
Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this), if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) { 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 (TargetDefault == PPCTarget) {
if (Subtarget.isAIX()) PPCTarget = TargetAIX; if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin; if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
@ -73,6 +103,15 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS)
setRelocationModel(Reloc::PIC); 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 /// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target. /// a static compiler for this target.
/// ///

View File

@ -26,44 +26,63 @@ namespace llvm {
class PassManager; class PassManager;
class GlobalValue; class GlobalValue;
/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
///
class PPCTargetMachine : public TargetMachine { class PPCTargetMachine : public TargetMachine {
const TargetData DataLayout; // Calculates type size & alignment PPCSubtarget Subtarget;
PPCInstrInfo InstrInfo; const TargetData DataLayout; // Calculates type size & alignment
PPCSubtarget Subtarget; PPCInstrInfo InstrInfo;
PPCFrameInfo FrameInfo; PPCFrameInfo FrameInfo;
PPCJITInfo JITInfo; PPCJITInfo JITInfo;
PPCTargetLowering TLInfo; PPCTargetLowering TLInfo;
InstrItineraryData InstrItins; InstrItineraryData InstrItins;
public: 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 PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual TargetJITInfo *getJITInfo() { return &JITInfo; } virtual TargetJITInfo *getJITInfo() { return &JITInfo; }
virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; }
virtual PPCTargetLowering *getTargetLowering() const { virtual PPCTargetLowering *getTargetLowering() const {
return const_cast<PPCTargetLowering*>(&TLInfo); return const_cast<PPCTargetLowering*>(&TLInfo);
} }
virtual const MRegisterInfo *getRegisterInfo() const { virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo(); 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 { virtual const InstrItineraryData getInstrItineraryData() const {
return InstrItins; return InstrItins;
} }
static unsigned getJITMatchQuality();
static unsigned getModuleMatchQuality(const Module &M);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out, virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType, bool Fast); CodeGenFileType FileType, bool Fast);
bool addPassesToEmitMachineCode(FunctionPassManager &PM, bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE); 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 } // end namespace llvm
#endif #endif