]> granicus.if.org Git - llvm/commitdiff
[PatternMatch] Add matcher for LoadInst, NFC.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 Dec 2017 15:17:37 +0000 (15:17 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 Dec 2017 15:17:37 +0000 (15:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320155 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/PatternMatch.h

index 5124607436f410abc3ea75f853028e4b904d62fb..245d72fbd16e24ec13a5a8829d3fc7f2435710a3 100644 (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
 //