Move the code that creates instances of MipsInstrInfo and MipsFrameLowering out
authorAkira Hatanaka <ahatanaka@mips.com>
Thu, 2 Aug 2012 18:21:47 +0000 (18:21 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Thu, 2 Aug 2012 18:21:47 +0000 (18:21 +0000)
of MipsTargetMachine.cpp.

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

lib/Target/Mips/Mips16FrameLowering.cpp
lib/Target/Mips/Mips16InstrInfo.cpp
lib/Target/Mips/MipsFrameLowering.cpp
lib/Target/Mips/MipsFrameLowering.h
lib/Target/Mips/MipsInstrInfo.cpp
lib/Target/Mips/MipsInstrInfo.h
lib/Target/Mips/MipsSEFrameLowering.cpp
lib/Target/Mips/MipsSEInstrInfo.cpp
lib/Target/Mips/MipsTargetMachine.cpp

index 3df7d5f9f1f85991c826451ec15e7d1b89f33c19..030042f2e8326f4ec0703010b40acd4b591dbf9f 100644 (file)
@@ -80,3 +80,8 @@ void Mips16FrameLowering::
 processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                      RegScavenger *RS) const {
 }
+
+const MipsFrameLowering *
+llvm::createMips16FrameLowering(const MipsSubtarget &ST) {
+  return new Mips16FrameLowering(ST);
+}
index 59926b5b54c1034999a937f4f634b6405a7941fd..2bc286b6bb1f85d2ce0a73d2865fe70c6027ebe1 100644 (file)
@@ -126,3 +126,7 @@ void Mips16InstrInfo::ExpandRetRA16(MachineBasicBlock &MBB,
                                   unsigned Opc) const {
   BuildMI(MBB, I, I->getDebugLoc(), get(Opc));
 }
+
+const MipsInstrInfo *llvm::createMips16InstrInfo(MipsTargetMachine &TM) {
+  return new Mips16InstrInfo(TM);
+}
index f2ee41d00e43b8fcc74a236465603be68e32a18d..8c0474b0eec76c82b4d124b97e4dbd32e811ab16 100644 (file)
@@ -15,6 +15,7 @@
 #include "MipsAnalyzeImmediate.h"
 #include "MipsInstrInfo.h"
 #include "MipsMachineFunction.h"
+#include "MipsTargetMachine.h"
 #include "MCTargetDesc/MipsBaseInfo.h"
 #include "llvm/Function.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
@@ -81,6 +82,14 @@ using namespace llvm;
 //
 //===----------------------------------------------------------------------===//
 
+const MipsFrameLowering *MipsFrameLowering::create(MipsTargetMachine &TM,
+                                                   const MipsSubtarget &ST) {
+  if (TM.getSubtargetImpl()->inMips16Mode())
+    return llvm::createMips16FrameLowering(ST);
+
+  return llvm::createMipsSEFrameLowering(ST);
+}
+
 // hasFP - Return true if the specified function should have a dedicated frame
 // pointer register.  This is true if the function has variable sized allocas or
 // if frame pointer elimination is disabled.
index 9f234f9b37498ecae724473eed548fba7d2c5530..ed7b7fe76c2bb3d34221b66a983cf1e4d199a03d 100644 (file)
@@ -30,9 +30,16 @@ public:
     : TargetFrameLowering(StackGrowsDown, sti.hasMips64() ? 16 : 8, 0,
                           sti.hasMips64() ? 16 : 8), STI(sti) {}
 
+  static const MipsFrameLowering *create(MipsTargetMachine &TM,
+                                         const MipsSubtarget &ST);
+
   bool hasFP(const MachineFunction &MF) const;
 };
 
+/// Create MipsInstrInfo objects.
+const MipsFrameLowering *createMips16FrameLowering(const MipsSubtarget &ST);
+const MipsFrameLowering *createMipsSEFrameLowering(const MipsSubtarget &ST);
+
 } // End llvm namespace
 
 #endif
index 5b0d4eb6f0a8f0a81b67529317b19b07b13f61fe..50e3eb534e88cc24e305107c0f49d96046e6eb98 100644 (file)
@@ -31,6 +31,13 @@ MipsInstrInfo::MipsInstrInfo(MipsTargetMachine &tm, unsigned UncondBr)
   : MipsGenInstrInfo(Mips::ADJCALLSTACKDOWN, Mips::ADJCALLSTACKUP),
     TM(tm), UncondBrOpc(UncondBr) {}
 
+const MipsInstrInfo *MipsInstrInfo::create(MipsTargetMachine &TM) {
+  if (TM.getSubtargetImpl()->inMips16Mode())
+    return llvm::createMips16InstrInfo(TM);
+
+  return llvm::createMipsSEInstrInfo(TM);
+}
+
 bool MipsInstrInfo::isZeroImm(const MachineOperand &op) const {
   return op.isImm() && op.getImm() == 0;
 }
index 51fedc4fe4c02d8a1520863649801640857a44bc..7d562590624871f028083b8777a321e0226d3da7 100644 (file)
@@ -33,6 +33,8 @@ protected:
 public:
   explicit MipsInstrInfo(MipsTargetMachine &TM, unsigned UncondBrOpc);
 
+  static const MipsInstrInfo *create(MipsTargetMachine &TM);
+
   /// Branch Analysis
   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
                              MachineBasicBlock *&FBB,
@@ -98,6 +100,10 @@ namespace Mips {
                 MipsAnalyzeImmediate::Inst *LastInst);
 }
 
+/// Create MipsInstrInfo objects.
+const MipsInstrInfo *createMips16InstrInfo(MipsTargetMachine &TM);
+const MipsInstrInfo *createMipsSEInstrInfo(MipsTargetMachine &TM);
+
 }
 
 #endif
index b120ea3ebfd04d3664779db9a4720c203f0004a3..1c598471a0aa7298c9a1c6151712533454a06544 100644 (file)
@@ -203,3 +203,8 @@ processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
   if (hasFP(MF))
     MRI.setPhysRegUsed(FP);
 }
+
+const MipsFrameLowering *
+llvm::createMipsSEFrameLowering(const MipsSubtarget &ST) {
+  return new MipsSEFrameLowering(ST);
+}
index 5f8954ba484711993d56e45e7d1417663a0f0293..eeb1de36efc67818b77115b3b4c310d6a5da9103 100644 (file)
@@ -314,3 +314,7 @@ void MipsSEInstrInfo::ExpandBuildPairF64(MachineBasicBlock &MBB,
   BuildMI(MBB, I, dl, Mtc1Tdd, TRI.getSubReg(DstReg, Mips::sub_fpodd))
     .addReg(HiReg);
 }
+
+const MipsInstrInfo *llvm::createMipsSEInstrInfo(MipsTargetMachine &TM) {
+  return new MipsSEInstrInfo(TM);
+}
index 9480a77c74183a0b07ec51736b7dbd1525fb5ccc..03a024a361d5dfdf95cc1592689dcb5b5108c020 100644 (file)
 
 #include "MipsTargetMachine.h"
 #include "Mips.h"
-#include "Mips16FrameLowering.h"
-#include "Mips16InstrInfo.h"
-#include "MipsSEFrameLowering.h"
-#include "MipsSEInstrInfo.h"
+#include "MipsFrameLowering.h"
+#include "MipsInstrInfo.h"
 #include "llvm/PassManager.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -30,29 +28,6 @@ extern "C" void LLVMInitializeMipsTarget() {
   RegisterTargetMachine<MipselTargetMachine> B(TheMips64elTarget);
 }
 
-static const MipsInstrInfo *genInstrInfo(MipsTargetMachine &TM) {
-  const MipsInstrInfo *II;
-
-  if (TM.getSubtargetImpl()->inMips16Mode())
-    II = new Mips16InstrInfo(TM);
-  else
-    II = new MipsSEInstrInfo(TM);
-
-  return II;
-}
-
-static const MipsFrameLowering *genFrameLowering(MipsTargetMachine &TM,
-                                                 const MipsSubtarget &ST) {
-  const MipsFrameLowering *FL;
-
-  if (TM.getSubtargetImpl()->inMips16Mode())
-    FL = new Mips16FrameLowering(ST);
-  else
-    FL = new MipsSEFrameLowering(ST);
-
-  return FL;
-}
-
 // DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
 // The stack is always 8 byte aligned
 // On function prologue, the stack is created by decrementing
@@ -75,8 +50,8 @@ MipsTargetMachine(const Target &T, StringRef TT,
                (Subtarget.isABI_N64() ?
                 "E-p:64:64:64-i8:8:32-i16:16:32-i64:64:64-f128:128:128-n32" :
                 "E-p:32:32:32-i8:8:32-i16:16:32-i64:64:64-n32")),
-    InstrInfo(genInstrInfo(*this)),
-    FrameLowering(genFrameLowering(*this, Subtarget)),
+    InstrInfo(MipsInstrInfo::create(*this)),
+    FrameLowering(MipsFrameLowering::create(*this, Subtarget)),
     TLInfo(*this), TSInfo(*this), JITInfo() {
 }