diff options
Diffstat (limited to 'llvm/lib/Target/BPF/BTFDebug.h')
-rw-r--r-- | llvm/lib/Target/BPF/BTFDebug.h | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h index 0812c4f7915de..2f39f665299a5 100644 --- a/llvm/lib/Target/BPF/BTFDebug.h +++ b/llvm/lib/Target/BPF/BTFDebug.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/CodeGen/DebugHandlerBase.h" +#include "llvm/CodeGen/MachineInstr.h" #include <set> #include <unordered_map> #include "BTF.h" @@ -25,6 +26,7 @@ namespace llvm { class AsmPrinter; class BTFDebug; class DIType; +class GlobalVariable; class MCStreamer; class MCSymbol; class MachineFunction; @@ -61,8 +63,8 @@ class BTFTypeDerived : public BTFTypeBase { public: BTFTypeDerived(const DIDerivedType *Ty, unsigned Tag, bool NeedsFixup); - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; void setPointeeType(uint32_t PointeeType); }; @@ -72,8 +74,8 @@ class BTFTypeFwd : public BTFTypeBase { public: BTFTypeFwd(StringRef Name, bool IsUnion); - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle int type. @@ -84,9 +86,9 @@ class BTFTypeInt : public BTFTypeBase { public: BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits, uint32_t OffsetInBits, StringRef TypeName); - uint32_t getSize() { return BTFTypeBase::getSize() + sizeof(uint32_t); } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + uint32_t getSize() override { return BTFTypeBase::getSize() + sizeof(uint32_t); } + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle enumerate type. @@ -96,11 +98,11 @@ class BTFTypeEnum : public BTFTypeBase { public: BTFTypeEnum(const DICompositeType *ETy, uint32_t NumValues); - uint32_t getSize() { + uint32_t getSize() override { return BTFTypeBase::getSize() + EnumValues.size() * BTF::BTFEnumSize; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle array type. @@ -109,9 +111,9 @@ class BTFTypeArray : public BTFTypeBase { public: BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems); - uint32_t getSize() { return BTFTypeBase::getSize() + BTF::BTFArraySize; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + uint32_t getSize() override { return BTFTypeBase::getSize() + BTF::BTFArraySize; } + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle struct/union type. @@ -123,11 +125,11 @@ class BTFTypeStruct : public BTFTypeBase { public: BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, uint32_t NumMembers); - uint32_t getSize() { + uint32_t getSize() override { return BTFTypeBase::getSize() + Members.size() * BTF::BTFMemberSize; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; std::string getName(); }; @@ -140,11 +142,11 @@ class BTFTypeFuncProto : public BTFTypeBase { public: BTFTypeFuncProto(const DISubroutineType *STy, uint32_t NumParams, const std::unordered_map<uint32_t, StringRef> &FuncArgNames); - uint32_t getSize() { + uint32_t getSize() override { return BTFTypeBase::getSize() + Parameters.size() * BTF::BTFParamSize; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle subprogram @@ -153,9 +155,9 @@ class BTFTypeFunc : public BTFTypeBase { public: BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId, uint32_t Scope); - uint32_t getSize() { return BTFTypeBase::getSize(); } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + uint32_t getSize() override { return BTFTypeBase::getSize(); } + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle variable instances @@ -165,9 +167,9 @@ class BTFKindVar : public BTFTypeBase { public: BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo); - uint32_t getSize() { return BTFTypeBase::getSize() + 4; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + uint32_t getSize() override { return BTFTypeBase::getSize() + 4; } + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// Handle data sections @@ -178,15 +180,15 @@ class BTFKindDataSec : public BTFTypeBase { public: BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName); - uint32_t getSize() { + uint32_t getSize() override { return BTFTypeBase::getSize() + BTF::BTFDataSecVarSize * Vars.size(); } void addVar(uint32_t Id, const MCSymbol *Sym, uint32_t Size) { Vars.push_back(std::make_tuple(Id, Sym, Size)); } std::string getName() { return Name; } - void completeType(BTFDebug &BDebug); - void emitType(MCStreamer &OS); + void completeType(BTFDebug &BDebug) override; + void emitType(MCStreamer &OS) override; }; /// String table. @@ -249,7 +251,7 @@ class BTFDebug : public DebugHandlerBase { StringMap<std::vector<std::string>> FileContent; std::map<std::string, std::unique_ptr<BTFKindDataSec>> DataSecEntries; std::vector<BTFTypeStruct *> StructTypes; - std::map<std::string, uint32_t> PatchImms; + std::map<const GlobalVariable *, uint32_t> PatchImms; std::map<StringRef, std::pair<bool, std::vector<BTFTypeDerived *>>> FixupDerivedTypes; std::set<const Function *>ProtoFunctions; @@ -299,11 +301,11 @@ class BTFDebug : public DebugHandlerBase { void processFuncPrototypes(const Function *); /// Generate one field relocation record. - void generateFieldReloc(const MCSymbol *ORSym, DIType *RootTy, - StringRef AccessPattern); + void generatePatchImmReloc(const MCSymbol *ORSym, uint32_t RootId, + const GlobalVariable *, bool IsAma); - /// Populating unprocessed struct type. - unsigned populateStructType(const DIType *Ty); + /// Populating unprocessed type on demand. + unsigned populateType(const DIType *Ty); /// Process relocation instructions. void processReloc(const MachineOperand &MO); |