diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-01 16:27:31 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-11-01 16:27:31 +0000 |
commit | f89671d994ba27e2816a7e49eb8bbc1b43d2a147 (patch) | |
tree | 29ca9734a11b3e76b9add2ffa89d5ff04845c1e8 /lib/MC/MCMachOStreamer.cpp | |
parent | 9729d2e9989f970724776c3e947cc7244ae45f90 (diff) | |
download | external_llvm-f89671d994ba27e2816a7e49eb8bbc1b43d2a147.tar.gz external_llvm-f89671d994ba27e2816a7e49eb8bbc1b43d2a147.tar.bz2 external_llvm-f89671d994ba27e2816a7e49eb8bbc1b43d2a147.zip |
Move EmitInstruction to MCObjectStreamer so that ELF and MachO can share it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117925 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCMachOStreamer.cpp')
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index a10a63ee6a..21f3002dde 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -31,8 +31,8 @@ namespace { class MCMachOStreamer : public MCObjectStreamer { private: - void EmitInstToFragment(const MCInst &Inst); - void EmitInstToData(const MCInst &Inst); + virtual void EmitInstToFragment(const MCInst &Inst); + virtual void EmitInstToData(const MCInst &Inst); public: MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, @@ -98,8 +98,6 @@ public: //report_fatal_error("unsupported directive: '.file'"); } - virtual void EmitInstruction(const MCInst &Inst); - virtual void Finish(); /// @} @@ -406,39 +404,6 @@ void MCMachOStreamer::EmitInstToData(const MCInst &Inst) { DF->getContents().append(Code.begin(), Code.end()); } -void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { - // Scan for values. - for (unsigned i = Inst.getNumOperands(); i--; ) - if (Inst.getOperand(i).isExpr()) - AddValueSymbols(Inst.getOperand(i).getExpr()); - - getCurrentSectionData()->setHasInstructions(true); - - // Now that a machine instruction has been assembled into this section, make - // a line entry for any .loc directive that has been seen. - MCLineEntry::Make(this, getCurrentSection()); - - // If this instruction doesn't need relaxation, just emit it as data. - if (!getAssembler().getBackend().MayNeedRelaxation(Inst)) { - EmitInstToData(Inst); - return; - } - - // Otherwise, if we are relaxing everything, relax the instruction as much as - // possible and emit it as data. - if (getAssembler().getRelaxAll()) { - MCInst Relaxed; - getAssembler().getBackend().RelaxInstruction(Inst, Relaxed); - while (getAssembler().getBackend().MayNeedRelaxation(Relaxed)) - getAssembler().getBackend().RelaxInstruction(Relaxed, Relaxed); - EmitInstToData(Relaxed); - return; - } - - // Otherwise emit to a separate fragment. - EmitInstToFragment(Inst); -} - void MCMachOStreamer::Finish() { // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles()) { |