LLVM: lib/SandboxIR/Constant.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

14

16

17#ifndef NDEBUG

22#endif

23

38 return Ty->getContext().getOrCreateConstant(LLVMC);

39}

42 return Ty->getContext().getOrCreateConstant(LLVMC);

43}

46 return Ty->getContext().getOrCreateConstant(LLVMC);

47}

49 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);

50 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

51}

53 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V, IsSigned);

54 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

55}

57 auto *LLVMC =

59 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

60}

63 return Ty->getContext().getOrCreateConstant(LLVMC);

64}

66 auto *LLVMC = llvm::ConstantInt::get(Ctx.LLVMCtx, V);

68}

70 auto *LLVMC =

72 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

73}

75 auto *LLVMC = llvm::ConstantInt::get(Ty->LLVMTy, V);

76 return Ty->getContext().getOrCreateConstant(LLVMC);

77}

82

89

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);

108}

109

112 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

113}

116 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

117}

120 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

121}

124 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

125}

128 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

129}

132 return cast(Ty->getContext().getOrCreateConstant(LLVMC));

133}

137

139 auto &Ctx = T->getContext();

141 LLVMValues.reserve(V.size());

142 for (auto *Elm : V)

144 auto *LLVMC =

147}

148

153

155 auto &Ctx = T->getContext();

157 LLVMValues.reserve(V.size());

158 for (auto *Elm : V)

160 auto *LLVMC =

163}

164

167 bool Packed) {

168 unsigned VecSize = V.size();

170 EltTypes.reserve(VecSize);

172 EltTypes.push_back(Elm->getType());

174}

175

177 assert(!V.empty() && "Expected non-empty V!");

178 auto &Ctx = V[0]->getContext();

181 for (auto *Elm : V)

184}

185

191

195 return LLVMSplatValue ? Ctx.getOrCreateConstant(LLVMSplatValue) : nullptr;

196}

197

201 Ty->getContext().getOrCreateConstant(LLVMC));

202}

203

221

227

232

237

242

247

253

258

263

268

273

279

284

286 Ctx.getTracker()

290}

291

293 Ctx.getTracker()

294 .emplaceIfTracking<

296 this);

298}

299

300template <typename GlobalT, typename LLVMGlobalT, typename ParentT,

301 typename LLVMParentT>

305}

306

307

316

318 Ctx.getTracker()

319 .emplaceIfTracking<

321 this);

324}

325

329

334

338}

339

341 return Ctx.getOrCreateConstant(

343}

344

346 Ctx.getTracker()

351}

352

354 Ctx.getTracker()

358}

359

361 Ctx.getTracker()

362 .emplaceIfTracking<

366}

367

369 Ctx.getTracker()

370 .emplaceIfTracking<

372 this);

374}

375

380

385

387 Ctx.getTracker()

391}

392

394 Ctx.getTracker()

398}

399

404

409

413

416 Constant *DeactivationSymbol) {

422}

423

425 return Ctx.getOrCreateConstant(

427}

428

433

438

440 return Ctx.getOrCreateConstant(

442}

443

445 return Ctx.getOrCreateConstant(

447}

448

454

460

465

470

475

480

485

490

491}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_EXPORT_TEMPLATE

Value * getPointer(Value *Ptr)

Class for arbitrary precision integers.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

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)

static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)

static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)

Return true if Ty is big enough to represent V.

static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)

static LLVM_ABI bool isValueValidForType(Type *Ty, uint64_t V)

This static method returns true if the type Ty is big enough to represent the value V.

static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)

static ConstantInt * getSigned(IntegerType *Ty, int64_t V)

Return a ConstantInt with the specified value for the specified type.

static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)

static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)

static LLVM_ABI ConstantPointerNull * get(PointerType *T)

Static factory methods - Return objects of the specified value.

static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)

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.

void reserve(size_type N)

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

static LLVM_ABI UndefValue * get(Type *T)

Static factory methods - Return an 'undef' object of the specified type.

This class implements an extremely fast bulk output stream that can only output to a stream.

static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)

Lookup an existing BlockAddress constant for the given BasicBlock.

Definition Constant.cpp:466

LLVM_ABI Function * getFunction() const

Definition Constant.cpp:471

LLVM_ABI BasicBlock * getBasicBlock() const

Definition Constant.cpp:476

static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)

Return a BlockAddress for the specified function and basic block.

Definition Constant.cpp:455

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:449

LLVM_ABI Constant * getPointer() const

The pointer that is signed in this ptrauth signed pointer.

Definition Constant.cpp:424

LLVM_ABI Constant * getAddrDiscriminator() const

The address discriminator if any, or the null constant.

Definition Constant.cpp:439

LLVM_ABI ConstantInt * getDiscriminator() const

The integer discriminator, an i64 constant, or 0.

Definition Constant.cpp:434

static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)

Return a pointer signed with the specified parameters.

Definition Constant.cpp:414

LLVM_ABI ConstantInt * getKey() const

The Key ID, an i32 constant.

Definition Constant.cpp:429

Constant * getDeactivationSymbol() const

Definition Constant.cpp:444

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)

LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const

LLVM_ABI Constant * getOrCreateConstant(llvm::Constant *LLVMC)

Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.

static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)

Return a DSOLocalEquivalent for the specified global value.

Definition Constant.cpp:481

LLVM_ABI GlobalValue * getGlobalValue() const

Definition Constant.cpp:486

This class can be used for tracking most instruction setters.

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

llvm::GlobalValue::UnnamedAddr UnnamedAddr

LLVM_ABI void setUnnamedAddr(UnnamedAddr V)

Definition Constant.cpp:386

VisibilityTypes getVisibility() const

llvm::GlobalValue::VisibilityTypes VisibilityTypes

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

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...

MaybeAlign getAlign() const

Returns the alignment of the given variable.

Provides API functions, like getIterator() and getReverseIterator() to GlobalIFunc,...

Class to represent integer types.

LLVM_ABI PointerType * getType() const

NoCFIValue is always a pointer.

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.

Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...

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)

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.

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.

BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)

auto cast_or_null(const Y &Val)

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

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.