LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::sandboxir::ConstantInt Class Reference

#include "llvm/SandboxIR/Constant.h"

Inheritance diagram for llvm::sandboxir::ConstantInt:
Inheritance graph
[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.
 
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
 
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::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
 
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
 
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
 
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.
 
TypegetType () const
 
ContextgetContext () const
 
void replaceUsesWithIf (Value *OtherV, llvm::function_ref< bool(const Use &)> ShouldReplace)
 
void replaceAllUsesWith (Value *Other)
 
StringRef getName () const
 \Returns the LLVM IR name of the bottom-most LLVM value.
 
virtual void verify () const =0
 Should crash if there is something wrong with the instruction.
 
std::string getUid () const
 Returns the unique id in the form 'SB<number>.' like 'SB1.'.
 
virtual void dumpCommonHeader (raw_ostream &OS) const
 
void dumpCommonFooter (raw_ostream &OS) const
 
void dumpCommonPrefix (raw_ostream &OS) const
 
void dumpCommonSuffix (raw_ostream &OS) const
 
void printAsOperandCommon (raw_ostream &OS) const
 
virtual void dumpOS (raw_ostream &OS) const =0
 
LLVM_DUMP_METHOD void dump () const
 

Static Public Member Functions

static ConstantIntgetTrue (Context &Ctx)
 
static ConstantIntgetFalse (Context &Ctx)
 
static ConstantIntgetBool (Context &Ctx, bool V)
 
static ConstantgetTrue (Type *Ty)
 
static ConstantgetFalse (Type *Ty)
 
static ConstantgetBool (Type *Ty, bool V)
 
static 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 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 (Context &Ctx, const APInt &V)
 Return a ConstantInt with the specified value and an implied Type.
 
static ConstantIntget (IntegerType *Ty, StringRef Str, uint8_t Radix)
 Return a ConstantInt constructed from the string strStart with the given 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 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 { DEF_VALUE , DEF_USER , DEF_CONST , DEF_INSTR }
 
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)
 
Use getOperandUseInternal (unsigned OpIdx, bool Verify) const override
 \Returns the Use for the OpIdx'th operand.
 
- 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.
 
virtual Use getOperandUseInternal (unsigned OpIdx, bool Verify) const =0
 \Returns the Use for the OpIdx'th operand.
 
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.
 
virtual unsigned getUseOperandNo (const Use &Use) const =0
 \Returns the operand index of Use.
 
void swapOperandsInternal (unsigned OpIdxA, unsigned OpIdxB)
 
void verifyUserOfLLVMUse (const llvm::Use &Use) const
 
- Protected Member Functions inherited from llvm::sandboxir::Value
void clearValue ()
 
 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()

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

For isa/dyn_cast.

Definition at line 239 of file Constant.h.

References From.

◆ 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 163 of file Constant.h.

References 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 66 of file Constant.cpp.

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

◆ 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 70 of file Constant.cpp.

References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 53 of file Constant.cpp.

References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 75 of file Constant.cpp.

References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 49 of file Constant.cpp.

References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 155 of file Constant.h.

References llvm::sandboxir::Value::Val.

◆ getBitWidth()

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

getBitWidth - Return the scalar bitwidth of this constant.

Definition at line 126 of file Constant.h.

References 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 79 of file Constant.cpp.

References llvm::sandboxir::Value::Ctx, llvm::sandboxir::Context::getType(), 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 234 of file Constant.h.

References 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 148 of file Constant.h.

References 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 141 of file Constant.h.

References 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 57 of file Constant.cpp.

References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), llvm::ConstantInt::getSigned(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 242 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 121 of file Constant.h.

References 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 133 of file Constant.h.

References 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 207 of file Constant.h.

References 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 200 of file Constant.h.

References 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 216 of file Constant.h.

References llvm::sandboxir::Value::Val.

◆ isNegative()

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

Definition at line 183 of file Constant.h.

References 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 194 of file Constant.h.

References llvm::sandboxir::Value::Val.

◆ isValueValidForType() [1/2]

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

◆ 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 84 of file Constant.cpp.

References llvm::ConstantInt::isValueValidForType(), and llvm::sandboxir::Type::LLVMTy.

◆ 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 188 of file Constant.h.

References 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 225 of file Constant.h.

References 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 246 of file Constant.h.

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

Friends And Related Function Documentation

◆ Context

friend class Context
friend

Definition at line 72 of file Constant.h.


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