Add EmitInstToFragment to the generic object streamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2010-12-02 05:44:06 +00:00
parent 7fcd4dcb98
commit dedb045c32
4 changed files with 12 additions and 35 deletions

View File

@ -33,7 +33,6 @@ class MCObjectStreamer : public MCStreamer {
MCAssembler *Assembler;
MCSectionData *CurSectionData;
virtual void EmitInstToFragment(const MCInst &Inst) = 0;
virtual void EmitInstToData(const MCInst &Inst) = 0;
protected:
@ -67,6 +66,7 @@ public:
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
virtual void SwitchSection(const MCSection *Section);
virtual void EmitInstruction(const MCInst &Inst);
virtual void EmitInstToFragment(const MCInst &Inst);
virtual void Finish();
/// @}

View File

@ -459,23 +459,11 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
}
void MCELFStreamer::EmitInstToFragment(const MCInst &Inst) {
MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData());
this->MCObjectStreamer::EmitInstToFragment(Inst);
MCInstFragment &F = *cast<MCInstFragment>(getCurrentFragment());
// Add the fixups and data.
//
// FIXME: Revisit this design decision when relaxation is done, we may be
// able to get away with not storing any extra data in the MCInst.
SmallVector<MCFixup, 4> Fixups;
SmallString<256> Code;
raw_svector_ostream VecOS(Code);
getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups);
VecOS.flush();
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
fixSymbolsInTLSFixups(Fixups[i].getValue());
IF->getCode() = Code;
IF->getFixups() = Fixups;
for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i)
fixSymbolsInTLSFixups(F.getFixups()[i].getValue());
}
void MCELFStreamer::EmitInstToData(const MCInst &Inst) {

View File

@ -31,7 +31,6 @@ namespace {
class MCMachOStreamer : public MCObjectStreamer {
private:
virtual void EmitInstToFragment(const MCInst &Inst);
virtual void EmitInstToData(const MCInst &Inst);
public:
@ -341,23 +340,6 @@ void MCMachOStreamer::EmitValueToOffset(const MCExpr *Offset,
new MCOrgFragment(*Offset, Value, getCurrentSectionData());
}
void MCMachOStreamer::EmitInstToFragment(const MCInst &Inst) {
MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData());
// Add the fixups and data.
//
// FIXME: Revisit this design decision when relaxation is done, we may be
// able to get away with not storing any extra data in the MCInst.
SmallVector<MCFixup, 4> Fixups;
SmallString<256> Code;
raw_svector_ostream VecOS(Code);
getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups);
VecOS.flush();
IF->getCode() = Code;
IF->getFixups() = Fixups;
}
void MCMachOStreamer::EmitInstToData(const MCInst &Inst) {
MCDataFragment *DF = getOrCreateDataFragment();

View File

@ -172,6 +172,13 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
EmitInstToFragment(Inst);
}
void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst) {
MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData());
raw_svector_ostream VecOS(IF->getCode());
getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, IF->getFixups());
}
void MCObjectStreamer::Finish() {
getAssembler().Finish();
}