mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Phase 1 of refactoring the MachineRegisterInfo iterators to make them suitable
for use with C++11 range-based for-loops. The gist of phase 1 is to remove the skipInstruction() and skipBundle() methods from these iterators, instead splitting each iterator into a version that walks operands, a version that walks instructions, and a version that walks bundles. This has the result of making some "clever" loops in lib/CodeGen more verbose, but also makes their iterator invalidation characteristics much more obvious to the casual reader. (Making them concise again in the future is a good motivating case for a pre-incrementing range adapter!) Phase 2 of this undertaking with consist of removing the getOperand() method, and changing operator*() of the operand-walker to return a MachineOperand&. At that point, it should be possible to add range views for them that work as one might expect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203757 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -238,9 +238,10 @@ bool InlineSpiller::isSnippet(const LiveInterval &SnipLI) {
|
||||
MachineInstr *UseMI = 0;
|
||||
|
||||
// Check that all uses satisfy our criteria.
|
||||
for (MachineRegisterInfo::reg_nodbg_iterator
|
||||
RI = MRI.reg_nodbg_begin(SnipLI.reg);
|
||||
MachineInstr *MI = RI.skipInstruction();) {
|
||||
for (MachineRegisterInfo::reg_instr_nodbg_iterator
|
||||
RI = MRI.reg_instr_nodbg_begin(SnipLI.reg),
|
||||
E = MRI.reg_instr_nodbg_end(); RI != E; ) {
|
||||
MachineInstr *MI = &*(RI++);
|
||||
|
||||
// Allow copies to/from Reg.
|
||||
if (isFullCopyOf(MI, Reg))
|
||||
@@ -277,8 +278,9 @@ void InlineSpiller::collectRegsToSpill() {
|
||||
if (Original == Reg)
|
||||
return;
|
||||
|
||||
for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(Reg);
|
||||
MachineInstr *MI = RI.skipInstruction();) {
|
||||
for (MachineRegisterInfo::reg_instr_iterator
|
||||
RI = MRI.reg_instr_begin(Reg), E = MRI.reg_instr_end(); RI != E; ) {
|
||||
MachineInstr *MI = &*(RI++);
|
||||
unsigned SnipReg = isFullCopyOf(MI, Reg);
|
||||
if (!isSibling(SnipReg))
|
||||
continue;
|
||||
@@ -759,8 +761,10 @@ void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) {
|
||||
DEBUG(dbgs() << "Merged to stack int: " << *StackInt << '\n');
|
||||
|
||||
// Find all spills and copies of VNI.
|
||||
for (MachineRegisterInfo::use_nodbg_iterator UI = MRI.use_nodbg_begin(Reg);
|
||||
MachineInstr *MI = UI.skipInstruction();) {
|
||||
for (MachineRegisterInfo::use_instr_nodbg_iterator
|
||||
UI = MRI.use_instr_nodbg_begin(Reg), E = MRI.use_instr_nodbg_end();
|
||||
UI != E; ) {
|
||||
MachineInstr *MI = &*(UI++);
|
||||
if (!MI->isCopy() && !MI->mayStore())
|
||||
continue;
|
||||
SlotIndex Idx = LIS.getInstructionIndex(MI);
|
||||
@@ -920,10 +924,12 @@ void InlineSpiller::reMaterializeAll() {
|
||||
for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) {
|
||||
unsigned Reg = RegsToSpill[i];
|
||||
LiveInterval &LI = LIS.getInterval(Reg);
|
||||
for (MachineRegisterInfo::use_nodbg_iterator
|
||||
RI = MRI.use_nodbg_begin(Reg);
|
||||
MachineInstr *MI = RI.skipBundle();)
|
||||
for (MachineRegisterInfo::use_bundle_nodbg_iterator
|
||||
RI = MRI.use_bundle_nodbg_begin(Reg), E = MRI.use_bundle_nodbg_end();
|
||||
RI != E; ) {
|
||||
MachineInstr *MI = &*(RI++);
|
||||
anyRemat |= reMaterializeFor(LI, MI);
|
||||
}
|
||||
}
|
||||
if (!anyRemat)
|
||||
return;
|
||||
@@ -1187,8 +1193,10 @@ void InlineSpiller::spillAroundUses(unsigned Reg) {
|
||||
LiveInterval &OldLI = LIS.getInterval(Reg);
|
||||
|
||||
// Iterate over instructions using Reg.
|
||||
for (MachineRegisterInfo::reg_iterator RegI = MRI.reg_begin(Reg);
|
||||
MachineInstr *MI = RegI.skipBundle();) {
|
||||
for (MachineRegisterInfo::reg_bundle_iterator
|
||||
RegI = MRI.reg_bundle_begin(Reg), E = MRI.reg_bundle_end();
|
||||
RegI != E; ) {
|
||||
MachineInstr *MI = &*(RegI++);
|
||||
|
||||
// Debug values are not allowed to affect codegen.
|
||||
if (MI->isDebugValue()) {
|
||||
@@ -1313,8 +1321,10 @@ void InlineSpiller::spillAll() {
|
||||
|
||||
// Finally delete the SnippetCopies.
|
||||
for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) {
|
||||
for (MachineRegisterInfo::reg_iterator RI = MRI.reg_begin(RegsToSpill[i]);
|
||||
MachineInstr *MI = RI.skipInstruction();) {
|
||||
for (MachineRegisterInfo::reg_instr_iterator
|
||||
RI = MRI.reg_instr_begin(RegsToSpill[i]), E = MRI.reg_instr_end();
|
||||
RI != E; ) {
|
||||
MachineInstr *MI = &*(RI++);
|
||||
assert(SnippetCopies.count(MI) && "Remaining use wasn't a snippet copy");
|
||||
// FIXME: Do this with a LiveRangeEdit callback.
|
||||
LIS.RemoveMachineInstrFromMaps(MI);
|
||||
|
Reference in New Issue
Block a user