14 #ifndef LLVM_MC_MCCODEVIEW_H
15 #define LLVM_MC_MCCODEVIEW_H
26 class MCObjectStreamer;
28 class CodeViewContext;
37 uint16_t PrologueEnd : 1;
42 MCCVLoc(
unsigned functionid,
unsigned fileNum,
unsigned line,
unsigned column,
43 bool prologueend,
bool isstmt)
44 : FunctionId(functionid), FileNum(fileNum), Line(line), Column(column),
45 PrologueEnd(prologueend), IsStmt(isstmt) {}
63 bool isStmt()
const {
return IsStmt; }
71 void setLine(
unsigned line) { Line = line; }
75 assert(column <= UINT16_MAX);
176 unsigned IAFile,
unsigned IALine,
181 if (FuncId >= Functions.size())
183 if (Functions[FuncId].isUnallocatedFunctionInfo())
185 return &Functions[FuncId];
193 unsigned Column,
bool PrologueEnd,
bool IsStmt) {
211 size_t Offset = MCCVLines.size();
212 auto I = MCCVLineStartStop.insert(
215 I.first->second.second = Offset + 1;
216 MCCVLines.push_back(LineEntry);
220 std::vector<MCCVLineEntry> FilteredLines;
222 auto I = MCCVLineStartStop.find(FuncId);
223 if (
I != MCCVLineStartStop.end())
224 for (
size_t Idx =
I->second.first,
End =
I->second.second; Idx !=
End;
226 if (MCCVLines[Idx].getFunctionId() == FuncId)
227 FilteredLines.push_back(MCCVLines[Idx]);
228 return FilteredLines;
232 auto I = MCCVLineStartStop.find(FuncId);
234 if (
I == MCCVLineStartStop.end())
242 if (L >= MCCVLines.size())
253 unsigned PrimaryFunctionId,
254 unsigned SourceFileId,
255 unsigned SourceLineNum,
265 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
279 bool CVLocSeen =
false;
286 bool InsertedStrTabFragment =
false;
294 unsigned getStringTableOffset(
StringRef S);
301 std::map<unsigned, std::pair<size_t, size_t>> MCCVLineStartStop;
304 std::vector<MCCVLineEntry> MCCVLines;
307 std::vector<MCCVFunctionInfo> Functions;
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void encodeDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &F)
Instances of this class represent the information from a .cv_loc directive.
void emitLineTableForFunction(MCObjectStreamer &OS, unsigned FuncId, const MCSymbol *FuncBegin, const MCSymbol *FuncEnd)
Emits a line table substream.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet...
bool isUnallocatedFunctionInfo() const
Returns true if this is function info has not yet been used in a .cv_func_id or .cv_inline_site_id di...
static void Make(MCObjectStreamer *MCOS)
unsigned getFunctionId() const
const MCSymbol * getLabel() const
DenseMap< unsigned, LineInfo > InlinedAtMap
Map from inlined call site id to the inlined at location to use for that call site.
void setColumn(unsigned column)
Set the Column of this MCCVLoc.
void emitInlineLineTableForFunction(MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Encapsulates the layout of an assembly file at a particular point in time.
unsigned getColumn() const
Get the Column of this MCCVLoc.
bool isInlinedCallSite() const
Returns true if this represents an inlined call site, meaning ParentFuncIdPlusOne is neither zero nor...
void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt)
Saves the information from the currently parsed .cv_loc directive and sets CVLocSeen.
Streaming object file generation interface.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const MCCVLoc & getCurrentCVLoc()
void encodeInlineLineTable(MCAsmLayout &Layout, MCCVInlineLineTableFragment &F)
Encodes the binary annotations once we have a layout.
bool addFile(unsigned FileNumber, StringRef Filename)
ArrayRef< StringRef > getFilenames()
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
std::vector< MCCVLineEntry > getFunctionLineEntries(unsigned FuncId)
static const unsigned End
void setFunctionId(unsigned FID)
void setFileNum(unsigned fileNum)
Set the FileNum of this MCCVLoc.
ArrayRef< MCCVLineEntry > getLinesForExtent(size_t L, size_t R)
bool isValidFileNumber(unsigned FileNumber) const
This is a valid number for use with .cv_loc if we've already seen a .cv_file for it.
bool isValidCVFileNumber(unsigned FileNumber)
Fragment representing the .cv_def_range directive.
void setLine(unsigned line)
Set the Line of this MCCVLoc.
void addLineEntry(const MCCVLineEntry &LineEntry)
Add a line entry.
unsigned ParentFuncIdPlusOne
If this represents an inlined call site, then ParentFuncIdPlusOne will be the parent function id plus...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
std::pair< size_t, size_t > getLineExtent(unsigned FuncId)
MCCVLineEntry(const MCSymbol *Label, const MCCVLoc loc)
Fragment representing the binary annotations produced by the .cv_inline_linetable directive...
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
unsigned getParentFuncId() const
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
void emitDefRange(MCObjectStreamer &OS, ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
void setPrologueEnd(bool PE)
void emitStringTable(MCObjectStreamer &OS)
Emits the string table substream.
unsigned getLine() const
Get the Line of this MCCVLoc.
Instances of this class represent the line information for the CodeView line table entries...
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Information describing a function or inlined call site introduced by .cv_func_id or ...
void emitFileChecksums(MCObjectStreamer &OS)
Emits the file checksum substream.
unsigned getFileNum() const
Get the FileNum of this MCCVLoc.
bool isPrologueEnd() const
Holds state from .cv_file and .cv_loc directives for later emission.