LLVM 22.0.0git
FloatingPointPredicateUtils.h
Go to the documentation of this file.
1//===- llvm/Analysis/FloatingPointPredicateUtils.h ------------*- C++ -*---===//
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
9#ifndef LLVM_ANALYSIS_FLOATINGPOINTPREDICATEUTILS_H
10#define LLVM_ANALYSIS_FLOATINGPOINTPREDICATEUTILS_H
11
13#include "llvm/IR/SSAContext.h"
15
16namespace llvm {
17
20
21template <>
23FloatingPointPredicateUtils::queryDenormalMode(const Function &F, Value *Val);
24
25template <>
26LLVM_ABI bool FloatingPointPredicateUtils::lookThroughFAbs(const Function &F,
27 Value *LHS,
28 Value *&Src);
29
30template <>
31LLVM_ABI std::optional<APFloat>
32FloatingPointPredicateUtils::matchConstantFloat(const Function &F, Value *Val);
33
34/// Returns a pair of values, which if passed to llvm.is.fpclass, returns the
35/// same result as an fcmp with the given operands.
36///
37/// If \p LookThroughSrc is true, consider the input value when computing the
38/// mask.
39///
40/// If \p LookThroughSrc is false, ignore the source value (i.e. the first pair
41/// element will always be LHS.
42inline std::pair<Value *, FPClassTest>
44 Value *RHS, bool LookThroughSrc = true) {
46 LookThroughSrc = true);
47}
48
49/// Returns a pair of values, which if passed to llvm.is.fpclass, returns the
50/// same result as an fcmp with the given operands.
51///
52/// If \p LookThroughSrc is true, consider the input value when computing the
53/// mask.
54///
55/// If \p LookThroughSrc is false, ignore the source value (i.e. the first pair
56/// element will always be LHS.
57inline std::pair<Value *, FPClassTest>
59 const APFloat *ConstRHS, bool LookThroughSrc = true) {
60 return FloatingPointPredicateUtils::fcmpToClassTest(Pred, F, LHS, *ConstRHS,
61 LookThroughSrc);
62}
63
64inline std::tuple<Value *, FPClassTest, FPClassTest>
66 FPClassTest RHSClass, bool LookThroughSrc = true) {
68 LookThroughSrc);
69}
70
71inline std::tuple<Value *, FPClassTest, FPClassTest>
73 const APFloat &ConstRHS, bool LookThroughSrc = true) {
75 LookThroughSrc);
76}
77
78inline std::tuple<Value *, FPClassTest, FPClassTest>
80 Value *RHS, bool LookThroughSrc = true) {
82 LookThroughSrc);
83}
84
85} // namespace llvm
86
87#endif // LLVM_ANALYSIS_FLOATINGPOINTPREDICATEUTILS_H
#define LLVM_ABI
Definition: Compiler.h:213
Utilities for dealing with flags related to floating point properties and mode controls.
#define F(x, y, z)
Definition: MD5.cpp:55
This file declares a specialization of the GenericSSAContext<X> class template for LLVM IR.
Value * RHS
Value * LHS
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:678
static std::tuple< ValueRefT, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, FPClassTest RHSClass, bool LookThroughSrc)
Compute the possible floating-point classes that LHS could be based on fcmp \Pred LHS,...
static std::pair< ValueRefT, FPClassTest > fcmpToClassTest(FCmpInst::Predicate Pred, const FunctionT &F, ValueRefT LHS, ValueRefT RHS, bool LookThroughSrc)
Returns a pair of values, which if passed to llvm.is.fpclass, returns the same result as an fcmp with...
LLVM Value Representation.
Definition: Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::tuple< Value *, FPClassTest, FPClassTest > fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS, FPClassTest RHSClass, bool LookThroughSrc=true)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
std::pair< Value *, FPClassTest > fcmpToClassTest(FCmpInst::Predicate Pred, const Function &F, Value *LHS, Value *RHS, bool LookThroughSrc=true)
Returns a pair of values, which if passed to llvm.is.fpclass, returns the same result as an fcmp with...
Represent subnormal handling kind for floating point instruction inputs and outputs.