2018-06-09 01:24:15 +08:00
|
|
|
#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
|
|
|
|
#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
|
|
|
|
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Evaluate/common.h"
|
2018-06-09 01:24:15 +08:00
|
|
|
#include <fenv.h>
|
|
|
|
|
2020-01-10 00:10:57 +08:00
|
|
|
using Fortran::common::RoundingMode;
|
2018-06-09 01:24:15 +08:00
|
|
|
using Fortran::evaluate::RealFlags;
|
2018-06-12 02:35:53 +08:00
|
|
|
using Fortran::evaluate::Rounding;
|
2018-06-09 01:24:15 +08:00
|
|
|
|
|
|
|
class ScopedHostFloatingPointEnvironment {
|
|
|
|
public:
|
2019-01-30 08:47:41 +08:00
|
|
|
ScopedHostFloatingPointEnvironment(bool treatSubnormalOperandsAsZero = false,
|
|
|
|
bool flushSubnormalResultsToZero = false);
|
2018-06-09 01:24:15 +08:00
|
|
|
~ScopedHostFloatingPointEnvironment();
|
2018-06-09 06:49:06 +08:00
|
|
|
void ClearFlags() const;
|
2018-06-12 02:35:53 +08:00
|
|
|
static RealFlags CurrentFlags();
|
|
|
|
static void SetRounding(Rounding rounding);
|
2018-06-09 06:49:06 +08:00
|
|
|
|
2018-06-09 01:24:15 +08:00
|
|
|
private:
|
|
|
|
fenv_t originalFenv_;
|
|
|
|
fenv_t currentFenv_;
|
|
|
|
};
|
|
|
|
|
2020-03-29 12:00:16 +08:00
|
|
|
#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
|