LLVM 20.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
15
16namespace llvm::sandboxir {
17
18#ifndef NDEBUG
22}
23#endif // NDEBUG
24
27 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
28}
31 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
32}
34 auto *LLVMC = llvm::ConstantInt::getBool(Ctx.LLVMCtx, V);
35 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
36}
38 auto *LLVMC = llvm::ConstantInt::getTrue(Ty->LLVMTy);
39 return Ty->getContext().getOrCreateConstant(LLVMC);
40}
42 auto *LLVMC = llvm::ConstantInt::getFalse(Ty->LLVMTy);
43 return Ty->getContext().getOrCreateConstant(LLVMC);
44}
46 auto *LLVMC = llvm::ConstantInt::getBool(Ty->LLVMTy, V);
47 return Ty->getContext().getOrCreateConstant(LLVMC);
48}
49ConstantInt *ConstantInt::get(Type *Ty, uint64_t V, bool IsSigned) {
50 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
51 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
52}
54 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);
55 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
56}
58 auto *LLVMC =
59 llvm::ConstantInt::getSigned(cast<llvm::IntegerType>(Ty->LLVMTy), V);
60 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
61}
63 auto *LLVMC = llvm::ConstantInt::getSigned(Ty->LLVMTy, V);
64 return Ty->getContext().getOrCreateConstant(LLVMC);
65}
67 auto *LLVMC = llvm::ConstantInt::get(Ctx.LLVMCtx, V);
68 return cast<ConstantInt>(Ctx.getOrCreateConstant(LLVMC));
69}
71 auto *LLVMC =
72 llvm::ConstantInt::get(cast<llvm::IntegerType>(Ty->LLVMTy), Str, Radix);
73 return cast<ConstantInt>(Ty->getContext().getOrCreateConstant(LLVMC));
74}
76 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V);
77 return Ty->getContext().getOrCreateConstant(LLVMC);
78}
80 auto *LLVMTy = cast<llvm::ConstantInt>(Val)->getIntegerType();
81 return cast<IntegerType>(Ctx.getType(LLVMTy));
82}
83
86}
89}
90
91Constant *ConstantFP::get(Type *Ty, double V) {
92 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
93 return Ty->getContext().getOrCreateConstant(LLVMC);
94}
95
97 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, V);
98 return Ty->getContext().getOrCreateConstant(LLVMC);
99}
100
102 auto *LLVMC = llvm::ConstantFP::get(Ty->LLVMTy, Str);
103 return Ty->getContext().getOrCreateConstant(LLVMC);
104}
105
107 auto *LLVMC = llvm::ConstantFP::get(Ctx.LLVMCtx, V);
108 return cast<ConstantFP>(Ctx.getOrCreateConstant(LLVMC));
109}
110
111Constant *ConstantFP::getNaN(Type *Ty, bool Negative, uint64_t Payload) {
112 auto *LLVMC = llvm::ConstantFP::getNaN(Ty->LLVMTy, Negative, Payload);
113 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
114}
115Constant *ConstantFP::getQNaN(Type *Ty, bool Negative, APInt *Payload) {
116 auto *LLVMC = llvm::ConstantFP::getQNaN(Ty->LLVMTy, Negative, Payload);
117 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
118}
119Constant *ConstantFP::getSNaN(Type *Ty, bool Negative, APInt *Payload) {
120 auto *LLVMC = llvm::ConstantFP::getSNaN(Ty->LLVMTy, Negative, Payload);
121 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
122}
123Constant *ConstantFP::getZero(Type *Ty, bool Negative) {
124 auto *LLVMC = llvm::ConstantFP::getZero(Ty->LLVMTy, Negative);
125 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
126}
128 auto *LLVMC = llvm::ConstantFP::getNegativeZero(Ty->LLVMTy);
129 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
130}
132 auto *LLVMC = llvm::ConstantFP::getInfinity(Ty->LLVMTy, Negative);
133 return cast<Constant>(Ty->getContext().getOrCreateConstant(LLVMC));
134}
137}
138
140 auto &Ctx = T->getContext();
142 LLVMValues.reserve(V.size());
143 for (auto *Elm : V)
144 LLVMValues.push_back(cast<llvm::Constant>(Elm->Val));
145 auto *LLVMC =
146 llvm::ConstantArray::get(cast<llvm::ArrayType>(T->LLVMTy), LLVMValues);
147 return cast<ConstantArray>(Ctx.getOrCreateConstant(LLVMC));
148}
149
151 return cast<ArrayType>(
152 Ctx.getType(cast<llvm::ConstantArray>(Val)->getType()));
153}
154
156 auto &Ctx = T->getContext();
158 LLVMValues.reserve(V.size());
159 for (auto *Elm : V)
160 LLVMValues.push_back(cast<llvm::Constant>(Elm->Val));
161 auto *LLVMC =
162 llvm::ConstantStruct::get(cast<llvm::StructType>(T->LLVMTy), LLVMValues);
163 return cast<ConstantStruct>(Ctx.getOrCreateConstant(LLVMC));
164}
165
168 bool Packed) {
169 unsigned VecSize = V.size();
171 EltTypes.reserve(VecSize);
172 for (Constant *Elm : V)
173 EltTypes.push_back(Elm->getType());
174 return StructType::get(Ctx, EltTypes, Packed);
175}
176
178 auto *LLVMC = llvm::ConstantAggregateZero::get(Ty->LLVMTy);
179 return cast<ConstantAggregateZero>(
180 Ty->getContext().getOrCreateConstant(LLVMC));
181}
182
184 return cast<Constant>(Ctx.getValue(
185 cast<llvm::ConstantAggregateZero>(Val)->getSequentialElement()));
186}
188 return cast<Constant>(Ctx.getValue(
189 cast<llvm::ConstantAggregateZero>(Val)->getStructElement(Elt)));
190}
192 return cast<Constant>(
193 Ctx.getValue(cast<llvm::ConstantAggregateZero>(Val)->getElementValue(
194 cast<llvm::Constant>(C->Val))));
195}
197 return cast<Constant>(Ctx.getValue(
198 cast<llvm::ConstantAggregateZero>(Val)->getElementValue(Idx)));
199}
200
202 auto *LLVMC =
203 llvm::ConstantPointerNull::get(cast<llvm::PointerType>(Ty->LLVMTy));
204 return cast<ConstantPointerNull>(Ty->getContext().getOrCreateConstant(LLVMC));
205}
206
208 return cast<PointerType>(
209 Ctx.getType(cast<llvm::ConstantPointerNull>(Val)->getType()));
210}
211
213 auto *LLVMC = llvm::UndefValue::get(T->LLVMTy);
214 return cast<UndefValue>(T->getContext().getOrCreateConstant(LLVMC));
215}
216
218 return cast<UndefValue>(Ctx.getOrCreateConstant(
219 cast<llvm::UndefValue>(Val)->getSequentialElement()));
220}
221
223 return cast<UndefValue>(Ctx.getOrCreateConstant(
224 cast<llvm::UndefValue>(Val)->getStructElement(Elt)));
225}
226
228 return cast<UndefValue>(
229 Ctx.getOrCreateConstant(cast<llvm::UndefValue>(Val)->getElementValue(
230 cast<llvm::Constant>(C->Val))));
231}
232
234 return cast<UndefValue>(Ctx.getOrCreateConstant(
235 cast<llvm::UndefValue>(Val)->getElementValue(Idx)));
236}
237
239 auto *LLVMC = llvm::PoisonValue::get(T->LLVMTy);
240 return cast<PoisonValue>(T->getContext().getOrCreateConstant(LLVMC));
241}
242
244 return cast<PoisonValue>(Ctx.getOrCreateConstant(
245 cast<llvm::PoisonValue>(Val)->getSequentialElement()));
246}
247
249 return cast<PoisonValue>(Ctx.getOrCreateConstant(
250 cast<llvm::PoisonValue>(Val)->getStructElement(Elt)));
251}
252
254 return cast<PoisonValue>(
255 Ctx.getOrCreateConstant(cast<llvm::PoisonValue>(Val)->getElementValue(
256 cast<llvm::Constant>(C->Val))));
257}
258
260 return cast<PoisonValue>(Ctx.getOrCreateConstant(
261 cast<llvm::PoisonValue>(Val)->getElementValue(Idx)));
262}
263
268 this);
269 cast<llvm::GlobalObject>(Val)->setAlignment(Align);
270}
271
277 cast<llvm::GlobalObject>(Val)->setGlobalObjectSubClassData(V);
278}
279
284 this);
285 cast<llvm::GlobalObject>(Val)->setSection(S);
286}
287
288template <typename GlobalT, typename LLVMGlobalT, typename ParentT,
289 typename LLVMParentT>
291 LLVMGVToGV::operator()(LLVMGlobalT &LLVMGV) const {
292 return cast<GlobalT>(*Ctx.getValue(&LLVMGV));
293}
294
295// Explicit instantiations.
296template class GlobalWithNodeAPI<GlobalIFunc, llvm::GlobalIFunc, GlobalObject,
298template class GlobalWithNodeAPI<Function, llvm::Function, GlobalObject,
300template class GlobalWithNodeAPI<GlobalVariable, llvm::GlobalVariable,
302template class GlobalWithNodeAPI<GlobalAlias, llvm::GlobalAlias, GlobalValue,
304
305#ifdef _MSC_VER
306// These are needed for SandboxIRTest when building with LLVM_BUILD_LLVM_DYLIB
307template LLVM_EXPORT_TEMPLATE GlobalIFunc &
308GlobalWithNodeAPI<GlobalIFunc, llvm::GlobalIFunc, GlobalObject,
309 llvm::GlobalObject>::LLVMGVToGV::operator()(llvm::GlobalIFunc
310 &LLVMGV)
311 const;
312template LLVM_EXPORT_TEMPLATE Function &
313GlobalWithNodeAPI<Function, llvm::Function, GlobalObject, llvm::GlobalObject>::
314 LLVMGVToGV::operator()(llvm::Function &LLVMGV) const;
315
316template LLVM_EXPORT_TEMPLATE GlobalVariable &GlobalWithNodeAPI<
318 llvm::GlobalObject>::LLVMGVToGV::operator()(llvm::GlobalVariable &LLVMGV)
319 const;
320template LLVM_EXPORT_TEMPLATE GlobalAlias &
321GlobalWithNodeAPI<GlobalAlias, llvm::GlobalAlias, GlobalValue,
322 llvm::GlobalValue>::LLVMGVToGV::operator()(llvm::GlobalAlias
323 &LLVMGV) const;
324#endif
325
330 this);
331 cast<llvm::GlobalIFunc>(Val)->setResolver(
332 cast<llvm::Constant>(Resolver->Val));
333}
334
336 return Ctx.getOrCreateConstant(cast<llvm::GlobalIFunc>(Val)->getResolver());
337}
338
340 return cast<Function>(Ctx.getOrCreateConstant(
341 cast<llvm::GlobalIFunc>(Val)->getResolverFunction()));
342}
343
345GlobalVariable::LLVMGVToGV::operator()(llvm::GlobalVariable &LLVMGV) const {
346 return cast<GlobalVariable>(*Ctx.getValue(&LLVMGV));
347}
348
351 cast<llvm::GlobalVariable>(Val)->getInitializer());
352}
353
358 cast<llvm::GlobalVariable>(Val)->setInitializer(
359 cast<llvm::Constant>(InitVal->Val));
360}
361
366 cast<llvm::GlobalVariable>(Val)->setConstant(V);
367}
368
374 cast<llvm::GlobalVariable>(Val)->setExternallyInitialized(V);
375}
376
381 this);
382 cast<llvm::GlobalAlias>(Val)->setAliasee(cast<llvm::Constant>(Aliasee->Val));
383}
384
386 return cast<Constant>(
387 Ctx.getOrCreateConstant(cast<llvm::GlobalAlias>(Val)->getAliasee()));
388}
389
391 return cast<GlobalObject>(Ctx.getOrCreateConstant(
392 cast<llvm::GlobalAlias>(Val)->getAliaseeObject()));
393}
394
399 cast<llvm::GlobalValue>(Val)->setUnnamedAddr(V);
400}
401
406 cast<llvm::GlobalValue>(Val)->setVisibility(V);
407}
408
410 auto *LLVMC = llvm::NoCFIValue::get(cast<llvm::GlobalValue>(GV->Val));
411 return cast<NoCFIValue>(GV->getContext().getOrCreateConstant(LLVMC));
412}
413
415 auto *LLVMC = cast<llvm::NoCFIValue>(Val)->getGlobalValue();
416 return cast<GlobalValue>(Ctx.getOrCreateConstant(LLVMC));
417}
418
420 return cast<PointerType>(Ctx.getType(cast<llvm::NoCFIValue>(Val)->getType()));
421}
422
424 ConstantInt *Disc, Constant *AddrDisc) {
425 auto *LLVMC = llvm::ConstantPtrAuth::get(
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));
429}
430
433 cast<llvm::ConstantPtrAuth>(Val)->getPointer());
434}
435
437 return cast<ConstantInt>(
438 Ctx.getOrCreateConstant(cast<llvm::ConstantPtrAuth>(Val)->getKey()));
439}
440
442 return cast<ConstantInt>(Ctx.getOrCreateConstant(
443 cast<llvm::ConstantPtrAuth>(Val)->getDiscriminator()));
444}
445
448 cast<llvm::ConstantPtrAuth>(Val)->getAddrDiscriminator());
449}
450
452 auto *LLVMC = cast<llvm::ConstantPtrAuth>(Val)->getWithSameSchema(
453 cast<llvm::Constant>(Pointer->Val));
454 return cast<ConstantPtrAuth>(Ctx.getOrCreateConstant(LLVMC));
455}
456
458 auto *LLVMC = llvm::BlockAddress::get(cast<llvm::Function>(F->Val),
459 cast<llvm::BasicBlock>(BB->Val));
460 return cast<BlockAddress>(F->getContext().getOrCreateConstant(LLVMC));
461}
462
464 auto *LLVMC = llvm::BlockAddress::get(cast<llvm::BasicBlock>(BB->Val));
465 return cast<BlockAddress>(BB->getContext().getOrCreateConstant(LLVMC));
466}
467
469 auto *LLVMC = llvm::BlockAddress::lookup(cast<llvm::BasicBlock>(BB->Val));
470 return cast_or_null<BlockAddress>(BB->getContext().getValue(LLVMC));
471}
472
474 return cast<Function>(
475 Ctx.getValue(cast<llvm::BlockAddress>(Val)->getFunction()));
476}
477
479 return cast<BasicBlock>(
480 Ctx.getValue(cast<llvm::BlockAddress>(Val)->getBasicBlock()));
481}
482
484 auto *LLVMC = llvm::DSOLocalEquivalent::get(cast<llvm::GlobalValue>(GV->Val));
485 return cast<DSOLocalEquivalent>(GV->getContext().getValue(LLVMC));
486}
487
489 return cast<GlobalValue>(
490 Ctx.getValue(cast<llvm::DSOLocalEquivalent>(Val)->getGlobalValue()));
491}
492
493} // namespace llvm::sandboxir
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 BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Definition: Constants.cpp:1915
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constants.cpp:1897
static ConstantAggregateZero * get(Type *Ty)
Definition: Constants.cpp:1672
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1312
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constants.cpp:1046
static Constant * getInfinity(Type *Ty, bool Negative=false)
Definition: Constants.cpp:1103
static Constant * getZero(Type *Ty, bool Negative=false)
Definition: Constants.cpp:1057
static Constant * getNegativeZero(Type *Ty)
Definition: Constants.h:309
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
Definition: Constants.cpp:1024
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
Definition: Constants.cpp:1611
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constants.cpp:1035
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.
Definition: Constants.cpp:1597
static ConstantInt * getTrue(LLVMContext &Context)
Definition: Constants.cpp:866
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constants.h:126
static ConstantInt * getFalse(LLVMContext &Context)
Definition: Constants.cpp:873
static ConstantInt * getBool(LLVMContext &Context, bool V)
Definition: Constants.cpp:880
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1826
static ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
Definition: Constants.cpp:2072
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constants.cpp:1378
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
Definition: Constants.cpp:1970
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:66
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Definition: Constants.cpp:2028
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1878
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2203
void reserve(size_type N)
Definition: SmallVector.h:663
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1859
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
Contains a list of sandboxir::Instruction's.
Definition: BasicBlock.h:67
Context & getContext() const
Definition: BasicBlock.h:98
static BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Definition: Constant.cpp:468
Function * getFunction() const
Definition: Constant.cpp:473
BasicBlock * getBasicBlock() const
Definition: Constant.cpp:478
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition: Constant.cpp:457
static ConstantAggregateZero * get(Type *Ty)
Definition: Constant.cpp:177
Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
Definition: Constant.cpp:183
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:187
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:191
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition: Constant.cpp:139
ArrayType * getType() const
Definition: Constant.cpp:150
static Constant * getInfinity(Type *Ty, bool Negative=false)
Definition: Constant.cpp:131
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
Definition: Constant.cpp:111
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constant.cpp:119
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...
Definition: Constant.cpp:91
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
Definition: Constant.cpp:135
static Constant * getZero(Type *Ty, bool Negative=false)
Definition: Constant.cpp:123
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition: Constant.cpp:115
static Constant * getNegativeZero(Type *Ty)
Definition: Constant.cpp:127
static ConstantInt * getTrue(Context &Ctx)
Definition: Constant.cpp:25
static ConstantInt * getBool(Context &Ctx, bool V)
Definition: Constant.cpp:33
static ConstantInt * getFalse(Context &Ctx)
Definition: Constant.cpp:29
IntegerType * getIntegerType() const
Variant of the getType() method to always return an IntegerType, which reduces the amount of casting ...
Definition: Constant.cpp:79
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.
Definition: Constant.cpp:49
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constant.cpp:57
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.
Definition: Constant.cpp:84
static ConstantPointerNull * get(PointerType *Ty)
Definition: Constant.cpp:201
PointerType * getType() const
Definition: Constant.cpp:207
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:451
Constant * getPointer() const
The pointer that is signed in this ptrauth signed pointer.
Definition: Constant.cpp:431
Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
Definition: Constant.cpp:446
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
Definition: Constant.cpp:441
ConstantInt * getKey() const
The Key ID, an i32 constant.
Definition: Constant.cpp:436
static ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc)
Return a pointer signed with the specified parameters.
Definition: Constant.cpp:423
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition: Constant.cpp:155
static StructType * getTypeForElements(Context &Ctx, ArrayRef< Constant * > V, bool Packed=false)
This version of the method allows an empty list.
Definition: Constant.cpp:166
void dumpOS(raw_ostream &OS) const override
Definition: Constant.cpp:19
sandboxir::Value * getValue(llvm::Value *V) const
Definition: Context.cpp:601
Type * getType(llvm::Type *LLVMTy)
Definition: Context.h:220
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
Definition: Context.cpp:417
LLVMContext & LLVMCtx
Definition: Context.h:46
Tracker & getTracker()
Definition: Context.h:203
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
Definition: Constant.cpp:483
GlobalValue * getGlobalValue() const
Definition: Constant.cpp:488
This class can be used for tracking most instruction setters.
Definition: Tracker.h:275
Constant * getAliasee() const
Definition: Constant.cpp:385
const GlobalObject * getAliaseeObject() const
Definition: Constant.cpp:390
void setAliasee(Constant *Aliasee)
Definition: Constant.cpp:377
Constant * getResolver() const
Definition: Constant.cpp:335
void setResolver(Constant *Resolver)
Definition: Constant.cpp:326
Function * getResolverFunction()
Definition: Constant.cpp:339
unsigned getGlobalObjectSubClassData() const
Definition: Constant.h:711
void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the GlobalObject.
Definition: Constant.cpp:264
void setGlobalObjectSubClassData(unsigned V)
Definition: Constant.cpp:272
void setSection(StringRef S)
Change the section for this global.
Definition: Constant.cpp:280
UnnamedAddr getUnnamedAddr() const
Definition: Constant.h:636
void setUnnamedAddr(UnnamedAddr V)
Definition: Constant.cpp:395
VisibilityTypes getVisibility() const
Definition: Constant.h:649
void setVisibility(VisibilityTypes V)
Definition: Constant.cpp:402
Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: Constant.cpp:349
bool isExternallyInitialized() const
Definition: Constant.h:939
void setExternallyInitialized(bool Val)
Definition: Constant.cpp:369
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Constant.cpp:354
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Definition: Constant.h:934
Provides API functions, like getIterator() and getReverseIterator() to GlobalIFunc,...
Definition: Constant.h:767
Class to represent integer types.
Definition: Type.h:462
PointerType * getType() const
NoCFIValue is always a pointer.
Definition: Constant.cpp:419
GlobalValue * getGlobalValue() const
Definition: Constant.cpp:414
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Definition: Constant.cpp:409
PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
Definition: Constant.cpp:243
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:248
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constant.cpp:238
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:253
static 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:63
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Definition: Tracker.h:495
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition: Type.h:43
llvm::Type * LLVMTy
Definition: Type.h:45
Context & getContext() const
Definition: Type.h:89
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:227
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constant.cpp:212
UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
Definition: Constant.cpp:217
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:222
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
Definition: Value.h:103
void dumpCommonSuffix(raw_ostream &OS) const
Definition: Value.cpp:105
Context & Ctx
All values point to the context.
Definition: Value.h:172
Context & getContext() const
Definition: Value.h:256
void dumpCommonPrefix(raw_ostream &OS) const
Definition: Value.cpp:98
@ 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