X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FPatternMatch.h;h=fda925f5a9a8c2fe4b712df4618c0538a60a4423;hb=38b06447615440f935008a2141bd0a1fe078d437;hp=d27a7f1ed7864836134d422e20b4262bdef0acfc;hpb=fe2cce63aa26d0916fa7be32c6bf7fa8fb059ee7;p=oota-llvm.git diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index d27a7f1ed78..fda925f5a9a 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -156,18 +156,36 @@ inline BinaryOp_match m_Add(const LHS &L, return BinaryOp_match(L, R); } +template +inline BinaryOp_match m_FAdd(const LHS &L, + const RHS &R) { + return BinaryOp_match(L, R); +} + template inline BinaryOp_match m_Sub(const LHS &L, const RHS &R) { return BinaryOp_match(L, R); } +template +inline BinaryOp_match m_FSub(const LHS &L, + const RHS &R) { + return BinaryOp_match(L, R); +} + template inline BinaryOp_match m_Mul(const LHS &L, const RHS &R) { return BinaryOp_match(L, R); } +template +inline BinaryOp_match m_FMul(const LHS &L, + const RHS &R) { + return BinaryOp_match(L, R); +} + template inline BinaryOp_match m_UDiv(const LHS &L, const RHS &R) { @@ -494,6 +512,35 @@ template inline neg_match m_Neg(const LHS &L) { return L; } +template +struct fneg_match { + LHS_t L; + + fneg_match(const LHS_t &LHS) : L(LHS) {} + + template + bool match(OpTy *V) { + if (Instruction *I = dyn_cast(V)) + if (I->getOpcode() == Instruction::FSub) + return matchIfFNeg(I->getOperand(0), I->getOperand(1)); + if (ConstantExpr *CE = dyn_cast(V)) + if (CE->getOpcode() == Instruction::FSub) + return matchIfFNeg(CE->getOperand(0), CE->getOperand(1)); + if (ConstantFP *CF = dyn_cast(V)) + return L.match(ConstantExpr::getFNeg(CF)); + return false; + } +private: + bool matchIfFNeg(Value *LHS, Value *RHS) { + return LHS == ConstantExpr::getZeroValueForNegationExpr(LHS->getType()) && + L.match(RHS); + } +}; + +template +inline fneg_match m_FNeg(const LHS &L) { return L; } + + //===----------------------------------------------------------------------===// // Matchers for control flow //