LLVM  mainline
llvm::ConstantInt Class Reference

This is the shared class of boolean and integer constants. More...

#include <Constants.h>

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

List of all members.

## Public Member Functions

const APIntgetValue () const
Return the constant as an APInt value reference.
unsigned getBitWidth () const
getBitWidth - Return the bitwidth of this constant.
uint64_t getZExtValue () const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate for the type of this constant.
int64_t getSExtValue () const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constant.
bool equalsInt (uint64_t V) const
A helper method that can be used to determine if the constant contained within is equal to a constant.
IntegerTypegetType () const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount of casting needed in parts of the compiler.
bool isNegative () const
bool isZero () const
This is just a convenience method to make client code smaller for a common code.
bool isOne () const
This is just a convenience method to make client code smaller for a common case.
bool isMinusOne () const
This function will return true iff every bit in this constant is set to true.
bool isMaxValue (bool isSigned) const
This function will return true iff this constant represents the largest value that may be represented by the constant's type.
bool isMinValue (bool isSigned) const
This function will return true iff this constant represents the smallest value that may be represented by this constant's type.
bool uge (uint64_t Num) const
This function will return true iff this constant represents a value with active bits bigger than 64 bits or a value greater than the given uint64_t value.
uint64_t getLimitedValue (uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the limit value.

## Static Public Member Functions

static ConstantIntgetTrue (LLVMContext &Context)
static ConstantIntgetFalse (LLVMContext &Context)
static ConstantgetTrue (Type *Ty)
static ConstantgetFalse (Type *Ty)
static Constantget (Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static ConstantIntget (IntegerType *Ty, uint64_t V, bool isSigned=false)
Return a ConstantInt with the specified integer value for the specified type.
static ConstantIntgetSigned (IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
static ConstantgetSigned (Type *Ty, int64_t V)
static ConstantIntget (LLVMContext &Context, const APInt &V)
Return a ConstantInt with the specified value and an implied Type.
static ConstantIntget (IntegerType *Ty, StringRef Str, uint8_t radix)
static Constantget (Type *Ty, const APInt &V)
If Ty is a vector type, return a Constant with a splat of the given value.
static bool isValueValidForType (Type *Ty, uint64_t V)
This static method returns true if the type Ty is big enough to represent the value V.
static bool isValueValidForType (Type *Ty, int64_t V)
static bool classof (const Value *V)
Methods to support type inquiry through isa, cast, and dyn_cast.

## Protected Member Functions

void * operator new (size_t s)
Allocate a User with an operand pointer co-allocated.

class Constant

## Detailed Description

This is the shared class of boolean and integer constants.

This class represents both boolean and integral constants. Class for constant integers.

Definition at line 47 of file Constants.h.

## Member Function Documentation

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

Methods to support type inquiry through isa, cast, and dyn_cast.

Reimplemented from llvm::Constant.

Definition at line 224 of file Constants.h.

References llvm::Value::getValueID().

 bool llvm::ConstantInt::equalsInt ( uint64_t V ) const [inline]

A helper method that can be used to determine if the constant contained within is equal to a constant.

This only works for very small values, because this is all that can be represented with all types. Determine if this constant's value is same as an unsigned char.

Definition at line 133 of file Constants.h.

 ConstantInt * ConstantInt::get ( IntegerType * Ty, uint64_t V, bool isSigned = false )  [static]

Return a ConstantInt with the specified integer value for the specified type.

If the type is wider than 64 bits, the value will be zero-extended to fit the type, unless isSigned is true, in which case the value will be interpreted as a 64-bit signed integer and sign-extended to fit the type. Get a ConstantInt for a specific value.

Definition at line 591 of file Constants.cpp.

References llvm::IntegerType::getBitWidth(), and llvm::Type::getContext().

 ConstantInt * ConstantInt::get ( LLVMContext & Context, const APInt & V )  [static]

Return a ConstantInt with the specified value and an implied Type.

The type is the integer type that corresponds to the bit width of the value.

Definition at line 568 of file Constants.cpp.

 ConstantInt * ConstantInt::get ( IntegerType * Ty, StringRef Str, uint8_t radix )  [static]

Definition at line 616 of file Constants.cpp.

References llvm::IntegerType::getBitWidth(), and llvm::Type::getContext().

 Constant * ConstantInt::get ( Type * Ty, const APInt & V )  [static]

If Ty is a vector type, return a Constant with a splat of the given value.

Otherwise return a ConstantInt for the given value.

Definition at line 604 of file Constants.cpp.

 unsigned llvm::ConstantInt::getBitWidth ( ) const [inline]

getBitWidth - Return the bitwidth of this constant.

Definition at line 111 of file Constants.h.

References llvm::APInt::getBitWidth().

 ConstantInt * ConstantInt::getFalse ( LLVMContext & Context )  [static]
 Constant * ConstantInt::getFalse ( Type * Ty )  [static]

Definition at line 555 of file Constants.cpp.

 uint64_t llvm::ConstantInt::getLimitedValue ( uint64_t Limit = ~0ULL ) const [inline]

getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the limit value.

This causes the value to saturate to the limit.

Returns:
the min of the value of the constant and the specified value Get the constant's value with a saturation limit

Definition at line 219 of file Constants.h.

References llvm::APInt::getLimitedValue().

 int64_t llvm::ConstantInt::getSExtValue ( ) const [inline]

Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constant.

Note that this method can assert if the value does not fit in 64 bits. Return the sign extended value.

Definition at line 125 of file Constants.h.

References llvm::APInt::getSExtValue().

 ConstantInt * ConstantInt::getSigned ( IntegerType * Ty, int64_t V )  [static]

Return a ConstantInt with the specified value for the specified type.

The value V will be canonicalized to a an unsigned APInt. Accessing it with either getSExtValue() or getZExtValue() will yield a correctly sized and signed value for the type Ty. Get a ConstantInt for a specific signed value.

Definition at line 596 of file Constants.cpp.

 Constant * ConstantInt::getSigned ( Type * Ty, int64_t V )  [static]

Definition at line 600 of file Constants.cpp.

 ConstantInt * ConstantInt::getTrue ( LLVMContext & Context )  [static]
 Constant * ConstantInt::getTrue ( Type * Ty )  [static]

Definition at line 543 of file Constants.cpp.

 IntegerType* llvm::ConstantInt::getType ( ) const [inline]

getType - Specialize the getType() method to always return an IntegerType, which reduces the amount of casting needed in parts of the compiler.

Reimplemented from llvm::Value.

Definition at line 140 of file Constants.h.

 uint64_t llvm::ConstantInt::getZExtValue ( ) const [inline]

Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate for the type of this constant.

Note that this method can assert if the value does not fit in 64 bits. Return the zero extended value.

Definition at line 117 of file Constants.h.

References llvm::APInt::getZExtValue().

 bool llvm::ConstantInt::isMaxValue ( bool isSigned ) const [inline]

This function will return true iff this constant represents the largest value that may be represented by the constant's type.

Returns:
true iff this is the largest value that may be represented by this type. Determine if the value is maximal.

Definition at line 186 of file Constants.h.

References llvm::APInt::isMaxSignedValue(), and llvm::APInt::isMaxValue().

Referenced by isSignBitCheck(), and llvm::InstCombiner::visitAnd().

 bool llvm::ConstantInt::isMinusOne ( ) const [inline]

This function will return true iff every bit in this constant is set to true.

Returns:
true iff this constant's bits are all set to true. Determine if the value is all ones.

Definition at line 177 of file Constants.h.

References llvm::APInt::isAllOnesValue().

 bool llvm::ConstantInt::isMinValue ( bool isSigned ) const [inline]

This function will return true iff this constant represents the smallest value that may be represented by this constant's type.

Returns:
true if this is the smallest value that may be represented by this type. Determine if the value is minimal.

Definition at line 198 of file Constants.h.

References llvm::APInt::isMinSignedValue(), and llvm::APInt::isMinValue().

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

Definition at line 156 of file Constants.h.

References llvm::APInt::isNegative().

 bool llvm::ConstantInt::isOne ( ) const [inline]

This is just a convenience method to make client code smaller for a common case.

It also correctly performs the comparison without the potential for an assertion from getZExtValue(). Determine if the value is one.

Definition at line 169 of file Constants.h.

 bool ConstantInt::isValueValidForType ( Type * Ty, uint64_t V )  [static]

This static method returns true if the type Ty is big enough to represent the value V.

This can be used to avoid having the get method assert when V is larger than Ty can represent. Note that there are two versions of this method, one for unsigned and one for signed integers. Although ConstantInt canonicalizes everything to an unsigned integer, the signed version avoids callers having to convert a signed quantity to the appropriate unsigned type before calling the method.

Returns:
true if V is a valid value for type Ty Determine if the value is in range for the given type.

Definition at line 1240 of file Constants.cpp.

References llvm::Type::getIntegerBitWidth(), llvm::Type::isIntegerTy(), and llvm::Max.

 bool ConstantInt::isValueValidForType ( Type * Ty, int64_t V )  [static]
 bool llvm::ConstantInt::isZero ( ) const [inline]

This is just a convenience method to make client code smaller for a common code.

It also correctly performs the comparison without the potential for an assertion from getZExtValue().

Definition at line 161 of file Constants.h.

 void* llvm::ConstantInt::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 60 of file Constants.h.

References operator new().

 bool llvm::ConstantInt::uge ( uint64_t Num ) const [inline]

This function will return true iff this constant represents a value with active bits bigger than 64 bits or a value greater than the given uint64_t value.

Returns:
true iff this constant is greater or equal to the given number. Determine if the value is greater or equal to the given number.

Definition at line 210 of file Constants.h.

References llvm::APInt::getActiveBits(), and llvm::APInt::getZExtValue().

## Friends And Related Function Documentation

 friend class Constant [friend]

Definition at line 54 of file Constants.h.

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