FPEnv.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef LLVM_IR_FPENV_H
  15. #define LLVM_IR_FPENV_H
  16. #include "llvm/ADT/FloatingPointMode.h"
  17. #include "llvm/ADT/Optional.h"
  18. namespace llvm {
  19. class StringRef;
  20. namespace fp {
  21. /// Exception behavior used for floating point operations.
  22. ///
  23. /// Each of these values correspond to some metadata argument value of a
  24. /// constrained floating point intrinsic. See the LLVM Language Reference Manual
  25. /// for details.
  26. enum ExceptionBehavior : uint8_t {
  27. ebIgnore, ///< This corresponds to "fpexcept.ignore".
  28. ebMayTrap, ///< This corresponds to "fpexcept.maytrap".
  29. ebStrict ///< This corresponds to "fpexcept.strict".
  30. };
  31. }
  32. /// Returns a valid RoundingMode enumerator when given a string
  33. /// that is valid as input in constrained intrinsic rounding mode
  34. /// metadata.
  35. Optional<RoundingMode> StrToRoundingMode(StringRef);
  36. /// For any RoundingMode enumerator, returns a string valid as input in
  37. /// constrained intrinsic rounding mode metadata.
  38. Optional<StringRef> RoundingModeToStr(RoundingMode);
  39. /// Returns a valid ExceptionBehavior enumerator when given a string
  40. /// valid as input in constrained intrinsic exception behavior metadata.
  41. Optional<fp::ExceptionBehavior> StrToExceptionBehavior(StringRef);
  42. /// For any ExceptionBehavior enumerator, returns a string valid as
  43. /// input in constrained intrinsic exception behavior metadata.
  44. Optional<StringRef> ExceptionBehaviorToStr(fp::ExceptionBehavior);
  45. }
  46. #endif