Add new helpers for registering targets.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 25 Jul 2009 06:49:55 +0000 (06:49 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 25 Jul 2009 06:49:55 +0000 (06:49 +0000)
 - Less boilerplate == good.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77052 91177308-0d34-0410-b5e6-96231b3b80d8

40 files changed:
include/llvm/Target/TargetMachineRegistry.h [deleted file]
include/llvm/Target/TargetRegistry.h
lib/Target/ARM/ARM.h
lib/Target/ARM/ARMTargetMachine.cpp
lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/Alpha/Alpha.h
lib/Target/Alpha/AlphaTargetMachine.cpp
lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
lib/Target/CellSPU/SPU.h
lib/Target/CellSPU/SPUTargetMachine.cpp
lib/Target/CppBackend/CPPBackend.cpp
lib/Target/MSIL/MSILWriter.cpp
lib/Target/MSIL/MSILWriter.h
lib/Target/MSP430/MSP430.h
lib/Target/MSP430/MSP430AsmPrinter.cpp
lib/Target/MSP430/MSP430TargetMachine.cpp
lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
lib/Target/Mips/Mips.h
lib/Target/Mips/MipsTargetMachine.cpp
lib/Target/PIC16/PIC16.h
lib/Target/PIC16/PIC16AsmPrinter.cpp
lib/Target/PIC16/PIC16TargetMachine.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPC.h
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
lib/Target/Sparc/Sparc.h
lib/Target/Sparc/SparcTargetMachine.cpp
lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
lib/Target/SystemZ/SystemZ.h
lib/Target/SystemZ/SystemZTargetMachine.cpp
lib/Target/X86/AsmParser/X86AsmParser.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
lib/Target/X86/X86.h
lib/Target/X86/X86TargetMachine.cpp
lib/Target/XCore/XCore.h
lib/Target/XCore/XCoreAsmPrinter.cpp
lib/Target/XCore/XCoreTargetMachine.cpp

diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h
deleted file mode 100644 (file)
index a1b13d3..0000000
+++ /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
index 5ad74ec547ad1c939ac1df3a664055913cb012b3..6d692df27b85fc003f54db498e51f2974947e2df 100644 (file)
@@ -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
index 5a3555a2532d575e59274941641926b5949c1afd..b41ef90f129e0c32d03555a3321bdabbf997d248 100644 (file)
@@ -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);
 
index 08bb38215e3d373ffa0fcebb48184af44c4c2029..d71029475f2657ae0bf107ddd93156c8fe15a6c4 100644 (file)
@@ -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.
 ///
index cffbecd764bb94a43aa5da76b3fb54c0fc25f127..3d6fb8016b1a5eec547d3ed428ed87a52fc08331 100644 (file)
@@ -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);
 }
index 93c4c702603aeaf83a33516dde96e5e4d507093e..b8a06459e1cdec9e903f4b1751b8cb58b1f6dcf9 100644 (file)
@@ -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);
index 1947e6567037bc5472bad4799bd66e4dd7a5ae04..70d7b1524855fc57efbdfe101e9ee3328c66751f 100644 (file)
 #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);
index e6cc53a072296c5d682e5d3f8fbaa21dfdf70361..08a2c3430e29920c97445e18e1fe5bceee8356c9 100644 (file)
@@ -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);
 }
index 4defaec163c53b00e8f0081c0e8b41dc81a54823..c2681e4f5052525bb806ba2ee5865e496903aa4a 100644 (file)
@@ -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"
 #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
index a4475036966b42404ef6294aa5597f532a8b4cb7..df39710f3e6c9ec97ccef3ab900688f5fc12c518 100644 (file)
@@ -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);
 }
index 9fc36f657ae7c8c34c905885d0d0a027e922ff07..02713b5402dafd4368bc58b672853657e8c38f6a 100644 (file)
@@ -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
index f1b1a742914f3442e11bb3fa4f4f83eec8bf9f85..26215cd26fc27015b88ee507bfaf17a0ce4e595a 100644 (file)
 #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;
index 7c5d09ec1b0e99f50b44a74d347b061df32a97b5..b552e04c4f4aca54895933901241e3b698efa6b1 100644 (file)
@@ -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;
index c3808d379eea9bed501e51584e21717987f28604..ccac5189f3127dad03954c6a4ca4971ee650a632 100644 (file)
@@ -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;
index 09cfb219bfef393b1c4c512548a62d6c805f5436..21ff359920a3ae22c9a57492c491e4e43ffcb519 100644 (file)
@@ -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;
index 6251a42f9043c32c81bf727e26da9569c3b139a5..d9f5f8629541f481174a095382c9bd2bfdc79460 100644 (file)
@@ -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;
 
index 4905f25ceb875df4928a4d67a825d4815010af51..bb112bc25502fb3a5c430c1b4f85cdd63c70fb42 100644 (file)
@@ -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);
+}
index ffd93da921a54b5645b0677d796693db143476e3..d77b26b56c66318315690329f449f5d68fbf6e24 100644 (file)
 #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) :
index 132c9b0000b569adf72ef34c729d5380c8252a82..9eda5e222cf5cc89dd57e06ca24b5aeb26389173 100644 (file)
@@ -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);
 }
index 09a80729a567b8e4af1e51d4dff068c2cb19dbfb..a9ab050d6f0dc68e397c180bdfcd31f406313c35 100644 (file)
@@ -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;
index e82dcee6362046814c035cb3ad2e959e49165c89..b5e2da74ba7e4b9ffed57875f5df5c1081a648d7 100644 (file)
 #include "MipsTargetMachine.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-// Register the target.
-static RegisterTarget<MipsTargetMachine>    X(TheMipsTarget, "mips", "Mips");
-
-static RegisterTarget<MipselTargetMachine>  Y(TheMipselTarget, "mipsel", 
-                                              "Mipsel");
-
-// Force static initialization.
-extern "C" void LLVMInitializeMipsTarget() { }
+extern "C" void LLVMInitializeMipsTarget() {
+  // Register the target.
+  RegisterTargetMachine<MipsTargetMachine> X(TheMipsTarget);
+  RegisterTargetMachine<MipselTargetMachine> Y(TheMipselTarget);
+}
 
 const TargetAsmInfo *MipsTargetMachine::
 createTargetAsmInfo() const 
index b1df058cb8eecf8c24a3f4da5c44c7fc32526b9a..447beba7d693744260f71ab81d3206d05697ef7b 100644 (file)
@@ -343,10 +343,7 @@ namespace PIC16CC {
 
 
   FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
-  FunctionPass *createPIC16CodePrinterPass(formatted_raw_ostream &OS, 
-                                           TargetMachine &TM,
-                                           bool Verbose);
-  // Banksel optimzer pass.
+  // Banksel optimizer pass.
   FunctionPass *createPIC16MemSelOptimizerPass();
 
   extern Target ThePIC16Target;
index 8cd57614305dc019ac6a469e0808cc3b51f1bd1f..95d363e4ecc1754f6c47bfc5c6f8532fe263a6ee 100644 (file)
@@ -24,6 +24,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/Target/TargetRegistry.h"
 
 using namespace llvm;
 
@@ -107,17 +108,6 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   return false;  // we didn't modify anything.
 }
 
-/// createPIC16CodePrinterPass - Returns a pass that prints the PIC16
-/// 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::createPIC16CodePrinterPass(formatted_raw_ostream &o,
-                                               TargetMachine &tm,
-                                               bool verbose) {
-  return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
-}
-
 
 // printOperand - print operand of insn.
 void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
@@ -435,3 +425,11 @@ void PIC16AsmPrinter::EmitRemainingAutos() {
   }
 }
 
+
+extern "C" void LLVMInitializePIC16Target() { 
+  // Register the targets
+  RegisterTargetMachine<PIC16TargetMachine> A(ThePIC16Target);  
+  RegisterTargetMachine<CooperTargetMachine> B(TheCooperTarget);
+  RegisterAsmPrinter<PIC16AsmPrinter> C(ThePIC16Target);
+  RegisterAsmPrinter<PIC16AsmPrinter> D(TheCooperTarget);
+}
index dca6ade9384e2a7d2b0f13f48444d4678f3c62fe..6a4492c5484ba72978e930d0464fd8fcedefeda8 100644 (file)
 #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<PIC16TargetMachine> 
-X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental].");
-
-static RegisterTarget<CooperTargetMachine> 
-Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
-
-// Force static initialization.
-extern "C" void LLVMInitializePIC16Target() { 
-  TargetRegistry::RegisterAsmPrinter(ThePIC16Target,
-                                     &createPIC16CodePrinterPass);
-  TargetRegistry::RegisterAsmPrinter(TheCooperTarget,
-                                     &createPIC16CodePrinterPass);
-}
-
 // PIC16TargetMachine - Traditional PIC16 Machine.
 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M, 
                                        const std::string &FS, bool Cooper)
index 1ac3e32e568b36b0783baed1751503876f282057..146979ef5657f92ab370bd0eeb91bee9e1175dec 100644 (file)
@@ -1075,7 +1075,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
 /// for a MachineFunction to the given output stream, in a format that the
 /// Darwin assembler can deal with.
 ///
-FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
+static FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &o,
                                             TargetMachine &tm,
                                             bool verbose) {
   const PPCSubtarget *Subtarget = &tm.getSubtarget<PPCSubtarget>();
index 6d8974f2e08968672afd0764e7903d7b5d5095ac..7b98268bd83d0b146a893987d4616727ba5ada84 100644 (file)
@@ -29,9 +29,6 @@ namespace llvm {
   
 FunctionPass *createPPCBranchSelectionPass();
 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
-FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
-                                      TargetMachine &TM,
-                                      bool Verbose);
 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
                                        MachineCodeEmitter &MCE);
 FunctionPass *createPPCJITCodeEmitterPass(PPCTargetMachine &TM,
index 3d5ae5221af565f984afb66461ec1ff9d61c9770..bb228c614ecef448d8490f1579e8fd53ce701569 100644 (file)
 #include "PPCTargetMachine.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/Target/TargetRegistry.h"
 #include "llvm/Support/FormattedStream.h"
 using namespace llvm;
 
-// Register the targets
-static RegisterTarget<PPC32TargetMachine>
-X(ThePPC32Target, "ppc32", "PowerPC 32");
-
-static RegisterTarget<PPC64TargetMachine>
-Y(ThePPC64Target, "ppc64", "PowerPC 64");
-
-// Force static initialization.
-extern "C" void LLVMInitializePowerPCTarget() { }
+extern "C" void LLVMInitializePowerPCTarget() {
+  // Register the targets
+  RegisterTargetMachine<PPC32TargetMachine> A(ThePPC32Target);  
+  RegisterTargetMachine<PPC64TargetMachine> B(ThePPC64Target);
+}
 
 const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
   if (Subtarget.isDarwin())
index 39682c7a00bb9a1f30f41b1090a4931f0f76c761..ad99cca4ac05a452a8fea7de8f9028a947fc5e46 100644 (file)
@@ -76,17 +76,6 @@ namespace {
 
 #include "SparcGenAsmWriter.inc"
 
-/// createSparcCodePrinterPass - Returns a pass that prints the SPARC
-/// 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::createSparcCodePrinterPass(formatted_raw_ostream &o,
-                                               TargetMachine &tm,
-                                               bool verbose) {
-  return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
-}
-
 
 /// runOnMachineFunction - This uses the printInstruction()
 /// method to print assembly for each instruction.
@@ -336,6 +325,5 @@ bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
 
 // Force static initialization.
 extern "C" void LLVMInitializeSparcAsmPrinter() { 
-  TargetRegistry::RegisterAsmPrinter(TheSparcTarget, 
-                                     createSparcCodePrinterPass);
+  RegisterAsmPrinter<SparcAsmPrinter> X(TheSparcTarget);
 }
index 06ad1a4da35eb89b051326b1bdc191a0985df3d3..bb5155e1c263b521f5bee03a022bfebf8302e5df 100644 (file)
@@ -25,9 +25,6 @@ namespace llvm {
   class formatted_raw_ostream;
 
   FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
-  FunctionPass *createSparcCodePrinterPass(formatted_raw_ostream &OS,
-                                           TargetMachine &TM,
-                                           bool Verbose);
   FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
   FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
 
index 686cf9102838af58211fd49f76d2c172ec58794a..0605db393ec5fe9d78b2f88fb0773e3a7ec4f662 100644 (file)
 #include "Sparc.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-// Register the target.
-static RegisterTarget<SparcTargetMachine> X(TheSparcTarget, "sparc", "SPARC");
-
-// Force static initialization.
-extern "C" void LLVMInitializeSparcTarget() { }
+extern "C" void LLVMInitializeSparcTarget() {
+  // Register the target.
+  RegisterTargetMachine<SparcTargetMachine> X(TheSparcTarget);
+}
 
 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
   // FIXME: Handle Solaris subtarget someday :)
index ae449be9808ccd6a206e3a7a98f6d86bb4443bdb..572326e76d4191c9f2e0d86b2c109981715aef3e 100644 (file)
@@ -78,17 +78,6 @@ namespace {
 
 #include "SystemZGenAsmWriter.inc"
 
-/// createSystemZCodePrinterPass - Returns a pass that prints the SystemZ
-/// 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::createSystemZCodePrinterPass(formatted_raw_ostream &o,
-                                                 TargetMachine &tm,
-                                                 bool verbose) {
-  return new SystemZAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
-}
-
 void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
   unsigned FnAlign = MF.getAlignment();
   const Function *F = MF.getFunction();
@@ -403,6 +392,5 @@ void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
 
 // Force static initialization.
 extern "C" void LLVMInitializeSystemZAsmPrinter() {
-  TargetRegistry::RegisterAsmPrinter(TheSystemZTarget,
-                                     createSystemZCodePrinterPass);
+  RegisterAsmPrinter<SystemZAsmPrinter> X(TheSystemZTarget);
 }
index 466b44787c812b76623ed74e4c7384c448dbcd22..ea5240a10c9a01775800ef79f1ad7e3706efcb5c 100644 (file)
@@ -46,9 +46,6 @@ namespace llvm {
 
   FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
                                     CodeGenOpt::Level OptLevel);
-  FunctionPass *createSystemZCodePrinterPass(formatted_raw_ostream &o,
-                                             TargetMachine &tm,
-                                             bool verbose);
 
   extern Target TheSystemZTarget;
 
index 8799190e2e019250dca7cb18fa134215d1e2879c..8c11a47d1a67132152a1abe7dde86c63d81fe462 100644 (file)
@@ -1,4 +1,4 @@
-//===-- SystemZTargetMachine.cpp - Define TargetMachine for SystemZ -----------===//
+//===-- SystemZTargetMachine.cpp - Define TargetMachine for SystemZ -------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
 #include "SystemZ.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-namespace {
-  // Register the target.
-  RegisterTarget<SystemZTargetMachine> X(TheSystemZTarget,
-                                         "systemz",
-                                         "SystemZ [experimental]");
-}
-
-// Force static initialization.
 extern "C" void LLVMInitializeSystemZTarget() {
-
+  // Register the target.
+  RegisterTargetMachine<SystemZTargetMachine> X(TheSystemZTarget);
 }
 
 const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
index 7c50f31ab8fb04316b82dbebba3fb8f20f3d4798..c278de0af190cc13b39797da39c14a04824924c3 100644 (file)
@@ -56,14 +56,8 @@ bool X86ATTAsmParser::ParseInstruction(MCAsmParser &AP, const char *Name,
   return MatchInstruction(Name, Operands, Inst);
 }
 
-namespace {
-  TargetAsmParser *createAsmParser(const Target &T) {
-    return new X86ATTAsmParser(T);
-  }
-}
-
 // Force static initialization.
 extern "C" void LLVMInitializeX86AsmParser() {
-  TargetRegistry::RegisterAsmParser(TheX86_32Target, &createAsmParser);
-  TargetRegistry::RegisterAsmParser(TheX86_64Target, &createAsmParser);
+  RegisterAsmParser<X86ATTAsmParser> X(TheX86_32Target);
+  RegisterAsmParser<X86ATTAsmParser> Y(TheX86_64Target);
 }
index b6caf30c791fd8896ab6c60948925127024c98ed..ebf9acf9d861a3765a97831ab3da4780e73ebd84 100644 (file)
@@ -25,9 +25,9 @@ using namespace llvm;
 /// for a MachineFunction to the given output stream, using the given target
 /// machine description.
 ///
-FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
-                                             TargetMachine &tm,
-                                             bool verbose) {
+static FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
+                                              TargetMachine &tm,
+                                              bool verbose) {
   const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>();
 
   if (Subtarget->isFlavorIntel())
index 0c3bc3977cc91361adc6cf844b91cd31ced5c248..2647d687091deafe72f591937aecfac4b7b83dd3 100644 (file)
@@ -42,14 +42,6 @@ FunctionPass *createX86FloatingPointStackifierPass();
 ///
 FunctionPass *createX87FPRegKillInserterPass();
 
-/// createX86CodePrinterPass - Returns a pass that prints the X86
-/// assembly code for a MachineFunction to the given output stream,
-/// using the given target machine description.
-///
-FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
-                                       TargetMachine &tm,
-                                       bool Verbose);
-
 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
 /// to the specified MCE object.
 
index fa3ec6904dea114239e7910af5d21c2afb7b45d3..a720e6e894d4abf272f25fcb7cce32e7a83deacc 100644 (file)
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Target/TargetOptions.h"
-#include "llvm/Target/TargetMachineRegistry.h"
+#include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-// Register the target.
-static RegisterTarget<X86_32TargetMachine>
-X(TheX86_32Target, "x86",    "32-bit X86: Pentium-Pro and above");
-
-static RegisterTarget<X86_64TargetMachine>
-Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64");
-
-// Force static initialization.
 extern "C" void LLVMInitializeX86Target() { 
-  
+  // Register the target.
+  RegisterTargetMachine<X86_32TargetMachine> X(TheX86_32Target);
+  RegisterTargetMachine<X86_64TargetMachine> Y(TheX86_64Target);
 }
 
 const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
index b7b86304b10e696b45eddee2c6d6d0cc596895f8..8937fbe123c64074aa6e992430f90be858b46913 100644 (file)
@@ -24,9 +24,6 @@ namespace llvm {
   class formatted_raw_ostream;
 
   FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM);
-  FunctionPass *createXCoreCodePrinterPass(formatted_raw_ostream &OS,
-                                           TargetMachine &TM,
-                                           bool Verbose);
 
   extern Target TheXCoreTarget;
 
index 2a4d57b7ad35c94a519289440043a33e1f7c06d2..5f2484293f66b095a2850e7abee49f4337ad097f 100644 (file)
@@ -28,6 +28,7 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetRegistry.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
@@ -91,17 +92,6 @@ namespace {
 
 #include "XCoreGenAsmWriter.inc"
 
-/// createXCoreCodePrinterPass - Returns a pass that prints the XCore
-/// 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::createXCoreCodePrinterPass(formatted_raw_ostream &o,
-                                               TargetMachine &tm,
-                                               bool verbose) {
-  return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
-}
-
 void XCoreAsmPrinter::
 emitGlobalDirective(const std::string &name)
 {
@@ -387,3 +377,9 @@ bool XCoreAsmPrinter::doInitialization(Module &M) {
 }
 
 
+
+// Force static initialization.
+extern "C" void LLVMInitializeXCoreTarget() { 
+  RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget);
+  RegisterAsmPrinter<XCoreAsmPrinter> Y(TheXCoreTarget);
+}
index edc437b5e30503ab41e8606b1512654b8ce4eefa..faea96057217a16aaa4efbf551450ee376e2e73a 100644 (file)
 #include "XCore.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Target/TargetMachineRegistry.h"
 using namespace llvm;
 
-namespace {
-  // Register the target.
-  RegisterTarget<XCoreTargetMachine> X(TheXCoreTarget, "xcore", "XCore");
-}
-
-// Force static initialization.
-extern "C" void LLVMInitializeXCoreTarget() { 
-  TargetRegistry::RegisterAsmPrinter(TheXCoreTarget,
-                                     &createXCoreCodePrinterPass);
-}
-
 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
   return new XCoreTargetAsmInfo(*this);
 }