X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FWinCOFFStreamer.cpp;h=5489ef8d89dbf501342186d4af09f8a8a810040e;hb=60230ef987f234df88a166fc7878cf3051bca0a1;hp=d12201a6ca697c6ca35a0d72c41e5066960824ec;hpb=2c3a4641a7785da78839caf574277df9cd93b52c;p=oota-llvm.git diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp index d12201a6ca6..5489ef8d89d 100644 --- a/lib/MC/WinCOFFStreamer.cpp +++ b/lib/MC/WinCOFFStreamer.cpp @@ -72,16 +72,25 @@ public: virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); virtual void EmitFileDirective(StringRef Filename); - virtual void EmitInstruction(const MCInst &Instruction); virtual void EmitWin64EHHandlerData(); virtual void FinishImpl(); private: - virtual void EmitInstToFragment(const MCInst &Inst) { - llvm_unreachable("Not used by WinCOFF."); - } virtual void EmitInstToData(const MCInst &Inst) { - llvm_unreachable("Not used by WinCOFF."); + MCDataFragment *DF = getOrCreateDataFragment(); + + SmallVector Fixups; + SmallString<256> Code; + raw_svector_ostream VecOS(Code); + getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups); + VecOS.flush(); + + // Add the fixups and data. + for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { + Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); + DF->getFixups().push_back(Fixups[i]); + } + DF->getContents().append(Code.begin(), Code.end()); } void SetSection(StringRef Section, @@ -116,7 +125,6 @@ private: SectionKind::getBSS()); EmitCodeAlignment(4, 0); } - }; } // end anonymous namespace. @@ -334,22 +342,6 @@ void WinCOFFStreamer::EmitFileDirective(StringRef Filename) { // info will be a much large effort. } -void WinCOFFStreamer::EmitInstruction(const MCInst &Instruction) { - for (unsigned i = 0, e = Instruction.getNumOperands(); i != e; ++i) - if (Instruction.getOperand(i).isExpr()) - AddValueSymbols(Instruction.getOperand(i).getExpr()); - - getCurrentSectionData()->setHasInstructions(true); - - MCInstFragment *Fragment = - new MCInstFragment(Instruction, getCurrentSectionData()); - - raw_svector_ostream VecOS(Fragment->getContents()); - - getAssembler().getEmitter().EncodeInstruction(Instruction, VecOS, - Fragment->getFixups()); -} - void WinCOFFStreamer::EmitWin64EHHandlerData() { MCStreamer::EmitWin64EHHandlerData();