diff options
Diffstat (limited to 'llvm/include/llvm/IR/PatternMatch.h')
-rw-r--r-- | llvm/include/llvm/IR/PatternMatch.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h index 6e45dcfd719..2cd99d76cc9 100644 --- a/llvm/include/llvm/IR/PatternMatch.h +++ b/llvm/include/llvm/IR/PatternMatch.h @@ -157,6 +157,19 @@ inline match_combine_or<match_zero, match_neg_zero> m_AnyZero() { return m_CombineOr(m_Zero(), m_NegZero()); } +struct match_nan { + template <typename ITy> bool match(ITy *V) { + if (const auto *C = dyn_cast<ConstantFP>(V)) { + const APFloat &APF = C->getValueAPF(); + return APF.isNaN(); + } + return false; + } +}; + +/// Match an arbitrary NaN constant. This includes quiet and signalling nans. +inline match_nan m_NaN() { return match_nan(); } + struct apint_match { const APInt *&Res; apint_match(const APInt *&R) : Res(R) {} |