mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[MC] Move .cv_loc management logic out of MCContext
MCContext already has many tasks, and separating CodeView out from it is probably a good idea. The .cv_loc tracking was modelled on the DWARF tracking which lived directly in MCContext. Removes the inclusion of MCCodeView.h from MCContext.h, so now there are only 10 build actions while I hack on CodeView support instead of 265. llvm-svn: 279847
This commit is contained in:
parent
4f35a13881
commit
7500758e97
@ -25,6 +25,7 @@ namespace llvm {
|
||||
class MCContext;
|
||||
class MCObjectStreamer;
|
||||
class MCStreamer;
|
||||
class CodeViewContext;
|
||||
|
||||
/// \brief Instances of this class represent the information from a
|
||||
/// .cv_loc directive.
|
||||
@ -36,8 +37,8 @@ class MCCVLoc {
|
||||
uint16_t PrologueEnd : 1;
|
||||
uint16_t IsStmt : 1;
|
||||
|
||||
private: // MCContext manages these
|
||||
friend class MCContext;
|
||||
private: // CodeViewContext manages these
|
||||
friend class CodeViewContext;
|
||||
MCCVLoc(unsigned functionid, unsigned fileNum, unsigned line, unsigned column,
|
||||
bool prologueend, bool isstmt)
|
||||
: FunctionId(functionid), FileNum(fileNum), Line(line), Column(column),
|
||||
@ -114,6 +115,27 @@ public:
|
||||
bool addFile(unsigned FileNumber, StringRef Filename);
|
||||
ArrayRef<StringRef> getFilenames() { return Filenames; }
|
||||
|
||||
/// Saves the information from the currently parsed .cv_loc directive
|
||||
/// and sets CVLocSeen. When the next instruction is assembled an entry
|
||||
/// in the line number table with this information and the address of the
|
||||
/// instruction will be created.
|
||||
void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line,
|
||||
unsigned Column, bool PrologueEnd, bool IsStmt) {
|
||||
CurrentCVLoc.setFunctionId(FunctionId);
|
||||
CurrentCVLoc.setFileNum(FileNo);
|
||||
CurrentCVLoc.setLine(Line);
|
||||
CurrentCVLoc.setColumn(Column);
|
||||
CurrentCVLoc.setPrologueEnd(PrologueEnd);
|
||||
CurrentCVLoc.setIsStmt(IsStmt);
|
||||
CVLocSeen = true;
|
||||
}
|
||||
void clearCVLocSeen() { CVLocSeen = false; }
|
||||
|
||||
bool getCVLocSeen() { return CVLocSeen; }
|
||||
const MCCVLoc &getCurrentCVLoc() { return CurrentCVLoc; }
|
||||
|
||||
bool isValidCVFileNumber(unsigned FileNumber);
|
||||
|
||||
/// \brief Add a line entry.
|
||||
void addLineEntry(const MCCVLineEntry &LineEntry) {
|
||||
size_t Offset = MCCVLines.size();
|
||||
@ -180,6 +202,10 @@ public:
|
||||
void emitFileChecksums(MCObjectStreamer &OS);
|
||||
|
||||
private:
|
||||
/// The current CodeView line information from the last .cv_loc directive.
|
||||
MCCVLoc CurrentCVLoc = MCCVLoc(0, 0, 0, 0, false, true);
|
||||
bool CVLocSeen = false;
|
||||
|
||||
/// Map from string to string table offset.
|
||||
StringMap<unsigned> StringTable;
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/MC/MCCodeView.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/SectionKind.h"
|
||||
@ -141,10 +140,6 @@ namespace llvm {
|
||||
MCDwarfLoc CurrentDwarfLoc;
|
||||
bool DwarfLocSeen;
|
||||
|
||||
/// The current CodeView line information from the last .cv_loc directive.
|
||||
MCCVLoc CurrentCVLoc = MCCVLoc(0, 0, 0, 0, false, true);
|
||||
bool CVLocSeen = false;
|
||||
|
||||
/// Generate dwarf debugging info for assembly source files.
|
||||
bool GenDwarfForAssembly;
|
||||
|
||||
@ -534,35 +529,6 @@ namespace llvm {
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
/// \name CodeView Management
|
||||
/// @{
|
||||
|
||||
/// Creates an entry in the cv file table.
|
||||
unsigned getCVFile(StringRef FileName, unsigned FileNumber);
|
||||
|
||||
/// Saves the information from the currently parsed .cv_loc directive
|
||||
/// and sets CVLocSeen. When the next instruction is assembled an entry
|
||||
/// in the line number table with this information and the address of the
|
||||
/// instruction will be created.
|
||||
void setCurrentCVLoc(unsigned FunctionId, unsigned FileNo, unsigned Line,
|
||||
unsigned Column, bool PrologueEnd, bool IsStmt) {
|
||||
CurrentCVLoc.setFunctionId(FunctionId);
|
||||
CurrentCVLoc.setFileNum(FileNo);
|
||||
CurrentCVLoc.setLine(Line);
|
||||
CurrentCVLoc.setColumn(Column);
|
||||
CurrentCVLoc.setPrologueEnd(PrologueEnd);
|
||||
CurrentCVLoc.setIsStmt(IsStmt);
|
||||
CVLocSeen = true;
|
||||
}
|
||||
void clearCVLocSeen() { CVLocSeen = false; }
|
||||
|
||||
bool getCVLocSeen() { return CVLocSeen; }
|
||||
const MCCVLoc &getCurrentCVLoc() { return CurrentCVLoc; }
|
||||
|
||||
bool isValidCVFileNumber(unsigned FileNumber);
|
||||
/// @}
|
||||
|
||||
char *getSecureLogFile() { return SecureLogFile; }
|
||||
raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
|
||||
bool getSecureLogUsed() { return SecureLogUsed; }
|
||||
|
@ -709,8 +709,9 @@ public:
|
||||
StringRef FileName);
|
||||
|
||||
/// \brief Associate a filename with a specified logical file number. This
|
||||
/// implements the '.cv_file 4 "foo.c"' assembler directive.
|
||||
virtual unsigned EmitCVFileDirective(unsigned FileNo, StringRef Filename);
|
||||
/// implements the '.cv_file 4 "foo.c"' assembler directive. Returns true on
|
||||
/// success.
|
||||
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename);
|
||||
|
||||
/// \brief This implements the CodeView '.cv_loc' assembler directive.
|
||||
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
|
||||
|
@ -111,8 +111,9 @@ unsigned CodeViewDebug::maybeRecordFile(const DIFile *F) {
|
||||
if (Insertion.second) {
|
||||
// We have to compute the full filepath and emit a .cv_file directive.
|
||||
StringRef FullPath = getFullFilepath(F);
|
||||
NextId = OS.EmitCVFileDirective(NextId, FullPath);
|
||||
assert(NextId == FileIdMap.size() && ".cv_file directive failed");
|
||||
bool Success = OS.EmitCVFileDirective(NextId, FullPath);
|
||||
(void)Success;
|
||||
assert(Success && ".cv_file directive failed");
|
||||
}
|
||||
return Insertion.first->second;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "MIParser.h"
|
||||
#include "MILexer.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/AsmParser/Parser.h"
|
||||
#include "llvm/AsmParser/SlotMapping.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCCodeEmitter.h"
|
||||
#include "llvm/MC/MCCodeView.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCFixupKindInfo.h"
|
||||
@ -220,7 +221,7 @@ public:
|
||||
StringRef FileName) override;
|
||||
MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
|
||||
|
||||
unsigned EmitCVFileDirective(unsigned FileNo, StringRef Filename) override;
|
||||
bool EmitCVFileDirective(unsigned FileNo, StringRef Filename) override;
|
||||
void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line,
|
||||
unsigned Column, bool PrologueEnd, bool IsStmt,
|
||||
StringRef FileName) override;
|
||||
@ -1102,17 +1103,15 @@ MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(unsigned CUID) {
|
||||
return MCStreamer::getDwarfLineTableSymbol(0);
|
||||
}
|
||||
|
||||
unsigned MCAsmStreamer::EmitCVFileDirective(unsigned FileNo,
|
||||
StringRef Filename) {
|
||||
if (!getContext().getCVFile(Filename, FileNo))
|
||||
return 0;
|
||||
bool MCAsmStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
if (!getContext().getCVContext().addFile(FileNo, Filename))
|
||||
return false;
|
||||
|
||||
OS << "\t.cv_file\t" << FileNo << ' ';
|
||||
|
||||
PrintQuotedString(Filename, OS);
|
||||
EmitEOL();
|
||||
|
||||
return FileNo;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
|
||||
@ -1124,7 +1123,7 @@ void MCAsmStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
|
||||
if (PrologueEnd)
|
||||
OS << " prologue_end";
|
||||
|
||||
unsigned OldIsStmt = getContext().getCurrentCVLoc().isStmt();
|
||||
unsigned OldIsStmt = getContext().getCVContext().getCurrentCVLoc().isStmt();
|
||||
if (IsStmt != OldIsStmt) {
|
||||
OS << " is_stmt ";
|
||||
|
||||
|
@ -442,7 +442,8 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
|
||||
// a line entry made for it is made.
|
||||
//
|
||||
void MCCVLineEntry::Make(MCObjectStreamer *MCOS) {
|
||||
if (!MCOS->getContext().getCVLocSeen())
|
||||
CodeViewContext &CVC = MCOS->getContext().getCVContext();
|
||||
if (!CVC.getCVLocSeen())
|
||||
return;
|
||||
|
||||
// Create a symbol at in the current section for use in the line entry.
|
||||
@ -451,14 +452,14 @@ void MCCVLineEntry::Make(MCObjectStreamer *MCOS) {
|
||||
MCOS->EmitLabel(LineSym);
|
||||
|
||||
// Get the current .loc info saved in the context.
|
||||
const MCCVLoc &CVLoc = MCOS->getContext().getCurrentCVLoc();
|
||||
const MCCVLoc &CVLoc = CVC.getCurrentCVLoc();
|
||||
|
||||
// Create a (local) line entry with the symbol and the current .loc info.
|
||||
MCCVLineEntry LineEntry(LineSym, CVLoc);
|
||||
|
||||
// clear CVLocSeen saying the current .loc info is now used.
|
||||
MCOS->getContext().clearCVLocSeen();
|
||||
CVC.clearCVLocSeen();
|
||||
|
||||
// Add the line entry to this section's entries.
|
||||
MCOS->getContext().getCVContext().addLineEntry(LineEntry);
|
||||
CVC.addLineEntry(LineEntry);
|
||||
}
|
||||
|
@ -494,14 +494,6 @@ CodeViewContext &MCContext::getCVContext() {
|
||||
return *CVContext.get();
|
||||
}
|
||||
|
||||
unsigned MCContext::getCVFile(StringRef FileName, unsigned FileNumber) {
|
||||
return getCVContext().addFile(FileNumber, FileName) ? FileNumber : 0;
|
||||
}
|
||||
|
||||
bool MCContext::isValidCVFileNumber(unsigned FileNumber) {
|
||||
return getCVContext().isValidFileNumber(FileNumber);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Error Reporting
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "llvm/MC/MCFragment.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCAsmLayout.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
#include "llvm/MC/MCCodeEmitter.h"
|
||||
#include "llvm/MC/MCCodeView.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCCodeView.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDirectives.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
@ -234,6 +235,8 @@ public:
|
||||
MCContext &getContext() override { return Ctx; }
|
||||
MCStreamer &getStreamer() override { return Out; }
|
||||
|
||||
CodeViewContext &getCVContext() { return Ctx.getCVContext(); }
|
||||
|
||||
unsigned getAssemblerDialect() override {
|
||||
if (AssemblerDialect == ~0U)
|
||||
return MAI.getAssemblerDialect();
|
||||
@ -3274,9 +3277,9 @@ bool AsmParser::parseDirectiveCVFile() {
|
||||
parseEscapedString(Filename) ||
|
||||
parseToken(AsmToken::EndOfStatement,
|
||||
"unexpected token in '.cv_file' directive"))
|
||||
return true;
|
||||
return true;
|
||||
|
||||
if (getStreamer().EmitCVFileDirective(FileNumber, Filename) == 0)
|
||||
if (!getStreamer().EmitCVFileDirective(FileNumber, Filename))
|
||||
Error(FileNumberLoc, "file number already allocated");
|
||||
|
||||
return false;
|
||||
@ -3300,7 +3303,7 @@ bool AsmParser::parseDirectiveCVLoc() {
|
||||
parseIntToken(FileNumber, "expected integer in '.cv_loc' directive") ||
|
||||
check(FileNumber < 1, Loc,
|
||||
"file number less than one in '.cv_loc' directive") ||
|
||||
check(!getContext().isValidCVFileNumber(FileNumber), Loc,
|
||||
check(!getCVContext().isValidFileNumber(FileNumber), Loc,
|
||||
"unassigned file number in '.cv_loc' directive"))
|
||||
return true;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCCodeView.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
@ -215,16 +216,16 @@ void MCStreamer::EnsureValidDwarfFrame() {
|
||||
report_fatal_error("No open frame");
|
||||
}
|
||||
|
||||
unsigned MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
return getContext().getCVFile(Filename, FileNo);
|
||||
bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
return getContext().getCVContext().addFile(FileNo, Filename);
|
||||
}
|
||||
|
||||
void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
|
||||
unsigned Line, unsigned Column,
|
||||
bool PrologueEnd, bool IsStmt,
|
||||
StringRef FileName) {
|
||||
getContext().setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd,
|
||||
IsStmt);
|
||||
getContext().getCVContext().setCurrentCVLoc(FunctionId, FileNo, Line, Column,
|
||||
PrologueEnd, IsStmt);
|
||||
}
|
||||
|
||||
void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "AArch64RegisterInfo.h"
|
||||
#include "MCTargetDesc/AArch64FixupKinds.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/MC/MCAssembler.h"
|
||||
#include "llvm/MC/MCAsmBackend.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCDirectives.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
Loading…
Reference in New Issue
Block a user