Some refactoring so TargetRegistry.h no longer has to include any files
authorEvan Cheng <evan.cheng@apple.com>
Tue, 23 Aug 2011 20:15:21 +0000 (20:15 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 23 Aug 2011 20:15:21 +0000 (20:15 +0000)
from MC.

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

19 files changed:
include/llvm/MC/MCCodeGenInfo.h
include/llvm/MC/MCInstrAnalysis.h
include/llvm/Support/CodeGen.h [new file with mode: 0644]
include/llvm/Target/TargetRegistry.h
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
lib/Target/Alpha/MCTargetDesc/AlphaMCTargetDesc.cpp
lib/Target/Blackfin/MCTargetDesc/BlackfinMCTargetDesc.cpp
lib/Target/CellSPU/MCTargetDesc/SPUMCTargetDesc.cpp
lib/Target/MBlaze/MCTargetDesc/MBlazeMCTargetDesc.cpp
lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp
lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
lib/Target/PTX/MCTargetDesc/PTXMCTargetDesc.cpp
lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp
lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
tools/llvm-objdump/llvm-objdump.cpp

index 9e72ece6e334eca8ac80bb76384f63792863f3bf..1c54c47e2d95ba16c1f590138be91657df21c4b6 100644 (file)
 #ifndef LLVM_MC_MCCODEGENINFO_H
 #define LLVM_MC_MCCODEGENINFO_H
 
-namespace llvm {
-
-  // Relocation model types.
-  namespace Reloc {
-    enum Model { Default, Static, PIC_, DynamicNoPIC };
-  }
+#include "llvm/Support/CodeGen.h"
 
-  // Code model types.
-  namespace CodeModel {
-    enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
-  }
+namespace llvm {
 
   class MCCodeGenInfo {
     /// RelocationModel - Relocation model: statcic, pic, etc.
index 464768313b93adf6bb245b2014e79a54bccc738b..8f3c499b1c7382276416ca218f4a0303aa8d3d87 100644 (file)
@@ -23,8 +23,9 @@ protected:
   friend class Target;
   const MCInstrInfo *Info;
 
-  MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
 public:
+  MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
+
   virtual ~MCInstrAnalysis() {}
 
   virtual bool isBranch(const MCInst &Inst) const {
diff --git a/include/llvm/Support/CodeGen.h b/include/llvm/Support/CodeGen.h
new file mode 100644 (file)
index 0000000..41351dc
--- /dev/null
@@ -0,0 +1,32 @@
+//===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file define some types which define code generation concepts. For
+// example, relocation model.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_CODEGEN_H
+#define LLVM_SUPPORT_CODEGEN_H
+
+namespace llvm {
+
+  // Relocation model types.
+  namespace Reloc {
+    enum Model { Default, Static, PIC_, DynamicNoPIC };
+  }
+
+  // Code model types.
+  namespace CodeModel {
+    enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
+  }
+
+}  // end llvm namespace
+
+#endif
index 6e55c1fbf61daa89ea7a28d9207687daf65b4b3a..19a5fc34e3ea87cbf93ae3b423c2005d1f21e135 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef LLVM_TARGET_TARGETREGISTRY_H
 #define LLVM_TARGET_TARGETREGISTRY_H
 
-#include "llvm/MC/MCCodeGenInfo.h"
-#include "llvm/MC/MCInstrAnalysis.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/ADT/Triple.h"
 #include <string>
 #include <cassert>
@@ -36,6 +35,7 @@ namespace llvm {
   class MCCodeGenInfo;
   class MCContext;
   class MCDisassembler;
+  class MCInstrAnalysis;
   class MCInstPrinter;
   class MCInstrInfo;
   class MCRegisterInfo;
@@ -291,7 +291,7 @@ namespace llvm {
     ///
     MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
       if (!MCInstrAnalysisCtorFn)
-        return new MCInstrAnalysis(Info);
+        return 0;
       return MCInstrAnalysisCtorFn(Info);
     }
 
@@ -890,6 +890,39 @@ namespace llvm {
     }
   };
 
+  /// RegisterMCInstrAnalysis - Helper template for registering a target
+  /// instruction analyzer implementation.  This invokes the static "Create"
+  /// method on the class to actually do the construction.  Usage:
+  ///
+  /// extern "C" void LLVMInitializeFooTarget() {
+  ///   extern Target TheFooTarget;
+  ///   RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
+  /// }
+  template<class MCInstrAnalysisImpl>
+  struct RegisterMCInstrAnalysis {
+    RegisterMCInstrAnalysis(Target &T) {
+      TargetRegistry::RegisterMCInstrAnalysis(T, &Allocator);
+    }
+  private:
+    static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
+      return new MCInstrAnalysisImpl(Info);
+    }
+  };
+
+  /// RegisterMCInstrAnalysisFn - Helper template for registering a target
+  /// instruction analyzer implementation.  This invokes the specified function
+  /// to do the construction.  Usage:
+  ///
+  /// extern "C" void LLVMInitializeFooTarget() {
+  ///   extern Target TheFooTarget;
+  ///   RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
+  /// }
+  struct RegisterMCInstrAnalysisFn {
+    RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) {
+      TargetRegistry::RegisterMCInstrAnalysis(T, Fn);
+    }
+  };
+
   /// RegisterMCRegInfo - Helper template for registering a target register info
   /// implementation.  This invokes the static "Create" method on the class to
   /// actually do the construction.  Usage:
index 40efea74545cd89208d426a54025b39a32ed64da..8f989debf0e9e66b2ff985d3fa46099aa635628b 100644 (file)
@@ -18,6 +18,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrDesc.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetAsmParser.h"
index 8cb0ccf380dc3260220cbd1e5f555986c0357a2b..92c90c4cbd338d44c8ad3a552b995c1219d3ad9f 100644 (file)
@@ -15,6 +15,8 @@
 #include "ARMMCAsmInfo.h"
 #include "ARMBaseInfo.h"
 #include "InstPrinter/ARMInstPrinter.h"
+#include "llvm/MC/MCCodeGenInfo.h"
+#include "llvm/MC/MCInstrAnalysis.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
@@ -216,17 +218,18 @@ extern "C" void LLVMInitializeARMTargetMC() {
   TargetRegistry::RegisterMCRegInfo(TheARMTarget, createARMMCRegisterInfo);
   TargetRegistry::RegisterMCRegInfo(TheThumbTarget, createARMMCRegisterInfo);
 
-  TargetRegistry::RegisterMCInstrAnalysis(TheARMTarget,
-                                          createARMMCInstrAnalysis);
-  TargetRegistry::RegisterMCInstrAnalysis(TheThumbTarget,
-                                          createARMMCInstrAnalysis);
-
   // Register the MC subtarget info.
   TargetRegistry::RegisterMCSubtargetInfo(TheARMTarget,
                                           ARM_MC::createARMMCSubtargetInfo);
   TargetRegistry::RegisterMCSubtargetInfo(TheThumbTarget,
                                           ARM_MC::createARMMCSubtargetInfo);
 
+  // Register the MC instruction analyzer.
+  TargetRegistry::RegisterMCInstrAnalysis(TheARMTarget,
+                                          createARMMCInstrAnalysis);
+  TargetRegistry::RegisterMCInstrAnalysis(TheThumbTarget,
+                                          createARMMCInstrAnalysis);
+
   // Register the MC Code Emitter
   TargetRegistry::RegisterMCCodeEmitter(TheARMTarget, createARMMCCodeEmitter);
   TargetRegistry::RegisterMCCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
index a38023bcfd62cf7439b665fd20ab39a3564f34e1..b6afa28ed8db266cdc63a075a903160f8686a439 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "AlphaMCTargetDesc.h"
 #include "AlphaMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 5fdc527aef0c0516748553d89189c713872340e5..922c0ca6f4afcefb1f2f9caace90eb5572eba992 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "BlackfinMCTargetDesc.h"
 #include "BlackfinMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 075ec07302eb38cb501a21ce36f977260dd717be..f60fb7aa1a38d5cf0b8a68546615bbec121dd5c3 100644 (file)
@@ -14,6 +14,7 @@
 #include "SPUMCTargetDesc.h"
 #include "SPUMCAsmInfo.h"
 #include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 18d751393ecca3be1c8ff2861f484fffaee36798..27de592db48f51e0de6329c0958b1a00da863dbc 100644 (file)
@@ -14,6 +14,7 @@
 #include "MBlazeMCTargetDesc.h"
 #include "MBlazeMCAsmInfo.h"
 #include "InstPrinter/MBlazeInstPrinter.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
index b028a488772f7ff51a35f61e314e96691c4106d0..c48fd4830304844b0b398b50203973e96735a12c 100644 (file)
@@ -14,6 +14,7 @@
 #include "MSP430MCTargetDesc.h"
 #include "MSP430MCAsmInfo.h"
 #include "InstPrinter/MSP430InstPrinter.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index bb846d8b7bc4a850af73e820b79f8f9f3a746aab..f318db3fc710314e8dfd580175414214fd330628 100644 (file)
@@ -15,6 +15,7 @@
 #include "MipsMCAsmInfo.h"
 #include "InstPrinter/MipsInstPrinter.h"
 #include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 7217b6d288813fb244d0f3b1c20cb348d65146c8..3932b7cc52970af67f3e9839c9fc8e297d499e51 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "PTXMCTargetDesc.h"
 #include "PTXMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index ba452fc662cd2c10fbbd60e62649ce86c5d976a7..c1396a17bee41fe518b2985f40ff6e52e82018bc 100644 (file)
@@ -15,6 +15,7 @@
 #include "PPCMCAsmInfo.h"
 #include "InstPrinter/PPCInstPrinter.h"
 #include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
index eedf87e1cef56e67d9a70a57444fcbfea7357670..9876af57bb59ffb25142b4999ecff68ba5f47ec7 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "SparcMCTargetDesc.h"
 #include "SparcMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index ffcd14603cb4144cf64a92fe8a062dd192fa84e9..6bc65b8e641ee8197b396a39ffe9b6a7b1bcc31f 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "SystemZMCTargetDesc.h"
 #include "SystemZMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 1d89005ca316f12a044eb9d9f91cf42f613a4baf..64bb01cf63fb895e151bb29184f67266132e211a 100644 (file)
@@ -16,6 +16,8 @@
 #include "InstPrinter/X86ATTInstPrinter.h"
 #include "InstPrinter/X86IntelInstPrinter.h"
 #include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCCodeGenInfo.h"
+#include "llvm/MC/MCInstrAnalysis.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
@@ -393,6 +395,10 @@ static MCInstPrinter *createX86MCInstPrinter(const Target &T,
   return 0;
 }
 
+static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) {
+  return new MCInstrAnalysis(Info);
+}
+
 // Force static initialization.
 extern "C" void LLVMInitializeX86TargetMC() {
   // Register the MC asm info.
@@ -417,6 +423,12 @@ extern "C" void LLVMInitializeX86TargetMC() {
   TargetRegistry::RegisterMCSubtargetInfo(TheX86_64Target,
                                           X86_MC::createX86MCSubtargetInfo);
 
+  // Register the MC instruction analyzer.
+  TargetRegistry::RegisterMCInstrAnalysis(TheX86_32Target,
+                                          createX86MCInstrAnalysis);
+  TargetRegistry::RegisterMCInstrAnalysis(TheX86_64Target,
+                                          createX86MCInstrAnalysis);
+
   // Register the code emitter.
   TargetRegistry::RegisterMCCodeEmitter(TheX86_32Target,
                                         createX86MCCodeEmitter);
index 6e5460ef16de15f57da9e296fd3801b5794ec283..a4c0a5053b06397caf615d475d23abdb73de6635 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "XCoreMCTargetDesc.h"
 #include "XCoreMCAsmInfo.h"
+#include "llvm/MC/MCCodeGenInfo.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCSubtargetInfo.h"
index 4804f596b24e7e6f77416156cd731bb95f7613b8..b0bb36bd3d83dcffb252785748cf1302273652aa 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/MC/MCDisassembler.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCInstPrinter.h"
+#include "llvm/MC/MCInstrAnalysis.h"
 #include "llvm/MC/MCInstrDesc.h"
 #include "llvm/MC/MCInstrInfo.h"
 #include "llvm/Support/CommandLine.h"