29 #define HANDLE_BTF_KIND(ID, NAME) "BTF_KIND_" #NAME, 45 : DTy(DTy), NeedsFixup(NeedsFixup) {
47 case dwarf::DW_TAG_pointer_type:
48 Kind = BTF::BTF_KIND_PTR;
50 case dwarf::DW_TAG_const_type:
51 Kind = BTF::BTF_KIND_CONST;
53 case dwarf::DW_TAG_volatile_type:
54 Kind = BTF::BTF_KIND_VOLATILE;
56 case dwarf::DW_TAG_typedef:
57 Kind = BTF::BTF_KIND_TYPEDEF;
59 case dwarf::DW_TAG_restrict_type:
60 Kind = BTF::BTF_KIND_RESTRICT;
79 const DIType *ResolvedType = DTy->getBaseType();
81 assert((
Kind == BTF::BTF_KIND_PTR ||
Kind == BTF::BTF_KIND_CONST ||
82 Kind == BTF::BTF_KIND_VOLATILE) &&
83 "Invalid null basetype");
98 Kind = BTF::BTF_KIND_FWD;
119 case dwarf::DW_ATE_boolean:
122 case dwarf::DW_ATE_signed:
123 case dwarf::DW_ATE_signed_char:
126 case dwarf::DW_ATE_unsigned:
127 case dwarf::DW_ATE_unsigned_char:
134 Kind = BTF::BTF_KIND_INT;
137 IntVal = (BTFEncoding << 24) | OffsetInBits << 16 | SizeInBits;
155 Kind = BTF::BTF_KIND_ENUM;
168 for (
const auto Element : Elements) {
169 const auto *Enum = cast<DIEnumerator>(Element);
174 BTFEnum.
Val =
static_cast<uint32_t>(Enum->getValue());
175 EnumValues.push_back(BTFEnum);
181 for (
const auto &Enum : EnumValues) {
188 Kind = BTF::BTF_KIND_ARRAY;
193 ArrayInfo.ElemType = ElemTypeId;
194 ArrayInfo.Nelems = NumElems;
220 : STy(STy), HasBitField(HasBitField) {
221 Kind = IsStruct ? BTF::BTF_KIND_STRUCT : BTF::BTF_KIND_UNION;
235 for (
const auto *Element : Elements) {
237 const auto *DDTy = cast<DIDerivedType>(Element);
241 uint8_t BitFieldSize = DDTy->isBitField() ? DDTy->getSizeInBits() : 0;
242 BTFMember.
Offset = BitFieldSize << 24 | DDTy->getOffsetInBits();
244 BTFMember.
Offset = DDTy->getOffsetInBits();
246 const auto *BaseTy = DDTy->getBaseType();
248 Members.push_back(BTFMember);
254 for (
const auto &Member : Members) {
271 const std::unordered_map<uint32_t, StringRef> &FuncArgNames)
272 : STy(STy), FuncArgNames(FuncArgNames) {
273 Kind = BTF::BTF_KIND_FUNC_PROTO;
283 auto RetType = Elements[0];
289 for (
unsigned I = 1,
N = Elements.
size();
I <
N; ++
I) {
291 auto Element = Elements[
I];
299 Parameters.push_back(Param);
305 for (
const auto &Param : Parameters) {
314 Kind = BTF::BTF_KIND_FUNC;
331 Kind = BTF::BTF_KIND_VAR;
348 Kind = BTF::BTF_KIND_DATASEC;
361 for (
const auto &V : Vars) {
363 Asm->EmitLabelReference(std::get<1>(V), 4);
370 for (
auto &OffsetM : OffsetToIdMap) {
371 if (Table[OffsetM.second] == S)
372 return OffsetM.first;
376 OffsetToIdMap[
Offset] = Table.size();
384 LineInfoGenerated(
false), SecNameOff(0), ArrayIndexTypeId(0),
385 MapDefNotCollected(
true) {
389 uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry,
391 TypeEntry->setId(TypeEntries.size() + 1);
394 TypeEntries.push_back(std::move(TypeEntry));
398 uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry) {
399 TypeEntry->setId(TypeEntries.size() + 1);
401 TypeEntries.push_back(std::move(TypeEntry));
408 if (Encoding != dwarf::DW_ATE_boolean && Encoding != dwarf::DW_ATE_signed &&
409 Encoding != dwarf::DW_ATE_signed_char &&
410 Encoding != dwarf::DW_ATE_unsigned &&
411 Encoding != dwarf::DW_ATE_unsigned_char)
416 auto TypeEntry = std::make_unique<BTFTypeInt>(
418 TypeId = addType(std::move(TypeEntry), BTy);
422 void BTFDebug::visitSubroutineType(
424 const std::unordered_map<uint32_t, StringRef> &FuncArgNames,
435 auto TypeEntry = std::make_unique<BTFTypeFuncProto>(STy, VLen, FuncArgNames);
437 TypeId = addType(std::move(TypeEntry));
439 TypeId = addType(std::move(TypeEntry), STy);
442 for (
const auto Element : Elements) {
443 visitTypeEntry(Element);
448 void BTFDebug::visitStructType(
const DICompositeType *CTy,
bool IsStruct,
456 bool HasBitField =
false;
457 for (
const auto *Element : Elements) {
458 auto E = cast<DIDerivedType>(Element);
459 if (
E->isBitField()) {
466 std::make_unique<BTFTypeStruct>(CTy, IsStruct, HasBitField, VLen);
467 StructTypes.push_back(TypeEntry.get());
468 TypeId = addType(std::move(TypeEntry), CTy);
471 for (
const auto *Element : Elements)
472 visitTypeEntry(cast<DIDerivedType>(Element));
479 visitTypeEntry(ElemType, ElemTypeId,
false,
false);
483 for (
int I = Elements.size() - 1;
I >= 0; --
I) {
484 if (
auto *Element = dyn_cast_or_null<DINode>(Elements[
I]))
485 if (Element->getTag() == dwarf::DW_TAG_subrange_type) {
486 const DISubrange *SR = cast<DISubrange>(Element);
493 std::make_unique<BTFTypeArray>(ElemTypeId,
494 Count >= 0 ? Count : 0);
496 ElemTypeId = addType(std::move(TypeEntry), CTy);
498 ElemTypeId = addType(std::move(TypeEntry));
507 if (!ArrayIndexTypeId) {
508 auto TypeEntry = std::make_unique<BTFTypeInt>(dwarf::DW_ATE_unsigned, 32,
509 0,
"__ARRAY_SIZE_TYPE__");
510 ArrayIndexTypeId = addType(std::move(TypeEntry));
520 auto TypeEntry = std::make_unique<BTFTypeEnum>(CTy, VLen);
521 TypeId = addType(std::move(TypeEntry), CTy);
526 void BTFDebug::visitFwdDeclType(
const DICompositeType *CTy,
bool IsUnion,
528 auto TypeEntry = std::make_unique<BTFTypeFwd>(CTy->
getName(), IsUnion);
529 TypeId = addType(std::move(TypeEntry), CTy);
536 if (
Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type) {
539 visitFwdDeclType(CTy,
Tag == dwarf::DW_TAG_union_type, TypeId);
541 visitStructType(CTy,
Tag == dwarf::DW_TAG_structure_type, TypeId);
542 }
else if (
Tag == dwarf::DW_TAG_array_type)
543 visitArrayType(CTy, TypeId);
544 else if (
Tag == dwarf::DW_TAG_enumeration_type)
545 visitEnumType(CTy, TypeId);
550 bool CheckPointer,
bool SeenPointer) {
555 if (CheckPointer && !SeenPointer) {
556 SeenPointer = Tag == dwarf::DW_TAG_pointer_type;
559 if (CheckPointer && SeenPointer) {
562 if (
const auto *CTy = dyn_cast<DICompositeType>(Base)) {
563 auto CTag = CTy->
getTag();
564 if ((CTag == dwarf::DW_TAG_structure_type ||
565 CTag == dwarf::DW_TAG_union_type) &&
570 auto TypeEntry = std::make_unique<BTFTypeDerived>(DTy,
Tag,
true);
572 Fixup.first = CTag == dwarf::DW_TAG_union_type;
573 Fixup.second.push_back(TypeEntry.get());
574 TypeId = addType(std::move(TypeEntry), DTy);
581 if (Tag == dwarf::DW_TAG_pointer_type || Tag == dwarf::DW_TAG_typedef ||
582 Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type ||
583 Tag == dwarf::DW_TAG_restrict_type) {
584 auto TypeEntry = std::make_unique<BTFTypeDerived>(DTy,
Tag,
false);
585 TypeId = addType(std::move(TypeEntry), DTy);
586 }
else if (Tag != dwarf::DW_TAG_member) {
593 if (Tag == dwarf::DW_TAG_member)
594 visitTypeEntry(DTy->getBaseType(), TempTypeId,
true,
false);
596 visitTypeEntry(DTy->getBaseType(), TempTypeId, CheckPointer, SeenPointer);
600 bool CheckPointer,
bool SeenPointer) {
601 if (!Ty || DIToIdMap.find(Ty) != DIToIdMap.end()) {
602 TypeId = DIToIdMap[Ty];
606 if (
const auto *BTy = dyn_cast<DIBasicType>(Ty))
607 visitBasicType(BTy, TypeId);
608 else if (
const auto *STy = dyn_cast<DISubroutineType>(Ty))
609 visitSubroutineType(STy,
false, std::unordered_map<uint32_t, StringRef>(),
611 else if (
const auto *CTy = dyn_cast<DICompositeType>(Ty))
612 visitCompositeType(CTy, TypeId);
613 else if (
const auto *DTy = dyn_cast<DIDerivedType>(Ty))
614 visitDerivedType(DTy, TypeId, CheckPointer, SeenPointer);
619 void BTFDebug::visitTypeEntry(
const DIType *Ty) {
621 visitTypeEntry(Ty, TypeId,
false,
false);
624 void BTFDebug::visitMapDefType(
const DIType *Ty,
uint32_t &TypeId) {
625 if (!Ty || DIToIdMap.find(Ty) != DIToIdMap.end()) {
626 TypeId = DIToIdMap[Ty];
641 bool HasBitField =
false;
642 for (
const auto *Element : Elements) {
643 auto E = cast<DIDerivedType>(Element);
644 if (
E->isBitField()) {
651 std::make_unique<BTFTypeStruct>(CTy,
true, HasBitField, Elements.size());
652 StructTypes.push_back(TypeEntry.get());
653 TypeId = addType(std::move(TypeEntry), CTy);
656 for (
const auto *Element : Elements) {
657 const auto *MemberType = cast<DIDerivedType>(Element);
658 visitTypeEntry(MemberType->getBaseType());
663 std::string BTFDebug::populateFileContent(
const DISubprogram *
SP) {
665 std::string FileName;
667 if (!
File->getFilename().startswith(
"/") &&
File->getDirectory().size())
668 FileName =
File->getDirectory().str() +
"/" +
File->getFilename().str();
670 FileName =
File->getFilename();
673 if (FileContent.
find(FileName) != FileContent.
end())
676 std::vector<std::string> Content;
678 Content.push_back(Line);
680 std::unique_ptr<MemoryBuffer> Buf;
684 else if (
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
686 Buf = std::move(*BufOrErr);
689 Content.push_back(*
I);
691 FileContent[FileName] = Content;
697 std::string FileName = populateFileContent(SP);
700 LineInfo.
Label = Label;
703 if (Line < FileContent[FileName].
size())
709 LineInfoTable[SecNameOff].push_back(LineInfo);
712 void BTFDebug::emitCommonHeader() {
719 void BTFDebug::emitBTFSection() {
721 if (!TypeEntries.size() && StringTable.
getSize() == 1)
732 for (
const auto &TypeEntry : TypeEntries)
733 TypeLen += TypeEntry->getSize();
734 StrLen = StringTable.
getSize();
742 for (
const auto &TypeEntry : TypeEntries)
743 TypeEntry->emitType(OS);
747 for (
const auto &S : StringTable.
getTable()) {
751 StringOffset += S.size() + 1;
755 void BTFDebug::emitBTFExtSection() {
758 if (!FuncInfoTable.size() && !LineInfoTable.size() &&
759 !FieldRelocTable.size())
773 for (
const auto &FuncSec : FuncInfoTable) {
777 for (
const auto &LineSec : LineInfoTable) {
781 for (
const auto &FieldRelocSec : FieldRelocTable) {
799 for (
const auto &FuncSec : FuncInfoTable) {
800 OS.
AddComment(
"FuncInfo section string offset=" +
804 for (
const auto &FuncInfo : FuncSec.second) {
813 for (
const auto &LineSec : LineInfoTable) {
814 OS.
AddComment(
"LineInfo section string offset=" +
818 for (
const auto &LineInfo : LineSec.second) {
824 OS.
EmitIntValue(LineInfo.LineNum << 10 | LineInfo.ColumnNum, 4);
832 for (
const auto &FieldRelocSec : FieldRelocTable) {
833 OS.
AddComment(
"Field reloc section string offset=" +
837 for (
const auto &FieldRelocInfo : FieldRelocSec.second) {
849 auto *Unit = SP->getUnit();
852 SkipInstruction =
true;
855 SkipInstruction =
false;
876 if (MapDefNotCollected) {
877 processGlobals(
true);
878 MapDefNotCollected =
false;
884 std::unordered_map<uint32_t, StringRef> FuncArgNames;
885 for (
const DINode *DN : SP->getRetainedNodes()) {
886 if (
const auto *DV = dyn_cast<DILocalVariable>(DN)) {
890 visitTypeEntry(DV->getType());
891 FuncArgNames[
Arg] = DV->getName();
898 visitSubroutineType(SP->getType(),
true, FuncArgNames, ProtoTypeId);
903 std::make_unique<BTFTypeFunc>(SP->
getName(), ProtoTypeId,
Scope);
904 uint32_t FuncTypeId = addType(std::move(FuncTypeEntry));
906 for (
const auto &TypeEntry : TypeEntries)
907 TypeEntry->completeType(*
this);
912 FuncInfo.
Label = FuncLabel;
913 FuncInfo.
TypeId = FuncTypeId;
917 assert(SectionELF &&
"Null section for Function Label");
922 FuncInfoTable[SecNameOff].push_back(FuncInfo);
926 SkipInstruction =
false;
927 LineInfoGenerated =
false;
933 unsigned BTFDebug::populateStructType(
const DIType *Ty) {
935 visitTypeEntry(Ty, Id,
false,
false);
936 for (
const auto &TypeEntry : TypeEntries)
937 TypeEntry->completeType(*
this);
942 void BTFDebug::generateFieldReloc(
const MCSymbol *ORSym,
DIType *RootTy,
944 unsigned RootId = populateStructType(RootTy);
947 size_t SecondColon = AccessPattern.
find_first_of(
':', FirstColon + 1);
950 SecondColon - FirstColon);
952 FirstDollar - SecondColon);
955 FieldReloc.
Label = ORSym;
957 FieldReloc.
TypeID = RootId;
958 FieldReloc.
RelocKind = std::stoull(RelocKindStr);
959 PatchImms[AccessPattern.
str()] = std::stoul(PatchImmStr);
960 FieldRelocTable[SecNameOff].push_back(FieldReloc);
972 MDNode *MDN = GVar->getMetadata(LLVMContext::MD_preserve_access_index);
974 generateFieldReloc(ORSym, Ty, GVar->
getName());
988 unsigned NumDefs = 0;
1012 }
else if (MI->
getOpcode() == BPF::CORE_MEM ||
1013 MI->
getOpcode() == BPF::CORE_ALU32_MEM ||
1017 }
else if (MI->
getOpcode() == BPF::JAL) {
1021 processFuncPrototypes(dyn_cast<Function>(MO.
getGlobal()));
1031 if (LineInfoGenerated ==
false) {
1034 constructLineInfo(S, FuncLabel, S->getLine(), 0);
1035 LineInfoGenerated =
true;
1046 auto SP = DL.
get()->getScope()->getSubprogram();
1049 LineInfoGenerated =
true;
1053 void BTFDebug::processGlobals(
bool ProcessingMapDef) {
1059 if (Global.hasSection()) {
1060 SecName = Global.getSection();
1061 }
else if (Global.hasInitializer()) {
1063 if (Global.isConstant())
1064 SecName =
".rodata";
1066 SecName = Global.getInitializer()->isZeroValue() ?
".bss" :
".data";
1070 SecName =
".extern";
1073 if (ProcessingMapDef != SecName.
startswith(
".maps"))
1077 Global.getDebugInfo(GVs);
1080 if (GVs.
size() == 0)
1084 for (
auto *GVE : GVs) {
1086 visitMapDefType(GVE->getVariable()->getType(), GVTypeId);
1088 visitTypeEntry(GVE->getVariable()->getType(), GVTypeId,
false,
false);
1099 auto Linkage = Global.getLinkage();
1109 }
else if (Global.hasInitializer()) {
1116 std::make_unique<BTFKindVar>(Global.getName(), GVTypeId, GVarInfo);
1117 uint32_t VarId = addType(std::move(VarEntry));
1122 if (DataSecEntries.find(SecName) == DataSecEntries.end()) {
1123 DataSecEntries[SecName] = std::make_unique<BTFKindDataSec>(
Asm, SecName);
1127 const DataLayout &DL = Global.getParent()->getDataLayout();
1128 uint32_t Size = DL.getTypeAllocSize(Global.getType()->getElementType());
1143 uint32_t Imm = PatchImms[GVar->getName().str()];
1150 }
else if (MI->
getOpcode() == BPF::CORE_MEM ||
1151 MI->
getOpcode() == BPF::CORE_ALU32_MEM ||
1158 uint32_t Imm = PatchImms[GVar->getName().str()];
1173 void BTFDebug::processFuncPrototypes(
const Function *
F) {
1178 if (!SP || SP->isDefinition())
1182 if (ProtoFunctions.find(F) != ProtoFunctions.end())
1184 ProtoFunctions.insert(F);
1187 const std::unordered_map<uint32_t, StringRef> FuncArgNames;
1188 visitSubroutineType(SP->getType(),
false, FuncArgNames, ProtoTypeId);
1191 auto FuncTypeEntry =
1192 std::make_unique<BTFTypeFunc>(SP->
getName(), ProtoTypeId,
Scope);
1193 addType(std::move(FuncTypeEntry));
1198 if (MapDefNotCollected) {
1199 processGlobals(
true);
1200 MapDefNotCollected =
false;
1204 processGlobals(
false);
1206 for (
auto &DataSec : DataSecEntries)
1207 addType(std::move(DataSec.second));
1210 for (
auto &
Fixup : FixupDerivedTypes) {
1212 bool IsUnion =
Fixup.second.first;
1223 if (StructTypeId == 0) {
1224 auto FwdTypeEntry = std::make_unique<BTFTypeFwd>(
TypeName, IsUnion);
1225 StructTypeId = addType(std::move(FwdTypeEntry));
1228 for (
auto &DType :
Fixup.second.second) {
1229 DType->setPointeeType(StructTypeId);
1234 for (
const auto &TypeEntry : TypeEntries)
1235 TypeEntry->completeType(*
this);
1239 emitBTFExtSection();
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
uint32_t RelocKind
What to patch the instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
A parsed version of the target data layout string in and methods for querying it. ...
BTFTypeArray(uint32_t ElemTypeId, uint32_t NumElems)
Represents either an error or a value T.
uint64_t getOffsetInBits() const
void endFunctionImpl(const MachineFunction *MF) override
Post process after all instructions in this function are processed.
DILocation * get() const
Get the underlying DILocation.
Represent one func and its type id.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
BTFKindDataSec(AsmPrinter *AsmPrt, std::string SecName)
uint32_t ColumnNum
the column number
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
uint32_t getArrayIndexTypeId()
Get the special array index type id.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
BTFTypeEnum(const DICompositeType *ETy, uint32_t NumValues)
iterator find(StringRef Key)
Externally visible function.
BTFTypeInt(uint32_t Encoding, uint32_t SizeInBits, uint32_t OffsetInBits, StringRef TypeName)
A forward iterator which reads text lines from a buffer.
void completeType(BTFDebug &BDebug)
Represent a BTF array.
block Block Frequency true
bool isMetaInstruction() const
Return true if this instruction doesn't produce any output in the form of executable instructions...
bool isForwardDecl() const
static const char * BTFKindStr[]
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
uint32_t Offset
BitOffset or BitFieldSize+BitOffset.
StringRef getName() const
Tagged DWARF-like metadata node.
DINodeArray getElements() const
uint32_t Type
Member type.
MCContext & getContext() const
DebugLoc PrevInstLoc
Previous instruction's location information.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
BTFTypeDerived(const DIDerivedType *Ty, unsigned Tag, bool NeedsFixup)
Max # of struct/union/enum members or func args.
static MCOperand createReg(unsigned Reg)
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
Class to represent struct types.
virtual void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
BTF_KIND_ENUM is followed by multiple "struct BTFEnum".
BTFKindVar(StringRef VarName, uint32_t TypeId, uint32_t VarInfo)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
uint32_t roundupToBytes(uint32_t NumBits)
uint64_t getSizeInBits() const
const char * getSymbolName() const
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
Context object for machine code objects.
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
DIType * getBaseType() const
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
MCSymbol * getFunctionBegin() const
LLVM_NODISCARD size_t size() const
size - Get the string size.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Represent one field relocation.
BTF_KIND_FUNC_PROTO are followed by multiple "struct BTFParam".
Instances of this class represent a single low-level machine instruction.
Analysis containing CSE Info
void endModule() override
Complete all the types and emit the BTF sections.
ExternalWeak linkage description.
BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, uint32_t NumMembers)
Represent either a struct or a union.
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
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)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
DISubprogram * getSubprogram() const
Get the attached subprogram.
Instrumentation for Order File
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
CountType getCount() const
struct BTF::CommonType BTFType
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
const GlobalValue * getGlobal() const
AsmPrinter * Asm
Target of debug info emission.
Collect and emit BTF information.
This class is intended to be used as a driving class for all asm writers.
uint32_t NameOff
Member name offset in the string table.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
bool InstLower(const MachineInstr *MI, MCInst &OutMI)
Emit proper patchable instructions.
StringRef getName() const
Return the name for this struct type if it has an identity.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
Linkage: ExternalLinkage.
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void EmitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Linkage: ExternalLinkage.
BTF_KIND_STRUCT and BTF_KIND_UNION are followed by multiple "struct BTFMember".
uint32_t NameOff
Type name offset in the string table.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PowerPC TLS Dynamic Call Fixup
std::vector< std::string > & getTable()
void setOpcode(unsigned Op)
This is the shared class of boolean and integer constants.
uint32_t LineNum
the line number
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
StringRef getName() const
MCSymbol * getSymbol(const GlobalValue *GV) const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
int32_t Val
Enum member value.
uint32_t NameOff
Enum name offset in the string table.
void setPointeeType(uint32_t PointeeType)
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
MCSymbol * Label
MCSymbol identifying insn for the lineinfo.
static Twine utohexstr(const uint64_t &Val)
uint32_t getTypeId(const DIType *Ty)
Get the type id for a particular DIType.
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it...
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
This file contains support for writing BTF debug info.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
Type array for a subprogram.
Representation of each machine instruction.
uint32_t OffsetNameOff
The string to traverse types.
uint32_t addString(StringRef S)
Add a string to the string table and returns its offset in the table.
unsigned getEncoding() const
BTFTypeFwd(StringRef Name, bool IsUnion)
Represent a struct/union forward declaration.
Linkage
Describes symbol linkage.
BTFTypeFunc(StringRef FuncName, uint32_t ProtoTypeId, uint32_t Scope)
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
This represents a section on linux, lots of unix variants and some bare metal systems.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Base class for debug information backends.
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.
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
static const std::string AmaAttr
The attribute attached to globals representing a field access.
const MCSymbol * Label
Func MCSymbol.
const Module * getModule() const
uint32_t FileNameOff
file name offset in the .BTF string table
size_t addString(StringRef S)
Add string to the string table.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const std::string to_string(const T &Value)
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
void completeType(BTFDebug &BDebug)
Complete BTF type generation after all related DebugInfo types have been visited so their BTF type id...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
DITypeRefArray getTypeArray() const
MachineModuleInfo * MMI
Collected machine module information.
iterator_range< global_iterator > globals()
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
uint32_t Info
"Info" bits arrangement: Bits 0-15: vlen (e.g.
Register getReg() const
getReg - Returns the register number.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
const MCSymbol * Label
MCSymbol identifying insn for the reloc.
Linkage: InternalLinkage.
const MachineOperand & getOperand(unsigned i) const
static MCOperand createImm(int64_t Val)
void emitType(MCStreamer &OS)
Emit types for this BTF type entry.
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
uint32_t TypeId
Type id referring to .BTF type section.
StringRef getSectionName() const
uint32_t LineOff
line offset in the .BTF string table
Basic type, like 'int' or 'float'.