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
25 auto *LLVMC = llvm::ConstantInt::getTrue(Ctx.LLVMCtx);
26 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
27}
29 auto *LLVMC = llvm::ConstantInt::getFalse(Ctx.LLVMCtx);
30 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
31}
32ConstantInt *ConstantInt::getBool(Context &Ctx, bool V) {
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}
52ConstantInt *ConstantInt::get(IntegerType *Ty, uint64_t V, bool IsSigned) {
53 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
54 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
55}
56ConstantInt *ConstantInt::getSigned(IntegerType *Ty, int64_t V) {
57 auto *LLVMC =
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}
65ConstantInt *ConstantInt::get(Context &Ctx, const APInt &V) {
66 auto *LLVMC = llvm::ConstantInt::get(Ctx.LLVMCtx, V);
67 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
68}
69ConstantInt *ConstantInt::get(IntegerType *Ty, StringRef Str, uint8_t Radix) {
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
87 return llvm::ConstantInt::isValueValidForType(Ty->LLVMTy, V);
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
105ConstantFP *ConstantFP::get(const APFloat &V, Context &Ctx) {
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}
135 return llvm::ConstantFP::isValueValidForType(Ty->LLVMTy, V);
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 =
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 =
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));
183 return Ctx.getOrCreateConstant(llvm::ConstantVector::get(LLVMV));
184}
185
187 auto *LLVMElt = cast<llvm::Constant>(Elt->Val);
188 auto &Ctx = Elt->getContext();
189 return Ctx.getOrCreateConstant(llvm::ConstantVector::getSplat(EC, LLVMElt));
190}
191
192Constant *ConstantVector::getSplatValue(bool AllowPoison) const {
193 auto *LLVMSplatValue = cast_or_null<llvm::Constant>(
195 return LLVMSplatValue ? Ctx.getOrCreateConstant(LLVMSplatValue) : nullptr;
196}
197
198ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) {
199 auto *LLVMC = llvm::ConstantAggregateZero::get(Ty->LLVMTy);
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}
218 return cast<Constant>(Ctx.getValue(
219 cast<llvm::ConstantAggregateZero>(Val)->getElementValue(Idx)));
220}
221
222ConstantPointerNull *ConstantPointerNull::get(PointerType *Ty) {
223 auto *LLVMC =
225 return cast<ConstantPointerNull>(Ty->getContext().getOrCreateConstant(LLVMC));
226}
227
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
259PoisonValue *PoisonValue::get(Type *T) {
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
269PoisonValue *PoisonValue::getStructElement(unsigned Elt) const {
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
280PoisonValue *PoisonValue::getElementValue(unsigned Idx) const {
281 return cast<PoisonValue>(Ctx.getOrCreateConstant(
282 cast<llvm::PoisonValue>(Val)->getElementValue(Idx)));
283}
284
286 Ctx.getTracker()
287 .emplaceIfTracking<GenericSetter<&GlobalVariable::getAlign,
289 cast<llvm::GlobalVariable>(Val)->setAlignment(Align);
290}
291
293 Ctx.getTracker()
294 .emplaceIfTracking<
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.
316
318 Ctx.getTracker()
319 .emplaceIfTracking<
321 this);
322 cast<llvm::GlobalIFunc>(Val)->setResolver(
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
341 return Ctx.getOrCreateConstant(
343}
344
346 Ctx.getTracker()
349 cast<llvm::GlobalVariable>(Val)->setInitializer(
350 cast<llvm::Constant>(InitVal->Val));
351}
352
354 Ctx.getTracker()
355 .emplaceIfTracking<GenericSetter<&GlobalVariable::isConstant,
357 cast<llvm::GlobalVariable>(Val)->setConstant(V);
358}
359
361 Ctx.getTracker()
362 .emplaceIfTracking<
365 cast<llvm::GlobalVariable>(Val)->setExternallyInitialized(V);
366}
367
369 Ctx.getTracker()
370 .emplaceIfTracking<
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
387 Ctx.getTracker()
388 .emplaceIfTracking<GenericSetter<&GlobalValue::getUnnamedAddr,
390 cast<llvm::GlobalValue>(Val)->setUnnamedAddr(V);
391}
392
394 Ctx.getTracker()
395 .emplaceIfTracking<GenericSetter<&GlobalValue::getVisibility,
397 cast<llvm::GlobalValue>(Val)->setVisibility(V);
398}
399
400NoCFIValue *NoCFIValue::get(GlobalValue *GV) {
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(
419 return cast<ConstantPtrAuth>(Ptr->getContext().getOrCreateConstant(LLVMC));
420}
421
423 return Ctx.getOrCreateConstant(
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
441
442ConstantPtrAuth *ConstantPtrAuth::getWithSameSchema(Constant *Pointer) const {
444 cast<llvm::Constant>(Pointer->Val));
445 return cast<ConstantPtrAuth>(Ctx.getOrCreateConstant(LLVMC));
446}
447
450 cast<llvm::BasicBlock>(BB->Val));
451 return cast<BlockAddress>(F->getContext().getOrCreateConstant(LLVMC));
452}
453
454BlockAddress *BlockAddress::get(BasicBlock *BB) {
455 auto *LLVMC = llvm::BlockAddress::get(cast<llvm::BasicBlock>(BB->Val));
456 return cast<BlockAddress>(BB->getContext().getOrCreateConstant(LLVMC));
457}
458
459BlockAddress *BlockAddress::lookup(const BasicBlock *BB) {
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
474DSOLocalEquivalent *DSOLocalEquivalent::get(GlobalValue *GV) {
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
#define F(x, y, z)
Definition MD5.cpp:55
#define T
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
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)
Definition Constants.h:315
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.
Definition Constants.h:131
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.
Definition Record.h:2199
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.
Definition StringRef.h:55
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.
Definition raw_ostream.h:53
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
Constant(llvm::Constant *C, sandboxir::Context &SBCtx)
Definition Constant.h:34
friend class Function
Definition Constant.h:39
friend class ConstantInt
Definition Constant.h:38
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
Definition Context.cpp:629
LLVM_ABI Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
Definition Context.cpp:445
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::GlobalValue::UnnamedAddr UnnamedAddr
Definition Constant.h:924
LLVM_ABI void setUnnamedAddr(UnnamedAddr V)
Definition Constant.cpp:386
VisibilityTypes getVisibility() const
Definition Constant.h:939
llvm::GlobalValue::VisibilityTypes VisibilityTypes
Definition Constant.h:938
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
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
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition Type.h:47
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
UndefValue(llvm::UndefValue *C, Context &Ctx)
Definition Constant.h:799
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
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
Definition BasicBlock.h:75
auto cast_or_null(const Y &Val)
Definition Casting.h:720
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.
Definition Casting.h:565
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