LLVM: lib/IR/MDBuilder.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

19using namespace llvm;

20

24

28

30 if (Accuracy == 0.0)

31 return nullptr;

32 assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");

33 auto *Op =

36}

37

39 uint32_t FalseWeight, bool IsExpected) {

41}

42

47

52

54 bool IsExpected) {

55 assert(Weights.size() >= 1 && "Need at least one branch weights!");

56

57 unsigned int Offset = IsExpected ? 2 : 1;

60 if (IsExpected)

62

64 for (unsigned i = 0, e = Weights.size(); i != e; ++i)

66

68}

69

71

77 if (Synthetic)

79 else

82 if (Imports) {

85 for (auto ID : OrderID)

87 }

89}

90

95

97 assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!");

98

100 return createRange(ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi));

101}

102

104

105 if (Hi == Lo)

106 return nullptr;

107

108

110}

111

118

121 bool VarArgArePassed) {

123

125 Ops.push_back(createConstant(ConstantInt::get(Int64, CalleeArgNo)));

126

128 Ops.push_back(createConstant(ConstantInt::get(Int64, ArgNo, true)));

129

132

134}

135

138 if (!ExistingCallbacks)

140

143 cast(NewCBCalleeIdxAsCM->getValue())->getZExtValue();

144 (void)NewCBCalleeIdx;

145

147 unsigned NumExistingOps = ExistingCallbacks->getNumOperands();

148 Ops.resize(NumExistingOps + 1);

149

150 for (unsigned u = 0; u < NumExistingOps; u++) {

152

153 auto *OldCBCalleeIdxAsCM =

156 cast(OldCBCalleeIdxAsCM->getValue())->getZExtValue();

157 (void)OldCBCalleeIdx;

158 assert(NewCBCalleeIdx != OldCBCalleeIdx &&

159 "Cannot map a callback callee index twice!");

160 }

161

162 Ops[NumExistingOps] = NewCB;

164}

165

173

176

177 for (const auto &Entry : Sections) {

178 const StringRef &Sec = Entry.first;

180

181

183 if (!AuxConsts.empty()) {

189 }

190 }

191

193}

194

197 if (Extra)

198 Args.push_back(Extra);

199 if (!Name.empty())

202

203

204

205

207

208

209

210 return Root;

211}

212

216

217

218

228

232

236

237

238

242 for (unsigned i = 0, e = Fields.size(); i != e; ++i) {

244 Vals[i * 3 + 1] = createConstant(ConstantInt::get(Int64, Fields[i].Size));

245 Vals[i * 3 + 2] = Fields[i].Type;

246 }

248}

249

250

251

253 StringRef Name, ArrayRef<std::pair<MDNode *, uint64_t>> Fields) {

257 for (unsigned i = 0, e = Fields.size(); i != e; ++i) {

258 Ops[i * 2 + 1] = Fields[i].first;

259 Ops[i * 2 + 2] = createConstant(ConstantInt::get(Int64, Fields[i].second));

260 }

262}

263

264

265

272

273

274

279 if (IsConstant) {

282 }

284}

285

291 Ops[0] = Parent;

293 Ops[2] = Id;

294 for (unsigned I = 0, E = Fields.size(); I != E; ++I) {

295 Ops[I * 3 + 3] = Fields[I].Type;

298 }

300}

301

304 bool IsImmutable) {

308 if (IsImmutable) {

309 auto *ImmutabilityFlagNode = createConstant(ConstantInt::get(Int64, 1));

311 ImmutabilityFlagNode});

312 }

313 return MDNode::get(Context, {BaseType, AccessType, OffsetNode, SizeNode});

314}

315

319 Metadata *OffsetNode = Tag->getOperand(2);

321

323

324

325 unsigned ImmutabilityFlagOp = NewFormat ? 4 : 3;

326 if (Tag->getNumOperands() <= ImmutabilityFlagOp)

327 return Tag;

328

329

330 Metadata *ImmutabilityFlagNode = Tag->getOperand(ImmutabilityFlagOp);

332 return Tag;

333

334

335 if (!NewFormat)

337

341}

342

350

360

365 for (size_t I = 0; I < LLVMStats.size(); I++) {

367 Ops[I * 2 + 1] =

368 createConstant(ConstantInt::get(Int64Ty, LLVMStats[I].second));

369 }

371}

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

static bool isConstant(const MachineInstr &MI)

AMDGPU Lower Kernel Arguments

This file contains the declarations for the subclasses of Constant, which represent the different fla...

const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]

This file contains the declarations for profiling metadata utility functions.

Class for arbitrary precision integers.

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

size_t size() const

size - Get the array size.

This is the shared class of boolean and integer constants.

This is an important base class in LLVM.

Implements a dense probed hash-table based set.

Class to represent integer types.

static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)

This static method is the primary way of constructing an IntegerType.

LLVM_ABI MDNode * createTBAAAccessTag(MDNode *BaseType, MDNode *AccessType, uint64_t Offset, uint64_t Size, bool IsImmutable=false)

Return metadata for a TBAA access tag with the given base type, final access type,...

Definition MDBuilder.cpp:302

LLVM_ABI MDNode * createCallbackEncoding(unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed)

Return metadata describing a callback (see llvm::AbstractCallSite).

Definition MDBuilder.cpp:119

LLVM_ABI MDNode * createAnonymousAARoot(StringRef Name=StringRef(), MDNode *Extra=nullptr)

Return metadata appropriate for a AA root node (scope or TBAA).

Definition MDBuilder.cpp:195

LLVM_ABI MDNode * createFunctionEntryCount(uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)

Return metadata containing the entry Count for a function, a boolean \Synthetic indicating whether th...

Definition MDBuilder.cpp:72

LLVM_ABI MDNode * createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, StringRef FName)

Return metadata containing the pseudo probe descriptor for a function.

Definition MDBuilder.cpp:351

LLVM_ABI ConstantAsMetadata * createConstant(Constant *C)

Return the given constant as metadata.

Definition MDBuilder.cpp:25

LLVM_ABI MDNode * createFPMath(float Accuracy)

Return metadata with the given settings.

Definition MDBuilder.cpp:29

LLVM_ABI MDNode * createPCSections(ArrayRef< PCSection > Sections)

Return metadata for PC sections.

Definition MDBuilder.cpp:174

LLVM_ABI MDNode * createTBAANode(StringRef Name, MDNode *Parent, bool isConstant=false)

Return metadata for a non-root TBAA node with the given name, parent in the TBAA tree,...

Definition MDBuilder.cpp:219

LLVM_ABI MDNode * createTBAARoot(StringRef Name)

Return metadata appropriate for a TBAA root node with the given name.

Definition MDBuilder.cpp:213

LLVM_ABI MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)

Return metadata containing two branch weights.

Definition MDBuilder.cpp:38

LLVM_ABI MDString * createString(StringRef Str)

Return the given string as metadata.

Definition MDBuilder.cpp:21

LLVM_ABI MDNode * createTBAAScalarTypeNode(StringRef Name, MDNode *Parent, uint64_t Offset=0)

Return metadata for a TBAA scalar type node with the given name, an offset and a parent in the TBAA t...

Definition MDBuilder.cpp:266

LLVM_ABI MDNode * createIrrLoopHeaderWeight(uint64_t Weight)

Return metadata containing an irreducible loop header weight.

Definition MDBuilder.cpp:343

LLVM_ABI MDNode * createUnpredictable()

Return metadata specifying that a branch or switch is unpredictable.

Definition MDBuilder.cpp:70

LLVM_ABI MDNode * createTBAAStructTypeNode(StringRef Name, ArrayRef< std::pair< MDNode *, uint64_t > > Fields)

Return metadata for a TBAA struct node in the type DAG with the given name, a list of pairs (offset,...

Definition MDBuilder.cpp:252

LLVM_ABI MDNode * createCallees(ArrayRef< Function * > Callees)

Return metadata indicating the possible callees of indirect calls.

Definition MDBuilder.cpp:112

LLVM_ABI MDNode * createAliasScopeDomain(StringRef Name)

Return metadata appropriate for an alias scope domain node with the given name.

Definition MDBuilder.cpp:229

LLVM_ABI MDNode * createRange(const APInt &Lo, const APInt &Hi)

Return metadata describing the range [Lo, Hi).

Definition MDBuilder.cpp:96

LLVM_ABI MDNode * createLikelyBranchWeights()

Return metadata containing two branch weights, with significant bias towards true destination.

Definition MDBuilder.cpp:43

LLVM_ABI MDNode * createTBAAStructNode(ArrayRef< TBAAStructField > Fields)

Return metadata for a tbaa.struct node with the given struct field descriptions.

Definition MDBuilder.cpp:239

LLVM_ABI MDNode * mergeCallbackEncodings(MDNode *ExistingCallbacks, MDNode *NewCB)

Merge the new callback encoding NewCB into ExistingCallbacks.

Definition MDBuilder.cpp:136

LLVM_ABI MDNode * createMutableTBAAAccessTag(MDNode *Tag)

Return mutable version of the given mutable or immutable TBAA access tag.

Definition MDBuilder.cpp:316

LLVM_ABI MDNode * createGlobalObjectSectionPrefix(StringRef Prefix)

Return metadata containing the section prefix for a global object.

Definition MDBuilder.cpp:91

LLVM_ABI MDNode * createLLVMStats(ArrayRef< std::pair< StringRef, uint64_t > > LLVMStatsVec)

Return metadata containing llvm statistics.

Definition MDBuilder.cpp:362

LLVM_ABI MDNode * createRTTIPointerPrologue(Constant *PrologueSig, Constant *RTTI)

Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" s...

Definition MDBuilder.cpp:166

LLVM_ABI MDNode * createUnlikelyBranchWeights()

Return metadata containing two branch weights, with significant bias towards false destination.

Definition MDBuilder.cpp:48

LLVM_ABI MDNode * createAliasScope(StringRef Name, MDNode *Domain)

Return metadata appropriate for an alias scope node with the given name.

Definition MDBuilder.cpp:233

LLVM_ABI MDNode * createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType, uint64_t Offset, bool IsConstant=false)

Return metadata for a TBAA tag node with the given base type, access type and offset relative to the ...

Definition MDBuilder.cpp:275

LLVM_ABI MDNode * createTBAATypeNode(MDNode *Parent, uint64_t Size, Metadata *Id, ArrayRef< TBAAStructField > Fields=ArrayRef< TBAAStructField >())

Return metadata for a TBAA type node in the TBAA type DAG with the given parent type,...

Definition MDBuilder.cpp:286

LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)

Replace a specific operand.

static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)

const MDOperand & getOperand(unsigned I) const

static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)

unsigned getNumOperands() const

Return number of MDNode operands.

static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)

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.

The instances of the Type class are immutable: once they are created, they are never changed.

static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)

static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)

static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)

static LLVM_ABI Type * getFloatTy(LLVMContext &C)

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ C

The default llvm calling convention, compatible with C.

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)

Extract a Value from Metadata.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty

void sort(IteratorTy Start, IteratorTy End)

FunctionAddr VTableAddr Count

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

DWARFExpression::Operation Op

decltype(auto) cast(const From &Val)

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

static LLVM_ABI const char * ExpectedBranchWeights

static LLVM_ABI const char * SyntheticFunctionEntryCount

static LLVM_ABI const char * FunctionEntryCount

static LLVM_ABI const char * BranchWeights