LLVM: lib/Target/BPF/BTFDebug.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_LIB_TARGET_BPF_BTFDEBUG_H
15#define LLVM_LIB_TARGET_BPF_BTFDEBUG_H
16
20#include
21#include
22#include
23#include <unordered_map>
24
25namespace llvm {
26
37
38
40protected:
45
46public:
52
54
55
56
58
60};
61
62
63
66 bool NeedsFixup;
68
69public:
75};
76
77
86
87
99
100
103 std::vector EnumValues;
104
105public:
112};
113
114
124
125
128 bool HasBitField;
129 std::vector Members;
130
131public:
140};
141
142
145 std::unordered_map<uint32_t, StringRef> FuncArgNames;
146 std::vector Parameters;
147
148public:
150 const std::unordered_map<uint32_t, StringRef> &FuncArgNames);
156};
157
158
168
169
180
181
184 std::string Name;
185 std::vector<std::tuple<uint32_t, const MCSymbol *, uint32_t>> Vars;
186
187public:
193 Vars.push_back(std::make_tuple(Id, Sym, Size));
194 }
195 std::string getName() { return Name; }
198};
199
200
208
209
220
221
224 std::vector EnumValues;
225
226public:
233};
234
244
245
247
249
250
251
252 std::map<uint32_t, uint32_t> OffsetToIdMap;
253
254 std::vectorstd::string Table;
255
256public:
259 std::vectorstd::string &getTable() { return Table; }
260
261
263};
264
265
270
271
279
280
287
288
291 bool SkipInstruction;
292 bool LineInfoGenerated;
295 bool MapDefNotCollected;
297 std::vector<std::unique_ptr> TypeEntries;
298 std::unordered_map<const DIType *, uint32_t> DIToIdMap;
299 std::map<uint32_t, std::vector> FuncInfoTable;
300 std::map<uint32_t, std::vector> LineInfoTable;
301 std::map<uint32_t, std::vector> FieldRelocTable;
303 std::map<std::string, std::unique_ptr, std::less<>>
304 DataSecEntries;
305 std::vector<BTFTypeStruct *> StructTypes;
306 std::map<const GlobalVariable *, std::pair<int64_t, uint32_t>> PatchImms;
308 std::vector<std::pair<const DIDerivedType *, BTFTypeDerived *>>>
309 FixupDerivedTypes;
310 std::set<const Function *>ProtoFunctions;
311
312
313
314
315 uint32_t addType(std::unique_ptr TypeEntry, const DIType *Ty);
316
317 uint32_t addType(std::unique_ptr TypeEntry);
318
319
320
321
322 void visitTypeEntry(const DIType *Ty);
323 void visitTypeEntry(const DIType *Ty, uint32_t &TypeId, bool CheckPointer,
324 bool SeenPointer);
326 void visitSubroutineType(
328 const std::unordered_map<uint32_t, StringRef> &FuncArgNames,
330 void visitFwdDeclType(const DICompositeType *CTy, bool IsUnion,
333 void visitStructType(const DICompositeType *STy, bool IsStruct,
338 bool CheckPointer, bool SeenPointer);
339 void visitMapDefType(const DIType *Ty, uint32_t &TypeId);
340
341
342
343 bool IsForwardDeclCandidate(const DIType *Base);
344
345
346
347 std::string populateFileContent(const DIFile *File);
348
349
352
353
354 void processGlobals(bool ProcessingMapDef);
355
356
357
358 void processGlobalInitializer(const Constant *C);
359
360
361 void processFuncPrototypes(const Function *);
362
363
364 void processDeclAnnotations(DINodeArray Annotations, uint32_t BaseTypeId,
365 int ComponentId);
366
367
370
371
372
373
374
375
376 int genBTFTypeTags(const DIDerivedType *DTy, int BaseTypeId);
377
378
379 void generatePatchImmReloc(const MCSymbol *ORSym, uint32_t RootId,
381
382
383 unsigned populateType(const DIType *Ty);
384
385
386
388
389
390 void emitCommonHeader();
391
392
393 void emitBTFSection();
394
395
396 void emitBTFExtSection();
397
398protected:
399
401
402
404
405public:
407
408
410
411
413 assert(ArrayIndexTypeId);
414 return ArrayIndexTypeId;
415 }
416
417
419
420
422 assert(Ty && "Invalid null Type");
423 assert(DIToIdMap.find(Ty) != DIToIdMap.end() &&
424 "DIType not added in the BDIToIdMap");
425 return DIToIdMap[Ty];
426 }
427
428
430
431
433};
434
435}
436
437#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file contains the layout of .BTF and .BTF.ext ELF sections.
Annotations lets you mark points and ranges inside source code, for tests:
This class is intended to be used as a driving class for all asm writers.
Collect and emit BTF information.
Definition BTFDebug.h:289
void endFunctionImpl(const MachineFunction *MF) override
Post process after all instructions in this function are processed.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
bool InstLower(const MachineInstr *MI, MCInst &OutMI)
Emit proper patchable instructions.
size_t addString(StringRef S)
Add string to the string table.
Definition BTFDebug.h:418
uint32_t getArrayIndexTypeId()
Get the special array index type id.
Definition BTFDebug.h:412
uint32_t getTypeId(const DIType *Ty)
Get the type id for a particular DIType.
Definition BTFDebug.h:421
void endModule() override
Complete all the types and emit the BTF sections.
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void addDataSecEntry(uint32_t Id, const MCSymbol *Sym, uint32_t Size)
Definition BTFDebug.h:192
BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName)
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:189
std::string getName()
Definition BTFDebug.h:195
BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:176
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
String table.
Definition BTFDebug.h:246
BTFStringTable()
Definition BTFDebug.h:257
uint32_t getSize()
Definition BTFDebug.h:258
uint32_t addString(StringRef S)
Add a string to the string table and returns its offset in the table.
std::vector< std::string > & getTable()
Definition BTFDebug.h:259
BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Represent a BTF array.
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:120
uint8_t Kind
Definition BTFDebug.h:41
void setId(uint32_t Id)
Definition BTFDebug.h:49
struct BTF::CommonType BTFType
Definition BTFDebug.h:44
BTFTypeBase()
Definition BTFDebug.h:47
virtual uint32_t getSize()
Get the size of this BTF type entry.
Definition BTFDebug.h:53
virtual void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
Definition BTFDebug.h:57
bool IsCompleted
Definition BTFDebug.h:42
uint32_t Id
Definition BTFDebug.h:43
virtual ~BTFTypeBase()=default
virtual void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
uint32_t getId()
Definition BTFDebug.h:50
uint32_t roundupToBytes(uint32_t NumBits)
Definition BTFDebug.h:51
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:216
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void setPointeeType(uint32_t PointeeType)
BTFTypeDerived(const DIDerivedType *Ty, unsigned Tag, bool NeedsFixup)
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:228
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeEnum64(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:107
BTFTypeEnum(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeFloat(uint32_t SizeInBits, StringRef TypeName)
BTFTypeFuncProto(const DISubroutineType *STy, uint32_t NumParams, const std::unordered_map< uint32_t, StringRef > &FuncArgNames)
The Func kind represents both subprogram and pointee of function pointers.
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:151
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId, uint32_t Scope)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:164
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
BTFTypeFwd(StringRef Name, bool IsUnion)
Represent a struct/union forward declaration.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:95
BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits, uint32_t OffsetInBits, StringRef TypeName)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
Definition BTFDebug.h:134
BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, uint32_t NumMembers)
Represent either a struct or a union.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTFTypeTypeTag(uint32_t NextTypeId, StringRef Tag)
This is an important base class in LLVM.
Basic type, like 'int' or 'float'.
Subprogram description. Uses SubclassData1.
Type array for a subprogram.
DebugHandlerBase(AsmPrinter *A)
Instances of this class represent a single low-level machine instruction.
Streaming machine code generation interface.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Represent one field relocation.
Definition BTFDebug.h:281
uint32_t RelocKind
What to patch the instruction.
Definition BTFDebug.h:285
const MCSymbol * Label
MCSymbol identifying insn for the reloc.
Definition BTFDebug.h:282
uint32_t TypeID
Type ID.
Definition BTFDebug.h:283
uint32_t OffsetNameOff
The string to traverse types.
Definition BTFDebug.h:284
Represent one func and its type id.
Definition BTFDebug.h:266
uint32_t TypeId
Type id referring to .BTF type section.
Definition BTFDebug.h:268
const MCSymbol * Label
Func MCSymbol.
Definition BTFDebug.h:267
Represent one line info.
Definition BTFDebug.h:272
uint32_t LineOff
line offset in the .BTF string table
Definition BTFDebug.h:275
MCSymbol * Label
MCSymbol identifying insn for the lineinfo.
Definition BTFDebug.h:273
uint32_t ColumnNum
the column number
Definition BTFDebug.h:277
uint32_t FileNameOff
file name offset in the .BTF string table
Definition BTFDebug.h:274
uint32_t LineNum
the line number
Definition BTFDebug.h:276
BTF_KIND_ARRAY is followed by one "struct BTFArray".
The BTF common type definition.