summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-12-17 02:45:41 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-12-17 02:45:41 +0000
commit42a037abb150978b2a0a747a279a9bc5b94fa4b3 (patch)
treec3e840444452103c21c629de4a0b04c9dee5abb8 /llvm/lib/MC/MCAssembler.cpp
parentbf067ba253f9fee232a6c99fece52a0a3e4caeee (diff)
downloadbcm5719-llvm-42a037abb150978b2a0a747a279a9bc5b94fa4b3.tar.gz
bcm5719-llvm-42a037abb150978b2a0a747a279a9bc5b94fa4b3.zip
MC/Assembler: Make the MCObjectWriter available through the lifetime of the
assembler. llvm-svn: 122031
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 243975c2bc6..f91dc53c022 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -167,10 +167,11 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment,
/* *** */
-MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend,
- MCCodeEmitter &_Emitter, raw_ostream &_OS)
- : Context(_Context), Backend(_Backend), Emitter(_Emitter),
- OS(_OS), RelaxAll(false), SubsectionsViaSymbols(false)
+MCAssembler::MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
+ MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
+ raw_ostream &OS_)
+ : Context(Context_), Backend(Backend_), Emitter(Emitter_), Writer(Writer_),
+ OS(OS_), RelaxAll(false), SubsectionsViaSymbols(false)
{
}
@@ -495,7 +496,7 @@ uint64_t MCAssembler::HandleFixup(MCObjectWriter &Writer,
return FixedValue;
}
-void MCAssembler::Finish(MCObjectWriter *Writer) {
+void MCAssembler::Finish() {
DEBUG_WITH_TYPE("mc-dump", {
llvm::errs() << "assembler backend - pre-layout\n--\n";
dump(); });
@@ -503,8 +504,6 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
// Create the layout object.
MCAsmLayout Layout(*this);
-
-
// Create dummy fragments and assign section ordinals.
unsigned SectionIndex = 0;
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -527,17 +526,8 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
it2->setLayoutOrder(FragmentIndex++);
}
- llvm::OwningPtr<MCObjectWriter> OwnWriter(0);
- if (Writer == 0) {
- //no custom Writer_ : create the default one life-managed by OwningPtr
- OwnWriter.reset(getBackend().createObjectWriter(OS));
- Writer = OwnWriter.get();
- if (!Writer)
- report_fatal_error("unable to create object writer!");
- }
-
// Layout until everything fits.
- while (LayoutOnce(*Writer, Layout))
+ while (LayoutOnce(Writer, Layout))
continue;
DEBUG_WITH_TYPE("mc-dump", {
@@ -555,7 +545,7 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
// Allow the object writer a chance to perform post-layout binding (for
// example, to set the index fields in the symbol data).
- Writer->ExecutePostLayoutBinding(*this, Layout);
+ Writer.ExecutePostLayoutBinding(*this, Layout);
// Evaluate and apply the fixups, generating relocation entries as necessary.
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -566,7 +556,7 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
for (MCDataFragment::fixup_iterator it3 = DF->fixup_begin(),
ie3 = DF->fixup_end(); it3 != ie3; ++it3) {
MCFixup &Fixup = *it3;
- uint64_t FixedValue = HandleFixup(*Writer, Layout, *DF, Fixup);
+ uint64_t FixedValue = HandleFixup(Writer, Layout, *DF, Fixup);
getBackend().ApplyFixup(Fixup, DF->getContents().data(),
DF->getContents().size(), FixedValue);
}
@@ -576,7 +566,7 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
for (MCInstFragment::fixup_iterator it3 = IF->fixup_begin(),
ie3 = IF->fixup_end(); it3 != ie3; ++it3) {
MCFixup &Fixup = *it3;
- uint64_t FixedValue = HandleFixup(*Writer, Layout, *IF, Fixup);
+ uint64_t FixedValue = HandleFixup(Writer, Layout, *IF, Fixup);
getBackend().ApplyFixup(Fixup, IF->getCode().data(),
IF->getCode().size(), FixedValue);
}
@@ -585,7 +575,7 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
}
// Write the object file.
- Writer->WriteObject(*this, Layout);
+ Writer.WriteObject(*this, Layout);
stats::ObjectBytes += OS.tell() - StartOffset;
}
OpenPOWER on IntegriCloud