diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 06:49:55 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-25 06:49:55 +0000 |
commit | 0c795d61878156817cedbac51ec2921f2634c1a5 (patch) | |
tree | 368d6bec69dc60fd9d6fcf8201a1a76500a7546f | |
parent | 92ccf70ad448eb02f9f273d2c70ae4708b3bd0f2 (diff) |
Add new helpers for registering targets.
- Less boilerplate == good.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77052 91177308-0d34-0410-b5e6-96231b3b80d8
40 files changed, 188 insertions, 344 deletions
diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h deleted file mode 100644 index a1b13d360d..0000000000 --- a/include/llvm/Target/TargetMachineRegistry.h +++ /dev/null @@ -1,55 +0,0 @@ -//===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file exposes two classes: the TargetMachineRegistry class, which allows -// tools to inspect all of registered targets, and the RegisterTarget class, -// which TargetMachine implementations should use to register themselves with -// the system. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H -#define LLVM_TARGET_TARGETMACHINEREGISTRY_H - -#include "llvm/Module.h" -#include "llvm/Target/TargetRegistry.h" - -namespace llvm { - class Module; - class Target; - class TargetMachine; - - //===--------------------------------------------------------------------===// - /// RegisterTarget - This class is used to make targets automatically register - /// themselves with the tools they are linked with. Targets should define an - /// single global Target instance and register it using the TargetRegistry - /// interfaces. Targets must also include a static instance of this class. - /// - /// The type 'TargetMachineImpl' should provide a constructor with two - /// parameters: - /// - const Module& M: the module that is being compiled: - /// - const std::string& FS: target-specific string describing target - /// flavour. - - template<class TargetMachineImpl> - struct RegisterTarget { - RegisterTarget(Target &T, const char *Name, const char *ShortDesc) { - TargetRegistry::RegisterTargetMachine(T, &Allocator); - } - - private: - static TargetMachine *Allocator(const Target &T, const Module &M, - const std::string &FS) { - return new TargetMachineImpl(T, M, FS); - } - }; - -} - -#endif diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 5ad74ec547..6d692df27b 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -19,6 +19,9 @@ #ifndef LLVM_TARGET_TARGETREGISTRY_H #define LLVM_TARGET_TARGETREGISTRY_H +// FIXME: We shouldn't need this header, but we need it until there is a +// different interface to get the TargetAsmInfo. +#include "llvm/Target/TargetMachine.h" #include <string> #include <cassert> @@ -278,6 +281,98 @@ namespace llvm { /// @} }; + + //===--------------------------------------------------------------------===// + + /// RegisterTarget - Helper template for registering a target, for use in the + /// target's initialization function. Usage: + /// + /// + /// Target TheFooTarget; // The global target instance. + /// + /// namespace { + /// struct FooInfo { + /// static unsigned getJITMatchQuality() { ... } + /// static unsigned getTripleMatchQuality(const std::string &) { ... } + /// static unsigned getModuleMatchQuality(const Module &) { ... } + /// }; + /// } + /// + /// extern "C" void LLVMInitializeFooTargetInfo() { + /// RegisterTarget<FooAsmPrinter> X(TheFooTarget, "foo", "Foo description"); + /// } + template<class TargetInfoImpl> + struct RegisterTarget { + RegisterTarget(Target &T, const char *Name, const char *Desc) { + TargetRegistry::RegisterTarget(T, Name, Desc, + &TargetInfoImpl::getTripleMatchQuality, + &TargetInfoImpl::getModuleMatchQuality, + &TargetInfoImpl::getJITMatchQuality); + } + }; + + /// RegisterTargetMachine - Helper template for registering a target machine + /// implementation, for use in the target machine initialization + /// function. Usage: + /// + /// extern "C" void LLVMInitializeFooTarget() { + /// extern Target TheFooTarget; + /// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget); + /// } + template<class TargetMachineImpl> + struct RegisterTargetMachine { + RegisterTargetMachine(Target &T) { + TargetRegistry::RegisterTargetMachine(T, &Allocator); + } + + private: + static TargetMachine *Allocator(const Target &T, const Module &M, + const std::string &FS) { + return new TargetMachineImpl(T, M, FS); + } + }; + + /// RegisterAsmPrinter - Helper template for registering a target specific + /// assembly printer, for use in the target machine initialization + /// function. Usage: + /// + /// extern "C" void LLVMInitializeFooAsmPrinter() { + /// extern Target TheFooTarget; + /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget); + /// } + template<class AsmPrinterImpl> + struct RegisterAsmPrinter { + RegisterAsmPrinter(Target &T) { + TargetRegistry::RegisterAsmPrinter(T, &Allocator); + } + + private: + static FunctionPass *Allocator(formatted_raw_ostream &OS, + TargetMachine &TM, + bool Verbose) { + return new AsmPrinterImpl(OS, TM, TM.getTargetAsmInfo(), Verbose); + } + }; + + /// RegisterAsmParser - Helper template for registering a target specific asm + /// parser, for use in the target machine initialization function. Usage: + /// + /// extern "C" void LLVMInitializeFooAsmPrinter() { + /// extern Target TheFooTarget; + /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget); + /// } + template<class AsmParserImpl> + struct RegisterAsmParser { + RegisterAsmParser(Target &T) { + TargetRegistry::RegisterAsmParser(T, &Allocator); + } + + private: + static TargetAsmParser *Allocator(const Target &T) { + return new AsmParserImpl(T); + } + }; + } #endif diff --git a/lib/Target/ARM/ARM.h b/lib/Target/ARM/ARM.h index 5a3555a253..b41ef90f12 100644 --- a/lib/Target/ARM/ARM.h +++ b/lib/Target/ARM/ARM.h @@ -93,9 +93,6 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) { } FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM); -FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O, - TargetMachine &TM, - bool Verbose); FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM, MachineCodeEmitter &MCE); diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 08bb38215e..d71029475f 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -19,8 +19,8 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetRegistry.h" using namespace llvm; static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden, @@ -28,14 +28,11 @@ static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden, static cl::opt<bool> DisableIfConversion("disable-arm-if-conversion",cl::Hidden, cl::desc("Disable if-conversion pass")); -// Register the target. -static RegisterTarget<ARMTargetMachine> X(llvm::TheARMTarget, "arm", "ARM"); - -static RegisterTarget<ThumbTargetMachine> Y(llvm::TheThumbTarget, "thumb", - "Thumb"); - -// Force static initialization. -extern "C" void LLVMInitializeARMTarget() { } +extern "C" void LLVMInitializeARMTarget() { + // Register the target. + RegisterTargetMachine<ARMTargetMachine> X(TheARMTarget); + RegisterTargetMachine<ThumbTargetMachine> Y(TheThumbTarget); +} /// TargetMachine ctor - Create an ARM architecture model. /// diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index cffbecd764..3d6fb8016b 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1304,19 +1304,8 @@ bool ARMAsmPrinter::doFinalization(Module &M) { return AsmPrinter::doFinalization(M); } -/// createARMCodePrinterPass - Returns a pass that prints the ARM -/// assembly code for a MachineFunction to the given output stream, -/// using the given target machine description. This should work -/// regardless of whether the function is in SSA form. -/// -FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose) { - return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); -} - // Force static initialization. extern "C" void LLVMInitializeARMAsmPrinter() { - TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass); - TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass); + RegisterAsmPrinter<ARMAsmPrinter> X(TheARMTarget); + RegisterAsmPrinter<ARMAsmPrinter> Y(TheThumbTarget); } diff --git a/lib/Target/Alpha/Alpha.h b/lib/Target/Alpha/Alpha.h index 93c4c70260..b8a06459e1 100644 --- a/lib/Target/Alpha/Alpha.h +++ b/lib/Target/Alpha/Alpha.h @@ -26,9 +26,6 @@ namespace llvm { class formatted_raw_ostream; FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM); - FunctionPass *createAlphaCodePrinterPass(formatted_raw_ostream &OS, - TargetMachine &TM, - bool Verbose); FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM); FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM, MachineCodeEmitter &MCE); diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp index 1947e65670..70d7b15248 100644 --- a/lib/Target/Alpha/AlphaTargetMachine.cpp +++ b/lib/Target/Alpha/AlphaTargetMachine.cpp @@ -16,17 +16,15 @@ #include "AlphaTargetMachine.h" #include "llvm/Module.h" #include "llvm/PassManager.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Target/TargetRegistry.h" using namespace llvm; -// Register the targets -static RegisterTarget<AlphaTargetMachine> X(TheAlphaTarget, "alpha", - "Alpha [experimental]"); - -// Force static initialization. -extern "C" void LLVMInitializeAlphaTarget() { } +extern "C" void LLVMInitializeAlphaTarget() { + // Register the target. + RegisterTargetMachine<AlphaTargetMachine> X(TheAlphaTarget); +} const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const { return new AlphaTargetAsmInfo(*this); diff --git a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp index e6cc53a072..08a2c3430e 100644 --- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp +++ b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp @@ -63,17 +63,6 @@ namespace { }; } // end of anonymous namespace -/// createAlphaCodePrinterPass - Returns a pass that prints the Alpha -/// assembly code for a MachineFunction to the given output stream, -/// using the given target machine description. This should work -/// regardless of whether the function is in SSA form. -/// -FunctionPass *llvm::createAlphaCodePrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose) { - return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); -} - #include "AlphaGenAsmWriter.inc" void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum) @@ -288,6 +277,5 @@ bool AlphaAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, // Force static initialization. extern "C" void LLVMInitializeAlphaAsmPrinter() { - TargetRegistry::RegisterAsmPrinter(TheAlphaTarget, - createAlphaCodePrinterPass); + RegisterAsmPrinter<AlphaAsmPrinter> X(TheAlphaTarget); } diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 4defaec163..c2681e4f50 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -32,7 +32,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/CFG.h" @@ -50,11 +49,10 @@ #include <sstream> using namespace llvm; -// Register the target. -static RegisterTarget<CTargetMachine> X(TheCBackendTarget, "c", "C backend"); - -// Force static initialization. -extern "C" void LLVMInitializeCBackendTarget() { } +extern "C" void LLVMInitializeCBackendTarget() { + // Register the target. + RegisterTargetMachine<CTargetMachine> X(TheCBackendTarget); +} namespace { /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp index a447503696..df39710f3e 100644 --- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp +++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp @@ -584,17 +584,7 @@ void LinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { O << '\n'; } -/// createSPUCodePrinterPass - Returns a pass that prints the Cell SPU -/// assembly code for a MachineFunction to the given output stream, in a format -/// that the Linux SPU assembler can deal with. -/// -FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose) { - return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); -} - // Force static initialization. extern "C" void LLVMInitializeCellSPUAsmPrinter() { - TargetRegistry::RegisterAsmPrinter(TheCellSPUTarget, createSPUAsmPrinterPass); + RegisterAsmPrinter<LinuxAsmPrinter> X(TheCellSPUTarget); } diff --git a/lib/Target/CellSPU/SPU.h b/lib/Target/CellSPU/SPU.h index 9fc36f657a..02713b5402 100644 --- a/lib/Target/CellSPU/SPU.h +++ b/lib/Target/CellSPU/SPU.h @@ -24,9 +24,6 @@ namespace llvm { class formatted_raw_ostream; FunctionPass *createSPUISelDag(SPUTargetMachine &TM); - FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose); /*--== Utility functions/predicates/etc used all over the place: --==*/ //! Predicate test for a signed 10-bit value diff --git a/lib/Target/CellSPU/SPUTargetMachine.cpp b/lib/Target/CellSPU/SPUTargetMachine.cpp index f1b1a74291..26215cd26f 100644 --- a/lib/Target/CellSPU/SPUTargetMachine.cpp +++ b/lib/Target/CellSPU/SPUTargetMachine.cpp @@ -17,21 +17,17 @@ #include "SPUTargetMachine.h" #include "llvm/Module.h" #include "llvm/PassManager.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/CodeGen/RegAllocRegistry.h" #include "llvm/CodeGen/SchedulerRegistry.h" +#include "llvm/Target/TargetRegistry.h" using namespace llvm; -namespace { - // Register the targets - RegisterTarget<SPUTargetMachine> - CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]"); +extern "C" void LLVMInitializeCellSPUTarget() { + // Register the target. + RegisterTargetMachine<SPUTargetMachine> X(TheCellSPUTarget); } -// Force static initialization. -extern "C" void LLVMInitializeCellSPUTarget() { } - const std::pair<unsigned, int> * SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { NumEntries = 1; diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 7c5d09ec1b..b552e04c4f 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -23,7 +23,6 @@ #include "llvm/Pass.h" #include "llvm/PassManager.h" #include "llvm/TypeSymbolTable.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" @@ -31,6 +30,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Streams.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Config/config.h" #include <algorithm> #include <set> @@ -72,11 +72,10 @@ static cl::opt<std::string> NameToGenerate("cppfor", cl::Optional, cl::desc("Specify the name of the thing to generate"), cl::init("!bad!")); -// Register the target. -static RegisterTarget<CPPTargetMachine> X(TheCppBackendTarget, "cpp", "C++ backend"); - -// Force static initialization. -extern "C" void LLVMInitializeCppBackendTarget() { } +extern "C" void LLVMInitializeCppBackendTarget() { + // Register the target. + RegisterTargetMachine<CPPTargetMachine> X(TheCppBackendTarget); +} namespace { typedef std::vector<const Type*> TypeList; diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index c3808d379e..ccac5189f3 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -22,6 +22,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Transforms/Scalar.h" #include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/Passes.h" @@ -48,10 +49,10 @@ namespace { }; } -static RegisterTarget<MSILTarget> X(TheMSILTarget, "msil", "MSIL backend"); - -// Force static initialization. -extern "C" void LLVMInitializeMSILTarget() { } +extern "C" void LLVMInitializeMSILTarget() { + // Register the target. + RegisterTargetMachine<MSILTarget> X(TheMSILTarget); +} bool MSILModule::runOnModule(Module &M) { ModulePtr = &M; diff --git a/lib/Target/MSIL/MSILWriter.h b/lib/Target/MSIL/MSILWriter.h index 09cfb219bf..21ff359920 100644 --- a/lib/Target/MSIL/MSILWriter.h +++ b/lib/Target/MSIL/MSILWriter.h @@ -26,7 +26,6 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Support/Mangler.h" #include <ios> using namespace llvm; diff --git a/lib/Target/MSP430/MSP430.h b/lib/Target/MSP430/MSP430.h index 6251a42f90..d9f5f86295 100644 --- a/lib/Target/MSP430/MSP430.h +++ b/lib/Target/MSP430/MSP430.h @@ -24,9 +24,6 @@ namespace llvm { FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel); - FunctionPass *createMSP430CodePrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose); extern Target TheMSP430Target; diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index 4905f25ceb..bb112bc255 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -1,4 +1,4 @@ -//===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer ------------------===// +//===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer ----------------===// // // The LLVM Compiler Infrastructure // @@ -27,6 +27,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/FormattedStream.h" @@ -72,17 +73,6 @@ namespace { #include "MSP430GenAsmWriter.inc" -/// createMSP430CodePrinterPass - Returns a pass that prints the MSP430 -/// assembly code for a MachineFunction to the given output stream, -/// using the given target machine description. This should work -/// regardless of whether the function is in SSA form. -/// -FunctionPass *llvm::createMSP430CodePrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose) { - return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); -} - void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) { const Function *F = MF.getFunction(); @@ -255,3 +245,9 @@ void MSP430AsmPrinter::printCCOperand(const MachineInstr *MI, int OpNum) { break; } } + +extern "C" void LLVMInitializeMSP430Target() { + // Register the target. + RegisterTargetMachine<MSP430TargetMachine> X(TheMSP430Target); + RegisterAsmPrinter<MSP430AsmPrinter> Y(TheMSP430Target); +} diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp index ffd93da921..d77b26b56c 100644 --- a/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -18,20 +18,8 @@ #include "llvm/PassManager.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetAsmInfo.h" -#include "llvm/Target/TargetMachineRegistry.h" - using namespace llvm; -// Register the targets -static RegisterTarget<MSP430TargetMachine> -X(TheMSP430Target, "msp430", "MSP430 [experimental]"); - -// Force static initialization. -extern "C" void LLVMInitializeMSP430Target() { - TargetRegistry::RegisterAsmPrinter(TheMSP430Target, - &createMSP430CodePrinterPass); -} - MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Module &M, const std::string &FS) : diff --git a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp index 132c9b0000..9eda5e222c 100644 --- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp @@ -87,16 +87,6 @@ namespace { #include "MipsGenAsmWriter.inc" -/// createMipsCodePrinterPass - Returns a pass that prints the MIPS -/// assembly code for a MachineFunction to the given output stream, -/// using the given target machine description. This should work -/// regardless of whether the function is in SSA form. -FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o, - TargetMachine &tm, - bool verbose) { - return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); -} - //===----------------------------------------------------------------------===// // // Mips Asm Directives @@ -560,8 +550,6 @@ void MipsAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) { // Force static initialization. extern "C" void LLVMInitializeMipsAsmPrinter() { - TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass); - - TargetRegistry::RegisterAsmPrinter(TheMipselTarget, - createMipsCodePrinterPass); + RegisterAsmPrinter<MipsAsmPrinter> X(TheMipsTarget); + RegisterAsmPrinter<MipsAsmPrinter> Y(TheMipselTarget); } diff --git a/lib/Target/Mips/Mips.h b/lib/Target/Mips/Mips.h index 09a80729a5..a9ab050d6f 100644 --- a/lib/Target/Mips/Mips.h +++ b/lib/Target/Mips/Mips.h @@ -25,9 +25,6 @@ namespace llvm { FunctionPass *createMipsISelDag(MipsTargetMachine &TM); FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM); - FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS, - TargetMachine &TM, - bool Verbose); extern Target TheMipsTarget; extern Target TheMipselTarget; diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index e82dcee636..b5e2da74ba 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/ |