From: Alexey Bataev Date: Fri, 8 Dec 2017 15:17:37 +0000 (+0000) Subject: [PatternMatch] Add matcher for LoadInst, NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95462df77a8fc567895580559862e26e944e3b48;p=llvm [PatternMatch] Add matcher for LoadInst, NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320155 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/PatternMatch.h b/include/llvm/IR/PatternMatch.h index 5124607436f..245d72fbd16 100644 --- a/include/llvm/IR/PatternMatch.h +++ b/include/llvm/IR/PatternMatch.h @@ -956,6 +956,26 @@ inline CastClass_match m_FPExt(const OpTy &Op) { return CastClass_match(Op); } +//===----------------------------------------------------------------------===// +// Matcher for LoadInst classes +// + +template struct LoadClass_match { + Op_t Op; + + LoadClass_match(const Op_t &OpMatch) : Op(OpMatch) {} + + template bool match(OpTy *V) { + if (auto *LI = dyn_cast(V)) + return Op.match(LI->getPointerOperand()); + return false; + } +}; + +/// Matches LoadInst. +template inline LoadClass_match m_Load(const OpTy &Op) { + return LoadClass_match(Op); +} //===----------------------------------------------------------------------===// // Matchers for unary operators //