50 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V, IsSigned);
54 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V, IsSigned);
67 auto *LLVMC = llvm::ConstantInt::get(
Ctx.
LLVMCtx, V);
72 llvm::ConstantInt::get(cast<llvm::IntegerType>(Ty->
LLVMTy), Str, Radix);
76 auto *LLVMC = llvm::ConstantInt::get(Ty->
LLVMTy, V);
80 auto *LLVMTy = cast<llvm::ConstantInt>(
Val)->getIntegerType();
92 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, V);
97 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, V);
102 auto *LLVMC = llvm::ConstantFP::get(Ty->
LLVMTy, Str);
107 auto *LLVMC = llvm::ConstantFP::get(
Ctx.
LLVMCtx, V);
140 auto &
Ctx =
T->getContext();
144 LLVMValues.
push_back(cast<llvm::Constant>(Elm->Val));
151 return cast<ArrayType>(
156 auto &
Ctx =
T->getContext();
160 LLVMValues.
push_back(cast<llvm::Constant>(Elm->Val));
169 unsigned VecSize = V.size();
179 return cast<ConstantAggregateZero>(
185 cast<llvm::ConstantAggregateZero>(
Val)->getSequentialElement()));
189 cast<llvm::ConstantAggregateZero>(
Val)->getStructElement(Elt)));
192 return cast<Constant>(
193 Ctx.
getValue(cast<llvm::ConstantAggregateZero>(
Val)->getElementValue(
194 cast<llvm::Constant>(
C->Val))));
198 cast<llvm::ConstantAggregateZero>(
Val)->getElementValue(
Idx)));
208 return cast<PointerType>(
209 Ctx.
getType(cast<llvm::ConstantPointerNull>(
Val)->getType()));
214 return cast<UndefValue>(
T->getContext().getOrCreateConstant(LLVMC));
219 cast<llvm::UndefValue>(
Val)->getSequentialElement()));
224 cast<llvm::UndefValue>(
Val)->getStructElement(Elt)));
228 return cast<UndefValue>(
230 cast<llvm::Constant>(
C->Val))));
235 cast<llvm::UndefValue>(
Val)->getElementValue(
Idx)));
240 return cast<PoisonValue>(
T->getContext().getOrCreateConstant(LLVMC));
245 cast<llvm::PoisonValue>(
Val)->getSequentialElement()));
250 cast<llvm::PoisonValue>(
Val)->getStructElement(Elt)));
254 return cast<PoisonValue>(
256 cast<llvm::Constant>(
C->Val))));
261 cast<llvm::PoisonValue>(
Val)->getElementValue(
Idx)));
269 cast<llvm::GlobalObject>(
Val)->setAlignment(
Align);
277 cast<llvm::GlobalObject>(
Val)->setGlobalObjectSubClassData(V);
285 cast<llvm::GlobalObject>(
Val)->setSection(S);
288template <
typename GlobalT,
typename LLVMGlobalT,
typename ParentT,
289 typename LLVMParentT>
292 return cast<GlobalT>(*Ctx.getValue(&LLVMGV));
312template LLVM_EXPORT_TEMPLATE
Function &
313GlobalWithNodeAPI<Function, llvm::Function, GlobalObject, llvm::GlobalObject>::
331 cast<llvm::GlobalIFunc>(
Val)->setResolver(
332 cast<llvm::Constant>(
Resolver->Val));
341 cast<llvm::GlobalIFunc>(
Val)->getResolverFunction()));
346 return cast<GlobalVariable>(*Ctx.getValue(&LLVMGV));
358 cast<llvm::GlobalVariable>(
Val)->setInitializer(
359 cast<llvm::Constant>(InitVal->
Val));
366 cast<llvm::GlobalVariable>(
Val)->setConstant(V);
374 cast<llvm::GlobalVariable>(
Val)->setExternallyInitialized(V);
382 cast<llvm::GlobalAlias>(
Val)->setAliasee(cast<llvm::Constant>(Aliasee->
Val));
386 return cast<Constant>(
392 cast<llvm::GlobalAlias>(
Val)->getAliaseeObject()));
399 cast<llvm::GlobalValue>(
Val)->setUnnamedAddr(V);
406 cast<llvm::GlobalValue>(
Val)->setVisibility(V);
415 auto *LLVMC = cast<llvm::NoCFIValue>(
Val)->getGlobalValue();
420 return cast<PointerType>(
Ctx.
getType(cast<llvm::NoCFIValue>(
Val)->getType()));
426 cast<llvm::Constant>(
Ptr->Val), cast<llvm::ConstantInt>(Key->Val),
427 cast<llvm::ConstantInt>(Disc->
Val), cast<llvm::Constant>(AddrDisc->
Val));
428 return cast<ConstantPtrAuth>(
Ptr->getContext().getOrCreateConstant(LLVMC));
437 return cast<ConstantInt>(
443 cast<llvm::ConstantPtrAuth>(
Val)->getDiscriminator()));
453 cast<llvm::Constant>(Pointer->Val));
459 cast<llvm::BasicBlock>(BB->
Val));
460 return cast<BlockAddress>(
F->getContext().getOrCreateConstant(LLVMC));
474 return cast<Function>(
479 return cast<BasicBlock>(
489 return cast<GlobalValue>(
490 Ctx.
getValue(cast<llvm::DSOLocalEquivalent>(
Val)->getGlobalValue()));
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 BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static ConstantAggregateZero * get(Type *Ty)
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static Constant * getInfinity(Type *Ty, bool Negative=false)
static Constant * getZero(Type *Ty, bool Negative=false)
static Constant * getNegativeZero(Type *Ty)
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
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 ConstantInt * getTrue(LLVMContext &Context)
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
static ConstantInt * getFalse(LLVMContext &Context)
static ConstantInt * getBool(LLVMContext &Context, bool V)
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
static 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 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 BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Function * getFunction() const
BasicBlock * getBasicBlock() const
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static ConstantAggregateZero * get(Type *Ty)
Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element.
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 Constant * get(ArrayType *T, ArrayRef< Constant * > V)
ArrayType * getType() const
static Constant * getInfinity(Type *Ty, bool Negative=false)
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static 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 bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static Constant * getZero(Type *Ty, bool Negative=false)
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static Constant * getNegativeZero(Type *Ty)
static ConstantInt * getTrue(Context &Ctx)
static ConstantInt * getBool(Context &Ctx, bool V)
static ConstantInt * getFalse(Context &Ctx)
IntegerType * getIntegerType() const
Variant of the getType() method to always return an IntegerType, which reduces the amount of casting ...
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 * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
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 ConstantPointerNull * get(PointerType *Ty)
PointerType * getType() const
ConstantPtrAuth * getWithSameSchema(Constant *Pointer) const
Produce a new ptrauth expression signing the given value using the same schema as is stored in one.
Constant * getPointer() const
The pointer that is signed in this ptrauth signed pointer.
Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
ConstantInt * getKey() const
The Key ID, an i32 constant.
static ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static StructType * getTypeForElements(Context &Ctx, ArrayRef< Constant * > V, bool Packed=false)
This version of the method allows an empty list.
void dumpOS(raw_ostream &OS) const override
sandboxir::Value * getValue(llvm::Value *V) const
Type * getType(llvm::Type *LLVMTy)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
GlobalValue * getGlobalValue() const
This class can be used for tracking most instruction setters.
Constant * getAliasee() const
const GlobalObject * getAliaseeObject() const
void setAliasee(Constant *Aliasee)
Constant * getResolver() const
void setResolver(Constant *Resolver)
Function * getResolverFunction()
unsigned getGlobalObjectSubClassData() const
void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the GlobalObject.
void setGlobalObjectSubClassData(unsigned V)
void setSection(StringRef S)
Change the section for this global.
UnnamedAddr getUnnamedAddr() const
void setUnnamedAddr(UnnamedAddr V)
VisibilityTypes getVisibility() const
void setVisibility(VisibilityTypes V)
Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool isExternallyInitialized() const
void setExternallyInitialized(bool Val)
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Provides API functions, like getIterator() and getReverseIterator() to GlobalIFunc,...
Class to represent integer types.
PointerType * getType() const
NoCFIValue is always a pointer.
GlobalValue * getGlobalValue() const
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
PoisonValue * getStructElement(unsigned Elt) const
If this poison has struct type, return a poison with the right element type for the specified element...
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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 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
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 UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
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.