diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-15 15:37:28 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-15 15:37:28 +0000 |
| commit | 829000e035f46f2a227a5466e4e427a2f3cc00a9 (patch) | |
| tree | be5a687969f682edded4aa6f13594ffd9aa9030e /include/llvm/Support/PatternMatch.h | |
| parent | 1e7804dbd25b8dbf534c850355d70ad215206f4b (diff) | |
Notes
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
| -rw-r--r-- | include/llvm/Support/PatternMatch.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index c0b6a6b98c09..23daad923929 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -437,7 +437,7 @@ m_SelectCst(const Cond &C) { // Matchers for CastInst classes // -template<typename Op_t, typename Class> +template<typename Op_t, unsigned Opcode> struct CastClass_match { Op_t Op; @@ -445,17 +445,28 @@ struct CastClass_match { template<typename OpTy> bool match(OpTy *V) { - if (Class *I = dyn_cast<Class>(V)) - return Op.match(I->getOperand(0)); + if (CastInst *I = dyn_cast<CastInst>(V)) + return I->getOpcode() == Opcode && Op.match(I->getOperand(0)); + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) + return CE->getOpcode() == Opcode && Op.match(CE->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); +/// m_PtrToInt +template<typename OpTy> +inline CastClass_match<OpTy, Instruction::PtrToInt> +m_PtrToInt(const OpTy &Op) { + return CastClass_match<OpTy, Instruction::PtrToInt>(Op); } +/// m_Trunc +template<typename OpTy> +inline CastClass_match<OpTy, Instruction::Trunc> +m_Trunc(const OpTy &Op) { + return CastClass_match<OpTy, Instruction::Trunc>(Op); +} + //===----------------------------------------------------------------------===// // Matchers for unary operators |
