LLVM 20.0.0git
|
#include "llvm/SandboxIR/Constant.h"
Public Member Functions | |
const APInt & | getValue () 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. | |
IntegerType * | getIntegerType () 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::Context & | getParent () 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 |
Value * | getOperand (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_iterator > | uses () |
iterator_range< const_use_iterator > | uses () const |
user_iterator | user_begin () |
user_iterator | user_end () |
const_user_iterator | user_begin () const |
const_user_iterator | user_end () const |
iterator_range< user_iterator > | users () |
iterator_range< const_user_iterator > | users () 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. | |
Type * | getType () const |
Context & | getContext () 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 ConstantInt * | getTrue (Context &Ctx) |
static ConstantInt * | getFalse (Context &Ctx) |
static ConstantInt * | getBool (Context &Ctx, bool V) |
static Constant * | getTrue (Type *Ty) |
static Constant * | getFalse (Type *Ty) |
static Constant * | getBool (Type *Ty, bool V) |
static ConstantInt * | get (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 ConstantInt * | get (IntegerType *Ty, uint64_t V, bool IsSigned=false) |
Return a ConstantInt with the specified integer value for the specified type. | |
static ConstantInt * | getSigned (IntegerType *Ty, int64_t V) |
Return a ConstantInt with the specified value for the specified type. | |
static Constant * | getSigned (Type *Ty, int64_t V) |
static ConstantInt * | get (Context &Ctx, const APInt &V) |
Return a ConstantInt with the specified value and an implied Type. | |
static ConstantInt * | get (IntegerType *Ty, StringRef Str, uint8_t Radix) |
Return a ConstantInt constructed from the string strStart with the given radix. | |
static Constant * | get (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. | |
Value & | operator= (const Value &)=delete |
Static Protected Member Functions inherited from llvm::sandboxir::Value | |
static const char * | getSubclassIDStr (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::Value * | Val = nullptr |
The LLVM Value that corresponds to this SandboxIR Value. | |
Context & | Ctx |
All values point to the context. | |
Definition at line 69 of file Constant.h.
|
inlinestatic |
|
inlineoverridevirtual |
Reimplemented from llvm::sandboxir::Constant.
Definition at line 249 of file Constant.h.
References llvm::sandboxir::Value::dumpCommonPrefix(), llvm::sandboxir::Value::dumpCommonSuffix(), and OS.
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.
|
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.
|
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.
|
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.
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.
|
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.
|
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.
|
inline |
getBitWidth - Return the scalar bitwidth of this constant.
Definition at line 126 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
static |
Definition at line 33 of file Constant.cpp.
References llvm::sandboxir::Value::Ctx, llvm::ConstantInt::getBool(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Context::LLVMCtx.
Definition at line 45 of file Constant.cpp.
References llvm::ConstantInt::getBool(), llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.
|
static |
Definition at line 29 of file Constant.cpp.
References llvm::sandboxir::Value::Ctx, llvm::ConstantInt::getFalse(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Context::LLVMCtx.
Definition at line 41 of file Constant.cpp.
References llvm::sandboxir::Type::getContext(), llvm::ConstantInt::getFalse(), llvm::sandboxir::Context::getOrCreateConstant(), and llvm::sandboxir::Type::LLVMTy.
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 - 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.
Definition at line 234 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
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.
|
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.
|
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.
Definition at line 62 of file Constant.cpp.
References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), llvm::ConstantInt::getSigned(), and llvm::sandboxir::Type::LLVMTy.
|
static |
Definition at line 25 of file Constant.cpp.
References llvm::sandboxir::Value::Ctx, llvm::sandboxir::Context::getOrCreateConstant(), llvm::ConstantInt::getTrue(), and llvm::sandboxir::Context::LLVMCtx.
Definition at line 37 of file Constant.cpp.
References llvm::sandboxir::Type::getContext(), llvm::sandboxir::Context::getOrCreateConstant(), llvm::ConstantInt::getTrue(), and llvm::sandboxir::Type::LLVMTy.
|
inlineoverridevirtual |
\Returns the operand index of Use
.
Reimplemented from llvm::sandboxir::Constant.
Definition at line 242 of file Constant.h.
References llvm_unreachable.
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.
|
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.
This function will return true iff this constant represents the largest value that may be represented by the constant's type.
Definition at line 207 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
inline |
This function will return true iff every bit in this constant is set to true.
Definition at line 200 of file Constant.h.
References llvm::sandboxir::Value::Val.
This function will return true iff this constant represents the smallest value that may be represented by this constant's type.
Definition at line 216 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
inline |
Definition at line 183 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
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.
Definition at line 87 of file Constant.cpp.
References llvm::ConstantInt::isValueValidForType(), and llvm::sandboxir::Type::LLVMTy.
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.
Definition at line 84 of file Constant.cpp.
References llvm::ConstantInt::isValueValidForType(), and llvm::sandboxir::Type::LLVMTy.
|
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.
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.
Definition at line 225 of file Constant.h.
References llvm::sandboxir::Value::Val.
|
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.
|
friend |
Definition at line 72 of file Constant.h.