add match support for casts.
authorChris Lattner <sabre@nondot.org>
Tue, 8 Jan 2008 07:02:44 +0000 (07:02 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 8 Jan 2008 07:02:44 +0000 (07:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45744 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PatternMatch.h

index 59c412baa895c3bc10aca1dd02a33375fa7ed9b3..ca558821021cf55433af008b1508e91d88ee53e4 100644 (file)
@@ -321,6 +321,30 @@ m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
                         FCmpInst, FCmpInst::Predicate>(Pred, L, R);
 }
 
+//===----------------------------------------------------------------------===//
+// Matchers for CastInst classes
+//
+
+template<typename Op_t, typename Class>
+struct CastClass_match {
+  Op_t Op;
+  
+  CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
+  
+  template<typename OpTy>
+  bool match(OpTy *V) {
+    if (Class *I = dyn_cast<Class>(V))
+      return Op.match(I->getOperand(0));
+    return false;
+  }
+};
+
+template<typename Class, typename OpTy>
+inline CastClass_match<OpTy, Class> m_Cast(const OpTy &Op) {
+  return CastClass_match<OpTy, Class>(Op);
+}
+
+  
 //===----------------------------------------------------------------------===//
 // Matchers for unary operators
 //