diff options
author | Lang Hames <lhames@gmail.com> | 2014-04-15 04:40:56 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2014-04-15 04:40:56 +0000 |
commit | a1bc0f56623b4ca1851d27c9f64cccdfdc055c06 (patch) | |
tree | dd9fe4641d2c5e95538962439dc0030c923df47a /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 33ec29ace9e2437fa818fba61d3ed8c558bba6ce (diff) | |
download | bcm5719-llvm-a1bc0f56623b4ca1851d27c9f64cccdfdc055c06.tar.gz bcm5719-llvm-a1bc0f56623b4ca1851d27c9f64cccdfdc055c06.zip |
[MC] Require an MCContext when constructing an MCDisassembler.
This patch re-introduces the MCContext member that was removed from
MCDisassembler in r206063, and requires that an MCContext be passed in at
MCDisassembler construction time. (Previously the MCContext member had been
initialized in an ad-hoc fashion after construction). The MCCContext member
can be used by MCDisassembler sub-classes to construct constant or
target-specific MCExprs.
This patch updates disassemblers for in-tree targets, and provides the
MCRegisterInfo instance that some disassemblers were using through the
MCContext (previously those backends were constructing their own
MCRegisterInfo instances).
llvm-svn: 206241
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 42c61c6386d..9d043f18c2e 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -309,24 +309,25 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) { return; } - std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI)); + std::unique_ptr<const MCObjectFileInfo> MOFI(new MCObjectFileInfo); + MCContext Ctx(AsmInfo.get(), MRI.get(), MOFI.get()); + + std::unique_ptr<MCDisassembler> DisAsm( + TheTarget->createMCDisassembler(*STI, Ctx)); + if (!DisAsm) { errs() << "error: no disassembler for target " << TripleName << "\n"; return; } - std::unique_ptr<const MCObjectFileInfo> MOFI; - std::unique_ptr<MCContext> Ctx; if (Symbolize) { - MOFI.reset(new MCObjectFileInfo); - Ctx.reset(new MCContext(AsmInfo.get(), MRI.get(), MOFI.get())); std::unique_ptr<MCRelocationInfo> RelInfo( - TheTarget->createMCRelocationInfo(TripleName, *Ctx.get())); + TheTarget->createMCRelocationInfo(TripleName, Ctx)); if (RelInfo) { std::unique_ptr<MCSymbolizer> Symzer( - MCObjectSymbolizer::createObjectSymbolizer(*Ctx.get(), - std::move(RelInfo), Obj)); + MCObjectSymbolizer::createObjectSymbolizer(Ctx, std::move(RelInfo), + Obj)); if (Symzer) DisAsm->setSymbolizer(std::move(Symzer)); } |