mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Add .loc methods to the streamer.
Next: Add support for the !HasDotLocAndDotFile case to the MCAsmStreamer and then switch codegen to use it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
668ac2fdae
commit
af6b580875
@ -342,7 +342,14 @@ namespace llvm {
|
|||||||
/// EmitDwarfFileDirective - Associate a filename with a specified logical
|
/// EmitDwarfFileDirective - Associate a filename with a specified logical
|
||||||
/// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
|
/// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
|
||||||
/// directive.
|
/// 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
|
/// EmitInstruction - Emit the given @p Instruction into the current
|
||||||
/// section.
|
/// section.
|
||||||
|
@ -166,7 +166,10 @@ public:
|
|||||||
unsigned char Value = 0);
|
unsigned char Value = 0);
|
||||||
|
|
||||||
virtual void EmitFileDirective(StringRef Filename);
|
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);
|
virtual void EmitInstruction(const MCInst &Inst);
|
||||||
|
|
||||||
@ -633,10 +636,42 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
|
|||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
|
bool MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
|
||||||
OS << "\t.file\t" << FileNo << ' ';
|
OS << "\t.file\t" << FileNo << ' ';
|
||||||
PrintQuotedString(Filename, OS);
|
PrintQuotedString(Filename, OS);
|
||||||
EmitEOL();
|
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) {
|
void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
||||||
|
@ -25,7 +25,7 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
|
|||||||
|
|
||||||
|
|
||||||
MCContext::MCContext(const MCAsmInfo &mai) : MAI(mai), NextUniqueID(0),
|
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;
|
MachOUniquingMap = 0;
|
||||||
ELFUniquingMap = 0;
|
ELFUniquingMap = 0;
|
||||||
COFFUniquingMap = 0;
|
COFFUniquingMap = 0;
|
||||||
|
@ -137,9 +137,6 @@ public:
|
|||||||
unsigned char Value = 0);
|
unsigned char Value = 0);
|
||||||
|
|
||||||
virtual void EmitFileDirective(StringRef Filename);
|
virtual void EmitFileDirective(StringRef Filename);
|
||||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
|
||||||
DEBUG(dbgs() << "FIXME: MCELFStreamer:EmitDwarfFileDirective not implemented\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Finish();
|
virtual void Finish();
|
||||||
|
|
||||||
|
@ -205,12 +205,23 @@ public:
|
|||||||
return Child->EmitFileDirective(Filename);
|
return Child->EmitFileDirective(Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) {
|
||||||
LogCall("EmitDwarfFileDirective",
|
LogCall("EmitDwarfFileDirective",
|
||||||
"FileNo:" + Twine(FileNo) + " Filename:" + Filename);
|
"FileNo:" + Twine(FileNo) + " Filename:" + Filename);
|
||||||
return Child->EmitDwarfFileDirective(FileNo, 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) {
|
virtual void EmitInstruction(const MCInst &Inst) {
|
||||||
LogCall("EmitInstruction");
|
LogCall("EmitInstruction");
|
||||||
return Child->EmitInstruction(Inst);
|
return Child->EmitInstruction(Inst);
|
||||||
|
@ -92,12 +92,6 @@ public:
|
|||||||
|
|
||||||
//report_fatal_error("unsupported directive: '.file'");
|
//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();
|
virtual void Finish();
|
||||||
|
|
||||||
|
@ -83,7 +83,12 @@ namespace {
|
|||||||
unsigned char Value = 0) {}
|
unsigned char Value = 0) {}
|
||||||
|
|
||||||
virtual void EmitFileDirective(StringRef Filename) {}
|
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 EmitInstruction(const MCInst &Inst) {}
|
||||||
|
|
||||||
virtual void Finish() {}
|
virtual void Finish() {}
|
||||||
|
@ -1995,9 +1995,8 @@ bool GenericAsmParser::ParseDirectiveFile(StringRef, SMLoc DirectiveLoc) {
|
|||||||
if (FileNumber == -1)
|
if (FileNumber == -1)
|
||||||
getStreamer().EmitFileDirective(Filename);
|
getStreamer().EmitFileDirective(Filename);
|
||||||
else {
|
else {
|
||||||
if (getContext().GetDwarfFile(Filename, FileNumber) == 0)
|
if (getStreamer().EmitDwarfFileDirective(FileNumber, Filename))
|
||||||
Error(FileNumberLoc, "file number already allocated");
|
Error(FileNumberLoc, "file number already allocated");
|
||||||
getStreamer().EmitDwarfFileDirective(FileNumber, Filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -2125,8 +2124,8 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getContext().setCurrentDwarfLoc(FileNumber, LineNumber, ColumnPos, Flags,
|
getStreamer().EmitDwarfLocDirective(FileNumber, LineNumber, ColumnPos, Flags,
|
||||||
Isa, Discriminator);
|
Isa, Discriminator);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCObjectWriter.h"
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
@ -63,6 +64,19 @@ void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
|
|||||||
EmitValue(E, 1, AddrSpace);
|
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
|
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
||||||
/// the specified string in the output .s file. This capability is
|
/// the specified string in the output .s file. This capability is
|
||||||
/// indicated by the hasRawTextSupport() predicate.
|
/// indicated by the hasRawTextSupport() predicate.
|
||||||
|
@ -77,7 +77,6 @@ public:
|
|||||||
unsigned MaxBytesToEmit);
|
unsigned MaxBytesToEmit);
|
||||||
virtual void EmitValueToOffset(const MCExpr *Offset, unsigned char Value);
|
virtual void EmitValueToOffset(const MCExpr *Offset, unsigned char Value);
|
||||||
virtual void EmitFileDirective(StringRef Filename);
|
virtual void EmitFileDirective(StringRef Filename);
|
||||||
virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
|
||||||
virtual void EmitInstruction(const MCInst &Instruction);
|
virtual void EmitInstruction(const MCInst &Instruction);
|
||||||
virtual void Finish();
|
virtual void Finish();
|
||||||
|
|
||||||
@ -414,11 +413,6 @@ void WinCOFFStreamer::EmitFileDirective(StringRef Filename) {
|
|||||||
// info will be a much large effort.
|
// info will be a much large effort.
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinCOFFStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
|
||||||
StringRef Filename) {
|
|
||||||
llvm_unreachable("not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
void WinCOFFStreamer::EmitInstruction(const MCInst &Instruction) {
|
void WinCOFFStreamer::EmitInstruction(const MCInst &Instruction) {
|
||||||
for (unsigned i = 0, e = Instruction.getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = Instruction.getNumOperands(); i != e; ++i)
|
||||||
if (Instruction.getOperand(i).isExpr())
|
if (Instruction.getOperand(i).isExpr())
|
||||||
|
@ -337,11 +337,13 @@ void PTXMCAsmStreamer::EmitFileDirective(StringRef Filename) {
|
|||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PTXMCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
// FIXME: should we inherit from MCAsmStreamer?
|
||||||
|
bool PTXMCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
|
||||||
StringRef Filename){
|
StringRef Filename){
|
||||||
OS << "\t.file\t" << FileNo << ' ';
|
OS << "\t.file\t" << FileNo << ' ';
|
||||||
PrintQuotedString(Filename, OS);
|
PrintQuotedString(Filename, OS);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
|
return this->MCStreamer::EmitDwarfFileDirective(FileNo, Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PTXMCAsmStreamer::AddEncodingComment(const MCInst &Inst) {}
|
void PTXMCAsmStreamer::AddEncodingComment(const MCInst &Inst) {}
|
||||||
|
@ -171,7 +171,7 @@ public:
|
|||||||
unsigned char Value = 0);
|
unsigned char Value = 0);
|
||||||
|
|
||||||
virtual void EmitFileDirective(StringRef Filename);
|
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);
|
virtual void EmitInstruction(const MCInst &Inst);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user