forked from OSchip/llvm-project
[CodeGen] Use MachineInstr::operands (NFC)
This commit is contained in:
parent
b241226aec
commit
ce227ce3b3
|
@ -1592,10 +1592,7 @@ void LiveIntervals::repairOldRegInRange(const MachineBasicBlock::iterator Begin,
|
|||
|
||||
// FIXME: This doesn't currently handle early-clobber or multiple removed
|
||||
// defs inside of the region to repair.
|
||||
for (MachineInstr::mop_iterator OI = MI.operands_begin(),
|
||||
OE = MI.operands_end();
|
||||
OI != OE; ++OI) {
|
||||
const MachineOperand &MO = *OI;
|
||||
for (const MachineOperand &MO : MI.operands()) {
|
||||
if (!MO.isReg() || MO.getReg() != Reg)
|
||||
continue;
|
||||
|
||||
|
@ -1680,15 +1677,13 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB,
|
|||
MachineInstr &MI = *I;
|
||||
if (MI.isDebugOrPseudoInstr())
|
||||
continue;
|
||||
for (MachineInstr::const_mop_iterator MOI = MI.operands_begin(),
|
||||
MOE = MI.operands_end();
|
||||
MOI != MOE; ++MOI) {
|
||||
if (MOI->isReg() && MOI->getReg().isVirtual()) {
|
||||
Register Reg = MOI->getReg();
|
||||
for (const MachineOperand &MO : MI.operands()) {
|
||||
if (MO.isReg() && MO.getReg().isVirtual()) {
|
||||
Register Reg = MO.getReg();
|
||||
// If the new instructions refer to subregs but the old instructions did
|
||||
// not, throw away any old live interval so it will be recomputed with
|
||||
// subranges.
|
||||
if (MOI->getSubReg() && hasInterval(Reg) &&
|
||||
if (MO.getSubReg() && hasInterval(Reg) &&
|
||||
!getInterval(Reg).hasSubRanges() &&
|
||||
MRI->shouldTrackSubRegLiveness(Reg))
|
||||
removeInterval(Reg);
|
||||
|
|
|
@ -308,16 +308,15 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink,
|
|||
bool HasLiveVRegUses = false;
|
||||
|
||||
// Check for live intervals that may shrink
|
||||
for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
|
||||
MOE = MI->operands_end(); MOI != MOE; ++MOI) {
|
||||
if (!MOI->isReg())
|
||||
for (const MachineOperand &MO : MI->operands()) {
|
||||
if (!MO.isReg())
|
||||
continue;
|
||||
Register Reg = MOI->getReg();
|
||||
Register Reg = MO.getReg();
|
||||
if (!Register::isVirtualRegister(Reg)) {
|
||||
// Check if MI reads any unreserved physregs.
|
||||
if (Reg && MOI->readsReg() && !MRI.isReserved(Reg))
|
||||
if (Reg && MO.readsReg() && !MRI.isReserved(Reg))
|
||||
ReadsPhysRegs = true;
|
||||
else if (MOI->isDef())
|
||||
else if (MO.isDef())
|
||||
LIS.removePhysRegDefAt(Reg.asMCReg(), Idx);
|
||||
continue;
|
||||
}
|
||||
|
@ -327,14 +326,14 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink,
|
|||
// unlikely to change anything. We typically don't want to shrink the
|
||||
// PIC base register that has lots of uses everywhere.
|
||||
// Always shrink COPY uses that probably come from live range splitting.
|
||||
if ((MI->readsVirtualRegister(Reg) && (MI->isCopy() || MOI->isDef())) ||
|
||||
(MOI->readsReg() && (MRI.hasOneNonDBGUse(Reg) || useIsKill(LI, *MOI))))
|
||||
if ((MI->readsVirtualRegister(Reg) && (MI->isCopy() || MO.isDef())) ||
|
||||
(MO.readsReg() && (MRI.hasOneNonDBGUse(Reg) || useIsKill(LI, MO))))
|
||||
ToShrink.insert(&LI);
|
||||
else if (MOI->readsReg())
|
||||
else if (MO.readsReg())
|
||||
HasLiveVRegUses = true;
|
||||
|
||||
// Remove defined value.
|
||||
if (MOI->isDef()) {
|
||||
if (MO.isDef()) {
|
||||
if (TheDelegate && LI.getVNInfoAt(Idx) != nullptr)
|
||||
TheDelegate->LRE_WillShrinkVirtReg(LI.reg());
|
||||
LIS.removeVRegDefAt(LI, Idx);
|
||||
|
|
|
@ -1042,17 +1042,16 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
|
|||
for (instr_iterator I = getFirstInstrTerminator(), E = instr_end();
|
||||
I != E; ++I) {
|
||||
MachineInstr *MI = &*I;
|
||||
for (MachineInstr::mop_iterator OI = MI->operands_begin(),
|
||||
OE = MI->operands_end(); OI != OE; ++OI) {
|
||||
if (!OI->isReg() || OI->getReg() == 0 ||
|
||||
!OI->isUse() || !OI->isKill() || OI->isUndef())
|
||||
for (MachineOperand &MO : MI->operands()) {
|
||||
if (!MO.isReg() || MO.getReg() == 0 || !MO.isUse() || !MO.isKill() ||
|
||||
MO.isUndef())
|
||||
continue;
|
||||
Register Reg = OI->getReg();
|
||||
Register Reg = MO.getReg();
|
||||
if (Register::isPhysicalRegister(Reg) ||
|
||||
LV->getVarInfo(Reg).removeKill(*MI)) {
|
||||
KilledRegs.push_back(Reg);
|
||||
LLVM_DEBUG(dbgs() << "Removing terminator kill: " << *MI);
|
||||
OI->setIsKill(false);
|
||||
LLVM_DEBUG(dbgs() << "Removing terminator kill: " << MI);
|
||||
MO.setIsKill(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1063,12 +1062,11 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
|
|||
I != E; ++I) {
|
||||
MachineInstr *MI = &*I;
|
||||
|
||||
for (MachineInstr::mop_iterator OI = MI->operands_begin(),
|
||||
OE = MI->operands_end(); OI != OE; ++OI) {
|
||||
if (!OI->isReg() || OI->getReg() == 0)
|
||||
for (const MachineOperand &MO : MI->operands()) {
|
||||
if (!MO.isReg() || MO.getReg() == 0)
|
||||
continue;
|
||||
|
||||
Register Reg = OI->getReg();
|
||||
Register Reg = MO.getReg();
|
||||
if (!is_contained(UsedRegs, Reg))
|
||||
UsedRegs.push_back(Reg);
|
||||
}
|
||||
|
|
|
@ -713,15 +713,13 @@ void ModuloScheduleExpander::removeDeadInstructions(MachineBasicBlock *KernelBB,
|
|||
continue;
|
||||
}
|
||||
bool used = true;
|
||||
for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
|
||||
MOE = MI->operands_end();
|
||||
MOI != MOE; ++MOI) {
|
||||
if (!MOI->isReg() || !MOI->isDef())
|
||||
for (const MachineOperand &MO : MI->operands()) {
|
||||
if (!MO.isReg() || !MO.isDef())
|
||||
continue;
|
||||
Register reg = MOI->getReg();
|
||||
Register reg = MO.getReg();
|
||||
// Assume physical registers are used, unless they are marked dead.
|
||||
if (Register::isPhysicalRegister(reg)) {
|
||||
used = !MOI->isDead();
|
||||
used = !MO.isDead();
|
||||
if (used)
|
||||
break;
|
||||
continue;
|
||||
|
|
|
@ -542,11 +542,7 @@ void VirtRegRewriter::rewrite() {
|
|||
MBBI != MBBE; ++MBBI) {
|
||||
LLVM_DEBUG(MBBI->print(dbgs(), Indexes));
|
||||
for (MachineInstr &MI : llvm::make_early_inc_range(MBBI->instrs())) {
|
||||
for (MachineInstr::mop_iterator MOI = MI.operands_begin(),
|
||||
MOE = MI.operands_end();
|
||||
MOI != MOE; ++MOI) {
|
||||
MachineOperand &MO = *MOI;
|
||||
|
||||
for (MachineOperand &MO : MI.operands()) {
|
||||
// Make sure MRI knows about registers clobbered by regmasks.
|
||||
if (MO.isRegMask())
|
||||
MRI->addPhysRegsUsedFromRegMask(MO.getRegMask());
|
||||
|
|
Loading…
Reference in New Issue