class ConstantInt

Declaration

class ConstantInt : public ConstantData { /* full declaration omitted */ };

Description

This is the shared class of boolean and integer constants. This class represents both boolean and integral constants. Class for constant integers.

Declared at: llvm/include/llvm/IR/Constants.h:79

Inherits from: ConstantData

Member Variables

private llvm::APInt Val

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

  • private ConstantInt(llvm::IntegerType * Ty, const llvm::APInt & V)
  • public ConstantInt(const llvm::ConstantInt &)
  • public static bool classof(const llvm::Value * V)
  • private void destroyConstantImpl()
  • public bool equalsInt(uint64_t V) const
  • public static llvm::Constant * get(llvm::Type * Ty, uint64_t V, bool IsSigned = false)
  • public static llvm::ConstantInt * get(llvm::IntegerType * Ty, uint64_t V, bool IsSigned = false)
  • public static llvm::ConstantInt * get(llvm::LLVMContext & Context, const llvm::APInt & V)
  • public static llvm::ConstantInt * get(llvm::IntegerType * Ty, llvm::StringRef Str, uint8_t Radix)
  • public static llvm::Constant * get(llvm::Type * Ty, const llvm::APInt & V)
  • public inline llvm::Align getAlignValue() const
  • public unsigned int getBitWidth() const
  • public static llvm::ConstantInt * getBool(llvm::LLVMContext & Context, bool V)
  • public static llvm::Constant * getBool(llvm::Type * Ty, bool V)
  • public static llvm::Constant * getFalse(llvm::Type * Ty)
  • public static llvm::ConstantInt * getFalse(llvm::LLVMContext & Context)
  • public uint64_t getLimitedValue(uint64_t Limit = ~0ULL) const
  • public inline llvm::MaybeAlign getMaybeAlignValue() const
  • public inline int64_t getSExtValue() const
  • public static llvm::Constant * getSigned(llvm::Type * Ty, int64_t V)
  • public static llvm::ConstantInt * getSigned(llvm::IntegerType * Ty, int64_t V)
  • public static llvm::Constant * getTrue(llvm::Type * Ty)
  • public static llvm::ConstantInt * getTrue(llvm::LLVMContext & Context)
  • public inline llvm::IntegerType * getType() const
  • public inline const llvm::APInt & getValue() const
  • public inline uint64_t getZExtValue() const
  • public bool isMaxValue(bool IsSigned) const
  • public bool isMinValue(bool IsSigned) const
  • public bool isMinusOne() const
  • public bool isNegative() const
  • public bool isOne() const
  • public static bool isValueValidForType(llvm::Type * Ty, uint64_t V)
  • public static bool isValueValidForType(llvm::Type * Ty, int64_t V)
  • public bool isZero() const
  • public bool uge(uint64_t Num) const

Inherited from ConstantData:

Inherited from Constant:

Inherited from User:

Inherited from Value:

Methods

ConstantInt(llvm::IntegerType* Ty,
            const llvm::APInt& V)

Declared at: llvm/include/llvm/IR/Constants.h:84

Parameters

llvm::IntegerType* Ty
const llvm::APInt& V

ConstantInt(const llvm::ConstantInt&)

Declared at: llvm/include/llvm/IR/Constants.h:89

Parameters

const llvm::ConstantInt&

static bool classof(const llvm::Value* V)

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:249

Parameters

const llvm::Value* V

void destroyConstantImpl()

Declared at: llvm/include/llvm/IR/Constants.h:86

bool equalsInt(uint64_t V) const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:168

Parameters

uint64_t V

static llvm::Constant* get(llvm::Type* Ty,
                           uint64_t V,
                           bool IsSigned = false)

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:100

Parameters

llvm::Type* Ty
uint64_t V
bool IsSigned = false

static llvm::ConstantInt* get(
    llvm::IntegerType* Ty,
    uint64_t V,
    bool IsSigned = false)

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:108

Parameters

llvm::IntegerType* Ty
uint64_t V
bool IsSigned = false

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

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:120

Parameters

llvm::LLVMContext& Context
const llvm::APInt& V

static llvm::ConstantInt* get(
    llvm::IntegerType* Ty,
    llvm::StringRef Str,
    uint8_t Radix)

Description

Return a ConstantInt constructed from the string strStart with the given radix.

Declared at: llvm/include/llvm/IR/Constants.h:124

Parameters

llvm::IntegerType* Ty
llvm::StringRef Str
uint8_t Radix

static llvm::Constant* get(llvm::Type* Ty,
                           const llvm::APInt& V)

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:128

Parameters

llvm::Type* Ty
const llvm::APInt& V

inline llvm::Align getAlignValue() const

Description

Return the constant as an llvm::Align, interpreting `0` as `Align(1)`. Note that this method can assert if the value does not fit in 64 bits or is not a power of two.

Declared at: llvm/include/llvm/IR/Constants.h:160

unsigned int getBitWidth() const

Description

getBitWidth - Return the bitwidth of this constant.

Declared at: llvm/include/llvm/IR/Constants.h:136

static llvm::ConstantInt* getBool(
    llvm::LLVMContext& Context,
    bool V)

Declared at: llvm/include/llvm/IR/Constants.h:93

Parameters

llvm::LLVMContext& Context
bool V

static llvm::Constant* getBool(llvm::Type* Ty,
                               bool V)

Declared at: llvm/include/llvm/IR/Constants.h:96

Parameters

llvm::Type* Ty
bool V

static llvm::Constant* getFalse(llvm::Type* Ty)

Declared at: llvm/include/llvm/IR/Constants.h:95

Parameters

llvm::Type* Ty

static llvm::ConstantInt* getFalse(
    llvm::LLVMContext& Context)

Declared at: llvm/include/llvm/IR/Constants.h:92

Parameters

llvm::LLVMContext& Context

uint64_t getLimitedValue(
    uint64_t Limit = ~0ULL) const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:244

Parameters

uint64_t Limit = ~0ULL

Returns

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

inline llvm::MaybeAlign getMaybeAlignValue() const

Description

Return the constant as an llvm::MaybeAlign. Note that this method can assert if the value does not fit in 64 bits or is not a power of two.

Declared at: llvm/include/llvm/IR/Constants.h:153

inline int64_t getSExtValue() const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:148

static llvm::Constant* getSigned(llvm::Type* Ty,
                                 int64_t V)

Declared at: llvm/include/llvm/IR/Constants.h:116

Parameters

llvm::Type* Ty
int64_t V

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

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:115

Parameters

llvm::IntegerType* Ty
int64_t V

static llvm::Constant* getTrue(llvm::Type* Ty)

Declared at: llvm/include/llvm/IR/Constants.h:94

Parameters

llvm::Type* Ty

static llvm::ConstantInt* getTrue(
    llvm::LLVMContext& Context)

Declared at: llvm/include/llvm/IR/Constants.h:91

Parameters

llvm::LLVMContext& Context

inline llvm::IntegerType* getType() const

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:173

inline const llvm::APInt& getValue() const

Description

Return the constant as an APInt value reference. This allows clients to obtain a full-precision copy of the value. Return the constant's value.

Declared at: llvm/include/llvm/IR/Constants.h:133

inline uint64_t getZExtValue() const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:142

bool isMaxValue(bool IsSigned) const

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:213

Parameters

bool IsSigned

Returns

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

bool isMinValue(bool IsSigned) const

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:225

Parameters

bool IsSigned

Returns

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

bool isMinusOne() const

Description

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

Declared at: llvm/include/llvm/IR/Constants.h:206

Returns

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

bool isNegative() const

Declared at: llvm/include/llvm/IR/Constants.h:189

bool isOne() const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:200

static bool isValueValidForType(llvm::Type* Ty,
                                uint64_t V)

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:186

Parameters

llvm::Type* Ty
uint64_t V

Returns

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

static bool isValueValidForType(llvm::Type* Ty,
                                int64_t V)

Declared at: llvm/include/llvm/IR/Constants.h:187

Parameters

llvm::Type* Ty
int64_t V

bool isZero() const

Description

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().

Declared at: llvm/include/llvm/IR/Constants.h:194

bool uge(uint64_t Num) const

Description

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.

Declared at: llvm/include/llvm/IR/Constants.h:237

Parameters

uint64_t Num

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.