14#ifndef LLVM_MC_MCDWARF_H
15#define LLVM_MC_MCDWARF_H
37class MCObjectStreamer;
56 bool UseRelocs =
false;
111#define DWARF2_LINE_DEFAULT_IS_STMT 1
113#define DWARF2_FLAG_IS_STMT (1 << 0)
114#define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
115#define DWARF2_FLAG_PROLOGUE_END (1 << 2)
116#define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
122 MCDwarfLoc(
unsigned fileNum,
unsigned line,
unsigned column,
unsigned flags,
123 unsigned isa,
unsigned discriminator)
124 : FileNum(fileNum), Line(line), Column(column),
Flags(flags), Isa(
isa),
125 Discriminator(discriminator) {}
157 assert(column <= UINT16_MAX);
163 assert(flags <= UINT8_MAX);
175 Discriminator = discriminator;
221 MCLineDivisions[Sec].push_back(LineEntry);
229 using iterator = MCDwarfLineEntryCollection::iterator;
240 return MCLineDivisions;
266 bool HasAllMD5 =
true;
267 bool HasAnyMD5 =
false;
273 std::optional<MD5::MD5Result> Checksum,
274 std::optional<StringRef> Source,
275 uint16_t DwarfVersion,
unsigned FileNumber = 0);
276 std::pair<MCSymbol *, MCSymbol *>
278 std::optional<MCDwarfLineStr> &LineStr)
const;
279 std::pair<MCSymbol *, MCSymbol *>
282 std::optional<MCDwarfLineStr> &LineStr)
const;
288 HasAllMD5 &= MD5Used;
289 HasAnyMD5 |= MD5Used;
292 return MCDwarfFiles.empty() || (HasAllMD5 == HasAnyMD5);
296 std::optional<MD5::MD5Result> Checksum,
297 std::optional<StringRef> Source) {
316 void emitV2FileDirTables(
MCStreamer *MCOS)
const;
318 std::optional<MCDwarfLineStr> &LineStr)
const;
323 bool HasSplitLineTable =
false;
327 std::optional<MD5::MD5Result> Checksum,
328 std::optional<StringRef> Source) {
329 if (!Header.RootFile.Name.empty())
331 Header.setRootFile(Directory, FileName, Checksum, Source);
335 std::optional<MD5::MD5Result> Checksum,
336 uint16_t DwarfVersion, std::optional<StringRef> Source) {
337 HasSplitLineTable =
true;
338 return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source,
356 std::optional<MCDwarfLineStr> &LineStr)
const;
364 std::optional<MD5::MD5Result> Checksum,
365 std::optional<StringRef> Source,
366 uint16_t DwarfVersion,
unsigned FileNumber = 0);
368 std::optional<MD5::MD5Result> Checksum,
369 std::optional<StringRef> Source,
uint16_t DwarfVersion,
370 unsigned FileNumber = 0) {
372 DwarfVersion, FileNumber));
376 std::optional<MD5::MD5Result> Checksum,
377 std::optional<StringRef> Source) {
378 Header.CompilationDir = std::string(Directory);
379 Header.RootFile.Name = std::string(FileName);
380 Header.RootFile.DirIndex = 0;
381 Header.RootFile.Checksum = Checksum;
382 Header.RootFile.Source = Source;
383 Header.trackMD5Usage(Checksum.has_value());
384 Header.HasSource = Source.has_value();
389 bool hasRootFile()
const {
return !Header.RootFile.Name.empty(); }
402 Header.Label = Label;
406 return Header.MCDwarfDirs;
410 return Header.MCDwarfDirs;
414 return Header.MCDwarfFiles;
418 return Header.MCDwarfFiles;
422 return MCLineSections;
425 return MCLineSections;
437 int64_t LineDelta,
uint64_t AddrDelta);
465 : Name(
name), FileNumber(fileNumber), LineNumber(lineNumber),
510 std::vector<char> Values;
516 Values(V.begin(), V.end()), Comment(Comment) {
520 MCCFIInstruction(
OpType Op, MCSymbol *L,
unsigned R1,
unsigned R2)
525 MCCFIInstruction(
OpType Op, MCSymbol *L,
unsigned R,
int O,
unsigned AS)
674 return StringRef(&Values[0], Values.size());
696 unsigned RAReg =
static_cast<unsigned>(INT_MAX);
This file defines the StringMap class.
This file implements a map that provides insertion order iteration.
PowerPC Reduce CR logical Operation
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Allocate memory in an ever growing pool, as if by bump-pointer.
Tagged union holding either a T or a Error.
Generic interface to target specific assembler backends.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
MCSymbol * getLabel() const
unsigned getAddressSpace() 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...
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
unsigned getRegister2() const
unsigned getRegister() const
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
OpType getOperation() const
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
StringRef getComment() const
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...
StringRef getValues() 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.
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
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...
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
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.
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Context object for machine code objects.
void maybeSetRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
unsigned getFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, std::optional< StringRef > Source)
static void encodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
static void encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, SmallVectorImpl< char > &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
Instances of this class represent the line information for the dwarf line table entries.
void setEndLabel(MCSymbol *EndLabel)
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
MCSymbol * getLabel() const
static void make(MCStreamer *MCOS, MCSection *Section)
Manage the .debug_line_str section contents, if we use it.
void emitSection(MCStreamer *MCOS)
Emit the .debug_line_str section if appropriate.
SmallString< 0 > getFinalizedData()
Returns finalized section.
void emitRef(MCStreamer *MCOS, StringRef Path)
Emit a reference to the string.
bool isMD5UsageConsistent() const
const MCDwarfFile & getRootFile() const
void setLabel(MCSymbol *Label)
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
void setRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
MCDwarfFile & getRootFile()
const MCLineSection & getMCLineSections() const
unsigned getFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
SmallVectorImpl< std::string > & getMCDwarfDirs()
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
MCLineSection & getMCLineSections()
MCSymbol * getLabel() const
static void emitOne(MCStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params, std::optional< MCDwarfLineStr > &LineStr) const
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Instances of this class represent the information from a dwarf .loc directive.
unsigned getLine() const
Get the Line of this MCDwarfLoc.
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
unsigned getFileNum() const
Get the FileNum of this MCDwarfLoc.
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
StringRef getName() const
static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
MCSymbol * getLabel() const
unsigned getLineNumber() const
unsigned getFileNumber() const
Instances of this class represent the line information for a compile unit where machine instructions ...
const MCLineDivisionMap & getMCLineEntries() const
void addEndEntry(MCSymbol *EndLabel)
MCDwarfLineEntryCollection::const_iterator const_iterator
MCDwarfLineEntryCollection::iterator iterator
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
Streaming object file generation interface.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Wrapper class representing virtual and physical registers.
Represents a location in source code.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Utility for building string tables with deduplicated suffixes.
MCSymbol * emitListsTableHeaderStart(MCStreamer &S)
This is an optimization pass for GlobalISel generic memory operations.
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...
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
std::optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
std::optional< StringRef > Source
The source code of the file.
MCDwarfFrameInfo()=default
const MCSymbol * Personality
uint32_t CompactUnwindEncoding
unsigned PersonalityEncoding
std::vector< MCCFIInstruction > Instructions
unsigned CurrentCfaRegister
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
int8_t DWARF2LineBase
Minimum line offset in a special line info.