15 #ifndef LLVM_MC_MCDWARF_H 16 #define LLVM_MC_MCDWARF_H 34 template <
typename T>
class ArrayRef;
38 class MCObjectStreamer;
78 #define DWARF2_LINE_DEFAULT_IS_STMT 1 80 #define DWARF2_FLAG_IS_STMT (1 << 0) 81 #define DWARF2_FLAG_BASIC_BLOCK (1 << 1) 82 #define DWARF2_FLAG_PROLOGUE_END (1 << 2) 83 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3) 89 MCDwarfLoc(
unsigned fileNum,
unsigned line,
unsigned column,
unsigned flags,
90 unsigned isa,
unsigned discriminator)
91 : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
92 Discriminator(discriminator) {}
124 assert(column <= UINT16_MAX);
130 assert(flags <= UINT8_MAX);
142 Discriminator = discriminator;
179 MCLineDivisions[Sec].push_back(LineEntry);
183 using iterator = MCDwarfLineEntryCollection::iterator;
194 return MCLineDivisions;
203 uint8_t DWARF2LineOpcodeBase = 13;
206 int8_t DWARF2LineBase = -5;
208 uint8_t DWARF2LineRange = 14;
218 bool HasSource =
false;
220 bool HasAllMD5 =
true;
221 bool HasAnyMD5 =
false;
229 unsigned FileNumber = 0);
230 std::pair<MCSymbol *, MCSymbol *>
233 std::pair<MCSymbol *, MCSymbol *>
242 HasAllMD5 &= MD5Used;
243 HasAnyMD5 |= MD5Used;
246 return MCDwarfFiles.
empty() || (HasAllMD5 == HasAnyMD5);
250 void emitV2FileDirTables(
MCStreamer *MCOS)
const;
296 unsigned FileNumber = 0);
299 unsigned FileNumber = 0) {
300 return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
332 Header.
Label = Label;
352 return MCLineSections;
355 return MCLineSections;
363 int64_t LineDelta, uint64_t AddrDelta,
raw_ostream &OS);
367 static bool FixedEncode(
MCContext &Context,
369 int64_t LineDelta, uint64_t AddrDelta,
374 int64_t LineDelta, uint64_t AddrDelta);
402 : Name(name), FileNumber(fileNumber), LineNumber(lineNumber),
445 std::vector<char> Values;
448 : Operation(Op), Label(L), Register(R),
Offset(O),
504 unsigned Register2) {
562 assert(Operation == OpDefCfa || Operation == OpOffset ||
563 Operation == OpRestore || Operation == OpUndefined ||
564 Operation == OpSameValue || Operation == OpDefCfaRegister ||
565 Operation == OpRelOffset || Operation == OpRegister);
570 assert(Operation == OpRegister);
575 assert(Operation == OpDefCfa || Operation == OpOffset ||
576 Operation == OpRelOffset || Operation == OpDefCfaOffset ||
577 Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
582 assert(Operation == OpEscape);
583 return StringRef(&Values[0], Values.size());
595 unsigned CurrentCfaRegister = 0;
596 unsigned PersonalityEncoding = 0;
597 unsigned LsdaEncoding = 0;
599 bool IsSignalFrame =
false;
600 bool IsSimple =
false;
601 unsigned RAReg =
static_cast<unsigned>(INT_MAX);
602 bool IsBKeyFrame =
false;
618 #endif // LLVM_MC_MCDWARF_H void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
const_iterator end(StringRef path)
Get end iterator over path.
unsigned getLine() const
Get the Line of this MCDwarfLoc.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
MCDwarfLineEntryCollection::iterator iterator
Optional< StringRef > Source
The source code of the file.
This class represents lattice values for constants.
SmallVectorImpl< std::string > & getMCDwarfDirs()
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
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...
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
std::vector< MCCFIInstruction > Instructions
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
bool isMD5UsageConsistent() const
StringRef getName() const
const MCLineDivisionMap & getMCLineEntries() const
Tagged union holding either a T or a Error.
unsigned getFile(StringRef &Directory, StringRef &FileName, MD5::MD5Result *Checksum, Optional< StringRef > &Source, unsigned FileNumber=0)
Context object for machine code objects.
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
unsigned getFile(StringRef Directory, StringRef FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source)
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 getFileNumber() const
MCSymbol * getLabel() const
unsigned getFileNum() const
Get the FileNum 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.
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Streaming machine code generation interface.
static MCCFIInstruction createDefCfa(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...
unsigned getRegister2() const
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
PowerPC Reduce CR logical Operation
Instances of this class represent the line information for a compile unit where machine instructions ...
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
void maybeSetRootFile(StringRef Directory, StringRef FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source)
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
OpType getOperation() const
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 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...
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
StringRef getValues() const
const MCLineSection & getMCLineSections() const
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
unsigned getRegister() const
MCDwarfLineEntryCollection::const_iterator const_iterator
Promote Memory to Register
LLVM_NODISCARD bool isa(const Y &Val)
Instances of this class represent the line information for the dwarf line table entries.
MCLineSection & getMCLineSections()
MCSymbol * getLabel() const
MCSymbol * getLabel() const
void setRootFile(StringRef Directory, StringRef FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source)
LLVM_NODISCARD bool empty() const
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
MD5::MD5Result * Checksum
The MD5 checksum, if there is one.
MCSymbol * getLabel() const
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Generic interface to target specific assembler backends.
This class implements an extremely fast bulk output stream that can only output to a stream...
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
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...
Represents a location in source code.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
unsigned getLineNumber() const
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
void setLabel(MCSymbol *Label)
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.