LLVM 22.0.0git
llvm::sandboxir::ConstantInt Class Reference

#include "llvm/SandboxIR/Constant.h"

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

Public Member Functions

const APIntgetValue () const
 Return the constant as an APInt value reference.
unsigned getBitWidth () const
 getBitWidth - Return the scalar 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.
MaybeAlign getMaybeAlignValue () const
 Return the constant as an llvm::MaybeAlign.
Align getAlignValue () const
 Return the constant as an llvm::Align, interpreting 0 as Align(1).
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.
LLVM_ABI IntegerTypegetIntegerType () const
 Variant of 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.
unsigned getUseOperandNo (const Use &Use) const override
 \Returns the operand index of Use.
void verify () const override
 Should crash if there is something wrong with the instruction.
void dumpOS (raw_ostream &OS) const override
Public Member Functions inherited from llvm::sandboxir::Constant
sandboxir::ContextgetParent () const
Public Member Functions inherited from llvm::sandboxir::User
virtual op_iterator op_begin ()
virtual op_iterator op_end ()
virtual const_op_iterator op_begin () const
virtual const_op_iterator op_end () const
op_range operands ()
const_op_range operands () const
ValuegetOperand (unsigned OpIdx) const
Use getOperandUse (unsigned OpIdx) const
 \Returns the operand edge for OpIdx.
virtual unsigned getNumOperands () const
virtual void setOperand (unsigned OperandIdx, Value *Operand)
bool replaceUsesOfWith (Value *FromV, Value *ToV)
 Replaces any operands that match FromV with ToV.
void verify () const override
 Should crash if there is something wrong with the instruction.
void dumpCommonHeader (raw_ostream &OS) const final
void dumpOS (raw_ostream &OS) const override
Public Member Functions inherited from llvm::sandboxir::Value
virtual ~Value ()=default
ClassID getSubclassID () const
LLVM_ABI use_iterator use_begin ()
const_use_iterator use_begin () const
use_iterator use_end ()
const_use_iterator use_end () const
iterator_range< use_iteratoruses ()
iterator_range< const_use_iteratoruses () const
LLVM_ABI user_iterator user_begin ()
user_iterator user_end ()
const_user_iterator user_begin () const
const_user_iterator user_end () const
iterator_range< user_iteratorusers ()
iterator_range< const_user_iteratorusers () const
LLVM_ABI unsigned getNumUses () const
 \Returns the number of user edges (not necessarily to unique users).
bool hasNUsesOrMore (unsigned Num) const
 Return true if this value has N uses or more.
bool hasNUses (unsigned Num) const
 Return true if this Value has exactly N uses.
LLVM_ABI TypegetType () const
ContextgetContext () const
LLVM_ABI void replaceUsesWithIf (Value *OtherV, llvm::function_ref< bool(const Use &)> ShouldReplace)
LLVM_ABI void replaceAllUsesWith (Value *Other)
StringRef getName () const
 \Returns the LLVM IR name of the bottom-most LLVM value.
std::string getUid () const
 Returns the unique id in the form 'SB<number>.' like 'SB1.'.
void dumpCommonFooter (raw_ostream &OS) const
void dumpCommonPrefix (raw_ostream &OS) const
void dumpCommonSuffix (raw_ostream &OS) const
void printAsOperandCommon (raw_ostream &OS) const
LLVM_DUMP_METHOD void dump () const

Static Public Member Functions

static LLVM_ABI ConstantIntgetTrue (Context &Ctx)
static LLVM_ABI ConstantIntgetFalse (Context &Ctx)
static LLVM_ABI ConstantIntgetBool (Context &Ctx, bool V)
static LLVM_ABI ConstantgetTrue (Type *Ty)
static LLVM_ABI ConstantgetFalse (Type *Ty)
static LLVM_ABI ConstantgetBool (Type *Ty, bool V)
static LLVM_ABI ConstantIntget (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 LLVM_ABI ConstantIntget (IntegerType *Ty, uint64_t V, bool IsSigned=false)
 Return a ConstantInt with the specified integer value for the specified type.
static LLVM_ABI ConstantIntgetSigned (IntegerType *Ty, int64_t V)
 Return a ConstantInt with the specified value for the specified type.
static LLVM_ABI ConstantgetSigned (Type *Ty, int64_t V)
static LLVM_ABI ConstantIntget (Context &Ctx, const APInt &V)
 Return a ConstantInt with the specified value and an implied Type.
static LLVM_ABI ConstantIntget (IntegerType *Ty, StringRef Str, uint8_t Radix)
 Return a ConstantInt constructed from the string strStart with the given radix.
static LLVM_ABI Constantget (Type *Ty, const APInt &V)
 If Ty is a vector type, return a Constant with a splat of the given value.
static LLVM_ABI 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 LLVM_ABI bool isValueValidForType (Type *Ty, int64_t V)
static bool classof (const sandboxir::Value *From)
 For isa/dyn_cast.
Static Public Member Functions inherited from llvm::sandboxir::Constant
static bool classof (const sandboxir::Value *From)
 For isa/dyn_cast.
Static Public Member Functions inherited from llvm::sandboxir::User
static bool classof (const Value *From)
 For isa/dyn_cast.

Friends

class Context

Additional Inherited Members

Public Types inherited from llvm::sandboxir::User
using op_iterator = OperandUseIterator
using const_op_iterator = OperandUseIterator
using op_range = iterator_range<op_iterator>
using const_op_range = iterator_range<const_op_iterator>
Public Types inherited from llvm::sandboxir::Value
enum class  ClassID : unsigned
using use_iterator = UserUseIterator
using const_use_iterator = UserUseIterator
using user_iterator = mapped_iterator<sandboxir::UserUseIterator, UseToUser>
using const_user_iterator = user_iterator
Protected Member Functions inherited from llvm::sandboxir::Constant
 Constant (llvm::Constant *C, sandboxir::Context &SBCtx)
 Constant (ClassID ID, llvm::Constant *C, sandboxir::Context &SBCtx)
Protected Member Functions inherited from llvm::sandboxir::User
 User (ClassID ID, llvm::Value *V, Context &Ctx)
Use getOperandUseDefault (unsigned OpIdx, bool Verify) const
 \Returns the Use edge that corresponds to OpIdx.
unsigned getUseOperandNoDefault (const Use &Use) const
 The default implementation works only for single-LLVMIR-instruction Users and only if they match exactly the LLVM instruction.
void swapOperandsInternal (unsigned OpIdxA, unsigned OpIdxB)
void verifyUserOfLLVMUse (const llvm::Use &Use) const
Protected Member Functions inherited from llvm::sandboxir::Value
void clearValue ()
LLVM_ABI Value (ClassID SubclassID, llvm::Value *Val, Context &Ctx)
 Value (const Value &)=delete
 Disable copies.
Valueoperator= (const Value &)=delete
Static Protected Member Functions inherited from llvm::sandboxir::Value
static const chargetSubclassIDStr (ClassID ID)
Protected Attributes inherited from llvm::sandboxir::Value
ClassID SubclassID
 For isa/dyn_cast.
unsigned UID
 A unique ID used for forming the name (used for debugging).
llvm::ValueVal = nullptr
 The LLVM Value that corresponds to this SandboxIR Value.
ContextCtx
 All values point to the context.

Detailed Description

Definition at line 69 of file Constant.h.

Member Function Documentation

◆ classof()

bool llvm::sandboxir::ConstantInt::classof ( const sandboxir::Value * From)
inlinestatic

For isa/dyn_cast.

Definition at line 241 of file Constant.h.

References llvm::sandboxir::Value::getSubclassID().

◆ dumpOS()

void llvm::sandboxir::ConstantInt::dumpOS ( raw_ostream & OS) const
inlineoverridevirtual

◆ equalsInt()

bool llvm::sandboxir::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 165 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ get() [1/5]

ConstantInt * llvm::sandboxir::ConstantInt::get ( Context & Ctx,
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 65 of file Constant.cpp.

References llvm::cast(), Context, and llvm::sandboxir::Value::Ctx.

◆ get() [2/5]

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

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

Definition at line 69 of file Constant.cpp.

References llvm::cast().

◆ get() [3/5]

ConstantInt * llvm::sandboxir::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 52 of file Constant.cpp.

References llvm::cast().

◆ get() [4/5]

Constant * llvm::sandboxir::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 74 of file Constant.cpp.

References llvm::sandboxir::Constant::Constant().

◆ get() [5/5]

ConstantInt * llvm::sandboxir::ConstantInt::get ( Type * Ty,
uint64_t V,
bool IsSigned = false )
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 48 of file Constant.cpp.

References llvm::cast().

◆ getAlignValue()

Align llvm::sandboxir::ConstantInt::getAlignValue ( ) const
inline

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.

Definition at line 157 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getBitWidth()

unsigned llvm::sandboxir::ConstantInt::getBitWidth ( ) const
inline

getBitWidth - Return the scalar bitwidth of this constant.

Definition at line 128 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getBool() [1/2]

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

◆ getBool() [2/2]

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

◆ getFalse() [1/2]

ConstantInt * llvm::sandboxir::ConstantInt::getFalse ( Context & Ctx)
static

◆ getFalse() [2/2]

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

◆ getIntegerType()

IntegerType * llvm::sandboxir::ConstantInt::getIntegerType ( ) const

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

Definition at line 78 of file Constant.cpp.

References llvm::cast(), llvm::sandboxir::Value::Ctx, and llvm::sandboxir::Value::Val.

◆ getLimitedValue()

uint64_t llvm::sandboxir::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 236 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getMaybeAlignValue()

MaybeAlign llvm::sandboxir::ConstantInt::getMaybeAlignValue ( ) const
inline

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.

Definition at line 150 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getSExtValue()

int64_t llvm::sandboxir::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 143 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getSigned() [1/2]

ConstantInt * llvm::sandboxir::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 56 of file Constant.cpp.

References llvm::cast(), and llvm::ConstantInt::getSigned().

◆ getSigned() [2/2]

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

◆ getTrue() [1/2]

ConstantInt * llvm::sandboxir::ConstantInt::getTrue ( Context & Ctx)
static

◆ getTrue() [2/2]

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

◆ getUseOperandNo()

unsigned llvm::sandboxir::ConstantInt::getUseOperandNo ( const Use & Use) const
inlineoverridevirtual

\Returns the operand index of Use.

Reimplemented from llvm::sandboxir::Constant.

Definition at line 244 of file Constant.h.

References llvm_unreachable.

◆ getValue()

const APInt & llvm::sandboxir::ConstantInt::getValue ( ) const
inline

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.

Definition at line 123 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ getZExtValue()

uint64_t llvm::sandboxir::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 135 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isMaxValue()

bool llvm::sandboxir::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 209 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isMinusOne()

bool llvm::sandboxir::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 202 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isMinValue()

bool llvm::sandboxir::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 218 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isNegative()

bool llvm::sandboxir::ConstantInt::isNegative ( ) const
inline

Definition at line 185 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isOne()

bool llvm::sandboxir::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 196 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ isValueValidForType() [1/2]

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

Definition at line 86 of file Constant.cpp.

References llvm::ConstantInt::isValueValidForType().

◆ isValueValidForType() [2/2]

bool llvm::sandboxir::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 83 of file Constant.cpp.

References llvm::ConstantInt::isValueValidForType().

◆ isZero()

bool llvm::sandboxir::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 190 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ uge()

bool llvm::sandboxir::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 227 of file Constant.h.

References llvm::cast(), and llvm::sandboxir::Value::Val.

◆ verify()

void llvm::sandboxir::ConstantInt::verify ( ) const
inlineoverridevirtual

Should crash if there is something wrong with the instruction.

Reimplemented from llvm::sandboxir::Constant.

Definition at line 248 of file Constant.h.

References assert(), llvm::isa(), and llvm::sandboxir::Value::Val.

◆ Context

friend class Context
friend

Definition at line 72 of file Constant.h.

References Context, OpIdx, and Verify.

Referenced by Context, get(), getBool(), getFalse(), and getTrue().


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