Move PPCJITInfo off of the TargetMachine and onto the subtarget.
authorEric Christopher <echristo@gmail.com>
Thu, 12 Jun 2014 22:28:06 +0000 (22:28 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 12 Jun 2014 22:28:06 +0000 (22:28 +0000)
Needed to migrate a few functions around to avoid circular header
dependencies.

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

lib/Target/PowerPC/PPCJITInfo.cpp
lib/Target/PowerPC/PPCJITInfo.h
lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/PowerPC/PPCSubtarget.h
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/PowerPC/PPCTargetMachine.h

index f3c83c6a56677ab1049a25a7bd856bda41047c4d..e5f113a0c030128acb7929260ed6c235ee2507c2 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "PPCJITInfo.h"
 #include "PPCRelocations.h"
-#include "PPCTargetMachine.h"
+#include "PPCSubtarget.h"
 #include "llvm/IR/Function.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -25,6 +25,11 @@ using namespace llvm;
 
 static TargetJITInfo::JITCompilerFn JITCompilerFunction;
 
+PPCJITInfo::PPCJITInfo(PPCSubtarget &STI)
+    : Subtarget(STI), is64Bit(STI.isPPC64()) {
+  useGOT = 0;
+}
+
 #define BUILD_ADDIS(RD,RS,IMM16) \
   ((15 << 26) | ((RD) << 21) | ((RS) << 16) | ((IMM16) & 65535))
 #define BUILD_ORI(RD,RS,UIMM16) \
index 033b7e322263730890caf183d91fb185a2a1cd30..b6b37ffb852b0f5cb9eef191f5bbaada8badb729 100644 (file)
 #ifndef POWERPC_JITINFO_H
 #define POWERPC_JITINFO_H
 
-#include "PPCSubtarget.h"
 #include "llvm/CodeGen/JITCodeEmitter.h"
 #include "llvm/Target/TargetJITInfo.h"
 
 namespace llvm {
+class PPCSubtarget;
+class PPCJITInfo : public TargetJITInfo {
+protected:
+  PPCSubtarget &Subtarget;
+  bool is64Bit;
 
-  class PPCJITInfo : public TargetJITInfo {
-  protected:
-    PPCSubtarget &Subtarget;
-    bool is64Bit;
-  public:
-    PPCJITInfo(PPCSubtarget &STI)
-        : Subtarget(STI), is64Bit(STI.isPPC64()) {
-      useGOT = 0;
-    }
+public:
+  PPCJITInfo(PPCSubtarget &STI);
 
-    StubLayout getStubLayout() override;
-    void *emitFunctionStub(const Function* F, void *Fn,
-                           JITCodeEmitter &JCE) override;
-    LazyResolverFn getLazyResolverFunction(JITCompilerFn) override;
-    void relocate(void *Function, MachineRelocation *MR,
-                  unsigned NumRelocs, unsigned char* GOTBase) override;
+  StubLayout getStubLayout() override;
+  void *emitFunctionStub(const Function *F, void *Fn,
+                         JITCodeEmitter &JCE) override;
+  LazyResolverFn getLazyResolverFunction(JITCompilerFn) override;
+  void relocate(void *Function, MachineRelocation *MR, unsigned NumRelocs,
+                unsigned char *GOTBase) override;
 
-    /// replaceMachineCodeForFunction - Make it so that calling the function
-    /// whose machine code is at OLD turns into a call to NEW, perhaps by
-    /// overwriting OLD with a branch to NEW.  This is used for self-modifying
-    /// code.
-    ///
-    void replaceMachineCodeForFunction(void *Old, void *New) override;
-  };
+  /// replaceMachineCodeForFunction - Make it so that calling the function
+  /// whose machine code is at OLD turns into a call to NEW, perhaps by
+  /// overwriting OLD with a branch to NEW.  This is used for self-modifying
+  /// code.
+  ///
+  void replaceMachineCodeForFunction(void *Old, void *New) override;
+};
 }
 
 #endif
index 355902875d667adb85116a3058b8e7c303fb83f6..6507caaafbb6a196fba1ee9519070631ec8b7007 100644 (file)
@@ -80,7 +80,7 @@ PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
     : PPCGenSubtargetInfo(TT, CPU, FS), IsPPC64(is64Bit), TargetTriple(TT),
       OptLevel(OptLevel),
       FrameLowering(initializeSubtargetDependencies(CPU, FS)),
-      DL(getDataLayoutString(*this)), InstrInfo(*this) {}
+      DL(getDataLayoutString(*this)), InstrInfo(*this), JITInfo(*this) {}
 
 /// SetJITMode - This is called to inform the subtarget info that we are
 /// producing code for the JIT.
index 9d4c264ac5e420bd3601e3543385f38a91ad08b1..7724e05874c4f2416f6d4823574ee98c8699b788 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "PPCFrameLowering.h"
 #include "PPCInstrInfo.h"
+#include "PPCJITInfo.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/MC/MCInstrItineraries.h"
@@ -105,9 +106,10 @@ protected:
   /// OptLevel - What default optimization level we're emitting code for.
   CodeGenOpt::Level OptLevel;
 
-  PPCFrameLowering    FrameLowering;
+  PPCFrameLowering FrameLowering;
   const DataLayout DL;
   PPCInstrInfo InstrInfo;
+  PPCJITInfo JITInfo;
 
 public:
   /// This constructor initializes the data members to match that
@@ -141,6 +143,7 @@ public:
   const PPCFrameLowering *getFrameLowering() const { return &FrameLowering; }
   const DataLayout *getDataLayout() const { return &DL; }
   const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
+  PPCJITInfo *getJITInfo() { return &JITInfo; }
 
   /// initializeSubtargetDependencies - Initializes using a CPU and feature string
   /// so that we can use initializer lists for subtarget initialization.
index ed82a63393052354db4bdc7823ea358b985af35c..c29de1b5d09de85df9530cab8eb693f98b8aeec0 100644 (file)
@@ -42,8 +42,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
                                    Reloc::Model RM, CodeModel::Model CM,
                                    CodeGenOpt::Level OL, bool is64Bit)
     : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
-      Subtarget(TT, CPU, FS, is64Bit, OL), JITInfo(Subtarget),
-      TLInfo(*this), TSInfo(*this) {
+      Subtarget(TT, CPU, FS, is64Bit, OL), TLInfo(*this), TSInfo(*this) {
   initAsmInfo();
 }
 
index ecfdf27591cb630372e6d3d4fb26c62d127ae1b2..00785afca5cb04282657eb03d27217c29e13a73e 100644 (file)
@@ -29,7 +29,6 @@ namespace llvm {
 ///
 class PPCTargetMachine : public LLVMTargetMachine {
   PPCSubtarget        Subtarget;
-  PPCJITInfo          JITInfo;
   PPCTargetLowering   TLInfo;
   PPCSelectionDAGInfo TSInfo;
 
@@ -45,7 +44,7 @@ public:
   const PPCFrameLowering *getFrameLowering() const override {
     return getSubtargetImpl()->getFrameLowering();
   }
-        PPCJITInfo        *getJITInfo() override         { return &JITInfo; }
+  PPCJITInfo *getJITInfo() override { return Subtarget.getJITInfo(); }
   const PPCTargetLowering *getTargetLowering() const override {
    return &TLInfo;
   }