Add iterator range MachineRegisterInfo::liveins(), adopt users, NFC

llvm-svn: 315927
This commit is contained in:
Krzysztof Parzyszek 2017-10-16 19:08:41 +00:00
parent 3f9b4b7c91
commit 72518eaa6f
9 changed files with 25 additions and 31 deletions

View File

@ -841,6 +841,9 @@ public:
livein_iterator livein_begin() const { return LiveIns.begin(); }
livein_iterator livein_end() const { return LiveIns.end(); }
bool livein_empty() const { return LiveIns.empty(); }
iterator_range<livein_iterator> liveins() const {
return make_range(livein_begin(), livein_end());
}
bool isLiveIn(unsigned Reg) const;

View File

@ -297,11 +297,11 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
}
// Print the live ins.
for (auto I = RegInfo.livein_begin(), E = RegInfo.livein_end(); I != E; ++I) {
for (std::pair<unsigned, unsigned> LI : RegInfo.liveins()) {
yaml::MachineFunctionLiveIn LiveIn;
printReg(I->first, LiveIn.Register, TRI);
if (I->second)
printReg(I->second, LiveIn.VirtualRegister, TRI);
printReg(LI.first, LiveIn.Register, TRI);
if (LI.second)
printReg(LI.second, LiveIn.VirtualRegister, TRI);
MF.LiveIns.push_back(LiveIn);
}

View File

@ -494,10 +494,9 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
DenseMap<unsigned, unsigned> LiveInMap;
if (!FuncInfo->ArgDbgValues.empty())
for (MachineRegisterInfo::livein_iterator LI = RegInfo->livein_begin(),
E = RegInfo->livein_end(); LI != E; ++LI)
if (LI->second)
LiveInMap.insert(std::make_pair(LI->first, LI->second));
for (std::pair<unsigned, unsigned> LI : RegInfo->liveins())
if (LI.second)
LiveInMap.insert(LI);
// Insert DBG_VALUE instructions for function arguments to the entry block.
for (unsigned i = 0, e = FuncInfo->ArgDbgValues.size(); i != e; ++i) {

View File

@ -1186,10 +1186,8 @@ int R600InstrInfo::getIndirectIndexBegin(const MachineFunction &MF) const {
}
const TargetRegisterClass *IndirectRC = getIndirectAddrRegClass();
for (MachineRegisterInfo::livein_iterator LI = MRI.livein_begin(),
LE = MRI.livein_end();
LI != LE; ++LI) {
unsigned Reg = LI->first;
for (std::pair<unsigned, unsigned> LI : MRI.liveins()) {
unsigned Reg = LI.first;
if (TargetRegisterInfo::isVirtualRegister(Reg) ||
!IndirectRC->contains(Reg))
continue;

View File

@ -1248,11 +1248,8 @@ unsigned HexagonEvaluator::getNextPhysReg(unsigned PReg, unsigned Width) const {
}
unsigned HexagonEvaluator::getVirtRegFor(unsigned PReg) const {
using iterator = MachineRegisterInfo::livein_iterator;
for (iterator I = MRI.livein_begin(), E = MRI.livein_end(); I != E; ++I) {
if (I->first == PReg)
return I->second;
}
for (std::pair<unsigned,unsigned> P : MRI.liveins())
if (P.first == PReg)
return P.second;
return 0;
}

View File

@ -913,8 +913,8 @@ void DataFlowGraph::build(unsigned Options) {
MachineRegisterInfo &MRI = MF.getRegInfo();
MachineBasicBlock &EntryB = *EA.Addr->getCode();
assert(EntryB.pred_empty() && "Function entry block has predecessors");
for (auto I = MRI.livein_begin(), E = MRI.livein_end(); I != E; ++I)
LiveIns.insert(RegisterRef(I->first));
for (std::pair<unsigned,unsigned> P : MRI.liveins())
LiveIns.insert(RegisterRef(P.first));
if (MRI.tracksLiveness()) {
for (auto I : EntryB.liveins())
LiveIns.insert(RegisterRef(I.PhysReg, I.LaneMask));

View File

@ -312,11 +312,9 @@ static void HandleVRSaveUpdate(MachineInstr &MI, const TargetInstrInfo &TII) {
// Live in and live out values already must be in the mask, so don't bother
// marking them.
for (MachineRegisterInfo::livein_iterator
I = MF->getRegInfo().livein_begin(),
E = MF->getRegInfo().livein_end(); I != E; ++I) {
unsigned RegNo = TRI->getEncodingValue(I->first);
if (VRRegNo[RegNo] == I->first) // If this really is a vector reg.
for (std::pair<unsigned, unsigned> LI : MF->getRegInfo().liveins()) {
unsigned RegNo = TRI->getEncodingValue(LI.first);
if (VRRegNo[RegNo] == LI.first) // If this really is a vector reg.
UsedRegMask &= ~(1 << (31-RegNo)); // Doesn't need to be marked.
}

View File

@ -3235,9 +3235,9 @@ SDValue X86TargetLowering::LowerFormalArguments(
if (CallConv == CallingConv::X86_RegCall ||
Fn->hasFnAttribute("no_caller_saved_registers")) {
const MachineRegisterInfo &MRI = MF.getRegInfo();
for (const auto &Pair : make_range(MRI.livein_begin(), MRI.livein_end()))
MF.getRegInfo().disableCalleeSavedRegister(Pair.first);
MachineRegisterInfo &MRI = MF.getRegInfo();
for (std::pair<unsigned, unsigned> Pair : MRI.liveins())
MRI.disableCalleeSavedRegister(Pair.first);
}
return Chain;

View File

@ -132,9 +132,8 @@ static bool isYmmOrZmmReg(unsigned Reg) {
}
static bool checkFnHasLiveInYmmOrZmm(MachineRegisterInfo &MRI) {
for (MachineRegisterInfo::livein_iterator I = MRI.livein_begin(),
E = MRI.livein_end(); I != E; ++I)
if (isYmmOrZmmReg(I->first))
for (std::pair<unsigned, unsigned> LI : MRI.liveins())
if (isYmmOrZmmReg(LI.first))
return true;
return false;