LLVM 22.0.0git
Constant.cpp
Go to the documentation of this file.
1//===- Constant.cpp - The Constant classes of Sandbox IR ------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
14
15namespace llvm::sandboxir {
16
17#ifndef NDEBUG
21}
22#endif // NDEBUG
23
26 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
27}
30 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
31}
33 auto *LLVMC = llvm::ConstantInt::getBool(Ctx.LLVMCtx, V);
34 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
35}
37 auto *LLVMC = llvm::ConstantInt::getTrue(Ty->LLVMTy);
38 return Ty->getContext().getOrCreateConstant(LLVMC);
39}
41 auto *LLVMC = llvm::ConstantInt::getFalse(Ty->LLVMTy);
42 return Ty->getContext().getOrCreateConstant(LLVMC);
43}
45 auto *LLVMC = llvm::ConstantInt::getBool(Ty->LLVMTy, V);
46 return Ty->getContext().getOrCreateConstant(LLVMC);
47}
48ConstantInt *ConstantInt::get(Type *Ty, uint64_t V, bool IsSigned) {
49 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
50 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
51}
53 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
54 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
55}
57 auto *LLVMC =
58 llvm::ConstantInt::getSigned(cast<llvm::IntegerType>(Ty->LLVMTy), V);
59 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
60}
62 auto *LLVMC = llvm::ConstantInt::getSigned(Ty->LLVMTy, V);
63 return Ty->getContext().getOrCreateConstant(LLVMC);
64}
66 auto *LLVMC = llvm::ConstantInt::get(Ctx.LLVMCtx, V);
67 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
68}
70 auto *LLVMC =
71 llvm::ConstantInt::get(cast<llvm::IntegerType>(Ty->LLVMTy), Str, Radix);
72 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
73}
75 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V);
76 return Ty->getContext().getOrCreateConstant(LLVMC);
77}
79 auto *LLVMTy = cast<llvm::ConstantInt>(Val)->getIntegerType();
80 return cast<IntegerType>(Ctx.getType(LLVMTy));
81}
82
85}
88}
89
90Constant *ConstantFP::get(Type *Ty, double V) {
91 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
92 return Ty->getContext().getOrCreateConstant(LLVMC);
93}
94
96 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
97 return Ty->getContext().getOrCreateConstant(LLVMC);
98}
99
101 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, Str);
102 return Ty->getContext().getOrCreateConstant(LLVMC);
103}
104
106 auto *LLVMC = llvm::ConstantFP::get(Ctx.LLVMCtx, V);
107 return cast<ConstantFP>(Ctx.getOrCreateConstant(LLVMC));
108}
109
110Constant *ConstantFP::getNaN(Type *Ty, bool Negative, uint64_t Payload) {
111 auto *LLVMC = llvm::ConstantFP::getNaN(Ty->LLVMTy, Negative, Payload);
112 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
113}
114Constant *ConstantFP::getQNaN(Type *Ty, bool Negative, APInt *Payload) {
115 auto *LLVMC = llvm::ConstantFP::getQNaN(Ty->LLVMTy, Negative, Payload);
116 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
117}
118Constant *ConstantFP::getSNaN(Type *Ty, bool Negative, APInt *Payload) {
119 auto *LLVMC = llvm::ConstantFP::getSNaN(Ty->LLVMTy, Negative, Payload);
120 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
121}
122Constant *ConstantFP::getZero(Type *Ty, bool Negative) {
123 auto *LLVMC = llvm::ConstantFP::getZero(Ty->LLVMTy, Negative);
124 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
125}
127 auto *LLVMC = llvm::ConstantFP::getNegativeZero(Ty->LLVMTy);
128 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
129}
131 auto *LLVMC = llvm::ConstantFP::getInfinity(Ty->LLVMTy, Negative);
132 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
133}
136}
137
139 auto &Ctx = T->getContext();
141 LLVMValues.reserve(V.size());
142 for (auto *Elm : V)
143 LLVMValues.push_back(cast<llvm::Constant>(Elm->Val));
144 auto *LLVMC =
145 llvm::ConstantArray::get(cast<llvm::ArrayType>(T->LLVMTy), LLVMValues);
146 return cast<ConstantArray>(Ctx.getOrCreateConstant(LLVMC));
147}
148
150 return cast<ArrayType>(
151 Ctx.getType(cast<llvm::ConstantArray>(Val)->getType()));
152}
153
155 auto &Ctx = T->getContext();
157 LLVMValues.reserve(V.size());
158 for (auto *Elm : V)
159 LLVMValues.push_back(cast<llvm::Constant>(Elm->Val));
160 auto *LLVMC =
161 llvm::ConstantStruct::get(cast<llvm::StructType>(T->LLVMTy), LLVMValues);
162 return cast<ConstantStruct>(Ctx.getOrCreateConstant(LLVMC));
163}
164
167 bool Packed) {
168 unsigned VecSize = V.size();
170 EltTypes.reserve(VecSize);
171 for (Constant *Elm : V)
172 EltTypes.push_back(Elm->getType());
173 return StructType::get(Ctx, EltTypes, Packed);
174}
175
177 assert(!V.empty() && "Expected non-empty V!");
178 auto &Ctx = V[0]->getContext();
180 LLVMV.reserve(V.size());
181 for (auto *Elm : V)
182 LLVMV.push_back(cast<llvm::Constant>(Elm->Val));
184}
185
187 auto *LLVMElt = cast<llvm::Constant>(Elt->Val);
188 auto &Ctx = Elt->getContext();
190}
191
192Constant *ConstantVector::getSplatValue(bool AllowPoison) const {
193 auto *LLVMSplatValue = cast_or_null<llvm::Constant>(
194 cast<llvm::ConstantVector>(Val)->getSplatValue(AllowPoison));
195 return LLVMSplatValue ? Ctx.getOrCreateConstant(LLVMSplatValue) : nullptr;
196}
197
199 auto *LLVMC = llvm::ConstantAggregateZero::get(Ty->LLVMTy);
200 return cast<ConstantAggregateZero>(
201 Ty->getContext().getOrCreateConstant(LLVMC));
202}
203
205 return cast<Constant>(Ctx.getValue(
206 cast<llvm::ConstantAggregateZero>(Val)->getSequentialElement()));
207}
209 return cast<Constant>(Ctx.getValue(
210 cast<llvm::ConstantAggregateZero>(Val)->getStructElement(Elt)));
211}
213 return cast<Constant>(
214 Ctx.getValue(cast<llvm::ConstantAggregateZero>(Val)->getElementValue(
215 cast<llvm::Constant>(C->Val))));
216}
218 return cast<Constant>(Ctx.getValue(
219 cast<llvm::ConstantAggregateZero>(Val)->getElementValue(Idx)));
220}
221
223 auto *LLVMC =
224 llvm::ConstantPointerNull::get(cast<llvm::PointerType>(Ty->LLVMTy));
225 return cast<ConstantPointerNull>(Ty->getContext().getOrCreateConstant(LLVMC));
226}
227
229 return cast<PointerType>(
230 Ctx.getType(cast<llvm::ConstantPointerNull>(Val)->getType()));
231}
232
234 auto *LLVMC = llvm::UndefValue::get(T->LLVMTy);
235 return cast<UndefValue>(T->getContext().getOrCreateConstant(LLVMC));
236}
237
239 return cast<UndefValue>(Ctx.getOrCreateConstant(
240 cast<llvm::UndefValue>(Val)->getSequentialElement()));
241}
242
244 return cast<UndefValue>(Ctx.getOrCreateConstant(
245 cast<llvm::UndefValue>(Val)->getStructElement(Elt)));
246}
247
249 return cast<UndefValue>(
250 Ctx.getOrCreateConstant(cast<llvm::UndefValue>(Val)->getElementValue(
251 cast<llvm::Constant>(C->Val))));
252}
253
255 return cast<UndefValue>(Ctx.getOrCreateConstant(
256 cast<llvm::UndefValue>(Val)->getElementValue(Idx)));
257}
258
260 auto *LLVMC = llvm::PoisonValue::get(T->LLVMTy);
261 return cast<PoisonValue>(T->getContext().getOrCreateConstant(LLVMC));
262}
263
265 return cast<PoisonValue>(Ctx.getOrCreateConstant(
266 cast<llvm::PoisonValue>(Val)->getSequentialElement()));
267}
268
270 return cast<PoisonValue>(Ctx.getOrCreateConstant(
271 cast<llvm::PoisonValue>(Val)->getStructElement(Elt)));
272}
273
275 return cast<PoisonValue>(
276 Ctx.getOrCreateConstant(cast<llvm::PoisonValue>(Val)->getElementValue(
277 cast<llvm::Constant>(C->Val))));
278}
279
281 return cast<PoisonValue>(Ctx.getOrCreateConstant(
282 cast<llvm::PoisonValue>(Val)->getElementValue(Idx)));
283}
284
289 cast<llvm::GlobalVariable>(Val)->setAlignment(Align);
290}
291
296 this);
297 cast<llvm::GlobalObject>(Val)->setSection(S);
298}
299
300template <typename GlobalT, typename LLVMGlobalT, typename ParentT,
301 typename LLVMParentT>
303 LLVMGVToGV::operator()(LLVMGlobalT &LLVMGV) const {
304 return cast<GlobalT>(*Ctx.getValue(&LLVMGV));
305}
306
307// Explicit instantiations.
308template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI<
310template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI<
312template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI<
314template class LLVM_EXPORT_TEMPLATE GlobalWithNodeAPI<
316
321 this);
322 cast<llvm::GlobalIFunc>(Val)->setResolver(
323 cast<llvm::Constant>(Resolver->Val));
324}
325
327 return Ctx.getOrCreateConstant(cast<llvm::GlobalIFunc>(Val)->getResolver());
328}
329
331 return cast<Function>(Ctx.getOrCreateConstant(
332 cast<llvm::GlobalIFunc>(Val)->getResolverFunction()));
333}
334
336GlobalVariable::LLVMGVToGV::operator()(llvm::GlobalVariable &LLVMGV) const {
337 return cast<GlobalVariable>(*Ctx.getValue(&LLVMGV));
338}
339
342 cast<llvm::GlobalVariable>(Val)->getInitializer());
343}
344
349 cast<llvm::GlobalVariable>(Val)->setInitializer(
350 cast<llvm::Constant>(InitVal->Val));
351}
352
357 cast<llvm::GlobalVariable>(Val)->setConstant(V);
358}
359
365 cast<llvm::GlobalVariable>(Val)->setExternallyInitialized(V);
366}
367
372 this);
373 cast<llvm::GlobalAlias>(Val)->setAliasee(cast<llvm::Constant>(Aliasee->Val));
374}
375
377 return cast<Constant>(
378 Ctx.getOrCreateConstant(cast<llvm::GlobalAlias>(Val)->getAliasee()));
379}
380
382 return cast<GlobalObject>(Ctx.getOrCreateConstant(
383 cast<llvm::GlobalAlias>(Val)->getAliaseeObject()));
384}
385
390 cast<llvm::GlobalValue>(Val)->setUnnamedAddr(V);
391}
392
397 cast<llvm::GlobalValue>(Val)->setVisibility(V);
398}
399
401 auto *LLVMC = llvm::NoCFIValue::get(cast<llvm::GlobalValue>(GV->Val));
402 return cast<NoCFIValue>(GV->getContext().getOrCreateConstant(LLVMC));
403}
404
406 auto *LLVMC = cast<llvm::NoCFIValue>(Val)->getGlobalValue();
407 return cast<GlobalValue>(Ctx.getOrCreateConstant(LLVMC));
408}
409
411 return cast<PointerType>(Ctx.getType(cast<llvm::NoCFIValue>(Val)->getType()));
412}
413
415 ConstantInt *Disc, Constant *AddrDisc) {
416 auto *LLVMC = llvm::ConstantPtrAuth::get(
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));
420}
421
424 cast<llvm::ConstantPtrAuth>(Val)->getPointer());
425}
426
428 return cast<ConstantInt>(
429 Ctx.getOrCreateConstant(cast<llvm::ConstantPtrAuth>(Val)->getKey()));
430}
431
433 return cast<ConstantInt>(Ctx.getOrCreateConstant(
434 cast<llvm::ConstantPtrAuth>(Val)->getDiscriminator()));
435}
436
439 cast<llvm::ConstantPtrAuth>(Val)->getAddrDiscriminator());
440}
441
443 auto *LLVMC = cast<llvm::ConstantPtrAuth>(Val)->getWithSameSchema(
444 cast<llvm::Constant>(Pointer->Val));
445 return cast<ConstantPtrAuth>(Ctx.getOrCreateConstant(LLVMC));
446}
447
449 auto *LLVMC = llvm::BlockAddress::get(cast<llvm::Function>(F->Val),
450 cast<llvm::BasicBlock>(BB->Val));
451 return cast<BlockAddress>(F->getContext().getOrCreateConstant(LLVMC));
452}
453
455 auto *LLVMC = llvm::BlockAddress::get(cast<llvm::BasicBlock>(BB->Val));
456 return cast<BlockAddress>(BB->getContext().getOrCreateConstant(LLVMC));
457}
458
460 auto *LLVMC = llvm::BlockAddress::lookup(cast<llvm::BasicBlock>(BB->Val));
461 return cast_or_null<BlockAddress>(BB->getContext().getValue(LLVMC));
462}
463
465 return cast<Function>(
466 Ctx.getValue(cast<llvm::BlockAddress>(Val)->getFunction()));
467}
468
470 return cast<BasicBlock>(
471 Ctx.getValue(cast<llvm::BlockAddress>(Val)->getBasicBlock()));
472}
473
475 auto *LLVMC = llvm::DSOLocalEquivalent::get(cast<llvm::GlobalValue>(GV->Val));
476 return cast<DSOLocalEquivalent>(GV->getContext().getValue(LLVMC));
477}
478
480 return cast<GlobalValue>(
481 Ctx.getValue(cast<llvm::DSOLocalEquivalent>(Val)->getGlobalValue()));
482}
483
484} // namespace llvm::sandboxir
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_EXPORT_TEMPLATE
Definition: Compiler.h:215
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
#define F(x, y, z)
Definition: MD5.cpp:55
raw_pwrite_stream & OS
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Definition: Constants.cpp:1922
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1911
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
Definition: Constants.cpp:1677
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1314
static LLVM_ABI Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constants.cpp:1048
static LLVM_ABI Constant * getInfinity(Type *Ty, bool Negative=false)
Definition: Constants.cpp:1105
static LLVM_ABI Constant * getZero(Type *Ty, bool Negative=false)
Definition: Constants.cpp:1059
static Constant * getNegativeZero(Type *Ty)
Definition: Constants.h:315
static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
Definition: Constants.cpp:1026
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
Definition: Constants.cpp:1616
static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constants.cpp:1037
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.
Definition: Constants.cpp:1602
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
Definition: Constants.cpp:868
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constants.h:131
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
Definition: Constants.cpp:875
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
Definition: Constants.cpp:882
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1833
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
Definition: Constants.cpp:2063
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1380
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
Definition: Constants.cpp:1474
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
Definition: Constants.cpp:1423
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
Definition: Constants.cpp:1961
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:67
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Definition: Constants.cpp:2019
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1885
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2196
void reserve(size_type N)
Definition: SmallVector.h:664
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1866
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
Contains a list of sandboxir::Instruction's.
Definition: BasicBlock.h:68
Context & getContext() const
Definition: BasicBlock.h:99
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Definition: Constant.cpp:459
LLVM_ABI Function * getFunction() const
Definition: Constant.cpp:464
LLVM_ABI BasicBlock * getBasicBlock() const
Definition: Constant.cpp:469
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constant.cpp:448
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
Definition: Constant.cpp:198
LLVM_ABI Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
Definition: Constant.cpp:204
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.
Definition: Constant.cpp:208
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....
Definition: Constant.cpp:212
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constant.cpp:138
LLVM_ABI ArrayType * getType() const
Definition: Constant.cpp:149
static LLVM_ABI Constant * getInfinity(Type *Ty, bool Negative=false)
Definition: Constant.cpp:130
static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
Definition: Constant.cpp:110
static LLVM_ABI Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constant.cpp:118
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...
Definition: Constant.cpp:90
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
Definition: Constant.cpp:134
static LLVM_ABI Constant * getZero(Type *Ty, bool Negative=false)
Definition: Constant.cpp:122
static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constant.cpp:114
static LLVM_ABI Constant * getNegativeZero(Type *Ty)
Definition: Constant.cpp:126
static LLVM_ABI ConstantInt * getTrue(Context &Ctx)
Definition: Constant.cpp:24
static LLVM_ABI ConstantInt * getBool(Context &Ctx, bool V)
Definition: Constant.cpp:32
static LLVM_ABI ConstantInt * getFalse(Context &Ctx)
Definition: Constant.cpp:28
LLVM_ABI IntegerType * getIntegerType() const
Variant of the getType() method to always return an IntegerType, which reduces the amount of casting ...
Definition: Constant.cpp:78
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.
Definition: Constant.cpp:48
static LLVM_ABI ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constant.cpp:56
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.
Definition: Constant.cpp:83
static LLVM_ABI ConstantPointerNull * get(PointerType *Ty)
Definition: Constant.cpp:222
LLVM_ABI PointerType * getType() const
Definition: Constant.cpp:228
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.
Definition: Constant.cpp:442
LLVM_ABI Constant * getPointer() const
The pointer that is signed in this ptrauth signed pointer.
Definition: Constant.cpp:422
LLVM_ABI Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
Definition: Constant.cpp:437
LLVM_ABI ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
Definition: Constant.cpp:432
LLVM_ABI ConstantInt * getKey() const
The Key ID, an i32 constant.
Definition: Constant.cpp:427
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
Definition: Constant.cpp:414
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constant.cpp:154
static LLVM_ABI StructType * getTypeForElements(Context &Ctx, ArrayRef< Constant * > V, bool Packed=false)
This version of the method allows an empty list.
Definition: Constant.cpp:165
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
Definition: Constant.cpp:186
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
Definition: Constant.cpp:176
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
Definition: Constant.cpp:192
void dumpOS(raw_ostream &OS) const override
Definition: Constant.cpp:18
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
Definition: Context.cpp:629
Type * getType(llvm::Type *LLVMTy)
Definition: Context.h:262
LLVM_ABI Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
Definition: Context.cpp:445
LLVMContext & LLVMCtx
Definition: Context.h:70
Tracker & getTracker()
Definition: Context.h:245
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
Definition: Constant.cpp:474
LLVM_ABI GlobalValue * getGlobalValue() const
Definition: Constant.cpp:479
This class can be used for tracking most instruction setters.
Definition: Tracker.h:277
LLVM_ABI Constant * getAliasee() const
Definition: Constant.cpp:376
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition: Constant.cpp:381
LLVM_ABI void setAliasee(Constant *Aliasee)
Definition: Constant.cpp:368
LLVM_ABI Constant * getResolver() const
Definition: Constant.cpp:326
LLVM_ABI void setResolver(Constant *Resolver)
Definition: Constant.cpp:317
LLVM_ABI Function * getResolverFunction()
Definition: Constant.cpp:330
LLVM_ABI void setSection(StringRef S)
Change the section for this global.
Definition: Constant.cpp:292
UnnamedAddr getUnnamedAddr() const
Definition: Constant.h:926
LLVM_ABI void setUnnamedAddr(UnnamedAddr V)
Definition: Constant.cpp:386
VisibilityTypes getVisibility() const
Definition: Constant.h:939
LLVM_ABI void setVisibility(VisibilityTypes V)
Definition: Constant.cpp:393
LLVM_ABI Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: Constant.cpp:340
bool isExternallyInitialized() const
Definition: Constant.h:1194
LLVM_ABI void setExternallyInitialized(bool Val)
Definition: Constant.cpp:360
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Constant.cpp:345
LLVM_ABI void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the GlobalVariable.
Definition: Constant.cpp:285
LLVM_ABI void setConstant(bool V)
Definition: Constant.cpp:353
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Definition: Constant.h:1189
MaybeAlign getAlign() const
Returns the alignment of the given variable.
Definition: Constant.h:1265
Provides API functions, like getIterator() and getReverseIterator() to GlobalIFunc,...
Definition: Constant.h:1031
Class to represent integer types.
Definition: Type.h:466
LLVM_ABI PointerType * getType() const
NoCFIValue is always a pointer.
Definition: Constant.cpp:410
LLVM_ABI GlobalValue * getGlobalValue() const
Definition: Constant.cpp:405
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Definition: Constant.cpp:400
LLVM_ABI PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
Definition: Constant.cpp:264
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...
Definition: Constant.cpp:269
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constant.cpp:259
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....
Definition: Constant.cpp:274
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.
Definition: Type.cpp:61
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Definition: Tracker.h:500
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition: Type.h:47
llvm::Type * LLVMTy
Definition: Type.h:49
Context & getContext() const
Definition: Type.h:94
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....
Definition: Constant.cpp:248
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constant.cpp:233
LLVM_ABI UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
Definition: Constant.cpp:238
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.
Definition: Constant.cpp:243
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
Definition: Value.h:106
void dumpCommonSuffix(raw_ostream &OS) const
Definition: Value.cpp:107
Context & Ctx
All values point to the context.
Definition: Value.h:179
Context & getContext() const
Definition: Value.h:263
void dumpCommonPrefix(raw_ostream &OS) const
Definition: Value.cpp:100
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117