FLANG
Fortran::evaluate::value::RealValue Class Reference

#include <flang/Evaluate/real-value.h>

Public Types

using Word = IntegerValue

Public Member Functions

 RealValue (const RealValue &)
 RealValue (RealValue &&)
RealValue & operator= (const RealValue &)
RealValue & operator= (RealValue &&)
 RealValue (int kind, const RealValue &v)
 RealValue (int kind, RealValue &&v)
 RealValue (int kind, const Word &w)
 Interpret w as the raw bit pattern for the given runtime kind.
 RealValue (int kind, double x)
void print (llvm::raw_ostream &os) const
LLVM_DUMP_METHOD void dump () const
bool IsNull () const
int kind () const
 The kind of the value currently stored.
int bits () const
std::size_t bytesStored () const
 Number of bytes accessed by FromRawBytes/StoreRawBytes.
bool operator== (const RealValue &y) const
bool operator!= (const RealValue &y) const
bool IsNegative () const
bool IsNotANumber () const
bool IsSignalingNaN () const
bool IsInfinite () const
bool IsFinite () const
bool IsZero () const
bool IsNormal () const
RealValue ABS () const
RealValue SetSign (bool toNegative) const
RealValue SIGN (const RealValue &x) const
RealValue Negate () const
Relation Compare (const RealValue &y) const
ValueWithRealFlags< RealValue > Add (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > Subtract (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > Multiply (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > Divide (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > SQRT (Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > NEAREST (bool upward) const
 NEAREST(), IEEE_NEXT_AFTER(), IEEE_NEXT_UP(), and IEEE_NEXT_DOWN()
ValueWithRealFlags< RealValue > HYPOT (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
ValueWithRealFlags< RealValue > DIM (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
 DIM(X,Y) = MAX(X-Y, 0)
ValueWithRealFlags< RealValue > MOD (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
 MOD(x,y) = x - AINT(x/y)*y (in the standard)
ValueWithRealFlags< RealValue > MODULO (const RealValue &y, Rounding rounding=TargetCharacteristics::defaultRounding) const
 MODULO(x,y) = x - FLOOR(x/y)*y (in the standard)
ValueWithRealFlags< RealValue > KahanSummation (const RealValue &y, RealValue &correction, Rounding rounding=TargetCharacteristics::defaultRounding) const
IntegerValue EXPONENT () const
RealValue RRSPACING () const
RealValue SPACING () const
RealValue SET_EXPONENT (std::int64_t e) const
RealValue FRACTION () const
ValueWithRealFlags< RealValue > SCALE (const IntegerValue &by, Rounding rounding=TargetCharacteristics::defaultRounding) const
 SCALE(); also known as IEEE_SCALB and (in IEEE-754 '08) ScaleB.
RealValue FlushSubnormalToZero () const
ValueWithRealFlags< RealValue > ToWholeNumber (common::RoundingMode mode=common::RoundingMode::ToZero) const
 Conversion to integer in the same real format (AINT(), ANINT())
ValueWithRealFlags< IntegerValue > ToInteger (common::RoundingMode mode=common::RoundingMode::ToZero, int toBits=0) const
 Conversion to an integer (INT(), NINT(), FLOOR(), CEILING())
Word RawBits () const
int Exponent () const
 Extracts "raw" biased exponent field.
std::string DumpHexadecimal () const
llvm::raw_ostream & AsFortran (llvm::raw_ostream &o, int kind, bool minimal=false) const
void StoreRawBytes (void *dst, size_t size, bool *changed=nullptr) const

Static Public Member Functions

static RealValue Zero (int kind)
static RealValue NegativeZero (int kind)
 Creates a floating-point with value -0.0 of a given kind.
static RealValue Infinity (int kind, bool negative=false)
static constexpr int bits (int kind)
static constexpr std::size_t bytesStored (int kind)
static RealValue EPSILON (int kind)
static RealValue HUGE (int kind)
static RealValue TINY (int kind)
static int DIGITS (int kind)
static int PRECISION (int kind)
static int RANGE (int kind)
static int MAXEXPONENT (int kind)
static int MINEXPONENT (int kind)
static RealValue NotANumber (int kind)
static ValueWithRealFlags< RealValue > FromInteger (int kind, const IntegerValue &n, bool isUnsigned=false, Rounding rounding=TargetCharacteristics::defaultRounding)
static ValueWithRealFlags< RealValue > Convert (int kind, const RealValue &from, Rounding rounding=TargetCharacteristics::defaultRounding)
static ValueWithRealFlags< RealValue > Read (int kind, const char *&pp, Rounding rounding=TargetCharacteristics::defaultRounding)
static RealValue FromRawBytes (int kind, const void *raw, std::size_t expectedSize)

Detailed Description

A floating-point value with dynamic precision.

The precision is dynamic, but only a predefined set of Fortran kinds are allowed. It is also kind-aware, i.e. knows which REAL kind it currently represents.

The implementation is hidden from this header using a pImpl-like idiom.

Constructor & Destructor Documentation

◆ RealValue()

Fortran::evaluate::value::RealValue::RealValue ( int kind,
double x )

Creates a floating-point value of a given kind from a host double, rounded to the target kind's precision (per the default rounding mode). Portable: does not assume that the host "double" shares any bit layout with the target kind, only that <cmath>'s frexp()/ldexp() are available.

Member Function Documentation

◆ AsFortran()

llvm::raw_ostream & Fortran::evaluate::value::RealValue::AsFortran ( llvm::raw_ostream & o,
int kind,
bool minimal = false ) const

Emits a character representation for an equivalent Fortran constant or parenthesized constant expression that produces this value.

◆ HYPOT()

ValueWithRealFlags< RealValue > Fortran::evaluate::value::RealValue::HYPOT ( const RealValue & y,
Rounding rounding = TargetCharacteristics::defaultRounding ) const

HYPOT(x,y)=SQRT(x**2 + y**2) computed so as to avoid spurious intermediate overflows.

◆ IsNull()

bool Fortran::evaluate::value::RealValue::IsNull ( ) const

Whether this object represents a default-initialized value (zero) or unknown value.

◆ Zero()

RealValue Fortran::evaluate::value::RealValue::Zero ( int kind)
static

Creates a floating-point with value +0.0 of a given kind. In contrast, the default ctor creates a null state that represents +0.0 of unknown kind.


The documentation for this class was generated from the following files: