summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2013-05-24 22:51:52 +0000
committerQuentin Colombet <qcolombet@apple.com>2013-05-24 22:51:52 +0000
commitf482805c285351648cbd2052ccf6b817b726fb0e (patch)
tree3a2acfbd646f1afb70d4bd1ae8a8e4103baf0f08 /llvm/lib
parent251f49657897b38603d5aaac7f81d61228fe5728 (diff)
downloadbcm5719-llvm-f482805c285351648cbd2052ccf6b817b726fb0e.tar.gz
bcm5719-llvm-f482805c285351648cbd2052ccf6b817b726fb0e.zip
Follow up of the introduction of MCSymbolizer.
- Ressurect old MCDisassemble API to soften transition. - Extend MCTargetDesc to set target specific symbolizer. llvm-svn: 182688
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCDisassembler.cpp9
-rw-r--r--llvm/lib/MC/MCDisassembler/Disassembler.cpp6
-rw-r--r--llvm/lib/MC/MCExternalSymbolizer.cpp14
-rw-r--r--llvm/lib/MC/MCRelocationInfo.cpp2
-rw-r--r--llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp9
-rw-r--r--llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp9
6 files changed, 37 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler.cpp
index c4cdbba26e2..bfd51ab1af9 100644
--- a/llvm/lib/MC/MCDisassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler.cpp
@@ -23,9 +23,14 @@ MCDisassembler::setupForSymbolicDisassembly(
void *DisInfo,
MCContext *Ctx,
OwningPtr<MCRelocationInfo> &RelInfo) {
+ this->GetOpInfo = GetOpInfo;
+ this->SymbolLookUp = SymbolLookUp;
+ this->DisInfo = DisInfo;
+ this->Ctx = Ctx;
assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
- Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
- SymbolLookUp, DisInfo));
+ if (!Symbolizer)
+ Symbolizer.reset(new MCExternalSymbolizer(*Ctx, RelInfo, GetOpInfo,
+ SymbolLookUp, DisInfo));
}
bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
index ba769369614..67dc136d416 100644
--- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
@@ -18,6 +18,7 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCRelocationInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/MC/MCSymbolizer.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
@@ -80,9 +81,12 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
if (!RelInfo)
return 0;
+ OwningPtr<MCSymbolizer> Symbolizer(
+ TheTarget->createMCSymbolizer(Triple, GetOpInfo, SymbolLookUp, DisInfo,
+ Ctx, RelInfo.take()));
+ DisAsm->setSymbolizer(Symbolizer);
DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo,
Ctx, RelInfo);
-
// Set up the instruction printer.
int AsmPrinterVariant = MAI->getAssemblerDialect();
MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant,
diff --git a/llvm/lib/MC/MCExternalSymbolizer.cpp b/llvm/lib/MC/MCExternalSymbolizer.cpp
index 5fb52b3bf60..47ef6c41fed 100644
--- a/llvm/lib/MC/MCExternalSymbolizer.cpp
+++ b/llvm/lib/MC/MCExternalSymbolizer.cpp
@@ -144,3 +144,17 @@ void MCExternalSymbolizer::tryAddingPcLoadReferenceComment(raw_ostream &cStream,
cStream << "literal pool for: " << ReferenceName;
}
}
+
+namespace llvm {
+MCSymbolizer *createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo,
+ LLVMSymbolLookupCallback SymbolLookUp,
+ void *DisInfo,
+ MCContext *Ctx,
+ MCRelocationInfo *RelInfo) {
+ assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
+
+ OwningPtr<MCRelocationInfo> RelInfoOwingPtr(RelInfo);
+ return new MCExternalSymbolizer(*Ctx, RelInfoOwingPtr, GetOpInfo,
+ SymbolLookUp, DisInfo);
+}
+}
diff --git a/llvm/lib/MC/MCRelocationInfo.cpp b/llvm/lib/MC/MCRelocationInfo.cpp
index a2a3174555a..53c48deded1 100644
--- a/llvm/lib/MC/MCRelocationInfo.cpp
+++ b/llvm/lib/MC/MCRelocationInfo.cpp
@@ -34,6 +34,6 @@ MCRelocationInfo::createExprForCAPIVariantKind(const MCExpr *SubExpr,
return SubExpr;
}
-MCRelocationInfo *llvm::createMCRelocationInfo(MCContext &Ctx) {
+MCRelocationInfo *llvm::createMCRelocationInfo(StringRef TT, MCContext &Ctx) {
return new MCRelocationInfo(Ctx);
}
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
index c092801a676..164f57b2d05 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
@@ -212,12 +212,13 @@ static MCInstPrinter *createARMMCInstPrinter(const Target &T,
return 0;
}
-static MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx) {
+static MCRelocationInfo *createARMMCRelocationInfo(StringRef TT,
+ MCContext &Ctx) {
Triple TheTriple(TT);
if (TheTriple.isEnvironmentMachO())
return createARMMachORelocationInfo(Ctx);
// Default to the stock relocation info.
- return llvm::createMCRelocationInfo(Ctx);
+ return llvm::createMCRelocationInfo(TT, Ctx);
}
namespace {
@@ -307,7 +308,7 @@ extern "C" void LLVMInitializeARMTargetMC() {
// Register the MC relocation info.
TargetRegistry::RegisterMCRelocationInfo(TheARMTarget,
- createMCRelocationInfo);
+ createARMMCRelocationInfo);
TargetRegistry::RegisterMCRelocationInfo(TheThumbTarget,
- createMCRelocationInfo);
+ createARMMCRelocationInfo);
}
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 6d23981d635..bd23ce40ec7 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -384,14 +384,15 @@ static MCInstPrinter *createX86MCInstPrinter(const Target &T,
return 0;
}
-static MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx) {
+static MCRelocationInfo *createX86MCRelocationInfo(StringRef TT,
+ MCContext &Ctx) {
Triple TheTriple(TT);
if (TheTriple.isEnvironmentMachO() && TheTriple.getArch() == Triple::x86_64)
return createX86_64MachORelocationInfo(Ctx);
else if (TheTriple.isOSBinFormatELF())
return createX86_64ELFRelocationInfo(Ctx);
// Default to the stock relocation info.
- return llvm::createMCRelocationInfo(Ctx);
+ return llvm::createMCRelocationInfo(TT, Ctx);
}
static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) {
@@ -454,7 +455,7 @@ extern "C" void LLVMInitializeX86TargetMC() {
// Register the MC relocation info.
TargetRegistry::RegisterMCRelocationInfo(TheX86_32Target,
- createMCRelocationInfo);
+ createX86MCRelocationInfo);
TargetRegistry::RegisterMCRelocationInfo(TheX86_64Target,
- createMCRelocationInfo);
+ createX86MCRelocationInfo);
}
OpenPOWER on IntegriCloud