summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2014-11-25 15:20:54 +0000
committerTom Stellard <thomas.stellard@amd.com>2014-12-10 02:12:51 +0000
commit3c01a870e48499b387ad65cda61adaabb4b0a00e (patch)
tree4f417ef6125475e4129cd05045da48162752aeef
parent3ac6db2dba3799046ee086fd885655c22bb2420f (diff)
MachineRegisterInfo: Add SubIdx argument to hasOneDef()
-rw-r--r--include/llvm/CodeGen/MachineRegisterInfo.h7
-rw-r--r--lib/CodeGen/MachineRegisterInfo.cpp22
2 files changed, 23 insertions, 6 deletions
diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h
index 2e7f034be6b..5a409610a57 100644
--- a/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -376,12 +376,7 @@ public:
/// hasOneDef - Return true if there is exactly one instruction defining the
/// specified register.
- bool hasOneDef(unsigned RegNo) const {
- def_iterator DI = def_begin(RegNo);
- if (DI == def_end())
- return false;
- return ++DI == def_end();
- }
+ bool hasOneDef(unsigned RegNo, unsigned SubIdx = 0) const;
/// use_iterator/use_begin/use_end - Walk all uses of the specified register.
typedef defusechain_iterator<true,false,false,true,false,false>
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp
index e9612f3cfde..18ca9fc7825 100644
--- a/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/lib/CodeGen/MachineRegisterInfo.cpp
@@ -325,6 +325,28 @@ bool MachineRegisterInfo::hasOneNonDBGUse(unsigned RegNo) const {
return ++UI == use_nodbg_end();
}
+bool MachineRegisterInfo::hasOneDef(unsigned RegNo, unsigned SubIdx) const {
+ def_iterator DI = def_begin(RegNo);
+ if (DI == def_end())
+ return false;
+
+ const TargetRegisterInfo *TRI = getTargetRegisterInfo();
+ if (!SubIdx ||
+ TRI->subRegWriteClobbersSuperReg(getRegClass(RegNo), SubIdx))
+ return ++DI == def_end();
+
+ bool HasDef = false;
+ for ( ; DI != def_end(); ++DI) {
+ if (HasDef)
+ return false;
+
+ HasDef = TRI->getSubRegIndexLaneMask(SubIdx) &
+ TRI->getSubRegIndexLaneMask(DI->getSubReg());
+ }
+
+ return HasDef;
+}
+
/// clearKillFlags - Iterate over all the uses of the given register and
/// clear the kill flag from the MachineOperand. This function is used by
/// optimization passes which extend register lifetimes and need only