diff options
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r-- | include/llvm/Support/PatternMatch.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 59c412baa8..ca55882102 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -322,6 +322,30 @@ m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &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 // |