LLVM  4.0.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
llvm::APFloat Class Reference

#include <APFloat.h>

Inheritance diagram for llvm::APFloat:
[legend]
Collaboration diagram for llvm::APFloat:
[legend]

Public Member Functions

 APFloat (const fltSemantics &Semantics)
 
 APFloat (const fltSemantics &Semantics, StringRef S)
 
 APFloat (const fltSemantics &Semantics, integerPart I)
 
 APFloat (const fltSemantics &Semantics, uninitializedTag)
 
 APFloat (const fltSemantics &Semantics, const APInt &I)
 
 APFloat (double d)
 
 APFloat (float f)
 
 APFloat (const APFloat &RHS)=default
 
 APFloat (APFloat &&RHS)=default
 
 ~APFloat ()=default
 
bool needsCleanup () const
 
void Profile (FoldingSetNodeID &NID) const
 
opStatus add (const APFloat &RHS, roundingMode RM)
 
opStatus subtract (const APFloat &RHS, roundingMode RM)
 
opStatus multiply (const APFloat &RHS, roundingMode RM)
 
opStatus divide (const APFloat &RHS, roundingMode RM)
 
opStatus remainder (const APFloat &RHS)
 
opStatus mod (const APFloat &RHS)
 
opStatus fusedMultiplyAdd (const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)
 
opStatus roundToIntegral (roundingMode RM)
 
opStatus next (bool nextDown)
 
APFloat operator+ (const APFloat &RHS) const
 
APFloat operator- (const APFloat &RHS) const
 
APFloat operator* (const APFloat &RHS) const
 
APFloat operator/ (const APFloat &RHS) const
 
void changeSign ()
 
void clearSign ()
 
void copySign (const APFloat &RHS)
 
opStatus convert (const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
 
opStatus convertToInteger (integerPart *Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
 
opStatus convertToInteger (APSInt &Result, roundingMode RM, bool *IsExact) const
 
opStatus convertFromAPInt (const APInt &Input, bool IsSigned, roundingMode RM)
 
opStatus convertFromSignExtendedInteger (const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
 
opStatus convertFromZeroExtendedInteger (const integerPart *Input, unsigned int InputSize, bool IsSigned, roundingMode RM)
 
opStatus convertFromString (StringRef, roundingMode)
 
APInt bitcastToAPInt () const
 
double convertToDouble () const
 
float convertToFloat () const
 
bool operator== (const APFloat &) const =delete
 
cmpResult compare (const APFloat &RHS) const
 
bool bitwiseIsEqual (const APFloat &RHS) const
 
unsigned int convertToHexString (char *DST, unsigned int HexDigits, bool UpperCase, roundingMode RM) const
 
bool isZero () const
 
bool isInfinity () const
 
bool isNaN () const
 
bool isNegative () const
 
bool isDenormal () const
 
bool isSignaling () const
 
bool isNormal () const
 
bool isFinite () const
 
fltCategory getCategory () const
 
const fltSemanticsgetSemantics () const
 
bool isNonZero () const
 
bool isFiniteNonZero () const
 
bool isPosZero () const
 
bool isNegZero () const
 
bool isSmallest () const
 
bool isLargest () const
 
bool isInteger () const
 
APFloatoperator= (const APFloat &RHS)=default
 
APFloatoperator= (APFloat &&RHS)=default
 
void toString (SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3) const
 
void print (raw_ostream &) const
 
void dump () const
 
bool getExactInverse (APFloat *inv) const
 
const APFloatgetSecondFloat () const
 

Static Public Member Functions

static APFloat getZero (const fltSemantics &Sem, bool Negative=false)
 Factory for Positive and Negative Zero. More...
 
static APFloat getInf (const fltSemantics &Sem, bool Negative=false)
 Factory for Positive and Negative Infinity. More...
 
static APFloat getNaN (const fltSemantics &Sem, bool Negative=false, unsigned type=0)
 Factory for NaN values. More...
 
static APFloat getQNaN (const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
 Factory for QNaN values. More...
 
static APFloat getSNaN (const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
 Factory for SNaN values. More...
 
static APFloat getLargest (const fltSemantics &Sem, bool Negative=false)
 Returns the largest finite number in the given semantics. More...
 
static APFloat getSmallest (const fltSemantics &Sem, bool Negative=false)
 Returns the smallest (by magnitude) finite number in the given semantics. More...
 
static APFloat getSmallestNormalized (const fltSemantics &Sem, bool Negative=false)
 Returns the smallest (by magnitude) normalized finite number in the given semantics. More...
 
static APFloat getAllOnesValue (unsigned BitWidth, bool isIEEE=false)
 Returns a float which is bitcasted from an all one value int. More...
 
static APFloat copySign (APFloat Value, const APFloat &Sign)
 
- Static Public Member Functions inherited from llvm::APFloatBase
static unsigned int semanticsPrecision (const fltSemantics &)
 
static ExponentType semanticsMinExponent (const fltSemantics &)
 
static ExponentType semanticsMaxExponent (const fltSemantics &)
 
static unsigned int semanticsSizeInBits (const fltSemantics &)
 
static unsigned getSizeInBits (const fltSemantics &Sem)
 Returns the size of the floating point number (in bits) in the given semantics. More...
 
static const fltSemanticsIEEEhalf ()
 
static const fltSemanticsIEEEsingle ()
 
static const fltSemanticsIEEEdouble ()
 
static const fltSemanticsIEEEquad ()
 
static const fltSemanticsPPCDoubleDouble ()
 
static const fltSemanticsx87DoubleExtended ()
 
static const fltSemanticsBogus ()
 A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real. More...
 

Public Attributes

friend IEEEFloat
 
friend DoubleAPFloat
 

Friends

hash_code hash_value (const APFloat &Arg)
 See friend declarations above. More...
 
int ilogb (const APFloat &Arg)
 
APFloat scalbn (APFloat X, int Exp, roundingMode RM)
 
APFloat frexp (const APFloat &X, int &Exp, roundingMode RM)
 

Additional Inherited Members

- Public Types inherited from llvm::APFloatBase
enum  cmpResult { cmpLessThan, cmpEqual, cmpGreaterThan, cmpUnordered }
 IEEE-754R 5.11: Floating Point Comparison Relations. More...
 
enum  roundingMode {
  rmNearestTiesToEven, rmTowardPositive, rmTowardNegative, rmTowardZero,
  rmNearestTiesToAway
}
 IEEE-754R 4.3: Rounding-direction attributes. More...
 
enum  opStatus {
  opOK = 0x00, opInvalidOp = 0x01, opDivByZero = 0x02, opOverflow = 0x04,
  opUnderflow = 0x08, opInexact = 0x10
}
 IEEE-754R 7: Default exception handling. More...
 
enum  fltCategory { fcInfinity, fcNaN, fcNormal, fcZero }
 Category of internally-represented number. More...
 
enum  uninitializedTag { uninitialized }
 Convenience enum used to construct an uninitialized APFloat. More...
 
enum  IlogbErrorKinds { IEK_Zero = INT_MIN + 1, IEK_NaN = INT_MIN, IEK_Inf = INT_MAX }
 Enumeration of ilogb error results. More...
 
typedef signed short ExponentType
 A signed type to represent a floating point numbers unbiased exponent. More...
 

Detailed Description

Definition at line 653 of file APFloat.h.

Constructor & Destructor Documentation

llvm::APFloat::APFloat ( const fltSemantics Semantics)
inline

Definition at line 816 of file APFloat.h.

llvm::APFloat::APFloat ( const fltSemantics Semantics,
StringRef  S 
)

Definition at line 4134 of file APFloat.cpp.

References convertFromString(), and llvm::APFloatBase::rmNearestTiesToEven.

llvm::APFloat::APFloat ( const fltSemantics Semantics,
integerPart  I 
)
inline

Definition at line 818 of file APFloat.h.

llvm::APFloat::APFloat ( const fltSemantics Semantics,
uninitializedTag   
)
inline

Definition at line 820 of file APFloat.h.

llvm::APFloat::APFloat ( const fltSemantics Semantics,
const APInt I 
)
inline

Definition at line 822 of file APFloat.h.

llvm::APFloat::APFloat ( double  d)
inlineexplicit

Definition at line 823 of file APFloat.h.

llvm::APFloat::APFloat ( float  f)
inlineexplicit

Definition at line 824 of file APFloat.h.

llvm::APFloat::APFloat ( const APFloat RHS)
default
llvm::APFloat::APFloat ( APFloat &&  RHS)
default
llvm::APFloat::~APFloat ( )
default

Member Function Documentation

opStatus llvm::APFloat::add ( const APFloat RHS,
roundingMode  RM 
)
inline
APInt llvm::APFloat::bitcastToAPInt ( ) const
inline
bool llvm::APFloat::bitwiseIsEqual ( const APFloat RHS) const
inline
void llvm::APFloat::changeSign ( )
inline
void llvm::APFloat::clearSign ( )
inline
cmpResult llvm::APFloat::compare ( const APFloat RHS) const
inline
APFloat::opStatus llvm::APFloat::convert ( const fltSemantics ToSemantics,
roundingMode  RM,
bool losesInfo 
)
opStatus llvm::APFloat::convertFromAPInt ( const APInt Input,
bool  IsSigned,
roundingMode  RM 
)
inline
opStatus llvm::APFloat::convertFromSignExtendedInteger ( const integerPart Input,
unsigned int  InputSize,
bool  IsSigned,
roundingMode  RM 
)
inline
APFloat::opStatus llvm::APFloat::convertFromString ( StringRef  ,
roundingMode   
)

Definition at line 4128 of file APFloat.cpp.

References llvm::detail::IEEEFloat::convertFromString().

Referenced by APFloat().

opStatus llvm::APFloat::convertFromZeroExtendedInteger ( const integerPart Input,
unsigned int  InputSize,
bool  IsSigned,
roundingMode  RM 
)
inline
double llvm::APFloat::convertToDouble ( ) const
inline
float llvm::APFloat::convertToFloat ( ) const
inline
unsigned int llvm::APFloat::convertToHexString ( char *  DST,
unsigned int  HexDigits,
bool  UpperCase,
roundingMode  RM 
) const
inline

Definition at line 1026 of file APFloat.h.

References llvm::detail::IEEEFloat::convertToHexString().

Referenced by toString().

opStatus llvm::APFloat::convertToInteger ( integerPart Input,
unsigned int  Width,
bool  IsSigned,
roundingMode  RM,
bool IsExact 
) const
inline
opStatus llvm::APFloat::convertToInteger ( APSInt Result,
roundingMode  RM,
bool IsExact 
) const
inline

Definition at line 991 of file APFloat.h.

References llvm::detail::IEEEFloat::convertToInteger().

void llvm::APFloat::copySign ( const APFloat RHS)
inline

Definition at line 977 of file APFloat.h.

References llvm::detail::IEEEFloat::copySign().

Referenced by llvm::SelectionDAG::getNode().

static APFloat llvm::APFloat::copySign ( APFloat  Value,
const APFloat Sign 
)
inlinestatic

Definition at line 979 of file APFloat.h.

References llvm::detail::IEEEFloat::copySign(), and getSemantics().

opStatus llvm::APFloat::divide ( const APFloat RHS,
roundingMode  RM 
)
inline
void llvm::APFloat::dump ( ) const

Definition at line 4192 of file APFloat.cpp.

References llvm::dbgs(), and print().

opStatus llvm::APFloat::fusedMultiplyAdd ( const APFloat Multiplicand,
const APFloat Addend,
roundingMode  RM 
)
inline
APFloat llvm::APFloat::getAllOnesValue ( unsigned  BitWidth,
bool  isIEEE = false 
)
static

Returns a float which is bitcasted from an all one value int.

Parameters
BitWidth- Select float type
isIEEE- If 128 bit number, select between PPC and IEEE

Definition at line 4164 of file APFloat.cpp.

References assert(), llvm::APInt::getAllOnesValue(), llvm_unreachable, llvm::semIEEEdouble, llvm::semIEEEhalf, llvm::semIEEEquad, llvm::semIEEEsingle, llvm::semPPCDoubleDouble, and llvm::semX87DoubleExtended.

Referenced by llvm::Constant::getAllOnesValue().

fltCategory llvm::APFloat::getCategory ( ) const
inline

Definition at line 1042 of file APFloat.h.

References llvm::detail::IEEEFloat::getCategory().

Referenced by isInfinity(), isNaN(), and isZero().

bool llvm::APFloat::getExactInverse ( APFloat inv) const
inline

Definition at line 1063 of file APFloat.h.

References llvm::detail::IEEEFloat::getExactInverse().

Referenced by CvtFDivConstToReciprocal().

static APFloat llvm::APFloat::getInf ( const fltSemantics Sem,
bool  Negative = false 
)
inlinestatic

Factory for Positive and Negative Infinity.

Parameters
NegativeTrue iff the number should be negative.

Definition at line 850 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

Referenced by llvm::ConstantFP::getInfinity().

static APFloat llvm::APFloat::getLargest ( const fltSemantics Sem,
bool  Negative = false 
)
inlinestatic

Returns the largest finite number in the given semantics.

Parameters
Negative- True iff the number should be negative

Definition at line 890 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

static APFloat llvm::APFloat::getNaN ( const fltSemantics Sem,
bool  Negative = false,
unsigned  type = 0 
)
inlinestatic

Factory for NaN values.

Parameters
Negative- True iff the NaN generated should be negative.
type- The unspecified fill bits for creating the NaN, 0 by default. The value is truncated as necessary.

Definition at line 861 of file APFloat.h.

References getQNaN().

Referenced by llvm::ConstantFP::getNaN().

static APFloat llvm::APFloat::getQNaN ( const fltSemantics Sem,
bool  Negative = false,
const APInt payload = nullptr 
)
inlinestatic

Factory for QNaN values.

Definition at line 872 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

Referenced by getNaN(), and toString().

const APFloat& llvm::APFloat::getSecondFloat ( ) const
inline

Definition at line 1069 of file APFloat.h.

References assert(), getSemantics(), and llvm::APFloatBase::PPCDoubleDouble().

const fltSemantics& llvm::APFloat::getSemantics ( ) const
inline
static APFloat llvm::APFloat::getSmallest ( const fltSemantics Sem,
bool  Negative = false 
)
inlinestatic

Returns the smallest (by magnitude) finite number in the given semantics.

Might be denormalized, which implies a relative loss of precision.

Parameters
Negative- True iff the number should be negative

Definition at line 900 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

static APFloat llvm::APFloat::getSmallestNormalized ( const fltSemantics Sem,
bool  Negative = false 
)
inlinestatic

Returns the smallest (by magnitude) normalized finite number in the given semantics.

Parameters
Negative- True iff the number should be negative

Definition at line 910 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

Referenced by llvm::InstCombiner::visitFCmpInst().

static APFloat llvm::APFloat::getSNaN ( const fltSemantics Sem,
bool  Negative = false,
const APInt payload = nullptr 
)
inlinestatic

Factory for SNaN values.

Definition at line 880 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

static APFloat llvm::APFloat::getZero ( const fltSemantics Sem,
bool  Negative = false 
)
inlinestatic

Factory for Positive and Negative Zero.

Parameters
NegativeTrue iff the number should be negative.

Definition at line 841 of file APFloat.h.

References llvm::APFloatBase::uninitialized.

Referenced by llvm::ExecutionEngine::getConstantValue(), llvm::ConstantFP::getNegativeZero(), llvm::Constant::getNullValue(), and llvm::X86TargetLowering::X86TargetLowering().

bool llvm::APFloat::isDenormal ( ) const
inline

Definition at line 1036 of file APFloat.h.

References llvm::detail::IEEEFloat::isDenormal().

Referenced by isNormal(), and llvm::InstCombiner::visitCallInst().

bool llvm::APFloat::isFinite ( ) const
inline

Definition at line 1040 of file APFloat.h.

References isInfinity(), and isNaN().

Referenced by isFiniteNonZero().

bool llvm::APFloat::isFiniteNonZero ( ) const
inline

Definition at line 1045 of file APFloat.h.

References isFinite(), and isZero().

Referenced by CvtFDivConstToReciprocal(), isFiniteNonZeroFp(), and isNormal().

bool llvm::APFloat::isInfinity ( ) const
inline
bool llvm::APFloat::isInteger ( ) const
inline

Definition at line 1050 of file APFloat.h.

References llvm::detail::IEEEFloat::isInteger().

bool llvm::APFloat::isLargest ( ) const
inline

Definition at line 1049 of file APFloat.h.

References llvm::detail::IEEEFloat::isLargest().

bool llvm::APFloat::isNaN ( ) const
inline
bool llvm::APFloat::isNegative ( ) const
inline
bool llvm::APFloat::isNegZero ( ) const
inline

Definition at line 1047 of file APFloat.h.

References isNegative(), and isZero().

Referenced by llvm::SystemZTargetLowering::isFPImmLegal().

bool llvm::APFloat::isNonZero ( ) const
inline

Definition at line 1044 of file APFloat.h.

References isZero().

bool llvm::APFloat::isNormal ( ) const
inline

Definition at line 1039 of file APFloat.h.

References isDenormal(), and isFiniteNonZero().

Referenced by isNormalFp(), and llvm::InstCombiner::visitCallInst().

bool llvm::APFloat::isPosZero ( ) const
inline
bool llvm::APFloat::isSignaling ( ) const
inline

Definition at line 1037 of file APFloat.h.

References llvm::detail::IEEEFloat::isSignaling().

Referenced by llvm::InstCombiner::visitCallInst().

bool llvm::APFloat::isSmallest ( ) const
inline

Definition at line 1048 of file APFloat.h.

References llvm::detail::IEEEFloat::isSmallest().

bool llvm::APFloat::isZero ( ) const
inline
opStatus llvm::APFloat::mod ( const APFloat RHS)
inline
opStatus llvm::APFloat::multiply ( const APFloat RHS,
roundingMode  RM 
)
inline
bool llvm::APFloat::needsCleanup ( ) const
inline

Definition at line 830 of file APFloat.h.

References getSemantics(), and llvm_unreachable.

opStatus llvm::APFloat::next ( bool  nextDown)
inline

Definition at line 957 of file APFloat.h.

References llvm::detail::IEEEFloat::next().

APFloat llvm::APFloat::operator* ( const APFloat RHS) const
inline

Definition at line 967 of file APFloat.h.

References getSemantics().

APFloat llvm::APFloat::operator+ ( const APFloat RHS) const
inline

Definition at line 959 of file APFloat.h.

References getSemantics().

APFloat llvm::APFloat::operator- ( const APFloat RHS) const
inline

Definition at line 963 of file APFloat.h.

References getSemantics().

APFloat llvm::APFloat::operator/ ( const APFloat RHS) const
inline

Definition at line 971 of file APFloat.h.

References getSemantics().

APFloat& llvm::APFloat::operator= ( const APFloat RHS)
default
APFloat& llvm::APFloat::operator= ( APFloat &&  RHS)
default
bool llvm::APFloat::operator== ( const APFloat ) const
delete
void llvm::APFloat::print ( raw_ostream OS) const

Definition at line 4186 of file APFloat.cpp.

References toString().

Referenced by dump().

void llvm::APFloat::Profile ( FoldingSetNodeID NID) const
inline

Definition at line 923 of file APFloat.h.

References llvm::detail::IEEEFloat::Profile().

opStatus llvm::APFloat::remainder ( const APFloat RHS)
inline

Definition at line 945 of file APFloat.h.

References llvm::detail::IEEEFloat::remainder().

opStatus llvm::APFloat::roundToIntegral ( roundingMode  RM)
inline

Definition at line 954 of file APFloat.h.

References llvm::detail::IEEEFloat::roundToIntegral().

Referenced by llvm::SelectionDAG::getNode().

opStatus llvm::APFloat::subtract ( const APFloat RHS,
roundingMode  RM 
)
inline
void llvm::APFloat::toString ( SmallVectorImpl< char > &  Str,
unsigned  FormatPrecision = 0,
unsigned  FormatMaxPadding = 3 
) const
inline

Definition at line 1055 of file APFloat.h.

References llvm::detail::IEEEFloat::toString().

Referenced by emitGlobalConstantFP(), print(), and toStringAPFloat().

Friends And Related Function Documentation

APFloat frexp ( const APFloat X,
int &  Exp,
roundingMode  RM 
)
friend
hash_code hash_value ( const APFloat Arg)
friend

See friend declarations above.

These additional declarations are required in order to compile LLVM with IBM xlC compiler.

Definition at line 4132 of file APFloat.cpp.

int ilogb ( const APFloat Arg)
friend

Definition at line 1075 of file APFloat.h.

APFloat scalbn ( APFloat  X,
int  Exp,
roundingMode  RM 
)
friend

Member Data Documentation

Definition at line 1079 of file APFloat.h.

Definition at line 1078 of file APFloat.h.


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