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 //