[PatternMatch] Add matcher for LoadInst, NFC.

llvm-svn: 320155
This commit is contained in:
Alexey Bataev 2017-12-08 15:17:37 +00:00
parent 26f106fda4
commit ad1d023d94
1 changed files with 20 additions and 0 deletions

View File

@ -956,6 +956,26 @@ inline CastClass_match<OpTy, Instruction::FPExt> m_FPExt(const OpTy &Op) {
return CastClass_match<OpTy, Instruction::FPExt>(Op);
}
//===----------------------------------------------------------------------===//
// Matcher for LoadInst classes
//
template <typename Op_t> struct LoadClass_match {
Op_t Op;
LoadClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
template <typename OpTy> bool match(OpTy *V) {
if (auto *LI = dyn_cast<LoadInst>(V))
return Op.match(LI->getPointerOperand());
return false;
}
};
/// Matches LoadInst.
template <typename OpTy> inline LoadClass_match<OpTy> m_Load(const OpTy &Op) {
return LoadClass_match<OpTy>(Op);
}
//===----------------------------------------------------------------------===//
// Matchers for unary operators
//