summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-01 03:07:29 +0000
committerChris Lattner <sabre@nondot.org>2008-01-01 03:07:29 +0000
commit39204d76c5607209756232ba5fef17ca6b0a8012 (patch)
treec0847454cee9b5ffcc55ec2f9b801a13fd1cbd8b /llvm/lib/CodeGen/MachineRegisterInfo.cpp
parent8a497053a7a43347c3a44851c17b66c1f92d7f85 (diff)
downloadbcm5719-llvm-39204d76c5607209756232ba5fef17ca6b0a8012.tar.gz
bcm5719-llvm-39204d76c5607209756232ba5fef17ca6b0a8012.zip
Add a trivial but handy function to efficiently return the machine
instruction that defines the specified vreg. Crazy. llvm-svn: 45480
Diffstat (limited to 'llvm/lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineRegisterInfo.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
index f217c042be2..b41a1e748cc 100644
--- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
@@ -44,3 +44,18 @@ void MachineRegisterInfo::HandleVRegListReallocation() {
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;
+}
OpenPOWER on IntegriCloud