FLANG
target-rounding.h
1//===-- include/flang/Common/target-rounding.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 FORTRAN_COMMON_TARGET_ROUNDING_H_
10#define FORTRAN_COMMON_TARGET_ROUNDING_H_
11
12#include "Fortran-consts.h"
13#include "enum-set.h"
14
15namespace Fortran::common {
16
17// Floating-point rounding control
18struct Rounding {
19 common::RoundingMode mode{common::RoundingMode::TiesToEven};
20 // When set, emulate status flag behavior peculiar to x86
21 // (viz., fail to set the Underflow flag when an inexact product of a
22 // multiplication is rounded up to a normal number from a subnormal
23 // in some rounding modes)
24#if __x86_64__ || _M_X64 || __riscv || __loongarch__
25 bool x86CompatibleBehavior{true};
26#else
27 bool x86CompatibleBehavior{false};
28#endif
29};
30
31// These are ordered like the bits in a common fenv.h header file.
32ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
33 Inexact)
35
36} // namespace Fortran::common
37#endif /* FORTRAN_COMMON_TARGET_ROUNDING_H_ */
Definition enum-set.h:28
Definition bit-population-count.h:20
Definition target-rounding.h:18