LLVM: lib/IR/MDBuilder.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
18using namespace llvm;
19
22}
23
26}
27
29 if (Accuracy == 0.0)
30 return nullptr;
31 assert(Accuracy > 0.0 && "Invalid fpmath accuracy!");
32 auto *Op =
35}
36
38 uint32_t FalseWeight, bool IsExpected) {
40}
41
43
45}
46
48
50}
51
53 bool IsExpected) {
54 assert(Weights.size() >= 1 && "Need at least one branch weights!");
55
56 unsigned int Offset = IsExpected ? 2 : 1;
59 if (IsExpected)
61
63 for (unsigned i = 0, e = Weights.size(); i != e; ++i)
65
67}
68
70
72 uint64_t Count, bool Synthetic,
76 if (Synthetic)
78 else
81 if (Imports) {
84 for (auto ID : OrderID)
86 }
88}
89
93}
94
96 assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!");
97
99 return createRange(ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi));
100}
101
103
105 return nullptr;
106
107
109}
110
116}
117
120 bool VarArgArePassed) {
122
125
128
131
133}
134
137 if (!ExistingCallbacks)
139
140 auto *NewCBCalleeIdxAsCM = cast(NewCB->getOperand(0));
142 cast(NewCBCalleeIdxAsCM->getValue())->getZExtValue();
143 (void)NewCBCalleeIdx;
144
146 unsigned NumExistingOps = ExistingCallbacks->getNumOperands();
147 Ops.resize(NumExistingOps + 1);
148
149 for (unsigned u = 0; u < NumExistingOps; u++) {
150 Ops[u] = ExistingCallbacks->getOperand(u);
151
152 auto *OldCBCalleeIdxAsCM =
153 cast(cast(Ops[u])->getOperand(0));
155 cast(OldCBCalleeIdxAsCM->getValue())->getZExtValue();
156 (void)OldCBCalleeIdx;
157 assert(NewCBCalleeIdx != OldCBCalleeIdx &&
158 "Cannot map a callback callee index twice!");
159 }
160
161 Ops[NumExistingOps] = NewCB;
163}
164
171}
172
175
176 for (const auto &Entry : Sections) {
177 const StringRef &Sec = Entry.first;
179
180
182 if (!AuxConsts.empty()) {
188 }
189 }
190
192}
193
196 if (Extra)
197 Args.push_back(Extra);
198 if (.empty())
201
202
203
204
206
207
208
209 return Root;
210}
211
214}
215
216
217
224 }
226}
227
230}
231
234}
235
236
237
241 for (unsigned i = 0, e = Fields.size(); i != e; ++i) {
244 Vals[i * 3 + 2] = Fields[i].Type;
245 }
247}
248
249
250
256 for (unsigned i = 0, e = Fields.size(); i != e; ++i) {
257 Ops[i * 2 + 1] = Fields[i].first;
258 Ops[i * 2 + 2] = createConstant(ConstantInt::get(Int64, Fields[i].second));
259 }
261}
262
263
264
270}
271
272
273
278 if (IsConstant) {
281 }
283}
284
290 Ops[0] = Parent;
292 Ops[2] = Id;
293 for (unsigned I = 0, E = Fields.size(); I != E; ++I) {
294 Ops[I * 3 + 3] = Fields[I].Type;
297 }
299}
300
303 bool IsImmutable) {
307 if (IsImmutable) {
310 ImmutabilityFlagNode});
311 }
312 return MDNode::get(Context, {BaseType, AccessType, OffsetNode, SizeNode});
313}
314
317 MDNode *AccessType = cast(Tag->getOperand(1));
318 Metadata *OffsetNode = Tag->getOperand(2);
319 uint64_t Offset = mdconst::extract(OffsetNode)->getZExtValue();
320
321 bool NewFormat = isa(AccessType->getOperand(0));
322
323
324 unsigned ImmutabilityFlagOp = NewFormat ? 4 : 3;
325 if (Tag->getNumOperands() <= ImmutabilityFlagOp)
326 return Tag;
327
328
329 Metadata *ImmutabilityFlagNode = Tag->getOperand(ImmutabilityFlagOp);
330 if (!mdconst::extract(ImmutabilityFlagNode)->getValue())
331 return Tag;
332
333
334 if (!NewFormat)
336
338 uint64_t Size = mdconst::extract(SizeNode)->getZExtValue();
340}
341
346 };
348}
349
354 Ops[0] = createConstant(ConstantInt::get(Int64Ty, GUID));
355 Ops[1] = createConstant(ConstantInt::get(Int64Ty, Hash));
358}
359
364 for (size_t I = 0; I < LLVMStats.size(); I++) {
366 Ops[I * 2 + 1] =
367 createConstant(ConstantInt::get(Int64Ty, LLVMStats[I].second));
368 }
370}
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
This class represents an Operation in the Expression.
Implements a dense probed hash-table based set.
Class to represent integer types.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
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,...
MDNode * createCallbackEncoding(unsigned CalleeArgNo, ArrayRef< int > Arguments, bool VarArgsArePassed)
Return metadata describing a callback (see llvm::AbstractCallSite).
MDNode * createAnonymousAARoot(StringRef Name=StringRef(), MDNode *Extra=nullptr)
Return metadata appropriate for a AA root node (scope or TBAA).
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...
MDNode * createPseudoProbeDesc(uint64_t GUID, uint64_t Hash, StringRef FName)
Return metadata containing the pseudo probe descriptor for a function.
ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
MDNode * createFPMath(float Accuracy)
Return metadata with the given settings.
MDNode * createPCSections(ArrayRef< PCSection > Sections)
Return metadata for PC sections.
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,...
MDNode * createTBAARoot(StringRef Name)
Return metadata appropriate for a TBAA root node with the given name.
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
MDString * createString(StringRef Str)
Return the given string as metadata.
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...
MDNode * createIrrLoopHeaderWeight(uint64_t Weight)
Return metadata containing an irreducible loop header weight.
MDNode * createFunctionSectionPrefix(StringRef Prefix)
Return metadata containing the section prefix for a function.
MDNode * createUnpredictable()
Return metadata specifying that a branch or switch is unpredictable.
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,...
MDNode * createCallees(ArrayRef< Function * > Callees)
Return metadata indicating the possible callees of indirect calls.
MDNode * createAliasScopeDomain(StringRef Name)
Return metadata appropriate for an alias scope domain node with the given name.
MDNode * createRange(const APInt &Lo, const APInt &Hi)
Return metadata describing the range [Lo, Hi).
MDNode * createLikelyBranchWeights()
Return metadata containing two branch weights, with significant bias towards true destination.
MDNode * createTBAAStructNode(ArrayRef< TBAAStructField > Fields)
Return metadata for a tbaa.struct node with the given struct field descriptions.
MDNode * mergeCallbackEncodings(MDNode *ExistingCallbacks, MDNode *NewCB)
Merge the new callback encoding NewCB into ExistingCallbacks.
MDNode * createMutableTBAAAccessTag(MDNode *Tag)
Return mutable version of the given mutable or immutable TBAA access tag.
MDNode * createLLVMStats(ArrayRef< std::pair< StringRef, uint64_t > > LLVMStatsVec)
Return metadata containing llvm statistics.
MDNode * createRTTIPointerPrologue(Constant *PrologueSig, Constant *RTTI)
Return metadata feeding to the CodeGen about how to generate a function prologue for the "function" s...
MDNode * createUnlikelyBranchWeights()
Return metadata containing two branch weights, with significant bias towards false destination.
MDNode * createAliasScope(StringRef Name, MDNode *Domain)
Return metadata appropriate for an alias scope node with the given name.
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 ...
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,...
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 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 IntegerType * getInt1Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
void sort(IteratorTy Start, IteratorTy End)