| 1 |
#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_ |
| 2 |
#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_ |
| 3 |
|
| 4 |
#include "flang/Evaluate/target.h" |
| 5 |
#include <fenv.h> |
| 6 |
|
| 7 |
using Fortran::common::RoundingMode; |
| 8 |
using Fortran::evaluate::RealFlags; |
| 9 |
using Fortran::evaluate::Rounding; |
| 10 |
|
| 11 |
class ScopedHostFloatingPointEnvironment { |
| 12 |
public: |
| 13 |
ScopedHostFloatingPointEnvironment(bool treatSubnormalOperandsAsZero = false, |
| 14 |
bool flushSubnormalResultsToZero = false); |
| 15 |
~ScopedHostFloatingPointEnvironment(); |
| 16 |
void ClearFlags() const; |
| 17 |
static RealFlags CurrentFlags(); |
| 18 |
static void SetRounding(Rounding rounding); |
| 19 |
|
| 20 |
private: |
| 21 |
fenv_t originalFenv_; |
| 22 |
#if __x86_64__ |
| 23 |
unsigned int originalMxcsr; |
| 24 |
#endif |
| 25 |
}; |
| 26 |
|
| 27 |
#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_ |