diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-11 22:52:14 +0000 | 
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-11 22:52:14 +0000 | 
| commit | 73edbf1682427b9b9e12a37275b8e575ed214f0b (patch) | |
| tree | 9e92f015d177688a30f79cabf263b6b12fea02aa /llvm/lib | |
| parent | 06ec4203477a26c02e9e5613b2cc0dad9c2a509e (diff) | |
| download | bcm5719-llvm-73edbf1682427b9b9e12a37275b8e575ed214f0b.tar.gz bcm5719-llvm-73edbf1682427b9b9e12a37275b8e575ed214f0b.zip  | |
Sink spillInterferences into RABasic.
This helper method is too simplistic for RAGreedy.
llvm-svn: 147976
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/RegAllocBase.cpp | 54 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/RegAllocBase.h | 9 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/RegAllocBasic.cpp | 62 | 
3 files changed, 62 insertions, 63 deletions
diff --git a/llvm/lib/CodeGen/RegAllocBase.cpp b/llvm/lib/CodeGen/RegAllocBase.cpp index 3f77df3221d..e08802390a3 100644 --- a/llvm/lib/CodeGen/RegAllocBase.cpp +++ b/llvm/lib/CodeGen/RegAllocBase.cpp @@ -242,60 +242,6 @@ unsigned RegAllocBase::checkPhysRegInterference(LiveInterval &VirtReg,    return 0;  } -// Helper for spillInteferences() that spills all interfering vregs currently -// assigned to this physical register. -void RegAllocBase::spillReg(LiveInterval& VirtReg, unsigned PhysReg, -                            SmallVectorImpl<LiveInterval*> &SplitVRegs) { -  LiveIntervalUnion::Query &Q = query(VirtReg, PhysReg); -  assert(Q.seenAllInterferences() && "need collectInterferences()"); -  const SmallVectorImpl<LiveInterval*> &PendingSpills = Q.interferingVRegs(); - -  for (SmallVectorImpl<LiveInterval*>::const_iterator I = PendingSpills.begin(), -         E = PendingSpills.end(); I != E; ++I) { -    LiveInterval &SpilledVReg = **I; -    DEBUG(dbgs() << "extracting from " << -          TRI->getName(PhysReg) << " " << SpilledVReg << '\n'); - -    // Deallocate the interfering vreg by removing it from the union. -    // A LiveInterval instance may not be in a union during modification! -    unassign(SpilledVReg, PhysReg); - -    // Spill the extracted interval. -    LiveRangeEdit LRE(SpilledVReg, SplitVRegs, 0, &PendingSpills); -    spiller().spill(LRE); -  } -  // After extracting segments, the query's results are invalid. But keep the -  // contents valid until we're done accessing pendingSpills. -  Q.clear(); -} - -// Spill or split all live virtual registers currently unified under PhysReg -// that interfere with VirtReg. The newly spilled or split live intervals are -// returned by appending them to SplitVRegs. -bool -RegAllocBase::spillInterferences(LiveInterval &VirtReg, unsigned PhysReg, -                                 SmallVectorImpl<LiveInterval*> &SplitVRegs) { -  // Record each interference and determine if all are spillable before mutating -  // either the union or live intervals. -  unsigned NumInterferences = 0; -  // Collect interferences assigned to any alias of the physical register. -  for (const unsigned *asI = TRI->getOverlaps(PhysReg); *asI; ++asI) { -    LiveIntervalUnion::Query &QAlias = query(VirtReg, *asI); -    NumInterferences += QAlias.collectInterferingVRegs(); -    if (QAlias.seenUnspillableVReg()) { -      return false; -    } -  } -  DEBUG(dbgs() << "spilling " << TRI->getName(PhysReg) << -        " interferences with " << VirtReg << "\n"); -  assert(NumInterferences > 0 && "expect interference"); - -  // Spill each interfering vreg allocated to PhysReg or an alias. -  for (const unsigned *AliasI = TRI->getOverlaps(PhysReg); *AliasI; ++AliasI) -    spillReg(VirtReg, *AliasI, SplitVRegs); -  return true; -} -  // Add newly allocated physical registers to the MBB live in sets.  void RegAllocBase::addMBBLiveIns(MachineFunction *MF) {    NamedRegionTimer T("MBB Live Ins", TimerGroupName, TimePassesIsEnabled); diff --git a/llvm/lib/CodeGen/RegAllocBase.h b/llvm/lib/CodeGen/RegAllocBase.h index 72620f71ad4..a4b1667661b 100644 --- a/llvm/lib/CodeGen/RegAllocBase.h +++ b/llvm/lib/CodeGen/RegAllocBase.h @@ -151,12 +151,6 @@ protected:    /// allocation is making progress.    void unassign(LiveInterval &VirtReg, unsigned PhysReg); -  // Helper for spilling all live virtual registers currently unified under preg -  // that interfere with the most recently queried lvr.  Return true if spilling -  // was successful, and append any new spilled/split intervals to splitLVRs. -  bool spillInterferences(LiveInterval &VirtReg, unsigned PhysReg, -                          SmallVectorImpl<LiveInterval*> &SplitVRegs); -    /// addMBBLiveIns - Add physreg liveins to basic blocks.    void addMBBLiveIns(MachineFunction *); @@ -174,9 +168,6 @@ public:  private:    void seedLiveRegs(); - -  void spillReg(LiveInterval &VirtReg, unsigned PhysReg, -                SmallVectorImpl<LiveInterval*> &SplitVRegs);  };  } // end namespace llvm diff --git a/llvm/lib/CodeGen/RegAllocBasic.cpp b/llvm/lib/CodeGen/RegAllocBasic.cpp index a67a6169bee..a659f5b7825 100644 --- a/llvm/lib/CodeGen/RegAllocBasic.cpp +++ b/llvm/lib/CodeGen/RegAllocBasic.cpp @@ -107,6 +107,15 @@ public:    /// Perform register allocation.    virtual bool runOnMachineFunction(MachineFunction &mf); +  // Helper for spilling all live virtual registers currently unified under preg +  // that interfere with the most recently queried lvr.  Return true if spilling +  // was successful, and append any new spilled/split intervals to splitLVRs. +  bool spillInterferences(LiveInterval &VirtReg, unsigned PhysReg, +                          SmallVectorImpl<LiveInterval*> &SplitVRegs); + +  void spillReg(LiveInterval &VirtReg, unsigned PhysReg, +                SmallVectorImpl<LiveInterval*> &SplitVRegs); +    static char ID;  }; @@ -157,6 +166,59 @@ void RABasic::releaseMemory() {    RegAllocBase::releaseMemory();  } +// Helper for spillInterferences() that spills all interfering vregs currently +// assigned to this physical register. +void RABasic::spillReg(LiveInterval& VirtReg, unsigned PhysReg, +                       SmallVectorImpl<LiveInterval*> &SplitVRegs) { +  LiveIntervalUnion::Query &Q = query(VirtReg, PhysReg); +  assert(Q.seenAllInterferences() && "need collectInterferences()"); +  const SmallVectorImpl<LiveInterval*> &PendingSpills = Q.interferingVRegs(); + +  for (SmallVectorImpl<LiveInterval*>::const_iterator I = PendingSpills.begin(), +         E = PendingSpills.end(); I != E; ++I) { +    LiveInterval &SpilledVReg = **I; +    DEBUG(dbgs() << "extracting from " << +          TRI->getName(PhysReg) << " " << SpilledVReg << '\n'); + +    // Deallocate the interfering vreg by removing it from the union. +    // A LiveInterval instance may not be in a union during modification! +    unassign(SpilledVReg, PhysReg); + +    // Spill the extracted interval. +    LiveRangeEdit LRE(SpilledVReg, SplitVRegs, 0, &PendingSpills); +    spiller().spill(LRE); +  } +  // After extracting segments, the query's results are invalid. But keep the +  // contents valid until we're done accessing pendingSpills. +  Q.clear(); +} + +// Spill or split all live virtual registers currently unified under PhysReg +// that interfere with VirtReg. The newly spilled or split live intervals are +// returned by appending them to SplitVRegs. +bool RABasic::spillInterferences(LiveInterval &VirtReg, unsigned PhysReg, +                                 SmallVectorImpl<LiveInterval*> &SplitVRegs) { +  // Record each interference and determine if all are spillable before mutating +  // either the union or live intervals. +  unsigned NumInterferences = 0; +  // Collect interferences assigned to any alias of the physical register. +  for (const unsigned *asI = TRI->getOverlaps(PhysReg); *asI; ++asI) { +    LiveIntervalUnion::Query &QAlias = query(VirtReg, *asI); +    NumInterferences += QAlias.collectInterferingVRegs(); +    if (QAlias.seenUnspillableVReg()) { +      return false; +    } +  } +  DEBUG(dbgs() << "spilling " << TRI->getName(PhysReg) << +        " interferences with " << VirtReg << "\n"); +  assert(NumInterferences > 0 && "expect interference"); + +  // Spill each interfering vreg allocated to PhysReg or an alias. +  for (const unsigned *AliasI = TRI->getOverlaps(PhysReg); *AliasI; ++AliasI) +    spillReg(VirtReg, *AliasI, SplitVRegs); +  return true; +} +  // Driver for the register assignment and splitting heuristics.  // Manages iteration over the LiveIntervalUnions.  //  | 

