aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-06-29 19:16:05 +0000
committerManman Ren <mren@apple.com>2012-06-29 19:16:05 +0000
commit54d69668b22b8c37aa6e45f14445f3988cc430d4 (patch)
treedfbca2139cc35b8cf629175925c4372c9f5b21b9 /lib/CodeGen/MachineRegisterInfo.cpp
parent2923bca2b5fe46189c4c5572047e1d95946ac549 (diff)
Add getUniqueVRegDef to MachineRegisterInfo.
This comes in handy during peephole optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159453 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--lib/CodeGen/MachineRegisterInfo.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp
index 9c0d749a26..863da72774 100644
--- a/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/lib/CodeGen/MachineRegisterInfo.cpp
@@ -165,6 +165,17 @@ MachineInstr *MachineRegisterInfo::getVRegDef(unsigned Reg) const {
return !I.atEnd() ? &*I : 0;
}
+/// getUniqueVRegDef - Return the unique machine instr that defines the
+/// specified virtual register or null if none is found. If there are
+/// multiple definitions or no definition, return null.
+MachineInstr *MachineRegisterInfo::getUniqueVRegDef(unsigned Reg) const {
+ if (def_empty(Reg)) return 0;
+ def_iterator I = def_begin(Reg);
+ if (llvm::next(I) != def_end())
+ return 0;
+ return &*I;
+}
+
bool MachineRegisterInfo::hasOneUse(unsigned RegNo) const {
use_iterator UI = use_begin(RegNo);
if (UI == use_end())