From 232ae7cc209662ef972356972c8e8158f602b735 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 2 Aug 2012 14:45:53 +0000 Subject: [PATCH] Add TargetRegisterInfo::hasRegUnit(). This trivial helper function tests if a register contains a register unit. It is similar to regsOverlap(), but with asymmetric arguments. llvm-svn: 161180 --- llvm/include/llvm/Target/TargetRegisterInfo.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/llvm/include/llvm/Target/TargetRegisterInfo.h b/llvm/include/llvm/Target/TargetRegisterInfo.h index a70b8f6cbdb4..df4d900e4c8e 100644 --- a/llvm/include/llvm/Target/TargetRegisterInfo.h +++ b/llvm/include/llvm/Target/TargetRegisterInfo.h @@ -349,6 +349,14 @@ public: return false; } + /// hasRegUnit - Returns true if Reg contains RegUnit. + bool hasRegUnit(unsigned Reg, unsigned RegUnit) const { + for (MCRegUnitIterator Units(Reg, this); Units.isValid(); ++Units) + if (*Units == RegUnit) + return true; + return false; + } + /// isSubRegister - Returns true if regB is a sub-register of regA. /// bool isSubRegister(unsigned regA, unsigned regB) const {