diff options
Diffstat (limited to 'llvm/include/llvm/IR/PatternMatch.h')
-rw-r--r-- | llvm/include/llvm/IR/PatternMatch.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h index 37a2fe52ec1..173b664028f 100644 --- a/llvm/include/llvm/IR/PatternMatch.h +++ b/llvm/include/llvm/IR/PatternMatch.h @@ -825,6 +825,28 @@ m_FNegNSZ(const RHS &X) { return m_FSub(m_AnyZeroFP(), X); } +template <typename Op_t> struct Freeze_match { + Op_t X; + + Freeze_match(const Op_t &Op) : X(Op) {} + template <typename OpTy> bool match(OpTy *V) { + auto *I = dyn_cast<UnaryOperator>(V); + if (!I) return false; + + if (isa<FreezeOperator>(I)) + return X.match(I->getOperand(0)); + + return false; + } +}; + +/// Matches freeze. +template <typename OpTy> +inline Freeze_match<OpTy> +m_Freeze(const OpTy &X) { + return Freeze_match<OpTy>(X); +} + template <typename LHS, typename RHS> inline BinaryOp_match<LHS, RHS, Instruction::Mul> m_Mul(const LHS &L, const RHS &R) { |