49 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V, IsSigned);
53 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V, IsSigned);
66 auto *LLVMC = llvm::ConstantInt::get(
Ctx.
LLVMCtx, V);
71 llvm::ConstantInt::get(cast<llvm::IntegerType>(Ty->
LLVMTy), Str, Radix);
75 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V);
79 auto *LLVMTy = cast<llvm::ConstantInt>(
Val)->getIntegerType();
91 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, V);
96 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, V);
101 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, Str);
106 auto *LLVMC = llvm::ConstantFP::get(
Ctx.
LLVMCtx, V);
139 auto &
Ctx =
T->getContext();
143 LLVMValues.
push_back(cast<llvm::Constant>(Elm->Val));
150 return cast<ArrayType>(
155 auto &
Ctx =
T->getContext();
159 LLVMValues.
push_back(cast<llvm::Constant>(Elm->Val));
168 unsigned VecSize = V.size();
177 assert(!V.empty() &&
"Expected non-empty V!");
178 auto &
Ctx = V[0]->getContext();
182 LLVMV.
push_back(cast<llvm::Constant>(Elm->Val));
187 auto *LLVMElt = cast<llvm::Constant>(Elt->
Val);
193 auto *LLVMSplatValue = cast_or_null<llvm::Constant>(
200 return cast<ConstantAggregateZero>(
206 cast<llvm::ConstantAggregateZero>(
Val)->getSequentialElement()));
210 cast<llvm::ConstantAggregateZero>(
Val)->getStructElement(Elt)));
213 return cast<Constant>(
214 Ctx.
getValue(cast<llvm::ConstantAggregateZero>(
Val)->getElementValue(
215 cast<llvm::Constant>(
C->Val))));
219 cast<llvm::ConstantAggregateZero>(
Val)->getElementValue(
Idx)));
229 return cast<PointerType>(
230 Ctx.
getType(cast<llvm::ConstantPointerNull>(
Val)->getType()));
235 return cast<UndefValue>(
T->getContext().getOrCreateConstant(LLVMC));
240 cast<llvm::UndefValue>(
Val)->getSequentialElement()));
245 cast<llvm::UndefValue>(
Val)->getStructElement(Elt)));
249 return cast<UndefValue>(
251 cast<llvm::Constant>(
C->Val))));
256 cast<llvm::UndefValue>(
Val)->getElementValue(
Idx)));
261 return cast<PoisonValue>(
T->getContext().getOrCreateConstant(LLVMC));
266 cast<llvm::PoisonValue>(
Val)->getSequentialElement()));
271 cast<llvm::PoisonValue>(
Val)->getStructElement(Elt)));
275 return cast<PoisonValue>(
277 cast<llvm::Constant>(
C->Val))));
282 cast<llvm::PoisonValue>(
Val)->getElementValue(
Idx)));
289 cast<llvm::GlobalVariable>(
Val)->setAlignment(
Align);
297 cast<llvm::GlobalObject>(
Val)->setSection(S);
300template <
typename GlobalT,
typename LLVMGlobalT,
typename ParentT,
301 typename LLVMParentT>
304 return cast<GlobalT>(*Ctx.getValue(&LLVMGV));
322 cast<llvm::GlobalIFunc>(
Val)->setResolver(
323 cast<llvm::Constant>(
Resolver->Val));
332 cast<llvm::GlobalIFunc>(
Val)->getResolverFunction()));
337 return cast<GlobalVariable>(*Ctx.getValue(&LLVMGV));
349 cast<llvm::GlobalVariable>(
Val)->setInitializer(
350 cast<llvm::Constant>(InitVal->
Val));
357 cast<llvm::GlobalVariable>(
Val)->setConstant(V);
365 cast<llvm::GlobalVariable>(
Val)->setExternallyInitialized(V);
373 cast<llvm::GlobalAlias>(
Val)->setAliasee(cast<llvm::Constant>(Aliasee->
Val));
377 return cast<Constant>(
383 cast<llvm::GlobalAlias>(
Val)->getAliaseeObject()));
390 cast<llvm::GlobalValue>(
Val)->setUnnamedAddr(V);
397 cast<llvm::GlobalValue>(
Val)->setVisibility(V);
406 auto *LLVMC = cast<llvm::NoCFIValue>(
Val)->getGlobalValue();
411 return cast<PointerType>(
Ctx.
getType(cast<llvm::NoCFIValue>(
Val)->getType()));
417 cast<llvm::Constant>(
Ptr->Val), cast<llvm::ConstantInt>(Key->Val),
418 cast<llvm::ConstantInt>(Disc->
Val), cast<llvm::Constant>(AddrDisc->
Val));
419 return cast<ConstantPtrAuth>(
Ptr->getContext().getOrCreateConstant(LLVMC));
428 return cast<ConstantInt>(
434 cast<llvm::ConstantPtrAuth>(
Val)->getDiscriminator()));
444 cast<llvm::Constant>(Pointer->Val));
450 cast<llvm::BasicBlock>(BB->
Val));
451 return cast<BlockAddress>(
F->getContext().getOrCreateConstant(LLVMC));
465 return cast<Function>(
470 return cast<BasicBlock>(
480 return cast<GlobalValue>(
481 Ctx.
getValue(cast<llvm::DSOLocalEquivalent>(
Val)->getGlobalValue()));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_EXPORT_TEMPLATE
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
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.
Contains a list of sandboxir::Instruction's.
Context & getContext() const
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
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
Type * getType(llvm::Type *LLVMTy)
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_ABI void setUnnamedAddr(UnnamedAddr V)
VisibilityTypes getVisibility() const
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.
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Context & getContext() const
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.
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.
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.