1 //===-- MachineFloatingPointModeUtils.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_CODEGEN_MACHINEFLOATINGPOINTPREDICATEUTILS_H 10 #define LLVM_CODEGEN_MACHINEFLOATINGPOINTPREDICATEUTILS_H 11 12 #include "llvm/CodeGen/MachineSSAContext.h" 13 #include "llvm/IR/GenericFloatingPointPredicateUtils.h" 14 15 namespace llvm { 16 17 using MachineFloatingPointPredicateUtils = 18 GenericFloatingPointPredicateUtils<MachineSSAContext>; 19 20 template <> 21 DenormalMode 22 MachineFloatingPointPredicateUtils::queryDenormalMode(const MachineFunction &MF, 23 Register Val); 24 25 template <> 26 bool MachineFloatingPointPredicateUtils::lookThroughFAbs( 27 const MachineFunction &MF, Register LHS, Register &Src); 28 29 template <> 30 std::optional<APFloat> MachineFloatingPointPredicateUtils::matchConstantFloat( 31 const MachineFunction &MF, Register Val); 32 33 /// Compute the possible floating-point classes that \p LHS could be based on 34 /// fcmp \Pred \p LHS, \p RHS. 35 /// 36 /// \returns { TestedValue, ClassesIfTrue, ClassesIfFalse } 37 /// 38 /// If the compare returns an exact class test, ClassesIfTrue == 39 /// ~ClassesIfFalse 40 /// 41 /// This is a less exact version of fcmpToClassTest (e.g. fcmpToClassTest will 42 /// only succeed for a test of x > 0 implies positive, but not x > 1). 43 /// 44 /// If \p LookThroughSrc is true, consider the input value when computing the 45 /// mask. This may look through sign bit operations. 46 /// 47 /// If \p LookThroughSrc is false, ignore the source value (i.e. the first 48 /// pair element will always be LHS. 49 /// 50 inline std::tuple<Register, FPClassTest, FPClassTest> 51 fcmpImpliesClass(CmpInst::Predicate Pred, const MachineFunction &MF, 52 Register LHS, Register RHS, bool LookThroughSrc = true) { 53 return MachineFloatingPointPredicateUtils::fcmpImpliesClass( 54 Pred, MF, LHS, RHS, LookThroughSrc); 55 } 56 57 } // namespace llvm 58 59 #endif // LLVM_CODEGEN_MACHINEFLOATINGPOINTPREDICATEUTILS_H 60