[llvm] r285051 - MachineInstrBundle: Pass iterators to getBundle(Start|End); NFC
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 24 19:55:18 PDT 2016
Author: matze
Date: Mon Oct 24 21:55:17 2016
New Revision: 285051
URL: http://llvm.org/viewvc/llvm-project?rev=285051&view=rev
Log:
MachineInstrBundle: Pass iterators to getBundle(Start|End); NFC
This is a function to go backwards in a block to find the first
instruction in a bundle, so iterator is a more natural choice for
parameter/return rather than a reference to a MachineInstruction.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h
llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Mon Oct 24 21:55:17 2016
@@ -460,7 +460,8 @@ public:
/// Create an MIBundleBuilder representing an existing instruction or bundle
/// that has MI as its head.
explicit MIBundleBuilder(MachineInstr *MI)
- : MBB(*MI->getParent()), Begin(MI), End(getBundleEnd(*MI)) {}
+ : MBB(*MI->getParent()), Begin(MI),
+ End(getBundleEnd(MI->getIterator())) {}
/// Return a reference to the basic block containing this bundle.
MachineBasicBlock &getMBB() const { return MBB; }
Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h Mon Oct 24 21:55:17 2016
@@ -41,34 +41,33 @@ MachineBasicBlock::instr_iterator finali
/// MachineFunction. Return true if any bundles are finalized.
bool finalizeBundles(MachineFunction &MF);
-/// getBundleStart - Returns the first instruction in the bundle containing MI.
-///
-inline MachineInstr &getBundleStart(MachineInstr &MI) {
- MachineBasicBlock::instr_iterator I(MI);
+/// Returns an iterator to the first instruction in the bundle containing \p I.
+inline MachineBasicBlock::instr_iterator getBundleStart(
+ MachineBasicBlock::instr_iterator I) {
while (I->isBundledWithPred())
--I;
- return *I;
+ return I;
}
-inline const MachineInstr &getBundleStart(const MachineInstr &MI) {
- MachineBasicBlock::const_instr_iterator I(MI);
+/// Returns an iterator to the first instruction in the bundle containing \p I.
+inline MachineBasicBlock::const_instr_iterator getBundleStart(
+ MachineBasicBlock::const_instr_iterator I) {
while (I->isBundledWithPred())
--I;
- return *I;
+ return I;
}
-/// Return an iterator pointing beyond the bundle containing MI.
-inline MachineBasicBlock::instr_iterator getBundleEnd(MachineInstr &MI) {
- MachineBasicBlock::instr_iterator I(MI);
+/// Returns an iterator pointing beyond the bundle containing \p I.
+inline MachineBasicBlock::instr_iterator getBundleEnd(
+ MachineBasicBlock::instr_iterator I) {
while (I->isBundledWithSucc())
++I;
return ++I;
}
-/// Return an iterator pointing beyond the bundle containing MI.
-inline MachineBasicBlock::const_instr_iterator
-getBundleEnd(const MachineInstr &MI) {
- MachineBasicBlock::const_instr_iterator I(MI);
+/// Returns an iterator pointing beyond the bundle containing \p I.
+inline MachineBasicBlock::const_instr_iterator getBundleEnd(
+ MachineBasicBlock::const_instr_iterator I) {
while (I->isBundledWithSucc())
++I;
return ++I;
@@ -115,7 +114,7 @@ protected:
///
explicit MachineOperandIteratorBase(MachineInstr &MI, bool WholeBundle) {
if (WholeBundle) {
- InstrI = getBundleStart(MI).getIterator();
+ InstrI = getBundleStart(MI.getIterator());
InstrE = MI.getParent()->instr_end();
} else {
InstrI = InstrE = MI.getIterator();
Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Oct 24 21:55:17 2016
@@ -898,10 +898,11 @@ public:
advance();
} while (Op && Op->getParent() == P);
} else if (ByBundle) {
- MachineInstr &P = getBundleStart(*Op->getParent());
+ MachineBasicBlock::instr_iterator P =
+ getBundleStart(Op->getParent()->getIterator());
do {
advance();
- } while (Op && &getBundleStart(*Op->getParent()) == &P);
+ } while (Op && getBundleStart(Op->getParent()->getIterator()) == P);
}
return *this;
@@ -1000,10 +1001,11 @@ public:
advance();
} while (Op && Op->getParent() == P);
} else if (ByBundle) {
- MachineInstr &P = getBundleStart(*Op->getParent());
+ MachineBasicBlock::instr_iterator P =
+ getBundleStart(Op->getParent()->getIterator());
do {
advance();
- } while (Op && &getBundleStart(*Op->getParent()) == &P);
+ } while (Op && getBundleStart(Op->getParent()->getIterator()) == P);
}
return *this;
@@ -1016,7 +1018,7 @@ public:
MachineInstr &operator*() const {
assert(Op && "Cannot dereference end iterator!");
if (ByBundle)
- return getBundleStart(*Op->getParent());
+ return *getBundleStart(Op->getParent()->getIterator());
return *Op->getParent();
}
Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Mon Oct 24 21:55:17 2016
@@ -405,7 +405,8 @@ namespace llvm {
/// Returns the base index for the given instruction.
SlotIndex getInstructionIndex(const MachineInstr &MI) const {
// Instructions inside a bundle have the same number as the bundle itself.
- Mi2IndexMap::const_iterator itr = mi2iMap.find(&getBundleStart(MI));
+ const MachineInstr &BundleStart = *getBundleStart(MI.getIterator());
+ Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleStart);
assert(itr != mi2iMap.end() && "Instruction not found in maps.");
return itr->second;
}
Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original)
+++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Mon Oct 24 21:55:17 2016
@@ -1222,7 +1222,7 @@ static void toggleBundleKillFlag(Machine
// might set it on too many operands. We will clear as many flags as we
// can though.
MachineBasicBlock::instr_iterator Begin = MI->getIterator();
- MachineBasicBlock::instr_iterator End = getBundleEnd(*MI);
+ MachineBasicBlock::instr_iterator End = getBundleEnd(Begin);
while (Begin != End) {
if (NewKillState) {
if ((--End)->addRegisterKilled(Reg, TRI, /* addIfNotFound= */ false))
@@ -1344,7 +1344,7 @@ void ScheduleDAGInstrs::fixupKills(Machi
DEBUG({
if (MI.getOpcode() == TargetOpcode::BUNDLE) {
MachineBasicBlock::instr_iterator Begin = MI.getIterator();
- MachineBasicBlock::instr_iterator End = getBundleEnd(MI);
+ MachineBasicBlock::instr_iterator End = getBundleEnd(Begin);
while (++Begin != End)
DEBUG(Begin->dump());
}
Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=285051&r1=285050&r2=285051&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Mon Oct 24 21:55:17 2016
@@ -4239,7 +4239,7 @@ unsigned HexagonInstrInfo::nonDbgBundleS
assert(BundleHead->isBundle() && "Not a bundle header");
auto MII = BundleHead.getInstrIterator();
// Skip the bundle header.
- return nonDbgMICount(++MII, getBundleEnd(*BundleHead));
+ return nonDbgMICount(++MII, getBundleEnd(BundleHead.getInstrIterator()));
}
More information about the llvm-commits
mailing list