Go to the documentation of this file.
14 #ifndef LLVM_LIB_TARGET_BPF_BTFDEBUG_H
15 #define LLVM_LIB_TARGET_BPF_BTFDEBUG_H
22 #include <unordered_map>
31 class MachineFunction;
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);
343 std::string populateFileContent(
const DISubprogram *SP);
350 void processGlobals(
bool ProcessingMapDef);
353 void processFuncPrototypes(
const Function *);
364 int genBTFTypeTags(
const DIDerivedType *DTy,
int BaseTypeId);
371 unsigned populateType(
const DIType *Ty);
378 void emitCommonHeader();
381 void emitBTFSection();
384 void emitBTFExtSection();
402 return ArrayIndexTypeId;
410 assert(Ty &&
"Invalid null Type");
411 assert(DIToIdMap.find(Ty) != DIToIdMap.end() &&
412 "DIType not added in the BDIToIdMap");
413 return DIToIdMap[Ty];
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
uint32_t OffsetNameOff
The string to traverse types.
Handle binary floating point type.
void setPointeeType(uint32_t PointeeType)
This is an optimization pass for GlobalISel generic memory operations.
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCSymbol * Label
Func MCSymbol.
Handle struct or union forward declaration.
bool InstLower(const MachineInstr *MI, MCInst &OutMI)
Emit proper patchable instructions.
uint32_t getSize() override
Get the size of this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t FileNameOff
file name offset in the .BTF string table
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
const MCSymbol * Label
MCSymbol identifying insn for the reloc.
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.
BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName)
uint32_t getSize() override
Get the size of this BTF type entry.
std::vector< std::string > & getTable()
Instances of this class represent a single low-level machine instruction.
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 getTypeId(const DIType *Ty)
Get the type id for a particular DIType.
Annotations lets you mark points and ranges inside source code, for tests:
Handle variable instances.
BTFTypeFloat(uint32_t SizeInBits, StringRef TypeName)
BTFTypeDerived(const DIDerivedType *Ty, unsigned Tag, bool NeedsFixup)
Streaming machine code generation interface.
uint32_t ColumnNum
the column number
BTFTypeTypeTag(uint32_t NextTypeId, StringRef Tag)
uint32_t addString(StringRef S)
Add a string to the string table and returns its offset in the table.
virtual uint32_t getSize()
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...
virtual ~BTFTypeBase()=default
struct BTF::CommonType BTFType
MachineOperand class - Representation of each machine instruction operand.
Handle several derived types include pointer, const, volatile, typedef and restrict.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
size_t addString(StringRef S)
Add string to the string table.
BTFTypeFwd(StringRef Name, bool IsUnion)
Represent a struct/union forward declaration.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Collect and emit BTF information.
BTFTypeEnum(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
Represent one func and its type id.
Representation of each machine instruction.
uint32_t LineNum
the line number
uint32_t getSize() override
Get the size of this BTF type entry.
void addDataSecEntry(uint32_t Id, const MCSymbol *Sym, uint32_t Size)
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 getSize() override
Get the size of this BTF type entry.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * Label
MCSymbol identifying insn for the lineinfo.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
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.
BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, uint32_t NumMembers)
Represent either a struct or a union.
void endFunctionImpl(const MachineFunction *MF) override
Post process after all instructions in this function are processed.
Basic type, like 'int' or 'float'.
BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits, uint32_t OffsetInBits, StringRef TypeName)
Type array for a subprogram.
The BTF common type definition.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
Represent one field relocation.
StringRef - Represent a constant reference to a string, i.e.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
uint32_t getArrayIndexTypeId()
Get the special array index type id.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
uint32_t getSize() override
Get the size of this BTF type entry.
uint32_t TypeId
Type id referring to .BTF type section.
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
void completeType(BTFDebug &BDebug) override
Represent a BTF array.
virtual void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
uint32_t getSize() override
Get the size of this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
This class is intended to be used as a driving class for all asm writers.
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.
BTFTypeEnum64(const DICompositeType *ETy, uint32_t NumValues, bool IsSigned)
uint32_t RelocKind
What to patch the instruction.
Handle struct/union type.
void setSymbolSize(const MCSymbol *Symbol, uint64_t Size) override
For symbols that have a size designated (e.g.
BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId, uint32_t Scope)
Base class for debug information backends.
BTFTypeDeclTag(uint32_t BaseTypeId, int ComponentId, StringRef Tag)
uint32_t LineOff
line offset in the .BTF string table
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.
uint32_t getSize() override
Get the size of this BTF type entry.
BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems)
Handle 64-bit enumerate type.
virtual void completeType(BTFDebug &BDebug)
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...
void completeType(BTFDebug &BDebug) override
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
void endModule() override
Complete all the types and emit the BTF sections.
BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo)
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
void emitType(MCStreamer &OS) override
Emit types for this BTF type entry.
The base class for BTF type generation.
BTF_KIND_ARRAY is followed by one "struct BTFArray".
uint32_t roundupToBytes(uint32_t NumBits)