summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDisassembler/Disassembler.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2012-12-07 23:53:27 +0000
committerJim Grosbach <grosbach@apple.com>2012-12-07 23:53:27 +0000
commit0ca9d5b7a5f40ca027a4d03ba9fcecf5bf223179 (patch)
treeed372b6ceda5fca4f5e496da6adeb92db6dbb7a0 /llvm/lib/MC/MCDisassembler/Disassembler.cpp
parent3087d026da6ad5d201497c0703ec876463180cfa (diff)
downloadbcm5719-llvm-0ca9d5b7a5f40ca027a4d03ba9fcecf5bf223179.tar.gz
bcm5719-llvm-0ca9d5b7a5f40ca027a4d03ba9fcecf5bf223179.zip
Add C API for specifying CPU to the disassembler.
It was a nasty oversight that we didn't include this when we added this API in the first place. Blech. rdar://12839439 llvm-svn: 169653
Diffstat (limited to 'llvm/lib/MC/MCDisassembler/Disassembler.cpp')
-rw-r--r--llvm/lib/MC/MCDisassembler/Disassembler.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
index d10f543ae02..ac583ac1272 100644
--- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
@@ -33,29 +33,29 @@ using namespace llvm;
// functions can all be passed as NULL. If successful, this returns a
// disassembler context. If not, it returns NULL.
//
-LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
- int TagType, LLVMOpInfoCallback GetOpInfo,
- LLVMSymbolLookupCallback SymbolLookUp) {
+LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
+ void *DisInfo, int TagType,
+ LLVMOpInfoCallback GetOpInfo,
+ LLVMSymbolLookupCallback SymbolLookUp){
// Get the target.
std::string Error;
- const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
+ const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
assert(TheTarget && "Unable to create target!");
// Get the assembler info needed to setup the MCContext.
- const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(TripleName);
+ const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(Triple);
assert(MAI && "Unable to create target asm info!");
const MCInstrInfo *MII = TheTarget->createMCInstrInfo();
assert(MII && "Unable to create target instruction info!");
- const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TripleName);
+ const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(Triple);
assert(MRI && "Unable to create target register info!");
// Package up features to be passed to target/subtarget
std::string FeaturesStr;
- std::string CPU;
- const MCSubtargetInfo *STI = TheTarget->createMCSubtargetInfo(TripleName, CPU,
+ const MCSubtargetInfo *STI = TheTarget->createMCSubtargetInfo(Triple, CPU,
FeaturesStr);
assert(STI && "Unable to create subtarget info!");
@@ -74,7 +74,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
*MAI, *MII, *MRI, *STI);
assert(IP && "Unable to create instruction printer!");
- LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
+ LLVMDisasmContext *DC = new LLVMDisasmContext(Triple, DisInfo, TagType,
GetOpInfo, SymbolLookUp,
TheTarget, MAI, MRI,
STI, MII, Ctx, DisAsm, IP);
@@ -83,6 +83,13 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
return DC;
}
+LLVMDisasmContextRef LLVMCreateDisasm(const char *Triple, void *DisInfo,
+ int TagType, LLVMOpInfoCallback GetOpInfo,
+ LLVMSymbolLookupCallback SymbolLookUp) {
+ return LLVMCreateDisasmCPU(Triple, "", DisInfo, TagType, GetOpInfo,
+ SymbolLookUp);
+}
+
//
// LLVMDisasmDispose() disposes of the disassembler specified by the context.
//
OpenPOWER on IntegriCloud