Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 1 | //===- FPEnv.h ---- FP Environment ------------------------------*- 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 | /// @file |
| 10 | /// This file contains the declarations of entities that describe floating |
| 11 | /// point environment and related functions. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_IR_FLOATINGPOINT_H |
| 16 | #define LLVM_IR_FLOATINGPOINT_H |
| 17 | |
| 18 | #include "llvm/ADT/FloatingPointMode.h" |
| 19 | #include "llvm/ADT/Optional.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class StringRef; |
| 23 | |
| 24 | namespace fp { |
| 25 | |
| 26 | /// Exception behavior used for floating point operations. |
| 27 | /// |
| 28 | /// Each of these values correspond to some metadata argument value of a |
| 29 | /// constrained floating point intrinsic. See the LLVM Language Reference Manual |
| 30 | /// for details. |
| 31 | enum ExceptionBehavior : uint8_t { |
| 32 | ebIgnore, ///< This corresponds to "fpexcept.ignore". |
| 33 | ebMayTrap, ///< This corresponds to "fpexcept.maytrap". |
| 34 | ebStrict ///< This corresponds to "fpexcept.strict". |
| 35 | }; |
| 36 | |
| 37 | } |
| 38 | |
| 39 | /// Returns a valid RoundingMode enumerator when given a string |
| 40 | /// that is valid as input in constrained intrinsic rounding mode |
| 41 | /// metadata. |
| 42 | Optional<RoundingMode> StrToRoundingMode(StringRef); |
| 43 | |
| 44 | /// For any RoundingMode enumerator, returns a string valid as input in |
| 45 | /// constrained intrinsic rounding mode metadata. |
| 46 | Optional<StringRef> RoundingModeToStr(RoundingMode); |
| 47 | |
| 48 | /// Returns a valid ExceptionBehavior enumerator when given a string |
| 49 | /// valid as input in constrained intrinsic exception behavior metadata. |
| 50 | Optional<fp::ExceptionBehavior> StrToExceptionBehavior(StringRef); |
| 51 | |
| 52 | /// For any ExceptionBehavior enumerator, returns a string valid as |
| 53 | /// input in constrained intrinsic exception behavior metadata. |
| 54 | Optional<StringRef> ExceptionBehaviorToStr(fp::ExceptionBehavior); |
| 55 | } |
| 56 | #endif |