LLVM 22.0.0git
MachineFloatingPointPredicateUtils.cpp
Go to the documentation of this file.
1//===- MachineFloatingPointPredicateUtils.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
14#include "llvm/IR/Constants.h"
15#include <optional>
16
17namespace llvm {
18
19using namespace MIPatternMatch;
20
21template <>
23MachineFloatingPointPredicateUtils::queryDenormalMode(const MachineFunction &MF,
24 Register Val) {
25 const MachineRegisterInfo &MRI = MF.getRegInfo();
26 LLT Ty = MRI.getType(Val).getScalarType();
27 return MF.getDenormalMode(getFltSemanticForLLT(Ty));
28}
29
30template <>
31bool MachineFloatingPointPredicateUtils::lookThroughFAbs(
32 const MachineFunction &MF, Register LHS, Register &Src) {
33 const MachineRegisterInfo &MRI = MF.getRegInfo();
34 return mi_match(LHS, MRI, m_GFabs(m_Reg(Src)));
35}
36
37template <>
38std::optional<APFloat> MachineFloatingPointPredicateUtils::matchConstantFloat(
39 const MachineFunction &MF, Register Val) {
40 const MachineRegisterInfo &MRI = MF.getRegInfo();
41 const ConstantFP *ConstVal;
42 if (mi_match(Val, MRI, m_GFCst(ConstVal)))
43 return ConstVal->getValueAPF();
44
45 return std::nullopt;
46}
47
48} // namespace llvm
unsigned const MachineRegisterInfo * MRI
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Implement a low-level type suitable for MachineInstr level instruction selection.
Contains matchers for matching SSA Machine Instructions.
This file declares a specialization of the GenericSSAContext<X> template class for Machine IR.
Value * LHS
Wrapper class representing virtual and physical registers.
Definition Register.h:19
operand_type_match m_Reg()
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
GFCstAndRegMatch m_GFCst(std::optional< FPValueAndVReg > &FPValReg)
UnaryOp_match< SrcTy, TargetOpcode::G_FABS > m_GFabs(const SrcTy &Src)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI const llvm::fltSemantics & getFltSemanticForLLT(LLT Ty)
Get the appropriate floating point arithmetic semantic based on the bit size of the given scalar LLT.
Represent subnormal handling kind for floating point instruction inputs and outputs.