summaryrefslogtreecommitdiff
path: root/lib/CodeGen/AggressiveAntiDepBreaker.h
diff options
context:
space:
mode:
authorDavid Goodwin <david_goodwin@apple.com>2009-10-26 22:31:16 +0000
committerDavid Goodwin <david_goodwin@apple.com>2009-10-26 22:31:16 +0000
commite10deca33e74a7c70ab585f78eee3fb52937f668 (patch)
tree040756b08ba58b1bd3d181e4fee5cb2d662925ec /lib/CodeGen/AggressiveAntiDepBreaker.h
parent06d4033a354115904e9df23608f9a7cd543d5dbc (diff)
downloadllvm-e10deca33e74a7c70ab585f78eee3fb52937f668.tar.gz
llvm-e10deca33e74a7c70ab585f78eee3fb52937f668.tar.bz2
llvm-e10deca33e74a7c70ab585f78eee3fb52937f668.tar.xz
Allow the aggressive anti-dep breaker to process the same region multiple times. This is necessary because new anti-dependencies are exposed when "current" ones are broken.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85166 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AggressiveAntiDepBreaker.h')
-rw-r--r--lib/CodeGen/AggressiveAntiDepBreaker.h103
1 files changed, 69 insertions, 34 deletions
diff --git a/lib/CodeGen/AggressiveAntiDepBreaker.h b/lib/CodeGen/AggressiveAntiDepBreaker.h
index e6b7268e77..f4a05290c0 100644
--- a/lib/CodeGen/AggressiveAntiDepBreaker.h
+++ b/lib/CodeGen/AggressiveAntiDepBreaker.h
@@ -28,11 +28,12 @@
#include "llvm/ADT/SmallSet.h"
namespace llvm {
- class AggressiveAntiDepBreaker : public AntiDepBreaker {
- MachineFunction& MF;
- MachineRegisterInfo &MRI;
- const TargetRegisterInfo *TRI;
-
+ /// Class AggressiveAntiDepState
+ /// Contains all the state necessary for anti-dep breaking. We place
+ /// into a separate class so be can conveniently save/restore it to
+ /// enable multi-pass anti-dep breaking.
+ class AggressiveAntiDepState {
+ public:
/// RegisterReference - Information about a register reference
/// within a liverange
typedef struct {
@@ -42,59 +43,43 @@ namespace llvm {
const TargetRegisterClass *RC;
} RegisterReference;
- /// AllocatableSet - The set of allocatable registers.
- /// We'll be ignoring anti-dependencies on non-allocatable registers,
- /// because they may not be safe to break.
- const BitVector AllocatableSet;
-
+ private:
/// GroupNodes - Implements a disjoint-union data structure to
/// form register groups. A node is represented by an index into
/// the vector. A node can "point to" itself to indicate that it
/// is the parent of a group, or point to another node to indicate
/// that it is a member of the same group as that node.
std::vector<unsigned> GroupNodes;
-
+
/// GroupNodeIndices - For each register, the index of the GroupNode
/// currently representing the group that the register belongs to.
/// Register 0 is always represented by the 0 group, a group
/// composed of registers that are not eligible for anti-aliasing.
unsigned GroupNodeIndices[TargetRegisterInfo::FirstVirtualRegister];
-
- /// RegRegs - Map registers to all their references within a live range.
+
+ /// RegRefs - Map registers to all their references within a live range.
std::multimap<unsigned, RegisterReference> RegRefs;
-
+
/// KillIndices - The index of the most recent kill (proceding bottom-up),
/// or ~0u if the register is not live.
unsigned KillIndices[TargetRegisterInfo::FirstVirtualRegister];
-
+
/// DefIndices - The index of the most recent complete def (proceding bottom
/// up), or ~0u if the register is live.
unsigned DefIndices[TargetRegisterInfo::FirstVirtualRegister];
public:
- AggressiveAntiDepBreaker(MachineFunction& MFi);
- ~AggressiveAntiDepBreaker();
+ AggressiveAntiDepState(MachineBasicBlock *BB);
- /// Start - Initialize anti-dep breaking for a new basic block.
- void StartBlock(MachineBasicBlock *BB);
-
- /// BreakAntiDependencies - Identifiy anti-dependencies along the critical path
- /// of the ScheduleDAG and break them by renaming registers.
- ///
- unsigned BreakAntiDependencies(std::vector<SUnit>& SUnits,
- MachineBasicBlock::iterator& Begin,
- MachineBasicBlock::iterator& End,
- unsigned InsertPosIndex);
+ /// GetKillIndices - Return the kill indices.
+ unsigned *GetKillIndices() { return KillIndices; }
- /// Observe - Update liveness information to account for the current
- /// instruction, which will not be scheduled.
- ///
- void Observe(MachineInstr *MI, unsigned Count, unsigned InsertPosIndex);
+ /// GetDefIndices - Return the define indices.
+ unsigned *GetDefIndices() { return DefIndices; }
- /// Finish - Finish anti-dep breaking for a basic block.
- void FinishBlock();
+ /// GetRegRefs - Return the RegRefs map.
+ std::multimap<unsigned, RegisterReference>& GetRegRefs() { return RegRefs; }
- private:
// GetGroup - Get the group for a register. The returned value is
// the index of the GroupNode representing the group.
unsigned GetGroup(unsigned Reg);
@@ -115,7 +100,57 @@ namespace llvm {
/// IsLive - Return true if Reg is live
bool IsLive(unsigned Reg);
+ };
+
+
+ /// Class AggressiveAntiDepBreaker
+ class AggressiveAntiDepBreaker : public AntiDepBreaker {
+ MachineFunction& MF;
+ MachineRegisterInfo &MRI;
+ const TargetRegisterInfo *TRI;
+
+ /// AllocatableSet - The set of allocatable registers.
+ /// We'll be ignoring anti-dependencies on non-allocatable registers,
+ /// because they may not be safe to break.
+ const BitVector AllocatableSet;
+
+ /// State - The state used to identify and rename anti-dependence
+ /// registers.
+ AggressiveAntiDepState *State;
+
+ /// SavedState - The state for the start of an anti-dep
+ /// region. Used to restore the state at the beginning of each
+ /// pass
+ AggressiveAntiDepState *SavedState;
+
+ public:
+ AggressiveAntiDepBreaker(MachineFunction& MFi);
+ ~AggressiveAntiDepBreaker();
+ /// GetMaxTrials - As anti-dependencies are broken, additional
+ /// dependencies may be exposed, so multiple passes are required.
+ unsigned GetMaxTrials();
+
+ /// Start - Initialize anti-dep breaking for a new basic block.
+ void StartBlock(MachineBasicBlock *BB);
+
+ /// BreakAntiDependencies - Identifiy anti-dependencies along the critical path
+ /// of the ScheduleDAG and break them by renaming registers.
+ ///
+ unsigned BreakAntiDependencies(std::vector<SUnit>& SUnits,
+ MachineBasicBlock::iterator& Begin,
+ MachineBasicBlock::iterator& End,
+ unsigned InsertPosIndex);
+
+ /// Observe - Update liveness information to account for the current
+ /// instruction, which will not be scheduled.
+ ///
+ void Observe(MachineInstr *MI, unsigned Count, unsigned InsertPosIndex);
+
+ /// Finish - Finish anti-dep breaking for a basic block.
+ void FinishBlock();
+
+ private:
/// IsImplicitDefUse - Return true if MO represents a register
/// that is both implicitly used and defined in MI
bool IsImplicitDefUse(MachineInstr *MI, MachineOperand& MO);