diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
commit | cd749a9c07f1de2fb8affde90537efa4bc3e7c54 (patch) | |
tree | b21f6de4e08b89bb7931806bab798fc2a5e3a686 /include/llvm/Support/PatternMatch.h | |
parent | 72621d11de5b873f1695f391eb95f0b336c3d2d4 (diff) | |
download | FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.zip FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.tar.gz |
Update llvm to r84119.
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r-- | include/llvm/Support/PatternMatch.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index fda925f..c0b6a6b 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -58,7 +58,7 @@ struct constantint_ty { if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) { const APInt &CIV = CI->getValue(); if (Val >= 0) - return CIV == Val; + return CIV == static_cast<uint64_t>(Val); // If Val is negative, and CI is shorter than it, truncate to the right // number of bits. If it is larger, then we have to sign extend. Just // compare their negated values. @@ -87,6 +87,18 @@ struct zero_ty { /// m_Zero() - Match an arbitrary zero/null constant. inline zero_ty m_Zero() { return zero_ty(); } +struct one_ty { + template<typename ITy> + bool match(ITy *V) { + if (const ConstantInt *C = dyn_cast<ConstantInt>(V)) + return C->isOne(); + return false; + } +}; + +/// m_One() - Match a an integer 1. +inline one_ty m_One() { return one_ty(); } + template<typename Class> struct bind_ty { @@ -311,7 +323,8 @@ struct BinaryOpClass_match { template<typename OpTy> bool match(OpTy *V) { if (Class *I = dyn_cast<Class>(V)) - if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) { + if (L.match(I->getOperand(0)) && + R.match(I->getOperand(1))) { if (Opcode) *Opcode = I->getOpcode(); return true; @@ -356,7 +369,8 @@ struct CmpClass_match { template<typename OpTy> bool match(OpTy *V) { if (Class *I = dyn_cast<Class>(V)) - if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) { + if (L.match(I->getOperand(0)) && + R.match(I->getOperand(1))) { Predicate = I->getPredicate(); return true; } @@ -403,7 +417,7 @@ struct SelectClass_match { }; template<typename Cond, typename LHS, typename RHS> -inline SelectClass_match<Cond, RHS, LHS> +inline SelectClass_match<Cond, LHS, RHS> m_Select(const Cond &C, const LHS &L, const RHS &R) { return SelectClass_match<Cond, LHS, RHS>(C, L, R); } @@ -503,7 +517,7 @@ struct neg_match { } private: bool matchIfNeg(Value *LHS, Value *RHS) { - return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) && + return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) && L.match(RHS); } }; @@ -532,7 +546,7 @@ struct fneg_match { } private: bool matchIfFNeg(Value *LHS, Value *RHS) { - return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) && + return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) && L.match(RHS); } }; |