diff options
Diffstat (limited to 'llvm/lib/Target/PowerPC')
-rw-r--r-- | llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPC.h | 2 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 75 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCTargetMachine.h | 15 |
4 files changed, 75 insertions, 32 deletions
diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index f568bc1b03c..7489e49ca58 100644 --- a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -43,7 +43,6 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetRegistry.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" @@ -318,7 +317,7 @@ namespace { /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter { public: - explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, + explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM, const TargetAsmInfo *T, bool V) : PPCAsmPrinter(O, TM, T, V){} @@ -344,7 +343,7 @@ namespace { class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter { formatted_raw_ostream &OS; public: - explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, + explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM, const TargetAsmInfo *T, bool V) : PPCAsmPrinter(O, TM, T, V), OS(O) {} @@ -1081,7 +1080,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { /// Darwin assembler can deal with. /// FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, + PPCTargetMachine &tm, bool verbose) { const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>(); @@ -1104,10 +1103,4 @@ extern "C" int PowerPCAsmPrinterForceLink; int PowerPCAsmPrinterForceLink = 0; // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { - extern Target ThePPC32Target; - TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass); - - extern Target ThePPC64Target; - TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass); -} +extern "C" void LLVMInitializePowerPCAsmPrinter() { } diff --git a/llvm/lib/Target/PowerPC/PPC.h b/llvm/lib/Target/PowerPC/PPC.h index 3aa313c73aa..89dc1c131e7 100644 --- a/llvm/lib/Target/PowerPC/PPC.h +++ b/llvm/lib/Target/PowerPC/PPC.h @@ -30,7 +30,7 @@ namespace llvm { FunctionPass *createPPCBranchSelectionPass(); FunctionPass *createPPCISelDag(PPCTargetMachine &TM); FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS, - TargetMachine &TM, + PPCTargetMachine &TM, bool Verbose); FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM, MachineCodeEmitter &MCE); diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index 7e401c453f0..c261f8793ff 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -30,13 +30,10 @@ extern "C" int PowerPCTargetMachineModule; int PowerPCTargetMachineModule = 0; // Register the targets -extern Target ThePPC32Target; static RegisterTarget<PPC32TargetMachine> -X(ThePPC32Target, "ppc32", "PowerPC 32"); - -extern Target ThePPC64Target; +X("ppc32", "PowerPC 32"); static RegisterTarget<PPC64TargetMachine> -Y(ThePPC64Target, "ppc64", "PowerPC 64"); +Y("ppc64", "PowerPC 64"); // Force static initialization. extern "C" void LLVMInitializePowerPCTarget() { } @@ -51,10 +48,60 @@ const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const { return new PPCLinuxTargetAsmInfo(*this); } -PPCTargetMachine::PPCTargetMachine(const Target&T, const Module &M, - const std::string &FS, bool is64Bit) - : LLVMTargetMachine(T), - Subtarget(*this, M, FS, is64Bit), +unsigned PPC32TargetMachine::getJITMatchQuality() { +#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__) + if (sizeof(void*) == 4) + return 10; +#endif + return 0; +} +unsigned PPC64TargetMachine::getJITMatchQuality() { +#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__) + if (sizeof(void*) == 8) + return 10; +#endif + return 0; +} + +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-") + return 20; + + // If the target triple is something non-powerpc, we don't match. + if (!TT.empty()) return 0; + + if (M.getEndianness() == Module::BigEndian && + M.getPointerSize() == Module::Pointer32) + return 10; // Weak match + else if (M.getEndianness() != Module::AnyEndianness || + M.getPointerSize() != Module::AnyPointerSize) + return 0; // Match for some other target + + return getJITMatchQuality()/2; +} + +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) + : Subtarget(*this, M, FS, is64Bit), DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this), FrameInfo(*this, is64Bit), JITInfo(*this, is64Bit), TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()), MachOWriterInfo(*this) { @@ -71,15 +118,13 @@ PPCTargetMachine::PPCTargetMachine(const Target&T, const Module &M, /// groups, which typically degrades performance. bool PPCTargetMachine::getEnableTailMergeDefault() const { return false; } -PPC32TargetMachine::PPC32TargetMachine(const Target &T, const Module &M, - const std::string &FS) - : PPCTargetMachine(T, M, FS, false) { +PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS) + : PPCTargetMachine(M, FS, false) { } -PPC64TargetMachine::PPC64TargetMachine(const Target &T, const Module &M, - const std::string &FS) - : PPCTargetMachine(T, M, FS, true) { +PPC64TargetMachine::PPC64TargetMachine(const Module &M, const std::string &FS) + : PPCTargetMachine(M, FS, true) { } diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.h b/llvm/lib/Target/PowerPC/PPCTargetMachine.h index 794123ad164..e6f61029f3b 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.h +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.h @@ -45,13 +45,12 @@ protected: // To avoid having target depend on the asmprinter stuff libraries, asmprinter // set this functions to ctor pointer at startup time if they are linked in. typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o, - TargetMachine &m, + PPCTargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; public: - PPCTargetMachine(const Target &T, const Module &M, const std::string &FS, - bool is64Bit); + PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit); virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; } virtual const PPCFrameInfo *getFrameInfo() const { return &FrameInfo; } @@ -104,14 +103,20 @@ public: /// class PPC32TargetMachine : public PPCTargetMachine { public: - PPC32TargetMachine(const Target &T, const Module &M, const std::string &FS); + 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 Target &T, const Module &M, const std::string &FS); + PPC64TargetMachine(const Module &M, const std::string &FS); + + static unsigned getJITMatchQuality(); + static unsigned getModuleMatchQuality(const Module &M); }; } // end namespace llvm |