[llvm-commits] [llvm] r152262 - in /llvm/trunk: include/llvm/CodeGen/DFAPacketizer.h include/llvm/CodeGen/ScheduleDAGInstrs.h lib/CodeGen/DFAPacketizer.cpp

Andrew Trick atrick at apple.com
Wed Mar 7 15:01:10 PST 2012


Author: atrick
Date: Wed Mar  7 17:01:09 2012
New Revision: 152262

URL: http://llvm.org/viewvc/llvm-project?rev=152262&view=rev
Log:
Cleanup VLIWPacketizer to use the updated ScheduleDAGInstrs interface.

Modified:
    llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h
    llvm/trunk/include/llvm/CodeGen/ScheduleDAGInstrs.h
    llvm/trunk/lib/CodeGen/DFAPacketizer.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h?rev=152262&r1=152261&r2=152262&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DFAPacketizer.h Wed Mar  7 17:01:09 2012
@@ -36,6 +36,7 @@
 class MachineLoopInfo;
 class MachineDominatorTree;
 class InstrItineraryData;
+class ScheduleDAGInstrs;
 class SUnit;
 
 class DFAPacketizer {
@@ -91,7 +92,7 @@
   const TargetInstrInfo *TII;
 
   // Encapsulate data types not exposed to the target interface.
-  void *SchedulerImpl;
+  ScheduleDAGInstrs *SchedulerImpl;
 
 protected:
   // Vector of instructions assigned to the current packet.

Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAGInstrs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAGInstrs.h?rev=152262&r1=152261&r2=152262&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/ScheduleDAGInstrs.h (original)
+++ llvm/trunk/include/llvm/CodeGen/ScheduleDAGInstrs.h Wed Mar  7 17:01:09 2012
@@ -245,15 +245,16 @@
     /// end - Return an iterator to the bottom of the current scheduling region.
     MachineBasicBlock::iterator end() const { return End; }
 
-    /// NewSUnit - Creates a new SUnit and return a ptr to it.
+    /// newSUnit - Creates a new SUnit and return a ptr to it.
     SUnit *newSUnit(MachineInstr *MI);
 
+    /// getSUnit - Return an existing SUnit for this MI, or NULL.
+    SUnit *getSUnit(MachineInstr *MI) const;
+
     /// startBlock - Prepare to perform scheduling in the given block.
-    ///
     virtual void startBlock(MachineBasicBlock *BB);
 
     /// finishBlock - Clean up after scheduling in the given block.
-    ///
     virtual void finishBlock();
 
     /// Initialize the scheduler state for the next scheduling region.
@@ -304,13 +305,6 @@
     virtual std::string getDAGName() const;
 
   protected:
-    SUnit *getSUnit(MachineInstr *MI) const {
-      DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);
-      if (I == MISUnitMap.end())
-        return 0;
-      return I->second;
-    }
-
     void initSUnits();
     void addPhysRegDataDeps(SUnit *SU, const MachineOperand &MO);
     void addPhysRegDeps(SUnit *SU, unsigned OperIdx);
@@ -322,8 +316,7 @@
     }
   };
 
-  /// NewSUnit - Creates a new SUnit and return a ptr to it.
-  ///
+  /// newSUnit - Creates a new SUnit and return a ptr to it.
   inline SUnit *ScheduleDAGInstrs::newSUnit(MachineInstr *MI) {
 #ifndef NDEBUG
     const SUnit *Addr = SUnits.empty() ? 0 : &SUnits[0];
@@ -334,6 +327,14 @@
     SUnits.back().OrigNode = &SUnits.back();
     return &SUnits.back();
   }
+
+  /// getSUnit - Return an existing SUnit for this MI, or NULL.
+  inline SUnit *ScheduleDAGInstrs::getSUnit(MachineInstr *MI) const {
+    DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);
+    if (I == MISUnitMap.end())
+      return 0;
+    return I->second;
+  }
 } // namespace llvm
 
 #endif

Modified: llvm/trunk/lib/CodeGen/DFAPacketizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DFAPacketizer.cpp?rev=152262&r1=152261&r2=152262&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/DFAPacketizer.cpp (original)
+++ llvm/trunk/lib/CodeGen/DFAPacketizer.cpp Wed Mar  7 17:01:09 2012
@@ -103,9 +103,6 @@
 namespace {
 // DefaultVLIWScheduler - This class extends ScheduleDAGInstrs and overrides
 // Schedule method to build the dependence graph.
-//
-// ScheduleDAGInstrs has LLVM_LIBRARY_VISIBILITY so we have to reference it as
-// an opaque pointer in VLIWPacketizerList.
 class DefaultVLIWScheduler : public ScheduleDAGInstrs {
 public:
   DefaultVLIWScheduler(MachineFunction &MF, MachineLoopInfo &MLI,
@@ -137,7 +134,7 @@
 
 // VLIWPacketizerList Dtor
 VLIWPacketizerList::~VLIWPacketizerList() {
-  delete (DefaultVLIWScheduler *)SchedulerImpl;
+  delete SchedulerImpl;
   delete ResourceTracker;
 }
 
@@ -184,20 +181,15 @@
 void VLIWPacketizerList::PacketizeMIs(MachineBasicBlock *MBB,
                                       MachineBasicBlock::iterator BeginItr,
                                       MachineBasicBlock::iterator EndItr) {
-  DefaultVLIWScheduler *Scheduler = (DefaultVLIWScheduler *)SchedulerImpl;
-  Scheduler->enterRegion(MBB, BeginItr, EndItr, MBB->size());
-  Scheduler->schedule();
-  Scheduler->exitRegion();
+  assert(MBB->end() == EndItr && "Bad EndIndex");
 
-  // Remember scheduling units.
-  SUnits = Scheduler->SUnits;
+  SchedulerImpl->enterRegion(MBB, BeginItr, EndItr, MBB->size());
 
-  // Generate MI -> SU map.
-  std::map <MachineInstr*, SUnit*> MIToSUnit;
-  for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
-    SUnit *SU = &SUnits[i];
-    MIToSUnit[SU->getInstr()] = SU;
-  }
+  // Build the DAG without reordering instructions.
+  SchedulerImpl->schedule();
+
+  // Remember scheduling units.
+  SUnits = SchedulerImpl->SUnits;
 
   // The main packetizer loop.
   for (; BeginItr != EndItr; ++BeginItr) {
@@ -213,7 +205,7 @@
       continue;
     }
 
-    SUnit *SUI = MIToSUnit[MI];
+    SUnit *SUI = SchedulerImpl->getSUnit(MI);
     assert(SUI && "Missing SUnit Info!");
 
     // Ask DFA if machine resource is available for MI.
@@ -223,7 +215,7 @@
       for (std::vector<MachineInstr*>::iterator VI = CurrentPacketMIs.begin(),
            VE = CurrentPacketMIs.end(); VI != VE; ++VI) {
         MachineInstr *MJ = *VI;
-        SUnit *SUJ = MIToSUnit[MJ];
+        SUnit *SUJ = SchedulerImpl->getSUnit(MJ);
         assert(SUJ && "Missing SUnit Info!");
 
         // Is it legal to packetize SUI and SUJ together.
@@ -247,4 +239,6 @@
 
   // End any packet left behind.
   endPacket(MBB, EndItr);
+
+  SchedulerImpl->exitRegion();
 }





More information about the llvm-commits mailing list