Go to the documentation of this file.
14 #ifndef LLVM_MC_MCDWARF_H
15 #define LLVM_MC_MCDWARF_H
33 template <
typename T>
class ArrayRef;
36 class MCObjectStreamer;
53 bool UseRelocs =
false;
106 #define DWARF2_LINE_DEFAULT_IS_STMT 1
108 #define DWARF2_FLAG_IS_STMT (1 << 0)
109 #define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
110 #define DWARF2_FLAG_PROLOGUE_END (1 << 2)
111 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
117 MCDwarfLoc(
unsigned fileNum,
unsigned line,
unsigned column,
unsigned flags,
118 unsigned isa,
unsigned discriminator)
119 : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(
isa),
120 Discriminator(discriminator) {}
152 assert(column <= UINT16_MAX);
158 assert(flags <= UINT8_MAX);
170 Discriminator = discriminator;
216 MCLineDivisions[Sec].push_back(LineEntry);
224 using iterator = MCDwarfLineEntryCollection::iterator;
235 return MCLineDivisions;
261 bool HasAllMD5 =
true;
262 bool HasAnyMD5 =
false;
271 unsigned FileNumber = 0);
272 std::pair<MCSymbol *, MCSymbol *>
275 std::pair<MCSymbol *, MCSymbol *>
284 HasAllMD5 &= MD5Used;
285 HasAnyMD5 |= MD5Used;
288 return MCDwarfFiles.empty() || (HasAllMD5 == HasAnyMD5);
312 void emitV2FileDirTables(
MCStreamer *MCOS)
const;
318 bool HasSplitLineTable =
false;
332 HasSplitLineTable =
true;
362 unsigned FileNumber = 0);
365 uint16_t DwarfVersion,
unsigned FileNumber = 0) {
367 DwarfVersion, FileNumber));
395 Header.
Label = Label;
415 return MCLineSections;
418 return MCLineSections;
430 int64_t LineDelta,
uint64_t AddrDelta);
458 : Name(
name), FileNumber(fileNumber), LineNumber(lineNumber),
503 std::vector<char> Values;
509 Values(V.
begin(), V.
end()), Comment(Comment) {
667 return StringRef(&Values[0], Values.size());
689 unsigned RAReg =
static_cast<unsigned>(INT_MAX);
707 #endif // LLVM_MC_MCDWARF_H
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
This is an optimization pass for GlobalISel generic memory operations.
static void emitOne(MCStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
StringRef getComment() const
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
unsigned getLine() const
Get the Line of this MCDwarfLoc.
Context object for machine code objects.
MCSymbol * getLabel() const
MCDwarfLineEntryCollection::const_iterator const_iterator
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
LLVM_NODISCARD bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS)
Tagged union holding either a T or a Error.
Optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
MCDwarfFrameInfo()=default
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
void setEndLabel(MCSymbol *EndLabel)
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int Offset, unsigned AddressSpace)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
constexpr bool hasValue() const
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Streaming machine code generation interface.
void emitSection(MCStreamer *MCOS)
Emit the .debug_line_str section if appropriate.
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
static void Emit(MCStreamer *MCOS)
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Generic interface to target specific assembler backends.
unsigned CurrentCfaRegister
Represents a location in source code.
Manage the .debug_line_str section contents, if we use it.
PowerPC Reduce CR logical Operation
Instances of this class represent the line information for a compile unit where machine instructions ...
const MCSymbol * Personality
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params, Optional< MCDwarfLineStr > &LineStr) const
Streaming object file generation interface.
static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
const MCLineDivisionMap & getMCLineEntries() const
This class implements an extremely fast bulk output stream that can only output to a stream.
OpType getOperation() const
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
unsigned getRegister() const
MCSymbol * getLabel() const
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
SmallVectorImpl< std::string > & getMCDwarfDirs()
int8_t DWARF2LineBase
Minimum line offset in a special line info.
const MCLineSection & getMCLineSections() const
static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
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.
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
unsigned getFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const MCDwarfFile & getRootFile() const
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
void setLabel(MCSymbol *Label)
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
unsigned getLineNumber() const
MCDwarfLineEntryCollection::iterator iterator
unsigned getRegister2() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
StringRef getName() const
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
MCSymbol * emitListsTableHeaderStart(MCStreamer &S)
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
Instances of this class represent the information from a dwarf .loc directive.
unsigned getAddressSpace() const
MCDwarfLineStr(MCContext &Ctx)
Construct an instance that can emit .debug_line_str (for use in a normal v5 line table).
StringRef - Represent a constant reference to a string, i.e.
StringRef getValues() const
static void make(MCStreamer *MCOS, MCSection *Section)
unsigned getFileNumber() const
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
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 CompactUnwindEncoding
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
constexpr bool has_value() const
void emitRef(MCStreamer *MCOS, StringRef Path)
Emit a reference to the string.
void maybeSetRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Wrapper class representing virtual and physical registers.
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const
unsigned PersonalityEncoding
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
unsigned getFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, Optional< StringRef > Source)
Optional< StringRef > Source
The source code of the file.
Utility for building string tables with deduplicated suffixes.
unsigned getFileNum() const
Get the FileNum of this MCDwarfLoc.
bool isMD5UsageConsistent() const
MCLineSection & getMCLineSections()
void addEndEntry(MCSymbol *EndLabel)
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
MCSymbol * getLabel() const
std::vector< MCCFIInstruction > Instructions
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
SmallString< 0 > getFinalizedData()
Returns finalized section.
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Instances of this class represent the line information for the dwarf line table entries.
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
MCSymbol * getLabel() const
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...