|
|
|||
File indexing completed on 2026-05-10 08:44:00
0001 //===- FPEnv.h ---- FP Environment ------------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 /// @file 0010 /// This file contains the declarations of entities that describe floating 0011 /// point environment and related functions. 0012 // 0013 //===----------------------------------------------------------------------===// 0014 0015 #ifndef LLVM_IR_FPENV_H 0016 #define LLVM_IR_FPENV_H 0017 0018 #include "llvm/ADT/FloatingPointMode.h" 0019 #include "llvm/IR/FMF.h" 0020 #include <optional> 0021 0022 namespace llvm { 0023 class StringRef; 0024 0025 namespace Intrinsic { 0026 typedef unsigned ID; 0027 } 0028 0029 class Instruction; 0030 0031 namespace fp { 0032 0033 /// Exception behavior used for floating point operations. 0034 /// 0035 /// Each of these values correspond to some metadata argument value of a 0036 /// constrained floating point intrinsic. See the LLVM Language Reference Manual 0037 /// for details. 0038 enum ExceptionBehavior : uint8_t { 0039 ebIgnore, ///< This corresponds to "fpexcept.ignore". 0040 ebMayTrap, ///< This corresponds to "fpexcept.maytrap". 0041 ebStrict ///< This corresponds to "fpexcept.strict". 0042 }; 0043 0044 } 0045 0046 /// Returns a valid RoundingMode enumerator when given a string 0047 /// that is valid as input in constrained intrinsic rounding mode 0048 /// metadata. 0049 std::optional<RoundingMode> convertStrToRoundingMode(StringRef); 0050 0051 /// For any RoundingMode enumerator, returns a string valid as input in 0052 /// constrained intrinsic rounding mode metadata. 0053 std::optional<StringRef> convertRoundingModeToStr(RoundingMode); 0054 0055 /// Returns a valid ExceptionBehavior enumerator when given a string 0056 /// valid as input in constrained intrinsic exception behavior metadata. 0057 std::optional<fp::ExceptionBehavior> convertStrToExceptionBehavior(StringRef); 0058 0059 /// For any ExceptionBehavior enumerator, returns a string valid as 0060 /// input in constrained intrinsic exception behavior metadata. 0061 std::optional<StringRef> convertExceptionBehaviorToStr(fp::ExceptionBehavior); 0062 0063 /// Returns true if the exception handling behavior and rounding mode 0064 /// match what is used in the default floating point environment. 0065 inline bool isDefaultFPEnvironment(fp::ExceptionBehavior EB, RoundingMode RM) { 0066 return EB == fp::ebIgnore && RM == RoundingMode::NearestTiesToEven; 0067 } 0068 0069 /// Returns constrained intrinsic id to represent the given instruction in 0070 /// strictfp function. If the instruction is already a constrained intrinsic or 0071 /// does not have a constrained intrinsic counterpart, the function returns 0072 /// zero. 0073 Intrinsic::ID getConstrainedIntrinsicID(const Instruction &Instr); 0074 0075 /// Returns true if the rounding mode RM may be QRM at compile time or 0076 /// at run time. 0077 inline bool canRoundingModeBe(RoundingMode RM, RoundingMode QRM) { 0078 return RM == QRM || RM == RoundingMode::Dynamic; 0079 } 0080 0081 /// Returns true if the possibility of a signaling NaN can be safely 0082 /// ignored. 0083 inline bool canIgnoreSNaN(fp::ExceptionBehavior EB, FastMathFlags FMF) { 0084 return (EB == fp::ebIgnore || FMF.noNaNs()); 0085 } 0086 } 0087 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|