38 return Ty->getContext().getOrCreateConstant(LLVMC);
42 return Ty->getContext().getOrCreateConstant(LLVMC);
46 return Ty->getContext().getOrCreateConstant(LLVMC);
49 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
53 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
63 return Ty->getContext().getOrCreateConstant(LLVMC);
66 auto *LLVMC = llvm::ConstantInt::get(
Ctx.LLVMCtx, V);
75 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V);
76 return Ty->getContext().getOrCreateConstant(LLVMC);
91 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
92 return Ty->getContext().getOrCreateConstant(LLVMC);
96 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
97 return Ty->getContext().getOrCreateConstant(LLVMC);
101 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, Str);
102 return Ty->getContext().getOrCreateConstant(LLVMC);
106 auto *LLVMC = llvm::ConstantFP::get(
Ctx.LLVMCtx, V);
112 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
116 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
120 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
124 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
128 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
132 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
139 auto &
Ctx =
T->getContext();
155 auto &
Ctx =
T->getContext();
168 unsigned VecSize = V.size();
177 assert(!V.empty() &&
"Expected non-empty V!");
178 auto &
Ctx = V[0]->getContext();
195 return LLVMSplatValue ?
Ctx.getOrCreateConstant(LLVMSplatValue) :
nullptr;
201 Ty->getContext().getOrCreateConstant(LLVMC));
300template <
typename GlobalT,
typename LLVMGlobalT,
typename ParentT,
301 typename LLVMParentT>
341 return Ctx.getOrCreateConstant(
423 return Ctx.getOrCreateConstant(
438 return Ctx.getOrCreateConstant(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_EXPORT_TEMPLATE
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static LLVM_ABI Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static LLVM_ABI Constant * getInfinity(Type *Ty, bool Negative=false)
static LLVM_ABI Constant * getZero(Type *Ty, bool Negative=false)
static Constant * getNegativeZero(Type *Ty)
static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
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 ConstantInt * getTrue(LLVMContext &Context)
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
This class implements an extremely fast bulk output stream that can only output to a stream.
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
LLVM_ABI Function * getFunction() const
LLVM_ABI BasicBlock * getBasicBlock() const
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
LLVM_ABI Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
LLVM_ABI Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element.
LLVM_ABI Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e....
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
LLVM_ABI ArrayType * getType() const
static LLVM_ABI Constant * getInfinity(Type *Ty, bool Negative=false)
static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
static LLVM_ABI Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static LLVM_ABI Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static LLVM_ABI Constant * getZero(Type *Ty, bool Negative=false)
static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static LLVM_ABI Constant * getNegativeZero(Type *Ty)
static LLVM_ABI ConstantInt * getTrue(Context &Ctx)
static LLVM_ABI ConstantInt * getBool(Context &Ctx, bool V)
static LLVM_ABI ConstantInt * getFalse(Context &Ctx)
LLVM_ABI IntegerType * getIntegerType() const
Variant of the getType() method to always return an IntegerType, which reduces the amount of casting ...
static LLVM_ABI 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 LLVM_ABI ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
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 ConstantPointerNull * get(PointerType *Ty)
LLVM_ABI PointerType * getType() const
LLVM_ABI ConstantPtrAuth * getWithSameSchema(Constant *Pointer) const
Produce a new ptrauth expression signing the given value using the same schema as is stored in one.
LLVM_ABI Constant * getPointer() const
The pointer that is signed in this ptrauth signed pointer.
LLVM_ABI Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
LLVM_ABI ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
LLVM_ABI ConstantInt * getKey() const
The Key ID, an i32 constant.
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static LLVM_ABI StructType * getTypeForElements(Context &Ctx, ArrayRef< Constant * > V, bool Packed=false)
This version of the method allows an empty list.
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
void dumpOS(raw_ostream &OS) const override
Constant(llvm::Constant *C, sandboxir::Context &SBCtx)
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
LLVM_ABI Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
LLVM_ABI GlobalValue * getGlobalValue() const
This class can be used for tracking most instruction setters.
LLVM_ABI Constant * getAliasee() const
LLVM_ABI const GlobalObject * getAliaseeObject() const
LLVM_ABI void setAliasee(Constant *Aliasee)
LLVM_ABI Constant * getResolver() const
LLVM_ABI void setResolver(Constant *Resolver)
LLVM_ABI Function * getResolverFunction()
LLVM_ABI void setSection(StringRef S)
Change the section for this global.
UnnamedAddr getUnnamedAddr() const
llvm::GlobalValue::UnnamedAddr UnnamedAddr
LLVM_ABI void setUnnamedAddr(UnnamedAddr V)
VisibilityTypes getVisibility() const
llvm::GlobalValue::VisibilityTypes VisibilityTypes
LLVM_ABI void setVisibility(VisibilityTypes V)
LLVM_ABI Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool isExternallyInitialized() const
LLVM_ABI void setExternallyInitialized(bool Val)
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
LLVM_ABI void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the GlobalVariable.
LLVM_ABI void setConstant(bool V)
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
MaybeAlign getAlign() const
Returns the alignment of the given variable.
Provides API functions, like getIterator() and getReverseIterator() to GlobalIFunc,...
Class to represent integer types.
LLVM_ABI PointerType * getType() const
NoCFIValue is always a pointer.
LLVM_ABI GlobalValue * getGlobalValue() const
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
LLVM_ABI PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
LLVM_ABI PoisonValue * getStructElement(unsigned Elt) const
If this poison has struct type, return a poison with the right element type for the specified element...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
LLVM_ABI PoisonValue * getElementValue(Constant *C) const
Return an poison of the right value for the specified GEP index if we can, otherwise return null (e....
static LLVM_ABI StructType * get(Context &Ctx, ArrayRef< Type * > Elements, bool IsPacked=false)
This static method is the primary way to create a literal StructType.
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
LLVM_ABI UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e....
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
UndefValue(llvm::UndefValue *C, Context &Ctx)
LLVM_ABI UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
LLVM_ABI UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element.
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
void dumpCommonSuffix(raw_ostream &OS) const
Context & Ctx
All values point to the context.
Context & getContext() const
void dumpCommonPrefix(raw_ostream &OS) const
@ C
The default llvm calling convention, compatible with C.
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
auto cast_or_null(const Y &Val)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.