LLVM 22.0.0git
FloatingPointPredicateUtils.cpp
Go to the documentation of this file.
1//===- FloatingPointPredicateUtils.cpp ------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include <optional>
12
13namespace llvm {
14
15using namespace PatternMatch;
16
17template <>
18DenormalMode FloatingPointPredicateUtils::queryDenormalMode(const Function &F,
19 Value *Val) {
20 Type *Ty = Val->getType()->getScalarType();
21 return F.getDenormalMode(Ty->getFltSemantics());
22}
23
24template <>
25bool FloatingPointPredicateUtils::lookThroughFAbs(const Function &F, Value *LHS,
26 Value *&Src) {
27 return match(LHS, m_FAbs(m_Value(Src)));
28}
29
30template <>
31std::optional<APFloat>
32FloatingPointPredicateUtils::matchConstantFloat(const Function &F, Value *Val) {
33 const APFloat *ConstVal;
34
35 if (!match(Val, m_APFloatAllowPoison(ConstVal)))
36 return std::nullopt;
37
38 return *ConstVal;
39}
40
41} // namespace llvm
#define F(x, y, z)
Definition MD5.cpp:55
Value * LHS
LLVM Value Representation.
Definition Value.h:75
bool match(Val *V, const Pattern &P)
apfloat_match m_APFloatAllowPoison(const APFloat *&Res)
Match APFloat while allowing poison in splat vector constants.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
m_Intrinsic_Ty< Opnd0 >::Ty m_FAbs(const Opnd0 &Op0)
This is an optimization pass for GlobalISel generic memory operations.
Represent subnormal handling kind for floating point instruction inputs and outputs.