aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-12-02 05:44:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-12-02 05:44:06 +0000
commitdedb045c3296c831962c4ae101531c38c273ba89 (patch)
treed2e79615a7075aa7744d122425f357c7fa169bf8
parent7fcd4dcb98d2e2bec231e713aefd2cacc879dd33 (diff)
downloadexternal_llvm-dedb045c3296c831962c4ae101531c38c273ba89.zip
external_llvm-dedb045c3296c831962c4ae101531c38c273ba89.tar.gz
external_llvm-dedb045c3296c831962c4ae101531c38c273ba89.tar.bz2
Add EmitInstToFragment to the generic object streamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120690 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCObjectStreamer.h2
-rw-r--r--lib/MC/MCELFStreamer.cpp20
-rw-r--r--lib/MC/MCMachOStreamer.cpp18
-rw-r--r--lib/MC/MCObjectStreamer.cpp7
4 files changed, 12 insertions, 35 deletions
diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h
index 9197ed3..f5ee41a 100644
--- a/include/llvm/MC/MCObjectStreamer.h
+++ b/include/llvm/MC/MCObjectStreamer.h
@@ -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();
/// @}
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 9dfc16e..f7cb3ed 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -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) {
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp
index 6824543..4da4ed8 100644
--- a/lib/MC/MCMachOStreamer.cpp
+++ b/lib/MC/MCMachOStreamer.cpp
@@ -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();
diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp
index 111bc1b..a8ea1a4 100644
--- a/lib/MC/MCObjectStreamer.cpp
+++ b/lib/MC/MCObjectStreamer.cpp
@@ -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();
}