14#ifndef LLVM_LIB_TARGET_BPF_BTFDEBUG_H
15#define LLVM_LIB_TARGET_BPF_BTFDEBUG_H
23#include <unordered_map>
103 std::vector<struct BTF::BTFEnum> EnumValues;
129 std::vector<struct BTF::BTFMember> Members;
145 std::unordered_map<uint32_t, StringRef> FuncArgNames;
146 std::vector<struct BTF::BTFParam> Parameters;
150 const std::unordered_map<uint32_t, StringRef> &FuncArgNames);
185 std::vector<std::tuple<uint32_t, const MCSymbol *, uint32_t>> Vars;
193 Vars.push_back(std::make_tuple(
Id,
Sym,
Size));
224 std::vector<struct BTF::BTFEnum64> EnumValues;
252 std::map<uint32_t, uint32_t> OffsetToIdMap;
254 std::vector<std::string> Table;
259 std::vector<std::string> &
getTable() {
return Table; }
291 bool SkipInstruction;
292 bool LineInfoGenerated;
295 bool MapDefNotCollected;
297 std::vector<std::unique_ptr<BTFTypeBase>> TypeEntries;
298 std::unordered_map<const DIType *, uint32_t> DIToIdMap;
299 std::map<uint32_t, std::vector<BTFFuncInfo>> FuncInfoTable;
300 std::map<uint32_t, std::vector<BTFLineInfo>> LineInfoTable;
301 std::map<uint32_t, std::vector<BTFFieldReloc>> FieldRelocTable;
303 std::map<std::string, std::unique_ptr<BTFKindDataSec>> DataSecEntries;
304 std::vector<BTFTypeStruct *> StructTypes;
305 std::map<const GlobalVariable *, std::pair<int64_t, uint32_t>> PatchImms;
307 std::vector<std::pair<const DIDerivedType *, BTFTypeDerived *>>>
309 std::set<const Function *>ProtoFunctions;
314 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry,
const DIType *Ty);
316 uint32_t addType(std::unique_ptr<BTFTypeBase> TypeEntry);
321 void visitTypeEntry(
const DIType *Ty);
322 void visitTypeEntry(
const DIType *Ty,
uint32_t &TypeId,
bool CheckPointer,
325 void visitSubroutineType(
327 const std::unordered_map<uint32_t, StringRef> &FuncArgNames,
337 bool CheckPointer,
bool SeenPointer);
342 bool IsForwardDeclCandidate(
const DIType *
Base);
346 std::string populateFileContent(
const DIFile *File);
353 void processGlobals(
bool ProcessingMapDef);
357 void processGlobalInitializer(
const Constant *
C);
360 void processFuncPrototypes(
const Function *);
375 int genBTFTypeTags(
const DIDerivedType *DTy,
int BaseTypeId);
382 unsigned populateType(
const DIType *Ty);
389 void emitCommonHeader();
392 void emitBTFSection();
395 void emitBTFExtSection();
413 return ArrayIndexTypeId;
421 assert(Ty &&
"Invalid null Type");
422 assert(DIToIdMap.find(Ty) != DIToIdMap.end() &&
423 "DIType not added in the BDIToIdMap");
424 return DIToIdMap[Ty];
This file defines the StringMap class.
This file contains the layout of .BTF and .BTF.ext ELF sections.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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.
uint32_t getArrayIndexTypeId()
Get the special array index type id.
uint32_t getTypeId(const DIType *Ty)
Get the type id for a particular DIType.
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)
uint32_t getSize() override
Get the size of this BTF type entry.
Handle variable instances.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of 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 addString(StringRef S)
Add a string to the string table and returns its offset in the table.
std::vector< std::string > & getTable()
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.
The base class for BTF type generation.
struct BTF::CommonType BTFType
virtual uint32_t getSize()
Get the size of this BTF type entry.
virtual void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
virtual ~BTFTypeBase()=default
virtual void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
uint32_t roundupToBytes(uint32_t NumBits)
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.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
Handle several derived types include pointer, const, volatile, typedef and restrict.
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)
Handle 64-bit enumerate type.
uint32_t getSize() override
Get the size of 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 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.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
Handle binary floating point type.
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.
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.
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.
Handle struct or union forward declaration.
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 emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of 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...
Handle struct/union type.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of 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 completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
This is an important base class in LLVM.
Basic type, like 'int' or 'float'.
Type array for a subprogram.
Base class for debug information backends.
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.
uint32_t RelocKind
What to patch the instruction.
const MCSymbol * Label
MCSymbol identifying insn for the reloc.
uint32_t OffsetNameOff
The string to traverse types.
Represent one func and its type id.
uint32_t TypeId
Type id referring to .BTF type section.
const MCSymbol * Label
Func MCSymbol.
uint32_t LineOff
line offset in the .BTF string table
MCSymbol * Label
MCSymbol identifying insn for the lineinfo.
uint32_t ColumnNum
the column number
uint32_t FileNameOff
file name offset in the .BTF string table
uint32_t LineNum
the line number
BTF_KIND_ARRAY is followed by one "struct BTFArray".
The BTF common type definition.