[llvm-commits] [llvm] r55076 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/X86/X86FastISel.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h utils/TableGen/FastISelEmitter.cpp

Dan Gohman gohman at apple.com
Wed Aug 20 14:05:57 PDT 2008


Author: djg
Date: Wed Aug 20 16:05:57 2008
New Revision: 55076

URL: http://llvm.org/viewvc/llvm-project?rev=55076&view=rev
Log:
Simplify FastISel's constructor argument list, make the FastISel
class hold a MachineRegisterInfo member, and make the
MachineBasicBlock be passed in to SelectInstructions rather
than the FastISel constructor.

Modified:
    llvm/trunk/include/llvm/CodeGen/FastISel.h
    llvm/trunk/include/llvm/Target/TargetLowering.h
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/Target/X86/X86FastISel.h
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.h
    llvm/trunk/utils/TableGen/FastISelEmitter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FastISel.h Wed Aug 20 16:05:57 2008
@@ -22,6 +22,7 @@
 
 class MachineBasicBlock;
 class MachineFunction;
+class MachineRegisterInfo;
 class TargetInstrInfo;
 class TargetRegisterClass;
 
@@ -30,8 +31,9 @@
 /// lowering, but runs quickly.
 class FastISel {
   MachineBasicBlock *MBB;
-  MachineFunction *MF;
-  const TargetInstrInfo *TII;
+  MachineFunction &MF;
+  MachineRegisterInfo &MRI;
+  const TargetInstrInfo &TII;
 
 public:
   /// SelectInstructions - Do "fast" instruction selection over the
@@ -41,14 +43,13 @@
   /// register numbers.
   BasicBlock::iterator
   SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
-                     DenseMap<const Value*, unsigned> &ValueMap);
+                     DenseMap<const Value*, unsigned> &ValueMap,
+                     MachineBasicBlock *mbb);
 
   virtual ~FastISel();
 
 protected:
-  FastISel(MachineBasicBlock *mbb, MachineFunction *mf,
-           const TargetInstrInfo *tii)
-    : MBB(mbb), MF(mf), TII(tii) {}
+  explicit FastISel(MachineFunction &mf);
 
   /// FastEmit_r - This method is called by target-independent code
   /// to request that an instruction with the given type and opcode

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Aug 20 16:05:57 2008
@@ -42,7 +42,6 @@
   class SDValue;
   class SelectionDAG;
   class TargetData;
-  class TargetInstrInfo;
   class TargetMachine;
   class TargetRegisterClass;
   class TargetSubtarget;
@@ -1116,9 +1115,7 @@
 
   /// createFastISel - This method returns a target specific FastISel object,
   /// or null if the target does not support "fast" ISel.
-  virtual FastISel *createFastISel(MachineBasicBlock *,
-                                   MachineFunction *,
-                                   const TargetInstrInfo *) { return 0; }
+  virtual FastISel *createFastISel(MachineFunction &) { return 0; }
 
   //===--------------------------------------------------------------------===//
   // Inline Asm Support hooks

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Aug 20 16:05:57 2008
@@ -16,6 +16,7 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
 /// SelectBinaryOp - Select and emit code for a binary operator instruction,
@@ -54,7 +55,9 @@
 BasicBlock::iterator
 FastISel::SelectInstructions(BasicBlock::iterator Begin,
                              BasicBlock::iterator End,
-                             DenseMap<const Value*, unsigned> &ValueMap) {
+                             DenseMap<const Value*, unsigned> &ValueMap,
+                             MachineBasicBlock *mbb) {
+  MBB = mbb;
   BasicBlock::iterator I = Begin;
 
   for (; I != End; ++I) {
@@ -108,7 +111,7 @@
       if (BI->isUnconditional()) {
          MachineFunction::iterator NextMBB =
            next(MachineFunction::iterator(MBB));
-         if (NextMBB != MF->end() &&
+         if (NextMBB != MF.end() &&
              NextMBB->getBasicBlock() == BI->getSuccessor(0)) {
           MBB->addSuccessor(NextMBB);
           break;
@@ -127,6 +130,10 @@
   return I;
 }
 
+FastISel::FastISel(MachineFunction &mf)
+  : MF(mf), MRI(mf.getRegInfo()), TII(*mf.getTarget().getInstrInfo()) {
+}
+
 FastISel::~FastISel() {}
 
 unsigned FastISel::FastEmit_(MVT::SimpleValueType, ISD::NodeType) {
@@ -145,11 +152,10 @@
 
 unsigned FastISel::FastEmitInst_(unsigned MachineInstOpcode,
                                  const TargetRegisterClass* RC) {
-  MachineRegisterInfo &MRI = MF->getRegInfo();
   unsigned ResultReg = MRI.createVirtualRegister(RC);
-  const TargetInstrDesc &II = TII->get(MachineInstOpcode);
+  const TargetInstrDesc &II = TII.get(MachineInstOpcode);
 
-  MachineInstr *MI = BuildMI(*MF, II, ResultReg);
+  MachineInstr *MI = BuildMI(MF, II, ResultReg);
   MBB->push_back(MI);
   return ResultReg;
 }
@@ -157,11 +163,10 @@
 unsigned FastISel::FastEmitInst_r(unsigned MachineInstOpcode,
                                   const TargetRegisterClass *RC,
                                   unsigned Op0) {
-  MachineRegisterInfo &MRI = MF->getRegInfo();
   unsigned ResultReg = MRI.createVirtualRegister(RC);
-  const TargetInstrDesc &II = TII->get(MachineInstOpcode);
+  const TargetInstrDesc &II = TII.get(MachineInstOpcode);
 
-  MachineInstr *MI = BuildMI(*MF, II, ResultReg).addReg(Op0);
+  MachineInstr *MI = BuildMI(MF, II, ResultReg).addReg(Op0);
   MBB->push_back(MI);
   return ResultReg;
 }
@@ -169,11 +174,10 @@
 unsigned FastISel::FastEmitInst_rr(unsigned MachineInstOpcode,
                                    const TargetRegisterClass *RC,
                                    unsigned Op0, unsigned Op1) {
-  MachineRegisterInfo &MRI = MF->getRegInfo();
   unsigned ResultReg = MRI.createVirtualRegister(RC);
-  const TargetInstrDesc &II = TII->get(MachineInstOpcode);
+  const TargetInstrDesc &II = TII.get(MachineInstOpcode);
 
-  MachineInstr *MI = BuildMI(*MF, II, ResultReg).addReg(Op0).addReg(Op1);
+  MachineInstr *MI = BuildMI(MF, II, ResultReg).addReg(Op0).addReg(Op1);
   MBB->push_back(MI);
   return ResultReg;
 }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Aug 20 16:05:57 2008
@@ -5111,9 +5111,9 @@
       !BB->isLandingPad() &&
       isa<BranchInst>(LLVMBB->getTerminator()) &&
       cast<BranchInst>(LLVMBB->getTerminator())->isUnconditional()) {
-    if (FastISel *F = TLI.createFastISel(BB, &FuncInfo.MF,
-                                       TLI.getTargetMachine().getInstrInfo())) {
-      Begin = F->SelectInstructions(Begin, LLVMBB->end(), FuncInfo.ValueMap);
+    if (FastISel *F = TLI.createFastISel(FuncInfo.MF)) {
+      Begin = F->SelectInstructions(Begin, LLVMBB->end(),
+                                    FuncInfo.ValueMap, BB);
 
       // Clean up the FastISel object. TODO: Reorganize what data is
       // stored in the FastISel class itself and what is merely passed

Modified: llvm/trunk/lib/Target/X86/X86FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.h?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.h (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.h Wed Aug 20 16:05:57 2008
@@ -18,14 +18,11 @@
 namespace llvm {
 
 class FastISel;
-class MachineBasicBlock;
 class MachineFunction;
-class TargetInstrInfo;
 
 namespace X86 {
 
-FastISel *createFastISel(MachineBasicBlock *mbb, MachineFunction *mf,
-                         const TargetInstrInfo *tii);
+FastISel *createFastISel(MachineFunction &mf);
 
 } // namespace X86
 

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Aug 20 16:05:57 2008
@@ -1872,10 +1872,8 @@
   return false;
 }
 
-FastISel *X86TargetLowering::createFastISel(MachineBasicBlock *mbb,
-                                            MachineFunction *mf,
-                                            const TargetInstrInfo *tii) {
-  return X86::createFastISel(mbb, mf, tii);
+FastISel *X86TargetLowering::createFastISel(MachineFunction &mf) {
+  return X86::createFastISel(mf);
 }
 
 

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed Aug 20 16:05:57 2008
@@ -469,9 +469,7 @@
 
     /// createFastISel - This method returns a target specific FastISel object,
     /// or null if the target does not support "fast" ISel.
-    virtual FastISel *createFastISel(MachineBasicBlock *mbb,
-                                     MachineFunction *mf,
-                                     const TargetInstrInfo *tii);
+    virtual FastISel *createFastISel(MachineFunction &mf);
     
   private:
     /// Subtarget - Keep a pointer to the X86Subtarget around so that we can

Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=55076&r1=55075&r2=55076&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Aug 20 16:05:57 2008
@@ -295,16 +295,14 @@
     OS << ");\n";
   }
   OS << "public:\n";
-  OS << "  FastISel(MachineBasicBlock *mbb, MachineFunction *mf, ";
-  OS << "const TargetInstrInfo *tii) : llvm::FastISel(mbb, mf, tii) {}\n";
+  OS << "  explicit FastISel(MachineFunction &mf) : llvm::FastISel(mf) {}\n";
   OS << "};\n";
   OS << "\n";
 
   // Define the target FastISel creation function.
   OS << "llvm::FastISel *" << InstNS
-     << "createFastISel(MachineBasicBlock *mbb, MachineFunction *mf, ";
-  OS << "const TargetInstrInfo *tii) {\n";
-  OS << "  return new " << InstNS << "FastISel(mbb, mf, tii);\n";
+     << "createFastISel(MachineFunction &mf) {\n";
+  OS << "  return new " << InstNS << "FastISel(mf);\n";
   OS << "}\n";
   OS << "\n";
 





More information about the llvm-commits mailing list