X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCObjectStreamer.cpp;h=5c08610657e4bb458f3737b96e5ac7eae9e34d6c;hb=94ad5a120fe320171f1630d1878ec1ae8b7eafa1;hp=d21ce8d1a117afc15661353600879e2841f25142;hpb=df39be6cb4eb44011db3d3e86f8fe463f81ce127;p=oota-llvm.git diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index d21ce8d1a11..5c08610657e 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -17,23 +17,27 @@ #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" +#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/ErrorHandling.h" using namespace llvm; -MCObjectStreamer::MCObjectStreamer(StreamerKind Kind, MCContext &Context, +MCObjectStreamer::MCObjectStreamer(MCContext &Context, + MCTargetStreamer *TargetStreamer, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter_) - : MCStreamer(Kind, Context), + : MCStreamer(Context, TargetStreamer), Assembler(new MCAssembler(Context, TAB, *Emitter_, *TAB.createObjectWriter(OS), OS)), CurSectionData(0) {} -MCObjectStreamer::MCObjectStreamer(StreamerKind Kind, MCContext &Context, +MCObjectStreamer::MCObjectStreamer(MCContext &Context, + MCTargetStreamer *TargetStreamer, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter_, MCAssembler *_Assembler) - : MCStreamer(Kind, Context), Assembler(_Assembler), CurSectionData(0) {} + : MCStreamer(Context, TargetStreamer), Assembler(_Assembler), + CurSectionData(0) {} MCObjectStreamer::~MCObjectStreamer() { delete &Assembler->getBackend(); @@ -98,15 +102,15 @@ const MCExpr *MCObjectStreamer::AddValueSymbols(const MCExpr *Value) { return Value; } -void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) { - assert(AddrSpace == 0 && "Address space must be 0!"); +void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) { MCDataFragment *DF = getOrCreateDataFragment(); + MCLineEntry::Make(this, getCurrentSection().first); + // Avoid fixups when possible. int64_t AbsValue; if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, getAssembler())) { - EmitIntValue(AbsValue, Size, AddrSpace); + EmitIntValue(AbsValue, Size); return; } DF->getFixups().push_back( @@ -241,7 +245,7 @@ void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst) { } #ifndef NDEBUG -static const char *BundlingNotImplementedMsg = +static const char *const BundlingNotImplementedMsg = "Aligned bundling is not implemented for this object format"; #endif @@ -257,6 +261,19 @@ void MCObjectStreamer::EmitBundleUnlock() { llvm_unreachable(BundlingNotImplementedMsg); } +void MCObjectStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, + unsigned Column, unsigned Flags, + unsigned Isa, + unsigned Discriminator, + StringRef FileName) { + // In case we see two .loc directives in a row, make sure the + // first one gets a line entry. + MCLineEntry::Make(this, getCurrentSection().first); + + this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags, + Isa, Discriminator, FileName); +} + void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, @@ -287,8 +304,8 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, insert(new MCDwarfCallFrameFragment(*AddrDelta)); } -void MCObjectStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { - assert(AddrSpace == 0 && "Address space must be 0!"); +void MCObjectStreamer::EmitBytes(StringRef Data) { + MCLineEntry::Make(this, getCurrentSection().first); getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end()); } @@ -351,14 +368,17 @@ void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) { DF->getContents().resize(DF->getContents().size() + 8, 0); } -void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue, - unsigned AddrSpace) { - assert(AddrSpace == 0 && "Address space must be 0!"); +void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) { // FIXME: A MCFillFragment would be more memory efficient but MCExpr has // problems evaluating expressions across multiple fragments. getOrCreateDataFragment()->getContents().append(NumBytes, FillValue); } +void MCObjectStreamer::EmitZeros(uint64_t NumBytes) { + unsigned ItemSize = getCurrentSection().first->isVirtualSection() ? 0 : 1; + insert(new MCFillFragment(0, ItemSize, NumBytes)); +} + void MCObjectStreamer::FinishImpl() { // Dump out the dwarf file & directory tables and line tables. const MCSymbol *LineSectionSymbol = NULL;