LLVM  mainline
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
llvm::ConstantFP Class Reference

ConstantFP - Floating Point Values [float, double]. More...

#include <Constants.h>

Inheritance diagram for llvm::ConstantFP:
Inheritance graph
[legend]
Collaboration diagram for llvm::ConstantFP:
Collaboration graph
[legend]

List of all members.

Public Member Functions

const APFloatgetValueAPF () const
bool isZero () const
 isZero - Return true if the value is positive or negative zero.
bool isNegative () const
 isNegative - Return true if the sign bit is set.
bool isInfinity () const
 isInfinity - Return true if the value is infinity
bool isNaN () const
 isNaN - Return true if the value is a NaN.
bool isExactlyValue (const APFloat &V) const
 isExactlyValue - We don't rely on operator== working on double values, as it returns true for things that are clearly not equal, like -0.0 and 0.0.
bool isExactlyValue (double V) const

Static Public Member Functions

static ConstantgetZeroValueForNegation (Type *Ty)
 Floating point negation must be implemented with f(x) = -0.0 - x.
static Constantget (Type *Ty, double V)
 get() - This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in the specified type.
static Constantget (Type *Ty, StringRef Str)
static ConstantFPget (LLVMContext &Context, const APFloat &V)
static ConstantgetNaN (Type *Ty, bool Negative=false, unsigned type=0)
static ConstantgetNegativeZero (Type *Ty)
static ConstantgetInfinity (Type *Ty, bool Negative=false)
static bool isValueValidForType (Type *Ty, const APFloat &V)
 isValueValidForType - return true if Ty is big enough to represent V.
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Protected Member Functions

 ConstantFP (Type *Ty, const APFloat &V)
void * operator new (size_t s)
 Allocate a User with an operand pointer co-allocated.

Friends

class LLVMContextImpl
class Constant

Detailed Description

ConstantFP - Floating Point Values [float, double].

Definition at line 232 of file Constants.h.


Constructor & Destructor Documentation

ConstantFP::ConstantFP ( Type Ty,
const APFloat V 
) [protected]

Definition at line 752 of file Constants.cpp.

References llvm::APFloat::getSemantics(), and TypeToFloatSemantics().


Member Function Documentation

static bool llvm::ConstantFP::classof ( const Value V) [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:

Reimplemented from llvm::Constant.

Definition at line 297 of file Constants.h.

References llvm::Value::getValueID().

Constant * ConstantFP::get ( Type Ty,
double  V 
) [static]

get() - This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in the specified type.

get() - This returns a constant fp for the specified value in the specified type.

This should only be used for simple constant values like 2.0/1.0 etc, that are known-valid both as host double and as the target format.

This should only be used for simple constant values like 2.0/1.0 etc, that are known-valid both as double and as the target format.

Definition at line 652 of file Constants.cpp.

References llvm::C, llvm::APFloat::convert(), llvm::Type::getContext(), llvm::Type::getScalarType(), llvm::ConstantVector::getSplat(), llvm::APFloat::rmNearestTiesToEven, and TypeToFloatSemantics().

Referenced by llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCastInstruction(), ConstantFoldScalarCall(), llvm::MDBuilder::createFPMath(), CvtFDivConstToReciprocal(), FitsInFPType(), FoldBitCast(), llvm::Constant::getAllOnesValue(), GetConstantFoldFPValue(), llvm::SelectionDAG::getConstantFP(), llvm::ConstantDataSequential::getElementAsConstant(), llvm::Constant::getNullValue(), llvm::RecurrenceDescriptor::getRecurrenceIdentity(), LLVMConstReal(), LLVMConstRealOfString(), LLVMConstRealOfStringAndSize(), LowerNegateToMultiply(), SimplifyFDivInst(), valueHasFloatPrecision(), llvm::InstCombiner::visitCallInst(), and llvm::InstCombiner::visitFCmpInst().

Constant * ConstantFP::get ( Type Ty,
StringRef  Str 
) [static]
ConstantFP * ConstantFP::get ( LLVMContext Context,
const APFloat V 
) [static]
Constant * ConstantFP::getInfinity ( Type Ty,
bool  Negative = false 
) [static]
Constant * ConstantFP::getNaN ( Type Ty,
bool  Negative = false,
unsigned  type = 0 
) [static]

Floating point negation must be implemented with f(x) = -0.0 - x.

This method returns the negative zero constant for floating point or vector floating point types; for all other types, it returns the null value.

Definition at line 705 of file Constants.cpp.

References getNegativeZero(), llvm::Constant::getNullValue(), and llvm::Type::isFPOrFPVectorTy().

Referenced by llvm::BinaryOperator::CreateFNeg(), llvm::BinaryOperator::CreateNeg(), llvm::BinaryOperator::CreateNSWNeg(), llvm::BinaryOperator::CreateNUWNeg(), llvm::ConstantExpr::getFNeg(), and llvm::ConstantExpr::getNeg().

isExactlyValue - We don't rely on operator== working on double values, as it returns true for things that are clearly not equal, like -0.0 and 0.0.

As such, this method can be used to do an exact bit-for-bit comparison of two floating point values. The version with a double operand is retained because it's so convenient to write isExactlyValue(2.0), but please use it only for simple constants.

Definition at line 758 of file Constants.cpp.

References llvm::APFloat::bitwiseIsEqual().

Referenced by isExactlyValue().

bool llvm::ConstantFP::isExactlyValue ( double  V) const [inline]
bool llvm::ConstantFP::isInfinity ( ) const [inline]

isInfinity - Return true if the value is infinity

Definition at line 277 of file Constants.h.

References llvm::APFloat::isInfinity().

bool llvm::ConstantFP::isNaN ( ) const [inline]

isNaN - Return true if the value is a NaN.

Definition at line 280 of file Constants.h.

References llvm::APFloat::isNaN().

bool llvm::ConstantFP::isNegative ( ) const [inline]

isNegative - Return true if the sign bit is set.

Definition at line 274 of file Constants.h.

References llvm::APFloat::isNegative().

bool ConstantFP::isValueValidForType ( Type Ty,
const APFloat V 
) [static]
bool llvm::ConstantFP::isZero ( ) const [inline]

isZero - Return true if the value is positive or negative zero.

Definition at line 271 of file Constants.h.

References llvm::APFloat::isZero().

void* llvm::ConstantFP::operator new ( size_t  Size) [inline, protected]

Allocate a User with an operand pointer co-allocated.

This is used for subclasses which need to allocate a variable number of operands, ie, 'hung off uses'.

Reimplemented from llvm::User.

Definition at line 246 of file Constants.h.

References operator new().


Friends And Related Function Documentation

friend class Constant [friend]

Definition at line 239 of file Constants.h.

friend class LLVMContextImpl [friend]

Definition at line 237 of file Constants.h.


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