14 #ifndef LLVM_MC_MCDWARF_H 15 #define LLVM_MC_MCDWARF_H 33 template <
typename T>
class ArrayRef;
37 class MCObjectStreamer;
80 #define DWARF2_LINE_DEFAULT_IS_STMT 1 82 #define DWARF2_FLAG_IS_STMT (1 << 0) 83 #define DWARF2_FLAG_BASIC_BLOCK (1 << 1) 84 #define DWARF2_FLAG_PROLOGUE_END (1 << 2) 85 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3) 91 MCDwarfLoc(
unsigned fileNum,
unsigned line,
unsigned column,
unsigned flags,
92 unsigned isa,
unsigned discriminator)
93 : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
94 Discriminator(discriminator) {}
126 assert(column <= UINT16_MAX);
132 assert(flags <= UINT8_MAX);
144 Discriminator = discriminator;
181 MCLineDivisions[Sec].push_back(LineEntry);
185 using iterator = MCDwarfLineEntryCollection::iterator;
196 return MCLineDivisions;
205 uint8_t DWARF2LineOpcodeBase = 13;
208 int8_t DWARF2LineBase = -5;
210 uint8_t DWARF2LineRange = 14;
220 bool HasSource =
false;
222 bool HasAllMD5 =
true;
223 bool HasAnyMD5 =
false;
232 unsigned FileNumber = 0);
233 std::pair<MCSymbol *, MCSymbol *>
236 std::pair<MCSymbol *, MCSymbol *>
245 HasAllMD5 &= MD5Used;
246 HasAnyMD5 |= MD5Used;
249 return MCDwarfFiles.
empty() || (HasAllMD5 == HasAnyMD5);
255 CompilationDir = Directory;
256 RootFile.
Name = FileName;
266 MCDwarfFiles.
clear();
267 RootFile.
Name.clear();
273 void emitV2FileDirTables(
MCStreamer *MCOS)
const;
279 bool HasSplitLineTable =
false;
287 Header.
setRootFile(Directory, FileName, Checksum, Source);
293 HasSplitLineTable =
true;
318 unsigned FileNumber = 0);
321 uint16_t DwarfVersion,
unsigned FileNumber = 0) {
322 return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
323 DwarfVersion, FileNumber));
351 Header.
Label = Label;
371 return MCLineSections;
374 return MCLineSections;
382 int64_t LineDelta, uint64_t AddrDelta,
raw_ostream &OS);
386 static bool FixedEncode(
MCContext &Context,
388 int64_t LineDelta, uint64_t AddrDelta,
393 int64_t LineDelta, uint64_t AddrDelta);
421 : Name(name), FileNumber(fileNumber), LineNumber(lineNumber),
464 std::vector<char> Values;
467 : Operation(Op), Label(L), Register(R),
Offset(O),
523 unsigned Register2) {
581 assert(Operation == OpDefCfa || Operation == OpOffset ||
582 Operation == OpRestore || Operation == OpUndefined ||
583 Operation == OpSameValue || Operation == OpDefCfaRegister ||
584 Operation == OpRelOffset || Operation == OpRegister);
589 assert(Operation == OpRegister);
594 assert(Operation == OpDefCfa || Operation == OpOffset ||
595 Operation == OpRelOffset || Operation == OpDefCfaOffset ||
596 Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
601 assert(Operation == OpEscape);
602 return StringRef(&Values[0], Values.size());
614 unsigned CurrentCfaRegister = 0;
615 unsigned PersonalityEncoding = 0;
616 unsigned LsdaEncoding = 0;
618 bool IsSignalFrame =
false;
619 bool IsSimple =
false;
620 unsigned RAReg =
static_cast<unsigned>(INT_MAX);
621 bool IsBKeyFrame =
false;
638 #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()
void maybeSetRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
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
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Tagged union holding either a T or a Error.
Context object for machine code objects.
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
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 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...
const MCDwarfFile & getRootFile() const
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
unsigned getFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
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
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.
unsigned getFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, Optional< StringRef > Source)
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.