mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 23:17:10 +00:00
Add a trivial but handy function to efficiently return the machine
instruction that defines the specified vreg. Crazy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -120,6 +120,12 @@ public:
|
|||||||
return VRegInfo.size()+MRegisterInfo::FirstVirtualRegister-1;
|
return VRegInfo.size()+MRegisterInfo::FirstVirtualRegister-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getVRegDef - Return the machine instr that defines the specified virtual
|
||||||
|
/// register or null if none is found. This assumes that the code is in SSA
|
||||||
|
/// form, so there should only be one definition.
|
||||||
|
MachineInstr *getVRegDef(unsigned Reg) const;
|
||||||
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Physical Register Use Info
|
// Physical Register Use Info
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@@ -44,3 +44,18 @@ void MachineRegisterInfo::HandleVRegListReallocation() {
|
|||||||
List->Contents.Reg.Prev = &VRegInfo[i].second;
|
List->Contents.Reg.Prev = &VRegInfo[i].second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// getVRegDef - Return the machine instr that defines the specified virtual
|
||||||
|
/// register or null if none is found. This assumes that the code is in SSA
|
||||||
|
/// form, so there should only be one definition.
|
||||||
|
MachineInstr *MachineRegisterInfo::getVRegDef(unsigned Reg) const {
|
||||||
|
assert(Reg-MRegisterInfo::FirstVirtualRegister < VRegInfo.size() &&
|
||||||
|
"Invalid vreg!");
|
||||||
|
for (reg_iterator I = reg_begin(Reg), E = reg_end(); I != E; ++I) {
|
||||||
|
// Since we are in SSA form, we can stop at the first definition.
|
||||||
|
if (I->isDef())
|
||||||
|
return I->getParent();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user