15 #include "llvm/Config/config.h"
36 if (MinInsnLength == 1)
38 if (AddrDelta % MinInsnLength != 0) {
42 return AddrDelta / MinInsnLength;
72 .addLineEntry(LineEntry, Section);
103 unsigned FileNum = 1;
104 unsigned LastLine = 1;
108 unsigned Discriminator = 0;
113 int64_t LineDelta =
static_cast<int64_t
>(LineEntry.getLine()) - LastLine;
115 if (FileNum != LineEntry.getFileNum()) {
116 FileNum = LineEntry.getFileNum();
120 if (Column != LineEntry.getColumn()) {
121 Column = LineEntry.getColumn();
125 if (Discriminator != LineEntry.getDiscriminator() &&
127 Discriminator = LineEntry.getDiscriminator();
134 if (Isa != LineEntry.getIsa()) {
135 Isa = LineEntry.getIsa();
140 Flags = LineEntry.getFlags();
148 MCOS->
EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
150 MCSymbol *Label = LineEntry.getLabel();
160 LastLine = LineEntry.getLine();
191 if (LineTables.empty())
198 for (
const auto &CUIDTablePair : LineTables)
199 CUIDTablePair.second.EmitCU(MCOS, Params);
207 std::pair<MCSymbol *, MCSymbol *>
210 static const char StandardOpcodeLengths[] = {
232 assert(!isa<MCSymbolRefExpr>(Expr));
246 std::pair<MCSymbol *, MCSymbol *>
288 for (
char Length : StandardOpcodeLengths)
316 return std::make_pair(LineStartSym, LineEndSym);
321 MCSymbol *LineEndSym = Header.
Emit(MCOS, Params).second;
333 unsigned FileNumber) {
334 return Header.
getFile(Directory, FileName, FileNumber);
339 unsigned FileNumber) {
342 if (FileName.
empty()) {
343 FileName =
"<stdin>";
347 if (FileNumber == 0) {
355 if (!IterBool.second)
356 return IterBool.first->second;
365 if (!File.
Name.empty())
368 if (Directory.
empty()) {
371 if (!tFileName.
empty()) {
373 if (!Directory.
empty())
374 FileName = tFileName;
381 if (Directory.
empty()) {
399 File.
Name = FileName;
408 int64_t LineDelta, uint64_t AddrDelta) {
424 int64_t LineDelta, uint64_t AddrDelta,
426 uint64_t Temp, Opcode;
427 bool NeedCopy =
false;
430 uint64_t MaxSpecialAddrDelta =
SpecialAddr(Params, 255);
438 if (LineDelta == INT64_MAX) {
439 if (AddrDelta == MaxSpecialAddrDelta)
440 OS << char(dwarf::DW_LNS_const_add_pc);
441 else if (AddrDelta) {
442 OS << char(dwarf::DW_LNS_advance_pc);
445 OS << char(dwarf::DW_LNS_extended_op);
447 OS << char(dwarf::DW_LNE_end_sequence);
458 OS << char(dwarf::DW_LNS_advance_line);
467 if (LineDelta == 0 && AddrDelta == 0) {
468 OS << char(dwarf::DW_LNS_copy);
476 if (AddrDelta < 256 + MaxSpecialAddrDelta) {
485 Opcode = Temp + (AddrDelta - MaxSpecialAddrDelta) * Params.
DWARF2LineRange;
487 OS << char(dwarf::DW_LNS_const_add_pc);
494 OS << char(dwarf::DW_LNS_advance_pc);
498 OS << char(dwarf::DW_LNS_copy);
500 assert(Temp <= 255 &&
"Buggy special opcode encoding.");
522 ? dwarf::DW_FORM_sec_offset
523 : dwarf::DW_FORM_data4);
527 ? dwarf::DW_FORM_sec_offset
528 : dwarf::DW_FORM_data4);
530 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
531 EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
533 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);
535 EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string);
537 if (!DwarfDebugFlags.
empty())
538 EmitAbbrev(MCOS, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string);
539 EmitAbbrev(MCOS, dwarf::DW_AT_producer, dwarf::DW_FORM_string);
540 EmitAbbrev(MCOS, dwarf::DW_AT_language, dwarf::DW_FORM_data2);
547 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);
548 EmitAbbrev(MCOS, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data4);
549 EmitAbbrev(MCOS, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data4);
550 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
551 EmitAbbrev(MCOS, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag);
569 const MCSymbol *InfoSectionSymbol) {
578 int Length = 4 + 2 + 4 + 1 + 1;
584 int Pad = 2 * AddrSize - (Length & (2 * AddrSize - 1));
585 if (Pad == 2 * AddrSize)
591 Length += 2 * AddrSize * Sections.size();
593 Length += 2 * AddrSize;
603 if (InfoSectionSymbol)
613 for(
int i = 0;
i < Pad;
i++)
619 const MCSymbol *StartSymbol = Sec->getBeginSymbol();
620 MCSymbol *EndSymbol = Sec->getEndSymbol(context);
621 assert(StartSymbol &&
"StartSymbol must not be NULL");
622 assert(EndSymbol &&
"EndSymbol must not be NULL");
627 *StartSymbol, *EndSymbol, 0);
641 const MCSymbol *AbbrevSectionSymbol,
643 const MCSymbol *RangesSectionSymbol) {
667 if (AbbrevSectionSymbol ==
nullptr)
685 if (LineSectionSymbol)
691 if (RangesSectionSymbol) {
704 const auto TextSection = Sections.begin();
705 assert(TextSection != Sections.end() &&
"No text section found");
707 MCSymbol *StartSymbol = (*TextSection)->getBeginSymbol();
708 MCSymbol *EndSymbol = (*TextSection)->getEndSymbol(context);
709 assert(StartSymbol &&
"StartSymbol must not be NULL");
710 assert(EndSymbol &&
"EndSymbol must not be NULL");
726 if (MCDwarfDirs.
size() > 0) {
743 if (!DwarfDebugFlags.
empty()){
750 if (!DwarfDebugProducer.
empty())
763 const std::vector<MCGenDwarfLabelEntry> &Entries =
765 for (
const auto &Entry : Entries) {
814 const MCSymbol *StartSymbol = Sec->getBeginSymbol();
815 MCSymbol *EndSymbol = Sec->getEndSymbol(context);
816 assert(StartSymbol &&
"StartSymbol must not be NULL");
817 assert(EndSymbol &&
"EndSymbol must not be NULL");
823 MCOS->
EmitValue(SectionStartAddr, AddrSize);
827 *StartSymbol, *EndSymbol, 0);
846 bool CreateDwarfSectionSymbols =
848 MCSymbol *LineSectionSymbol =
nullptr;
849 if (CreateDwarfSectionSymbols)
851 MCSymbol *AbbrevSectionSymbol =
nullptr;
852 MCSymbol *InfoSectionSymbol =
nullptr;
853 MCSymbol *RangesSectionSymbol =
nullptr;
865 const bool UseRangesSection =
868 CreateDwarfSectionSymbols |= UseRangesSection;
871 if (CreateDwarfSectionSymbols) {
876 if (CreateDwarfSectionSymbols) {
880 if (UseRangesSection) {
882 if (CreateDwarfSectionSymbols) {
888 assert((RangesSectionSymbol != NULL) || !UseRangesSection);
895 if (UseRangesSection)
903 RangesSectionSymbol);
960 unsigned symbolEncoding) {
962 unsigned format = symbolEncoding & 0x0f;
981 unsigned symbolEncoding,
bool isEH) {
995 unsigned symbolEncoding) {
1006 class FrameEmitterImpl {
1008 int InitialCFAOffset = 0;
1014 : IsEH(IsEH), Streamer(Streamer) {}
1020 unsigned personalityEncoding,
const MCSymbol *lsda,
1021 bool IsSignalFrame,
unsigned lsdaEncoding,
1024 bool LastInSection,
const MCSymbol &SectionStart);
1038 auto *
MRI = Streamer.getContext().getRegisterInfo();
1045 Reg1 =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg1,
true),
false);
1046 Reg2 =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg2,
true),
false);
1048 Streamer.EmitIntValue(dwarf::DW_CFA_register, 1);
1049 Streamer.EmitULEB128IntValue(Reg1);
1050 Streamer.EmitULEB128IntValue(Reg2);
1054 Streamer.EmitIntValue(dwarf::DW_CFA_GNU_window_save, 1);
1059 Streamer.EmitIntValue(dwarf::DW_CFA_undefined, 1);
1060 Streamer.EmitULEB128IntValue(Reg);
1065 const bool IsRelative =
1068 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_offset, 1);
1075 Streamer.EmitULEB128IntValue(CFAOffset);
1082 Reg =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg,
true),
false);
1083 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa, 1);
1084 Streamer.EmitULEB128IntValue(Reg);
1086 Streamer.EmitULEB128IntValue(CFAOffset);
1094 Reg =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg,
true),
false);
1095 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_register, 1);
1096 Streamer.EmitULEB128IntValue(Reg);
1103 const bool IsRelative =
1108 Reg =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg,
true),
false);
1112 Offset -= CFAOffset;
1113 Offset = Offset / dataAlignmentFactor;
1116 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended_sf, 1);
1117 Streamer.EmitULEB128IntValue(Reg);
1118 Streamer.EmitSLEB128IntValue(Offset);
1119 }
else if (Reg < 64) {
1120 Streamer.EmitIntValue(dwarf::DW_CFA_offset + Reg, 1);
1121 Streamer.EmitULEB128IntValue(Offset);
1123 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended, 1);
1124 Streamer.EmitULEB128IntValue(Reg);
1125 Streamer.EmitULEB128IntValue(Offset);
1130 Streamer.EmitIntValue(dwarf::DW_CFA_remember_state, 1);
1133 Streamer.EmitIntValue(dwarf::DW_CFA_restore_state, 1);
1137 Streamer.EmitIntValue(dwarf::DW_CFA_same_value, 1);
1138 Streamer.EmitULEB128IntValue(Reg);
1144 Reg =
MRI->getDwarfRegNum(
MRI->getLLVMRegNum(Reg,
true),
false);
1145 Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1);
1149 Streamer.EmitIntValue(dwarf::DW_CFA_GNU_args_size, 1);
1150 Streamer.EmitULEB128IntValue(Instr.
getOffset());
1166 if (Label && !Label->
isDefined())
continue;
1169 if (BaseLabel && Label) {
1171 if (ThisSym != BaseLabel) {
1172 Streamer.EmitDwarfAdvanceFrameAddr(BaseLabel, ThisSym);
1173 BaseLabel = ThisSym;
1177 EmitCFIInstruction(Instr);
1209 if (!Encoding)
return;
1213 if (!DwarfEHFrameOnly && Frame.
Lsda)
1214 Encoding |= 0x40000000;
1219 Streamer.EmitSymbolValue(Frame.
Begin, Size);
1228 Streamer.EmitIntValue(Encoding, Size);
1233 Streamer.EmitSymbolValue(Frame.
Personality, Size);
1235 Streamer.EmitIntValue(0, Size);
1239 if (!DwarfEHFrameOnly && Frame.
Lsda)
1240 Streamer.EmitSymbolValue(Frame.
Lsda, Size);
1242 Streamer.EmitIntValue(0, Size);
1248 switch (DwarfVersion) {
1261 unsigned personalityEncoding,
1264 unsigned lsdaEncoding,
1266 MCContext &context = Streamer.getContext();
1271 Streamer.EmitLabel(sectionStart);
1281 unsigned CIE_ID = IsEH ? 0 : -1;
1282 Streamer.EmitIntValue(CIE_ID, 4);
1286 Streamer.EmitIntValue(CIEVersion, 1);
1291 Augmentation +=
"z";
1293 Augmentation +=
"P";
1295 Augmentation +=
"L";
1296 Augmentation +=
"R";
1298 Augmentation +=
"S";
1299 Streamer.EmitBytes(Augmentation);
1301 Streamer.EmitIntValue(0, 1);
1303 if (CIEVersion >= 4) {
1308 Streamer.EmitIntValue(0, 1);
1318 if (CIEVersion == 1) {
1320 "DWARF 2 encodes return_address_register in one byte");
1323 Streamer.EmitULEB128IntValue(
1329 unsigned augmentationLength = 0;
1333 augmentationLength += 1;
1338 augmentationLength += 1;
1340 augmentationLength += 1;
1342 Streamer.EmitULEB128IntValue(augmentationLength);
1363 const std::vector<MCCFIInstruction> &Instructions =
1365 EmitCFIInstructions(Instructions,
nullptr);
1368 InitialCFAOffset = CFAOffset;
1373 Streamer.EmitLabel(sectionEnd);
1374 return *sectionStart;
1377 void FrameEmitterImpl::EmitFDE(
const MCSymbol &cieStart,
1381 MCContext &context = Streamer.getContext();
1386 CFAOffset = InitialCFAOffset;
1392 Streamer.EmitLabel(fdeStart);
1405 Streamer.EmitSymbolValue(&cieStart, 4);
1409 unsigned PCEncoding =
1421 unsigned augmentationLength = 0;
1426 Streamer.EmitULEB128IntValue(augmentationLength);
1440 unsigned Align = LastInSection ? asmInfo->
getPointerSize() : PCSize;
1441 Streamer.EmitValueToAlignment(Align);
1443 Streamer.EmitLabel(fdeEnd);
1448 static const CIEKey getEmptyKey() {
1449 return CIEKey(
nullptr, 0, -1,
false,
false);
1451 static const CIEKey getTombstoneKey() {
1452 return CIEKey(
nullptr, -1, 0,
false,
false);
1455 CIEKey(
const MCSymbol *Personality,
unsigned PersonalityEncoding,
1456 unsigned LsdaEncoding,
bool IsSignalFrame,
bool IsSimple)
1457 : Personality(Personality), PersonalityEncoding(PersonalityEncoding),
1458 LsdaEncoding(LsdaEncoding), IsSignalFrame(IsSignalFrame),
1459 IsSimple(IsSimple) {}
1461 unsigned PersonalityEncoding;
1462 unsigned LsdaEncoding;
1473 return static_cast<unsigned>(
1474 hash_combine(Key.Personality, Key.PersonalityEncoding, Key.LsdaEncoding,
1475 Key.IsSignalFrame, Key.IsSimple));
1477 static bool isEqual(
const CIEKey &LHS,
const CIEKey &RHS) {
1478 return LHS.Personality == RHS.Personality &&
1479 LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
1480 LHS.LsdaEncoding == RHS.LsdaEncoding &&
1481 LHS.IsSignalFrame == RHS.IsSignalFrame &&
1482 LHS.IsSimple == RHS.IsSimple;
1493 FrameEmitterImpl Emitter(IsEH, Streamer);
1499 bool SectionEmitted =
false;
1502 if (!SectionEmitted) {
1505 SectionEmitted =
true;
1507 NeedsEHFrameSection |=
1510 Emitter.EmitCompactUnwind(Frame);
1514 if (!NeedsEHFrameSection)
return;
1526 const MCSymbol *DummyDebugKey =
nullptr;
1528 for (
auto I = FrameArray.
begin(),
E = FrameArray.
end();
I !=
E;) {
1539 const MCSymbol *&CIEStart = IsEH ? CIEStarts[Key] : DummyDebugKey;
1545 Emitter.EmitFDE(*CIEStart, Frame,
I ==
E, *SectionStart);
1550 uint64_t AddrDelta) {
1564 if (AddrDelta == 0) {
1565 }
else if (
isUIntN(6, AddrDelta)) {
1566 uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta;
1569 OS << uint8_t(dwarf::DW_CFA_advance_loc1);
1570 OS << uint8_t(AddrDelta);
1572 OS << uint8_t(dwarf::DW_CFA_advance_loc2);
1579 OS << uint8_t(dwarf::DW_CFA_advance_loc4);
static const MCExpr * forceExpAbs(MCStreamer &OS, const MCExpr *Expr)
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
constexpr bool isUInt< 32 >(uint64_t x)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
const MCAsmInfo * getAsmInfo() const
unsigned getFDEEncoding() const
static int getDataAlignmentFactor(MCStreamer &streamer)
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
static CIEKey getTombstoneKey()
#define DWARF2_FLAG_PROLOGUE_END
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
bool getOmitDwarfIfHaveCompactUnwind() const
A raw_ostream that writes to an SmallVector or SmallString.
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
static void EmitGenDwarfInfo(MCStreamer *MCOS, const MCSymbol *AbbrevSectionSymbol, const MCSymbol *LineSectionSymbol, const MCSymbol *RangesSectionSymbol)
uint16_t getDwarfVersion() const
StringRef getDwarfDebugFlags()
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.
void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
unsigned getRegister() const
std::vector< MCCFIInstruction > Instructions
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
#define DWARF2_FLAG_IS_STMT
StringRef getDwarfDebugProducer()
bool getSupportsCompactUnwindWithoutEHFrame() const
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
MCSection * getCurrentSectionOnly() const
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
Base class for the full range of assembler expressions which are needed for parsing.
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
Reg
All possible values of the reg field in the ModR/M byte.
const std::vector< MCCFIInstruction > & getInitialFrameState() const
static void emitFDESymbol(MCObjectStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding, bool isEH)
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
MCContext & getContext() const
bool isLittleEndian() const
True if the target is little endian.
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Context object for machine code objects.
StringRef getValues() const
static void EmitGenDwarfAbbrev(MCStreamer *MCOS)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
unsigned getDwarfCompileUnitID()
Streaming object file generation interface.
Instances of this class represent the information from a dwarf .loc directive.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
unsigned getGenDwarfFileNumber()
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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...
size_t size() const
size - Get the array size.
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
void EmitCU(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params) const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
This class is intended to be used as a base class for asm properties and features specific to the tar...
MCSection * getDwarfLineSection() const
bool needsDwarfSectionOffsetDirective() const
static uint64_t SpecialAddr(MCDwarfLineTableParams Params, uint64_t op)
Given a special op, return the address skip amount (in units of DWARF2_LINE_MIN_INSN_LENGTH).
static unsigned getSizeForEncoding(MCStreamer &streamer, unsigned symbolEncoding)
StringRef filename(StringRef path)
Get filename.
Streaming machine code generation interface.
static unsigned getCIEVersion(bool IsEH, unsigned DwarfVersion)
MCSection * getCompactUnwindSection() const
static void EmitAbbrev(MCStreamer *MCOS, uint64_t Name, uint64_t Form)
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
void write(ArrayRef< value_type > Vals)
#define DWARF2_FLAG_EPILOGUE_BEGIN
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
static void emitAbsValue(MCStreamer &OS, const MCExpr *Value, unsigned Size)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static void EmitDwarfLineTable(MCObjectStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)
static void EmitGenDwarfAranges(MCStreamer *MCOS, const MCSymbol *InfoSectionSymbol)
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
cl::opt< int > DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(0))
static const unsigned End
#define DWARF2_FLAG_BASIC_BLOCK
const MCDwarfLoc & getCurrentDwarfLoc()
unsigned PersonalityEncoding
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
int8_t DWARF2LineBase
Minimum line offset in a special line info.
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
unsigned getPointerSize() const
Get the pointer size in bytes.
const SetVector< MCSection * > & getGenDwarfSectionSyms()
OpType getOperation() const
unsigned getMinInstAlignment() const
bool doDwarfFDESymbolsUseAbsDiff() const
static unsigned getHashValue(const CIEKey &Key)
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static bool isEqual(const CIEKey &LHS, const CIEKey &RHS)
unsigned getRegister2() const
StringRef str()
Return a StringRef for the vector contents.
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS)
uint32_t CompactUnwindEncoding
static void EmitGenDwarfRanges(MCStreamer *MCOS)
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
void encodeSLEB128(int64_t Value, raw_ostream &OS)
Utility function to encode a SLEB128 value to an output stream.
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
StringRef parent_path(StringRef path)
Get parent path.
static CIEKey getEmptyKey()
unsigned FindLineNumber(SMLoc Loc, unsigned BufferID=0) const
Find the line number for the specified location in the specified file.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
StringRef get_separator()
Return the preferred separator for this platform.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
static void Emit(MCStreamer *MCOS)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
#define DWARF2_LINE_DEFAULT_IS_STMT
static StringRef toStringRef(bool B)
Construct a string ref from a boolean.
static uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta)
const MCRegisterInfo * getRegisterInfo() const
Instances of this class represent the line information for the dwarf line table entries.
static void Emit(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params)
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
MCSection * getDwarfARangesSection() const
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params) const
static const MCExpr * MakeStartMinusEndExpr(const MCStreamer &MCOS, const MCSymbol &Start, const MCSymbol &End, int IntVal)
StringRef getName() const
getName - Get the symbol name.
static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding)
static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
const MCSymbol * Personality
bool isStackGrowthDirectionUp() const
True if target stack grow up.
MCSection * getDwarfFrameSection() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
unsigned getCalleeSaveStackSlotSize() const
Get the callee-saved register stack slot size in bytes.
constexpr bool isUInt< 16 >(uint64_t x)
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
const MCLineDivisionMap & getMCLineEntries() const
bool hasAggressiveSymbolFolding() const
void EmitULEB128IntValue(uint64_t Value, unsigned Padding=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
MCSymbol * endSection(MCSection *Section)
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
LLVM Value Representation.
Generic interface to target specific assembler backends.
const MCObjectFileInfo * getObjectFileInfo() const
MCSection * getDwarfInfoSection() const
MCSection * getDwarfRangesSection() const
unsigned getCompactUnwindDwarfEHFrameOnly() const
static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)
This class implements an extremely fast bulk output stream that can only output to a stream...
void encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned Padding=0)
Utility function to encode a ULEB128 value to an output stream.
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
StringRef - Represent a constant reference to a string, i.e.
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
unsigned getRARegister() const
This method should return the register where the return address can be found.
MCSection * getDwarfAbbrevSection() const
Represents a location in source code.
unsigned getFile(StringRef &Directory, StringRef &FileName, unsigned FileNumber=0)
bool isUIntN(unsigned N, uint64_t x)
isUIntN - Checks if an unsigned integer fits into the given (dynamic) bit width.
MCSymbol * getLabel() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
bool doesDwarfUseRelocationsAcrossSections() const