34 std::string TripleName;
53 return error(
"no asm info for target " + TripleName,
Context),
false;
57 return error(
"no subtarget info for target " + TripleName,
Context),
false;
59 MC.reset(
new MCContext(TheTriple, MAI.get(), MRI.get(), MSTI.get(),
nullptr,
60 nullptr,
true, Swift5ReflectionSegmentName));
62 MC->setObjectFileInfo(MOFI.get());
66 return error(
"no asm backend for target " + TripleName,
Context),
false;
70 return error(
"no instr info info for target " + TripleName,
Context),
false;
74 return error(
"no code emitter for target " + TripleName,
Context),
false;
76 switch (OutFileType) {
81 *MC, std::make_unique<formatted_raw_ostream>(OutFile),
true,
true, MIP,
82 std::unique_ptr<MCCodeEmitter>(MCE), std::unique_ptr<MCAsmBackend>(MAB),
88 TheTriple, *MC, std::unique_ptr<MCAsmBackend>(MAB),
97 return error(
"no object streamer for target " + TripleName,
Context),
false;
103 return error(
"no target machine for target " + TripleName,
Context),
false;
105 Asm.reset(TheTarget->
createAsmPrinter(*TM, std::unique_ptr<MCStreamer>(MS)));
107 return error(
"no asm printer for target " + TripleName,
Context),
false;
108 Asm->setDwarfUsesRelocationsAcrossSections(
false);
110 RangesSectionSize = 0;
111 RngListsSectionSize = 0;
113 LocListsSectionSize = 0;
115 FrameSectionSize = 0;
116 DebugInfoSectionSize = 0;
117 MacInfoSectionSize = 0;
118 MacroSectionSize = 0;
127 MC->setDwarfVersion(DwarfVersion);
147 unsigned DwarfVersion) {
151 Unit.setLabelBegin(Asm->createTempSymbol(
"cu_begin"));
152 Asm->OutStreamer->emitLabel(Unit.getLabelBegin());
157 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset() - 4);
158 Asm->emitInt16(DwarfVersion);
160 if (DwarfVersion >= 5) {
161 Asm->emitInt8(dwarf::DW_UT_compile);
162 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
166 DebugInfoSectionSize += 12;
171 Asm->emitInt8(Unit.getOrigUnit().getAddressByteSize());
172 DebugInfoSectionSize += 11;
176 EmittedUnits.push_back({Unit.getUniqueID(), Unit.getLabelBegin()});
182 const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
183 unsigned DwarfVersion) {
185 MC->setDwarfVersion(DwarfVersion);
186 Asm->emitDwarfAbbrevs(Abbrevs);
192 Asm->emitDwarfDIE(Die);
193 DebugInfoSectionSize += Die.
getSize();
200 .
Case(
"debug_line", MC->getObjectFileInfo()->getDwarfLineSection())
201 .
Case(
"debug_loc", MC->getObjectFileInfo()->getDwarfLocSection())
202 .
Case(
"debug_ranges",
203 MC->getObjectFileInfo()->getDwarfRangesSection())
204 .
Case(
"debug_frame", MC->getObjectFileInfo()->getDwarfFrameSection())
205 .
Case(
"debug_aranges",
206 MC->getObjectFileInfo()->getDwarfARangesSection())
207 .
Case(
"debug_addr", MC->getObjectFileInfo()->getDwarfAddrSection())
208 .
Case(
"debug_rnglists",
209 MC->getObjectFileInfo()->getDwarfRnglistsSection())
210 .
Case(
"debug_loclists",
211 MC->getObjectFileInfo()->getDwarfLoclistsSection())
225 Asm.emitInt32(11 + Die.
getSize() - 4);
228 Asm.emitInt8(MC->getTargetTriple().isArch64Bit() ? 8 : 4);
229 DebugInfoSectionSize += 11;
235 Asm->OutStreamer->switchSection(MOFI->getDwarfStrSection());
237 for (
auto Entry : Entries) {
239 Asm->OutStreamer->emitBytes(Entry.getString());
245 if (DwarfVersion >= 5) {
247 Asm->OutStreamer->switchSection(MOFI->getDwarfStrOffSection());
248 Asm->emitDwarfUnitLength(4,
"Length of String Offsets Set");
249 Asm->emitInt16(DwarfVersion);
257 if (EmittedUnits.empty())
261 std::vector<MCSymbol *> CompUnits;
264 for (
auto &
CU : EmittedUnits) {
265 CompUnits.push_back(
CU.LabelBegin);
267 UniqueIdToCuMap[
CU.ID] = Id++;
270 Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection());
272 Asm.get(), Table, CompUnits,
274 return UniqueIdToCuMap[Entry.getCUIndex()];
280 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamespaceSection());
281 auto *SectionBegin = Asm->createTempSymbol(
"namespac_begin");
282 Asm->OutStreamer->emitLabel(SectionBegin);
288 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamesSection());
289 auto *SectionBegin = Asm->createTempSymbol(
"names_begin");
290 Asm->OutStreamer->emitLabel(SectionBegin);
296 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelObjCSection());
297 auto *SectionBegin = Asm->createTempSymbol(
"objc_begin");
298 Asm->OutStreamer->emitLabel(SectionBegin);
304 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelTypesSection());
305 auto *SectionBegin = Asm->createTempSymbol(
"types_begin");
306 Asm->OutStreamer->emitLabel(SectionBegin);
312 MCSection *SwiftASTSection = MOFI->getDwarfSwiftASTSection();
322 MOFI->getSwift5ReflectionSection(ReflSectionKind);
323 if (ReflectionSection ==
nullptr)
332 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
335 MS->
switchSection(MC->getObjectFileInfo()->getDwarfARangesSection());
338 MCSymbol *BeginLabel = Asm->createTempSymbol(
"Barange");
339 MCSymbol *EndLabel = Asm->createTempSymbol(
"Earange");
341 unsigned HeaderSize =
348 unsigned TupleSize = AddressSize * 2;
351 Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
352 Asm->OutStreamer->emitLabel(BeginLabel);
354 Asm->emitInt32(Unit.getStartOffset());
355 Asm->emitInt8(AddressSize);
358 Asm->OutStreamer->emitFill(Padding, 0x0);
363 MS->
emitIntValue(Range.end() - Range.start(), AddressSize);
367 Asm->OutStreamer->emitIntValue(0, AddressSize);
368 Asm->OutStreamer->emitIntValue(0, AddressSize);
369 Asm->OutStreamer->emitLabel(EndLabel);
372void DwarfStreamer::emitDwarfDebugRangesTableFragment(
375 Patch.
set(RangesSectionSize);
378 MS->
switchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
379 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
383 if (std::optional<uint64_t> LowPC = Unit.getLowPc())
384 BaseAddress = *LowPC;
387 MS->
emitIntValue(Range.start() - BaseAddress, AddressSize);
388 MS->
emitIntValue(Range.end() - BaseAddress, AddressSize);
390 RangesSectionSize += AddressSize;
391 RangesSectionSize += AddressSize;
398 RangesSectionSize += AddressSize;
399 RangesSectionSize += AddressSize;
404 if (Unit.getOrigUnit().getVersion() < 5)
408 MS->
switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
410 MCSymbol *BeginLabel = Asm->createTempSymbol(
"Brnglists");
411 MCSymbol *EndLabel = Asm->createTempSymbol(
"Ernglists");
412 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
415 Asm->emitLabelDifference(EndLabel, BeginLabel,
sizeof(
uint32_t));
416 Asm->OutStreamer->emitLabel(BeginLabel);
417 RngListsSectionSize +=
sizeof(
uint32_t);
421 RngListsSectionSize +=
sizeof(
uint16_t);
425 RngListsSectionSize++;
429 RngListsSectionSize++;
433 RngListsSectionSize +=
sizeof(
uint32_t);
441 if (Unit.getOrigUnit().getVersion() < 5) {
442 emitDwarfDebugRangesTableFragment(Unit, LinkedRanges, Patch);
446 emitDwarfDebugRngListsTableFragment(Unit, LinkedRanges, Patch);
451 if (Unit.getOrigUnit().getVersion() < 5)
455 MS->
switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
457 if (EndLabel !=
nullptr)
458 Asm->OutStreamer->emitLabel(EndLabel);
461void DwarfStreamer::emitDwarfDebugRngListsTableFragment(
464 Patch.
set(RngListsSectionSize);
467 MS->
switchSection(MC->getObjectFileInfo()->getDwarfRnglistsSection());
469 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
473 MS->
emitInt8(dwarf::DW_RLE_start_length);
474 RngListsSectionSize += 1;
478 RngListsSectionSize += AddressSize;
485 MS->
emitInt8(dwarf::DW_RLE_end_of_list);
486 RngListsSectionSize += 1;
491 if (Unit.getOrigUnit().getVersion() < 5)
495 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
497 MCSymbol *BeginLabel = Asm->createTempSymbol(
"Bloclists");
498 MCSymbol *EndLabel = Asm->createTempSymbol(
"Eloclists");
499 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
502 Asm->emitLabelDifference(EndLabel, BeginLabel,
sizeof(
uint32_t));
503 Asm->OutStreamer->emitLabel(BeginLabel);
504 LocListsSectionSize +=
sizeof(
uint32_t);
508 LocListsSectionSize +=
sizeof(
uint16_t);
512 LocListsSectionSize++;
516 LocListsSectionSize++;
520 LocListsSectionSize +=
sizeof(
uint32_t);
530 if (Unit.getOrigUnit().getVersion() < 5) {
531 emitDwarfDebugLocTableFragment(Unit, LinkedLocationExpression, Patch);
535 emitDwarfDebugLocListsTableFragment(Unit, LinkedLocationExpression, Patch);
541 if (Unit.getOrigUnit().getVersion() < 5)
545 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
547 if (EndLabel !=
nullptr)
548 Asm->OutStreamer->emitLabel(EndLabel);
552void DwarfStreamer::emitDwarfDebugLocTableFragment(
556 Patch.
set(LocSectionSize);
559 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLocSection());
560 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
564 if (std::optional<uint64_t> LowPC = Unit.getLowPc())
565 BaseAddress = *LowPC;
568 LinkedLocationExpression) {
569 if (LocExpression.Range) {
570 MS->
emitIntValue(LocExpression.Range->LowPC - BaseAddress, AddressSize);
571 MS->
emitIntValue(LocExpression.Range->HighPC - BaseAddress, AddressSize);
573 LocSectionSize += AddressSize;
574 LocSectionSize += AddressSize;
577 Asm->OutStreamer->emitIntValue(LocExpression.Expr.size(), 2);
578 Asm->OutStreamer->emitBytes(StringRef(
579 (
const char *)LocExpression.Expr.data(), LocExpression.Expr.size()));
580 LocSectionSize += LocExpression.Expr.size() + 2;
587 LocSectionSize += AddressSize;
588 LocSectionSize += AddressSize;
592void DwarfStreamer::emitDwarfDebugLocListsTableFragment(
593 const CompileUnit &Unit,
595 PatchLocation Patch) {
596 Patch.set(LocListsSectionSize);
599 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLoclistsSection());
601 unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize();
603 for (
const DWARFLocationExpression &LocExpression :
604 LinkedLocationExpression) {
605 if (LocExpression.Range) {
607 MS->
emitInt8(dwarf::DW_LLE_start_length);
608 LocListsSectionSize += 1;
611 MS->
emitIntValue(LocExpression.Range->LowPC, AddressSize);
612 LocListsSectionSize += AddressSize;
616 LocExpression.Range->HighPC - LocExpression.Range->LowPC);
619 MS->
emitInt8(dwarf::DW_LLE_default_location);
620 LocListsSectionSize += 1;
624 Asm->OutStreamer->emitBytes(StringRef(
625 (
const char *)LocExpression.Expr.data(), LocExpression.Expr.size()));
626 LocListsSectionSize += LocExpression.Expr.size();
630 MS->
emitInt8(dwarf::DW_LLE_end_of_list);
631 LocListsSectionSize += 1;
636 unsigned MinInstLength,
637 std::vector<DWARFDebugLine::Row> &Rows,
638 unsigned PointerSize) {
640 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLineSection());
641 MCSymbol *LineStartSym = MC->createTempSymbol();
642 MCSymbol *LineEndSym = MC->createTempSymbol();
646 Asm->emitLabelDifference(LineEndSym, LineStartSym, 4);
647 Asm->OutStreamer->emitLabel(LineStartSym);
650 LineSectionSize += PrologueBytes.
size() + 4;
661 LineSectionSize += EncodingBuffer.
size();
667 unsigned FileNum = 1;
668 unsigned LastLine = 1;
670 unsigned IsStatement = 1;
674 unsigned RowsSinceLastSequence = 0;
683 LineSectionSize += 2 + PointerSize +
getULEB128Size(PointerSize + 1);
694 if (FileNum != Row.File) {
700 if (Column != Row.Column) {
710 if (Isa != Row.Isa) {
716 if (IsStatement != Row.IsStmt) {
717 IsStatement = Row.IsStmt;
719 LineSectionSize += 1;
721 if (Row.BasicBlock) {
723 LineSectionSize += 1;
726 if (Row.PrologueEnd) {
728 LineSectionSize += 1;
731 if (Row.EpilogueBegin) {
733 LineSectionSize += 1;
736 int64_t LineDelta = int64_t(Row.Line) - LastLine;
737 if (!Row.EndSequence) {
740 LineSectionSize += EncodingBuffer.
size();
744 RowsSinceLastSequence++;
759 LineSectionSize += EncodingBuffer.
size();
762 LastLine = FileNum = IsStatement = 1;
763 RowsSinceLastSequence = Column = Isa = 0;
767 if (RowsSinceLastSequence) {
771 LineSectionSize += EncodingBuffer.
size();
781 MS->
switchSection(MC->getObjectFileInfo()->getDwarfLineSection());
789 MCSymbol *BeginLabel = MC->createTempSymbol();
790 MCSymbol *EndLabel = MC->createTempSymbol();
794 warn(
"Unsupported line table version: dropping contents and not "
795 "unobfsucating line table.");
799 Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
800 Asm->OutStreamer->emitLabel(BeginLabel);
801 Asm->emitInt16(Version);
802 LineSectionSize += 6;
804 MCSymbol *HeaderBeginLabel = MC->createTempSymbol();
805 MCSymbol *HeaderEndLabel = MC->createTempSymbol();
806 Asm->emitLabelDifference(HeaderEndLabel, HeaderBeginLabel, 4);
807 Asm->OutStreamer->emitLabel(HeaderBeginLabel);
809 LineSectionSize += 4;
813 Offset += (Version >= 4) ? 5 : 4;
816 Asm->OutStreamer->emitBytes(Contents.
slice(AfterHeaderLengthOffset,
Offset));
817 LineSectionSize +=
Offset - AfterHeaderLengthOffset;
820 while (
const char *Dir =
Data.getCStr(&
Offset)) {
825 Asm->OutStreamer->emitBytes(Translated);
827 LineSectionSize += Translated.
size() + 1;
830 LineSectionSize += 1;
832 while (
const char *File =
Data.getCStr(&
Offset)) {
837 Asm->OutStreamer->emitBytes(Translated);
839 LineSectionSize += Translated.
size() + 1;
845 LineSectionSize +=
Offset - OffsetBeforeLEBs;
848 LineSectionSize += 1;
850 Asm->OutStreamer->emitLabel(HeaderEndLabel);
853 Asm->OutStreamer->emitBytes(Contents.
slice(
Offset, UnitEnd));
854 LineSectionSize += UnitEnd -
Offset;
856 Asm->OutStreamer->emitLabel(EndLabel);
862void DwarfStreamer::emitPubSectionForUnit(
864 const std::vector<CompileUnit::AccelInfo> &
Names) {
869 Asm->OutStreamer->switchSection(Sec);
870 MCSymbol *BeginLabel = Asm->createTempSymbol(
"pub" + SecName +
"_begin");
871 MCSymbol *EndLabel = Asm->createTempSymbol(
"pub" + SecName +
"_end");
873 bool HeaderEmitted =
false;
876 if (
Name.SkipPubSection)
879 if (!HeaderEmitted) {
881 Asm->emitLabelDifference(EndLabel, BeginLabel, 4);
882 Asm->OutStreamer->emitLabel(BeginLabel);
884 Asm->emitInt32(Unit.getStartOffset());
885 Asm->emitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset());
886 HeaderEmitted =
true;
888 Asm->emitInt32(
Name.Die->getOffset());
891 Asm->OutStreamer->emitBytes(
Name.Name.getString());
899 Asm->OutStreamer->emitLabel(EndLabel);
904 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubNamesSection(),
905 "names", Unit, Unit.getPubnames());
910 emitPubSectionForUnit(MC->getObjectFileInfo()->getDwarfPubTypesSection(),
911 "types", Unit, Unit.getPubtypes());
916 MS->
switchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
919 FrameSectionSize += CIEBytes.
size();
927 MS->
switchSection(MC->getObjectFileInfo()->getDwarfFrameSection());
933 FrameSectionSize += FDEBytes.
size() + 8 + AddrSize;
943 MS->
switchSection(MC->getObjectFileInfo()->getDwarfMacinfoSection());
944 emitMacroTableImpl(Table, UnitMacroMap, StringPool, MacInfoSectionSize);
949 MS->
switchSection(MC->getObjectFileInfo()->getDwarfMacroSection());
950 emitMacroTableImpl(Table, UnitMacroMap, StringPool, MacroSectionSize);
954void DwarfStreamer::emitMacroTableImpl(
const DWARFDebugMacro *MacroTable,
958 bool DefAttributeIsReported =
false;
959 bool UndefAttributeIsReported =
false;
960 bool ImportAttributeIsReported =
false;
961 for (
const DWARFDebugMacro::MacroList &
List : MacroTable->MacroLists) {
963 if (UnitIt == UnitMacroMap.
end()) {
965 "couldn`t find compile unit for the macro table with offset = {0:x}",
971 DIE *OutputUnitDIE = UnitIt->second->getOutputUnitDIE();
972 if (OutputUnitDIE ==
nullptr)
977 bool hasDWARFv5Header =
false;
978 for (
auto &V : OutputUnitDIE->values()) {
979 if (V.getAttribute() == dwarf::DW_AT_macro_info) {
980 V = DIEValue(V.getAttribute(), V.getForm(), DIEInteger(OutOffset));
982 }
else if (
V.getAttribute() == dwarf::DW_AT_macros) {
983 hasDWARFv5Header =
true;
984 V = DIEValue(
V.getAttribute(),
V.getForm(), DIEInteger(OutOffset));
990 if (hasDWARFv5Header) {
993 OutOffset +=
sizeof(
List.Header.Version);
999 DWARFDebugMacro::HeaderFlagMask::MACRO_OPCODE_OPERANDS_TABLE) {
1000 Flags &= ~DWARFDebugMacro::HeaderFlagMask::MACRO_OPCODE_OPERANDS_TABLE;
1001 warn(
"opcode_operands_table is not supported yet.");
1005 std::optional<uint64_t> StmtListOffset;
1006 if (
Flags & DWARFDebugMacro::HeaderFlagMask::MACRO_DEBUG_LINE_OFFSET) {
1008 for (
auto &V : OutputUnitDIE->values()) {
1009 if (
V.getAttribute() == dwarf::DW_AT_stmt_list) {
1010 StmtListOffset =
V.getDIEInteger().getValue();
1015 if (!StmtListOffset) {
1016 Flags &= ~DWARFDebugMacro::HeaderFlagMask::MACRO_DEBUG_LINE_OFFSET;
1017 warn(
"couldn`t find line table for macro table.");
1023 OutOffset +=
sizeof(
Flags);
1026 if (StmtListOffset) {
1028 OutOffset +=
List.Header.getOffsetByteSize();
1033 for (
const DWARFDebugMacro::Entry &MacroEntry :
List.Macros) {
1034 if (MacroEntry.Type == 0) {
1039 uint8_t MacroType = MacroEntry.Type;
1040 switch (MacroType) {
1042 bool HasVendorSpecificExtension =
1047 if (HasVendorSpecificExtension) {
1056 StringRef
String = MacroEntry.ExtStr;
1059 OutOffset +=
String.size() + 1;
1061 warn(
"unknown macro type. skip.");
1069 case dwarf::DW_MACRO_define:
1070 case dwarf::DW_MACRO_undef: {
1079 StringRef
String = MacroEntry.MacroStr;
1082 OutOffset +=
String.size() + 1;
1084 case dwarf::DW_MACRO_define_strp:
1085 case dwarf::DW_MACRO_undef_strp:
1086 case dwarf::DW_MACRO_define_strx:
1087 case dwarf::DW_MACRO_undef_strx: {
1088 assert(UnitIt->second->getOrigUnit().getVersion() >= 5);
1092 switch (MacroType) {
1093 case dwarf::DW_MACRO_define_strx: {
1094 MacroType = dwarf::DW_MACRO_define_strp;
1095 if (!DefAttributeIsReported) {
1096 warn(
"DW_MACRO_define_strx unsupported yet. Convert to "
1097 "DW_MACRO_define_strp.");
1098 DefAttributeIsReported =
true;
1101 case dwarf::DW_MACRO_undef_strx: {
1102 MacroType = dwarf::DW_MACRO_undef_strp;
1103 if (!UndefAttributeIsReported) {
1104 warn(
"DW_MACRO_undef_strx unsupported yet. Convert to "
1105 "DW_MACRO_undef_strp.");
1106 UndefAttributeIsReported =
true;
1122 DwarfStringPoolEntryRef EntryRef =
1123 StringPool.getEntry(MacroEntry.MacroStr);
1125 OutOffset +=
List.Header.getOffsetByteSize();
1128 case dwarf::DW_MACRO_start_file: {
1137 case dwarf::DW_MACRO_end_file: {
1142 case dwarf::DW_MACRO_import:
1143 case dwarf::DW_MACRO_import_sup: {
1144 if (!ImportAttributeIsReported) {
1145 warn(
"DW_MACRO_import and DW_MACRO_import_sup are unsupported yet. "
1147 ImportAttributeIsReported =
true;
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
A class that represents an address range.
The AddressRanges class helps normalize address range collections.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
A structured debug information entry.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
iterator find(const_arg_type_t< KeyT > Val)
void emitMacroTables(DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool) override
Emit all available macro tables(DWARFv4 and DWARFv5).
void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple namespaces accelerator table.
void emitStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool.
void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple names accelerator table.
void emitDwarfDebugArangesTable(const CompileUnit &Unit, const AddressRanges &LinkedRanges) override
Emit .debug_aranges entries for Unit.
void emitPaperTrailWarningsDie(DIE &Die) override
Emit DIE containing warnings.
void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch) override
Emit debug ranges(.debug_ranges, .debug_rnglists) fragment.
void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple Objective-C accelerator table.
void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_ranges, .debug_rnglists) footer.
void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table) override
Emit Apple type accelerator table.
void emitSectionContents(StringRef SecData, StringRef SecName) override
Emit contents of section SecName From Obj.
void finish()
Dump the file to the disk.
void emitPubNamesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubnames contribution for Unit.
void translateLineTable(DataExtractor LineData, uint64_t Offset) override
Copy the debug_line over to the updated binary while unobfuscating the file names and directories.
void emitDwarfDebugLocListFragment(const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, PatchLocation Patch) override
Emit debug ranges(.debug_loc, .debug_loclists) fragment.
void emitCIE(StringRef CIEBytes) override
Emit a CIE.
void emitDIE(DIE &Die) override
Recursively emit the DIE tree rooted at Die.
AsmPrinter & getAsmPrinter() const
void emitDwarfDebugLocListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_loc, .debug_loclists) footer.
void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) override
Emit the compilation unit header for Unit in the debug_info section.
MCSymbol * emitDwarfDebugLocListHeader(const CompileUnit &Unit) override
Emit debug locations(.debug_loc, .debug_loclists) header.
void emitPubTypesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubtypes contribution for Unit.
void emitAbbrevs(const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion) override
Emit the abbreviation table Abbrevs to the debug_abbrev section.
void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size)
Emit the swift reflection section stored in Buffer.
MCSymbol * emitDwarfDebugRangeListHeader(const CompileUnit &Unit) override
Emit debug ranges(.debug_ranges, .debug_rnglists) header.
void emitSwiftAST(StringRef Buffer)
Emit the swift_ast section stored in Buffer.
bool init(Triple TheTriple, StringRef Swift5ReflectionSegmentName)
void switchToDebugInfoSection(unsigned DwarfVersion)
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion.
void emitLineTableForUnit(MCDwarfLineTableParams Params, StringRef PrologueBytes, unsigned MinInstLength, std::vector< DWARFDebugLine::Row > &Rows, unsigned AdddressSize) override
Emit the line table described in Rows into the debug_line section.
void emitDebugNames(AccelTable< DWARF5AccelTableStaticData > &Table) override
Emit DWARF debug names.
void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) override
Emit an FDE with data Bytes.
std::unique_ptr< MCObjectWriter > createObjectWriter(raw_pwrite_stream &OS) const
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file.
Context object for machine code objects.
static void Encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void setAlignment(Align Value)
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
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.
void emitInt16(uint64_t Value)
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
void emitInt32(uint64_t Value)
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
void emitInt8(uint64_t Value)
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool MCIncrementalLinkerCompatible
A string table that doesn't need relocations.
std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Helper for making strong types.
Target - Wrapper for Target specific information.
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const
Create a MCObjectFileInfo implementation for the specified target triple.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool IsVerboseAsm, bool UseDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst) const
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, const MCSubtargetInfo &STI, bool RelaxAll, bool IncrementalLinkerCompatible, bool DWARFMustBeAtTheEnd) const
Create a target specific MCStreamer.
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOpt::Level OL=CodeGenOpt::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Triple - Helper class for working with autoconf configuration names.
const std::string & getTriple() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A raw_ostream that writes to an SmallVector or SmallString.
StringRef str() const
Return a StringRef for the vector contents.
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
MCTargetOptions InitMCTargetOptionsFromFlags()
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::vector< DWARFLocationExpression > DWARFLocationExpressionsVector
Represents a set of absolute location expressions.
void emitDWARF5AccelTable(AsmPrinter *Asm, AccelTable< DWARF5AccelTableData > &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit > > CUs)
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)
Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.
unsigned getSLEB128Size(int64_t Value)
Utility function to get the size of the SLEB128-encoded value.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Standard .debug_line state machine structure.
Represents a single DWARF expression, whose value is location-dependent.
void set(uint64_t New) const
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.