diff options
author | Chris Lattner <sabre@nondot.org> | 2008-01-08 07:02:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-01-08 07:02:44 +0000 |
commit | 4a83e963b356be29d2b7ddb55fe4565147332c34 (patch) | |
tree | b2a8198356287ef3f4b6596057f3383a16c670b6 /include/llvm/Support/PatternMatch.h | |
parent | a4040e9a9f313912469be454c0fde7ce50c64311 (diff) |
add match support for casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45744 91177308-0d34-0410-b5e6-96231b3b80d8
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 // |