forked from OSchip/llvm-project
Add .loc methods to the streamer.
Next: Add support for the !HasDotLocAndDotFile case to the MCAsmStreamer and then switch codegen to use it. llvm-svn: 119384
This commit is contained in:
parent
c4931c4746
commit
c653a895c8
|
@ -342,7 +342,14 @@ namespace llvm {
|
|||
/// EmitDwarfFileDirective - Associate a filename with a specified logical
|
||||
/// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
|
||||
/// directive.
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename) = 0;
|
||||
virtual bool EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
||||
|
||||
/// EmitDwarfLocDirective - This implements the DWARF2
|
||||
// '.loc fileno lineno ...' assembler directive.
|
||||
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa,
|
||||
unsigned Discriminator);
|
||||
|
||||
/// EmitInstruction - Emit the given @p Instruction into the current
|
||||
/// section.
|
||||
|
|
|
@ -166,7 +166,10 @@ public:
|
|||
unsigned char Value = 0);
|
||||
|
||||
virtual void EmitFileDirective(StringRef Filename);
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename);
|
||||
virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Filename);
|
||||
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa, unsigned Discriminator);
|
||||
|
||||
virtual void EmitInstruction(const MCInst &Inst);
|
||||
|
||||
|
@ -633,10 +636,42 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
|
|||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
|
||||
bool MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
|
||||
OS << "\t.file\t" << FileNo << ' ';
|
||||
PrintQuotedString(Filename, OS);
|
||||
EmitEOL();
|
||||
return this->MCStreamer::EmitDwarfFileDirective(FileNo, Filename);
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa,
|
||||
unsigned Discriminator) {
|
||||
OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
|
||||
if (Flags & DWARF2_FLAG_BASIC_BLOCK)
|
||||
OS << " basic_block";
|
||||
if (Flags & DWARF2_FLAG_PROLOGUE_END)
|
||||
OS << " prologue_end";
|
||||
if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
|
||||
OS << " epilogue_begin";
|
||||
|
||||
unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
|
||||
if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
|
||||
OS << " is_stmt ";
|
||||
|
||||
if (Flags & DWARF2_FLAG_IS_STMT)
|
||||
OS << "1";
|
||||
else
|
||||
OS << "0";
|
||||
}
|
||||
|
||||
if (Isa)
|
||||
OS << "isa " << Isa;
|
||||
if (Discriminator)
|
||||
OS << "discriminator " << Discriminator;
|
||||
EmitEOL();
|
||||
return this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
|
||||
Isa, Discriminator);
|
||||
}
|
||||
|
||||
void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
|
|||
|
||||
|
||||
MCContext::MCContext(const MCAsmInfo &mai) : MAI(mai), NextUniqueID(0),
|
||||
CurrentDwarfLoc(0,0,0,0,0,0) {
|
||||
CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0) {
|
||||
MachOUniquingMap = 0;
|
||||
ELFUniquingMap = 0;
|
||||
COFFUniquingMap = 0;
|
||||
|
|
|
@ -137,9 +137,6 @@ public:
|
|||
unsigned char Value = 0);
|
||||
|
||||
virtual void EmitFileDirective(StringRef Filename);
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
DEBUG(dbgs() << "FIXME: MCELFStreamer:EmitDwarfFileDirective not implemented\n");
|
||||
}
|
||||
|
||||
virtual void Finish();
|
||||
|
||||
|
|
|
@ -205,12 +205,23 @@ public:
|
|||
return Child->EmitFileDirective(Filename);
|
||||
}
|
||||
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
LogCall("EmitDwarfFileDirective",
|
||||
"FileNo:" + Twine(FileNo) + " Filename:" + Filename);
|
||||
return Child->EmitDwarfFileDirective(FileNo, Filename);
|
||||
}
|
||||
|
||||
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa, unsigned Discriminator) {
|
||||
LogCall("EmitDwarfLocDirective",
|
||||
"FileNo:" + Twine(FileNo) + " Line:" + Twine(Line) +
|
||||
" Column:" + Twine(Column) + " Flags:" + Twine(Flags) +
|
||||
" Isa:" + Twine(Isa) + " Discriminator:" + Twine(Discriminator));
|
||||
return Child->EmitDwarfLocDirective(FileNo, Line, Column, Flags,
|
||||
Isa, Discriminator);
|
||||
}
|
||||
|
||||
virtual void EmitInstruction(const MCInst &Inst) {
|
||||
LogCall("EmitInstruction");
|
||||
return Child->EmitInstruction(Inst);
|
||||
|
|
|
@ -92,12 +92,6 @@ public:
|
|||
|
||||
//report_fatal_error("unsupported directive: '.file'");
|
||||
}
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
||||
// FIXME: Just ignore the .file; it isn't important enough to fail the
|
||||
// entire assembly.
|
||||
|
||||
//report_fatal_error("unsupported directive: '.file'");
|
||||
}
|
||||
|
||||
virtual void Finish();
|
||||
|
||||
|
|
|
@ -83,7 +83,12 @@ namespace {
|
|||
unsigned char Value = 0) {}
|
||||
|
||||
virtual void EmitFileDirective(StringRef Filename) {}
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename) {}
|
||||
virtual bool EmitDwarfFileDirective(unsigned FileNo,StringRef Filename) {
|
||||
return false;
|
||||
}
|
||||
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa, unsigned Discriminator) {}
|
||||
virtual void EmitInstruction(const MCInst &Inst) {}
|
||||
|
||||
virtual void Finish() {}
|
||||
|
|
|
@ -1995,9 +1995,8 @@ bool GenericAsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
|
|||
if (FileNumber == -1)
|
||||
getStreamer().EmitFileDirective(Filename);
|
||||
else {
|
||||
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
|
||||
if (getStreamer().EmitDwarfFileDirective(FileNumber, Filename))
|
||||
Error(FileNumberLoc, "file number already allocated");
|
||||
getStreamer().EmitDwarfFileDirective(FileNumber, Filename);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -2125,8 +2124,8 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||
}
|
||||
}
|
||||
|
||||
getContext().setCurrentDwarfLoc(FileNumber, LineNumber, ColumnPos, Flags,
|
||||
Isa, Discriminator);
|
||||
getStreamer().EmitDwarfLocDirective(FileNumber, LineNumber, ColumnPos, Flags,
|
||||
Isa, Discriminator);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCObjectWriter.h"
|
||||
|
@ -63,6 +64,19 @@ void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
|
|||
EmitValue(E, 1, AddrSpace);
|
||||
}
|
||||
|
||||
bool MCStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
||||
StringRef Filename) {
|
||||
return getContext().GetDwarfFile(Filename, FileNo) == 0;
|
||||
}
|
||||
|
||||
void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
||||
unsigned Column, unsigned Flags,
|
||||
unsigned Isa,
|
||||
unsigned Discriminator) {
|
||||
getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
|
||||
Discriminator);
|
||||
}
|
||||
|
||||
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
||||
/// the specified string in the output .s file. This capability is
|
||||
/// indicated by the hasRawTextSupport() predicate.
|
||||
|
|
|
@ -77,7 +77,6 @@ public:
|
|||
unsigned MaxBytesToEmit);
|
||||
virtual void EmitValueToOffset(const MCExpr *Offset, unsigned char Value);
|
||||
virtual void EmitFileDirective(StringRef Filename);
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
||||
virtual void EmitInstruction(const MCInst &Instruction);
|
||||
virtual void Finish();
|
||||
|
||||
|
@ -414,11 +413,6 @@ void WinCOFFStreamer::EmitFileDirective(StringRef Filename) {
|
|||
// info will be a much large effort.
|
||||
}
|
||||
|
||||
void WinCOFFStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
||||
StringRef Filename) {
|
||||
llvm_unreachable("not implemented");
|
||||
}
|
||||
|
||||
void WinCOFFStreamer::EmitInstruction(const MCInst &Instruction) {
|
||||
for (unsigned i = 0, e = Instruction.getNumOperands(); i != e; ++i)
|
||||
if (Instruction.getOperand(i).isExpr())
|
||||
|
|
|
@ -337,11 +337,13 @@ void PTXMCAsmStreamer::EmitFileDirective(StringRef Filename) {
|
|||
EmitEOL();
|
||||
}
|
||||
|
||||
void PTXMCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
||||
// FIXME: should we inherit from MCAsmStreamer?
|
||||
bool PTXMCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
||||
StringRef Filename){
|
||||
OS << "\t.file\t" << FileNo << ' ';
|
||||
PrintQuotedString(Filename, OS);
|
||||
EmitEOL();
|
||||
return this->MCStreamer::EmitDwarfFileDirective(FileNo, Filename);
|
||||
}
|
||||
|
||||
void PTXMCAsmStreamer::AddEncodingComment(const MCInst &Inst) {}
|
||||
|
|
|
@ -171,7 +171,7 @@ public:
|
|||
unsigned char Value = 0);
|
||||
|
||||
virtual void EmitFileDirective(StringRef Filename);
|
||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename);
|
||||
virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Filename);
|
||||
|
||||
virtual void EmitInstruction(const MCInst &Inst);
|
||||
|
||||
|
|
Loading…
Reference in New Issue