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
diff --git a/lib/Target/PIC16/PIC16.h b/lib/Target/PIC16/PIC16.h
index b1df058..447beba 100644
--- a/lib/Target/PIC16/PIC16.h
+++ b/lib/Target/PIC16/PIC16.h
@@ -343,10 +343,7 @@
 
 
   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;
diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index 8cd5761..95d363e 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -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 @@
   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 @@
   }
 }
 
+
+extern "C" void LLVMInitializePIC16Target() { 
+  // Register the targets
+  RegisterTargetMachine<PIC16TargetMachine> A(ThePIC16Target);  
+  RegisterTargetMachine<CooperTargetMachine> B(TheCooperTarget);
+  RegisterAsmPrinter<PIC16AsmPrinter> C(ThePIC16Target);
+  RegisterAsmPrinter<PIC16AsmPrinter> D(TheCooperTarget);
+}
diff --git a/lib/Target/PIC16/PIC16TargetMachine.cpp b/lib/Target/PIC16/PIC16TargetMachine.cpp
index dca6ade..6a4492c 100644
--- a/lib/Target/PIC16/PIC16TargetMachine.cpp
+++ b/lib/Target/PIC16/PIC16TargetMachine.cpp
@@ -18,25 +18,9 @@
 #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)