From 4a83e963b356be29d2b7ddb55fe4565147332c34 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 8 Jan 2008 07:02:44 +0000 Subject: [PATCH] add match support for casts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45744 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/PatternMatch.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 59c412baa89..ca558821021 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -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 +struct CastClass_match { + Op_t Op; + + CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {} + + template + bool match(OpTy *V) { + if (Class *I = dyn_cast(V)) + return Op.match(I->getOperand(0)); + return false; + } +}; + +template +inline CastClass_match m_Cast(const OpTy &Op) { + return CastClass_match(Op); +} + + //===----------------------------------------------------------------------===// // Matchers for unary operators //