diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 09:22:31 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 09:22:31 +0000 |
commit | 4246790aa84a530b0378d917023584c2c7adb4a9 (patch) | |
tree | 3bf51eb9b30b759f48650cb5aaf3496c05c95177 | |
parent | 7a46d7898e3eff918c945131ca2ca705885f2552 (diff) | |
download | external_llvm-4246790aa84a530b0378d917023584c2c7adb4a9.zip external_llvm-4246790aa84a530b0378d917023584c2c7adb4a9.tar.gz external_llvm-4246790aa84a530b0378d917023584c2c7adb4a9.tar.bz2 |
Register Target's TargetMachine and AsmPrinter in the new registry.
- This abuses TargetMachineRegistry's constructor for now, this will get
cleaned up in time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75762 91177308-0d34-0410-b5e6-96231b3b80d8
37 files changed, 134 insertions, 59 deletions
diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h index b7ea448..26b20e6 100644 --- a/include/llvm/Target/TargetMachineRegistry.h +++ b/include/llvm/Target/TargetMachineRegistry.h @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "llvm/Support/Registry.h" +#include "llvm/Target/TargetRegistry.h" namespace llvm { class Module; @@ -76,12 +77,13 @@ namespace llvm { template<class TargetMachineImpl> struct RegisterTarget { - RegisterTarget(const char *Name, const char *ShortDesc) + RegisterTarget(Target &T, const char *Name, const char *ShortDesc) : Entry(Name, ShortDesc, &Allocator, &TargetMachineImpl::getModuleMatchQuality, &TargetMachineImpl::getJITMatchQuality), - Node(Entry) - {} + Node(Entry) { + TargetRegistry::RegisterTargetMachine(T, &Allocator); + } private: TargetMachineRegistry::entry Entry; diff --git a/lib/Target/ARM/ARM.h b/lib/Target/ARM/ARM.h index f6ae680..1b5b828 100644 --- a/lib/Target/ARM/ARM.h +++ b/lib/Target/ARM/ARM.h @@ -94,7 +94,7 @@ inline static const char *ARMCondCodeToString(ARMCC::CondCodes CC) { FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM); FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O, - ARMBaseTargetMachine &TM, + 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 6ebc1fd..bb760fd 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -36,8 +36,11 @@ extern "C" int ARMTargetMachineModule; int ARMTargetMachineModule = 0; // Register the target. -static RegisterTarget<ARMTargetMachine> X("arm", "ARM"); -static RegisterTarget<ThumbTargetMachine> Y("thumb", "Thumb"); +extern Target TheARMTarget; +static RegisterTarget<ARMTargetMachine> X(TheARMTarget, "arm", "ARM"); + +extern Target TheThumbTarget; +static RegisterTarget<ThumbTargetMachine> Y(TheThumbTarget, "thumb", "Thumb"); // Force static initialization. extern "C" void LLVMInitializeARMTarget() { } diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h index 56b18ae..cbf336f 100644 --- a/lib/Target/ARM/ARMTargetMachine.h +++ b/lib/Target/ARM/ARMTargetMachine.h @@ -42,7 +42,7 @@ 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, - ARMBaseTargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index de6adbd..098f5d3 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -31,6 +31,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.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" @@ -1287,7 +1288,7 @@ bool ARMAsmPrinter::doFinalization(Module &M) { /// regardless of whether the function is in SSA form. /// FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o, - ARMBaseTargetMachine &tm, + TargetMachine &tm, bool verbose) { return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); } @@ -1301,4 +1302,8 @@ namespace { } // Force static initialization. -extern "C" void LLVMInitializeARMAsmPrinter() { } +extern "C" void LLVMInitializeARMAsmPrinter() { + extern Target TheARMTarget, TheThumbTarget; + TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass); + TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass); +} diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp index 625d0ce..8775bb7 100644 --- a/lib/Target/Alpha/AlphaTargetMachine.cpp +++ b/lib/Target/Alpha/AlphaTargetMachine.cpp @@ -22,7 +22,9 @@ using namespace llvm; // Register the targets -static RegisterTarget<AlphaTargetMachine> X("alpha", "Alpha [experimental]"); +extern Target TheAlphaTarget; +static RegisterTarget<AlphaTargetMachine> X(TheAlphaTarget, "alpha", + "Alpha [experimental]"); // No assembler printer by default AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0; diff --git a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp index 21622db..ea810df 100644 --- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp +++ b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp @@ -24,6 +24,7 @@ #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" @@ -292,9 +293,6 @@ bool AlphaAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, return false; } -// Force static initialization. -extern "C" void LLVMInitializeAlphaAsmPrinter() { } - namespace { static struct Register { Register() { @@ -302,3 +300,10 @@ namespace { } } Registrator; } + +// Force static initialization. +extern "C" void LLVMInitializeAlphaAsmPrinter() { + extern Target TheAlphaTarget; + TargetRegistry::RegisterAsmPrinter(TheAlphaTarget, + createAlphaCodePrinterPass); +} diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index caf91c8..1eeee99 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -58,7 +58,8 @@ extern "C" int CBackendTargetMachineModule; int CBackendTargetMachineModule = 0; // Register the target. -static RegisterTarget<CTargetMachine> X("c", "C backend"); +extern Target TheCBackendTarget; +static RegisterTarget<CTargetMachine> X(TheCBackendTarget, "c", "C backend"); // Force static initialization. extern "C" void LLVMInitializeCBackendTarget() { } diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp index f0d8a36..0c36457 100644 --- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp +++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp @@ -37,6 +37,7 @@ #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 <set> @@ -289,7 +290,7 @@ namespace { class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter { DwarfWriter *DW; public: - explicit LinuxAsmPrinter(formatted_raw_ostream &O, SPUTargetMachine &TM, + explicit LinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : SPUAsmPrinter(O, TM, T, V), DW(0) {} @@ -599,14 +600,11 @@ bool LinuxAsmPrinter::doFinalization(Module &M) { /// that the Linux SPU assembler can deal with. /// FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o, - SPUTargetMachine &tm, + TargetMachine &tm, bool verbose) { return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); } -// Force static initialization. -extern "C" void LLVMInitializeCellSPUAsmPrinter() { } - namespace { static struct Register { Register() { @@ -614,3 +612,9 @@ namespace { } } Registrator; } + +// Force static initialization. +extern "C" void LLVMInitializeCellSPUAsmPrinter() { + extern Target TheCellSPUTarget; + TargetRegistry::RegisterAsmPrinter(TheCellSPUTarget, createSPUAsmPrinterPass); +} diff --git a/lib/Target/CellSPU/SPU.h b/lib/Target/CellSPU/SPU.h index 0262348..f76fc82 100644 --- a/lib/Target/CellSPU/SPU.h +++ b/lib/Target/CellSPU/SPU.h @@ -25,7 +25,7 @@ namespace llvm { FunctionPass *createSPUISelDag(SPUTargetMachine &TM); FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o, - SPUTargetMachine &tm, + TargetMachine &tm, bool verbose); /*--== Utility functions/predicates/etc used all over the place: --==*/ diff --git a/lib/Target/CellSPU/SPUTargetMachine.cpp b/lib/Target/CellSPU/SPUTargetMachine.cpp index 5c794c9..29bc705 100644 --- a/lib/Target/CellSPU/SPUTargetMachine.cpp +++ b/lib/Target/CellSPU/SPUTargetMachine.cpp @@ -23,10 +23,11 @@ using namespace llvm; +extern Target TheCellSPUTarget; namespace { // Register the targets RegisterTarget<SPUTargetMachine> - CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]"); + CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]"); } // No assembler printer by default diff --git a/lib/Target/CellSPU/SPUTargetMachine.h b/lib/Target/CellSPU/SPUTargetMachine.h index ce8e550..83ce9e7 100644 --- a/lib/Target/CellSPU/SPUTargetMachine.h +++ b/lib/Target/CellSPU/SPUTargetMachine.h @@ -42,7 +42,7 @@ 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, - SPUTargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index b2d72dd..7b2995f 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -81,7 +81,8 @@ extern "C" int CppBackendTargetMachineModule; int CppBackendTargetMachineModule = 0; // Register the target. -static RegisterTarget<CPPTargetMachine> X("cpp", "C++ backend"); +extern Target TheCppBackendTarget; +static RegisterTarget<CPPTargetMachine> X(TheCppBackendTarget, "cpp", "C++ backend"); // Force static initialization. extern "C" void LLVMInitializeCppBackendTarget() { } diff --git a/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp b/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp index b8aa37e..e5eedad 100644 --- a/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp +++ b/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp @@ -26,6 +26,7 @@ #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" @@ -369,7 +370,7 @@ bool IA64AsmPrinter::doFinalization(Module &M) { /// the given target machine description. /// FunctionPass *llvm::createIA64CodePrinterPass(formatted_raw_ostream &o, - IA64TargetMachine &tm, + TargetMachine &tm, bool verbose) { return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); } @@ -384,4 +385,7 @@ namespace { // Force static initialization. -extern "C" void LLVMInitializeIA64AsmPrinter() { } +extern "C" void LLVMInitializeIA64AsmPrinter() { + extern Target TheIA64Target; + TargetRegistry::RegisterAsmPrinter(TheIA64Target, createIA64CodePrinterPass); +} diff --git a/lib/Target/IA64/IA64.h b/lib/Target/IA64/IA64.h index afcbdaf..e45aeda 100644 --- a/lib/Target/IA64/IA64.h +++ b/lib/Target/IA64/IA64.h @@ -38,7 +38,7 @@ FunctionPass *createIA64BundlingPass(IA64TargetMachine &TM); /// regardless of whether the function is in SSA form. /// FunctionPass *createIA64CodePrinterPass(formatted_raw_ostream &o, - IA64TargetMachine &tm, + TargetMachine &tm, bool verbose); } // End llvm namespace diff --git a/lib/Target/IA64/IA64TargetMachine.cpp b/lib/Target/IA64/IA64TargetMachine.cpp index 00fdd5e..c75a93c 100644 --- a/lib/Target/IA64/IA64TargetMachine.cpp +++ b/lib/Target/IA64/IA64TargetMachine.cpp @@ -20,7 +20,8 @@ using namespace llvm; // Register the target -static RegisterTarget<IA64TargetMachine> X("ia64", +extern Target TheIA64Target; +static RegisterTarget<IA64TargetMachine> X(TheIA64Target, "ia64", "IA-64 (Itanium) [experimental]"); // No assembler printer by default diff --git a/lib/Target/IA64/IA64TargetMachine.h b/lib/Target/IA64/IA64TargetMachine.h index 8340052..6e78848 100644 --- a/lib/Target/IA64/IA64TargetMachine.h +++ b/lib/Target/IA64/IA64TargetMachine.h @@ -37,7 +37,7 @@ 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, - IA64TargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index 2ae1d4f..5cd442c 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -55,7 +55,8 @@ namespace { extern "C" int MSILTargetMachineModule; int MSILTargetMachineModule = 0; -static RegisterTarget<MSILTarget> X("msil", "MSIL backend"); +extern Target TheMSILTarget; +static RegisterTarget<MSILTarget> X(TheMSILTarget, "msil", "MSIL backend"); // Force static initialization. extern "C" void LLVMInitializeMSILTarget() { } diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp index 924c7e8..7156c87 100644 --- a/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -32,8 +32,9 @@ int MSP430TargetMachineModule = 0; // Register the targets +extern Target TheMSP430Target; static RegisterTarget<MSP430TargetMachine> -X("msp430", "MSP430 [experimental]"); +X(TheMSP430Target, "msp430", "MSP430 [experimental]"); // Force static initialization. extern "C" void LLVMInitializeMSP430Target() { } diff --git a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp index 719c2586..501dc6a 100644 --- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp @@ -33,6 +33,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" @@ -51,7 +52,7 @@ namespace { class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter { const MipsSubtarget *Subtarget; public: - explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM, + explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : AsmPrinter(O, TM, T, V) { Subtarget = &TM.getSubtarget<MipsSubtarget>(); @@ -92,7 +93,7 @@ namespace { /// 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, - MipsTargetMachine &tm, + TargetMachine &tm, bool verbose) { return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose); } @@ -584,4 +585,11 @@ namespace { } // Force static initialization. -extern "C" void LLVMInitializeMipsAsmPrinter() { } +extern "C" void LLVMInitializeMipsAsmPrinter() { + extern Target TheMipsTarget; + TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass); + + extern Target TheMipselTarget; + TargetRegistry::RegisterAsmPrinter(TheMipselTarget, + createMipsCodePrinterPass); +} diff --git a/lib/Target/Mips/Mips.h b/lib/Target/Mips/Mips.h index c1d6fdd..1ff34fb 100644 --- a/lib/Target/Mips/Mips.h +++ b/lib/Target/Mips/Mips.h @@ -26,7 +26,7 @@ namespace llvm { FunctionPass *createMipsISelDag(MipsTargetMachine &TM); FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM); FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS, - MipsTargetMachine &TM, + TargetMachine &TM, bool Verbose); } // end namespace llvm; diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index 1e6add4..1495c7a 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/lib/Target/Mips/MipsTargetMachine.cpp @@ -28,8 +28,12 @@ extern "C" int MipsTargetMachineModule; int MipsTargetMachineModule = 0; // Register the target. -static RegisterTarget<MipsTargetMachine> X("mips", "Mips"); -static RegisterTarget<MipselTargetMachine> Y("mipsel", "Mipsel"); +extern Target TheMipsTarget; +static RegisterTarget<MipsTargetMachine> X(TheMipsTarget, "mips", "Mips"); + +extern Target TheMipselTarget; +static RegisterTarget<MipselTargetMachine> Y(TheMipselTarget, "mipsel", + "Mipsel"); MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0; diff --git a/lib/Target/Mips/MipsTargetMachine.h b/lib/Target/Mips/MipsTargetMachine.h index 7dd8d2b..fa945a5 100644 --- a/lib/Target/Mips/MipsTargetMachine.h +++ b/lib/Target/Mips/MipsTargetMachine.h @@ -38,7 +38,7 @@ namespace llvm { // asmprinter set this functions to ctor pointer at startup time if they are // linked in. typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o, - MipsTargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/PIC16/PIC16TargetMachine.cpp b/lib/Target/PIC16/PIC16TargetMachine.cpp index 50deab1..f3f3956 100644 --- a/lib/Target/PIC16/PIC16TargetMachine.cpp +++ b/lib/Target/PIC16/PIC16TargetMachine.cpp @@ -32,10 +32,13 @@ int PIC16TargetMachineModule = 0; // Register the targets +extern Target ThePIC16Target; static RegisterTarget<PIC16TargetMachine> -X("pic16", "PIC16 14-bit [experimental]."); +X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental]."); + +extern Target TheCooperTarget; static RegisterTarget<CooperTargetMachine> -Y("cooper", "PIC16 Cooper [experimental]."); +Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental]."); // Force static initialization. extern "C" void LLVMInitializePIC16Target() { } diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 7489e49..f568bc1 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -43,6 +43,7 @@ #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" @@ -317,7 +318,7 @@ namespace { /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter { public: - explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM, + explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : PPCAsmPrinter(O, TM, T, V){} @@ -343,7 +344,7 @@ namespace { class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter { formatted_raw_ostream &OS; public: - explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM, + explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : PPCAsmPrinter(O, TM, T, V), OS(O) {} @@ -1080,7 +1081,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { /// Darwin assembler can deal with. /// FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o, - PPCTargetMachine &tm, + TargetMachine &tm, bool verbose) { const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>(); @@ -1103,4 +1104,10 @@ extern "C" int PowerPCAsmPrinterForceLink; int PowerPCAsmPrinterForceLink = 0; // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { } +extern "C" void LLVMInitializePowerPCAsmPrinter() { + extern Target ThePPC32Target; + TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass); + + extern Target ThePPC64Target; + TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass); +} diff --git a/lib/Target/PowerPC/PPC.h b/lib/Target/PowerPC/PPC.h index 89dc1c1..3aa313c 100644 --- a/lib/Target/PowerPC/PPC.h +++ b/lib/Target/PowerPC/PPC.h @@ -30,7 +30,7 @@ namespace llvm { FunctionPass *createPPCBranchSelectionPass(); FunctionPass *createPPCISelDag(PPCTargetMachine &TM); FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS, - PPCTargetMachine &TM, + TargetMachine &TM, bool Verbose); FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM, MachineCodeEmitter &MCE); diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index f1adc35..cac97e4 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -30,10 +30,13 @@ extern "C" int PowerPCTargetMachineModule; int PowerPCTargetMachineModule = 0; // Register the targets +extern Target ThePPC32Target; static RegisterTarget<PPC32TargetMachine> -X("ppc32", "PowerPC 32"); +X(ThePPC32Target, "ppc32", "PowerPC 32"); + +extern Target ThePPC64Target; static RegisterTarget<PPC64TargetMachine> -Y("ppc64", "PowerPC 64"); +Y(ThePPC64Target, "ppc64", "PowerPC 64"); // Force static initialization. extern "C" void LLVMInitializePowerPCTarget() { } diff --git a/lib/Target/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h index e6f6102..393474c 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.h +++ b/lib/Target/PowerPC/PPCTargetMachine.h @@ -45,7 +45,7 @@ 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, - PPCTargetMachine &tm, + TargetMachine &m, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp index c580285..03735b0 100644 --- a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp +++ b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp @@ -26,6 +26,7 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Mangler.h" @@ -359,4 +360,8 @@ namespace { } // Force static initialization. -extern "C" void LLVMInitializeSparcAsmPrinter() { } +extern "C" void LLVMInitializeSparcAsmPrinter() { + extern Target TheSparcTarget; + TargetRegistry::RegisterAsmPrinter(TheSparcTarget, + createSparcCodePrinterPass); +} diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 66d5497..6862b85 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -19,7 +19,8 @@ using namespace llvm; // Register the target. -static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC"); +extern Target TheSparcTarget; +static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC"); // No assembler printer by default SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0; diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h index 9721fdc..b8a25a6 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h @@ -37,7 +37,7 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { MCContext *Context; MCStreamer *Streamer; public: - explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM, + explicit X86ATTAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : AsmPrinter(O, TM, T, V) { Subtarget = &TM.getSubtarget<X86Subtarget>(); diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 40b24f3..3fad77e 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -17,6 +17,7 @@ #include "X86ATTAsmPrinter.h" #include "X86IntelAsmPrinter.h" #include "X86Subtarget.h" +#include "llvm/Target/TargetRegistry.h" using namespace llvm; /// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code @@ -24,7 +25,7 @@ using namespace llvm; /// machine description. /// FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o, - X86TargetMachine &tm, + TargetMachine &tm, bool verbose) { const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>(); @@ -45,4 +46,10 @@ extern "C" int X86AsmPrinterForceLink; int X86AsmPrinterForceLink = 0; // Force static initialization. -extern "C" void LLVMInitializeX86AsmPrinter() { } +extern "C" void LLVMInitializeX86AsmPrinter() { + extern Target TheX86_32Target; + TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass); + + extern Target TheX86_64Target; + TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass); +} diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h index 8872869..603de3e 100644 --- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h +++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h @@ -25,7 +25,7 @@ namespace llvm { struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter { - explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM, + explicit X86IntelAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : AsmPrinter(O, TM, T, V) {} diff --git a/lib/Target/X86/X86.h b/lib/Target/X86/X86.h index ead4ce1..457e18a 100644 --- a/lib/Target/X86/X86.h +++ b/lib/Target/X86/X86.h @@ -47,7 +47,7 @@ FunctionPass *createX87FPRegKillInserterPass(); /// using the given target machine description. /// FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o, - X86TargetMachine &tm, + TargetMachine &tm, bool Verbose); /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 344370e..6cd0fc3 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -31,13 +31,18 @@ extern "C" int X86TargetMachineModule; int X86TargetMachineModule = 0; // Register the target. +extern Target TheX86_32Target; static RegisterTarget<X86_32TargetMachine> -X("x86", "32-bit X86: Pentium-Pro and above"); +X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above"); + +extern Target TheX86_64Target; static RegisterTarget<X86_64TargetMachine> -Y("x86-64", "64-bit X86: EM64T and AMD64"); +Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64"); // Force static initialization. -extern "C" void LLVMInitializeX86Target() { } +extern "C" void LLVMInitializeX86Target() { + +} // No assembler printer by default X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0; diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index ea7a453..a0602cf 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -44,7 +44,7 @@ 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, - X86TargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; diff --git a/lib/Target/XCore/XCoreTargetMachine.cpp b/lib/Target/XCore/XCoreTargetMachine.cpp index 42b9875..b64edbe 100644 --- a/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/lib/Target/XCore/XCoreTargetMachine.cpp @@ -26,9 +26,10 @@ using namespace llvm; extern "C" int XCoreTargetMachineModule; int XCoreTargetMachineModule = 0; +extern Target TheXCoreTarget; namespace { // Register the target. - RegisterTarget<XCoreTargetMachine> X("xcore", "XCore"); + RegisterTarget<XCoreTargetMachine> X(TheXCoreTarget, "xcore", "XCore"); } // Force static initialization. |