///< neighborhood.
};
- /// computeRegisterLiveness - Return whether (physical) register \c Reg
- /// has been <def>ined and not <kill>ed as of just before \c MI.
+ /// Return whether (physical) register \p Reg has been <def>ined and not
+ /// <kill>ed as of just before \p Before.
///
- /// Search is localised to a neighborhood of
- /// \c Neighborhood instructions before (searching for defs or kills) and
- /// Neighborhood instructions after (searching just for defs) MI.
+ /// Search is localised to a neighborhood of \p Neighborhood instructions
+ /// before (searching for defs or kills) and \p Neighborhood instructions
+ /// after (searching just for defs) \p Before.
///
- /// \c Reg must be a physical register.
+ /// \p Reg must be a physical register.
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI,
- unsigned Reg, MachineInstr *MI,
- unsigned Neighborhood=10);
+ unsigned Reg,
+ const_iterator Before,
+ unsigned Neighborhood=10) const;
// Debugging methods.
void dump() const;
/// instructions after (searching just for defs) MI.
MachineBasicBlock::LivenessQueryResult
MachineBasicBlock::computeRegisterLiveness(const TargetRegisterInfo *TRI,
- unsigned Reg, MachineInstr *MI,
- unsigned Neighborhood) {
+ unsigned Reg, const_iterator Before,
+ unsigned Neighborhood) const {
unsigned N = Neighborhood;
- MachineBasicBlock *MBB = MI->getParent();
- // Start by searching backwards from MI, looking for kills, reads or defs.
-
- MachineBasicBlock::iterator I(MI);
+ // Start by searching backwards from Before, looking for kills, reads or defs.
+ const_iterator I(Before);
// If this is the first insn in the block, don't search backwards.
- if (I != MBB->begin()) {
+ if (I != begin()) {
do {
--I;
MachineOperandIteratorBase::PhysRegInfo Analysis =
- MIOperands(I).analyzePhysReg(Reg, TRI);
+ ConstMIOperands(I).analyzePhysReg(Reg, TRI);
if (Analysis.Defines)
// Outputs happen after inputs so they take precedence if both are
// Defined or read without a previous kill - live.
return Analysis.Reads ? LQR_Live : LQR_OverlappingLive;
- } while (I != MBB->begin() && --N > 0);
+ } while (I != begin() && --N > 0);
}
// Did we get to the start of the block?
- if (I == MBB->begin()) {
+ if (I == begin()) {
// If so, the register's state is definitely defined by the live-in state.
for (MCRegAliasIterator RAI(Reg, TRI, /*IncludeSelf=*/true);
RAI.isValid(); ++RAI) {
- if (MBB->isLiveIn(*RAI))
+ if (isLiveIn(*RAI))
return (*RAI == Reg) ? LQR_Live : LQR_OverlappingLive;
}
N = Neighborhood;
- // Try searching forwards from MI, looking for reads or defs.
- I = MachineBasicBlock::iterator(MI);
+ // Try searching forwards from Before, looking for reads or defs.
+ I = const_iterator(Before);
// If this is the last insn in the block, don't search forwards.
- if (I != MBB->end()) {
- for (++I; I != MBB->end() && N > 0; ++I, --N) {
+ if (I != end()) {
+ for (++I; I != end() && N > 0; ++I, --N) {
MachineOperandIteratorBase::PhysRegInfo Analysis =
- MIOperands(I).analyzePhysReg(Reg, TRI);
+ ConstMIOperands(I).analyzePhysReg(Reg, TRI);
if (Analysis.ReadsOverlap)
// Used, therefore must have been live.