mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 20:33:15 +00:00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169653 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
99faa3b4ec
commit
68a590df13
@ -139,12 +139,25 @@ extern "C" {
|
|||||||
* by passing a block of information in the DisInfo parameter and specifying the
|
* by passing a block of information in the DisInfo parameter and specifying the
|
||||||
* TagType and callback functions as described above. These can all be passed
|
* TagType and callback functions as described above. These can all be passed
|
||||||
* as NULL. If successful, this returns a disassembler context. If not, it
|
* as NULL. If successful, this returns a disassembler context. If not, it
|
||||||
* returns NULL.
|
* returns NULL. This function is equivalent to calling LLVMCreateDisasmCPU()
|
||||||
|
* with an empty CPU name.
|
||||||
*/
|
*/
|
||||||
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||||
int TagType, LLVMOpInfoCallback GetOpInfo,
|
int TagType, LLVMOpInfoCallback GetOpInfo,
|
||||||
LLVMSymbolLookupCallback SymbolLookUp);
|
LLVMSymbolLookupCallback SymbolLookUp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a disassembler for the TripleName and a specific CPU. Symbolic
|
||||||
|
* disassembly is supported by passing a block of information in the DisInfo
|
||||||
|
* parameter and specifying the TagType and callback functions as described
|
||||||
|
* above. These can all be passed * as NULL. If successful, this returns a
|
||||||
|
* disassembler context. If not, it returns NULL.
|
||||||
|
*/
|
||||||
|
LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
|
||||||
|
void *DisInfo, int TagType,
|
||||||
|
LLVMOpInfoCallback GetOpInfo,
|
||||||
|
LLVMSymbolLookupCallback SymbolLookUp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the disassembler's options. Returns 1 if it can set the Options and 0
|
* Set the disassembler's options. Returns 1 if it can set the Options and 0
|
||||||
* otherwise.
|
* otherwise.
|
||||||
|
@ -33,29 +33,29 @@ using namespace llvm;
|
|||||||
// functions can all be passed as NULL. If successful, this returns a
|
// functions can all be passed as NULL. If successful, this returns a
|
||||||
// disassembler context. If not, it returns NULL.
|
// disassembler context. If not, it returns NULL.
|
||||||
//
|
//
|
||||||
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,
|
||||||
int TagType, LLVMOpInfoCallback GetOpInfo,
|
void *DisInfo, int TagType,
|
||||||
LLVMSymbolLookupCallback SymbolLookUp) {
|
LLVMOpInfoCallback GetOpInfo,
|
||||||
|
LLVMSymbolLookupCallback SymbolLookUp){
|
||||||
// Get the target.
|
// Get the target.
|
||||||
std::string Error;
|
std::string Error;
|
||||||
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
|
const Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
|
||||||
assert(TheTarget && "Unable to create target!");
|
assert(TheTarget && "Unable to create target!");
|
||||||
|
|
||||||
// Get the assembler info needed to setup the MCContext.
|
// 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!");
|
assert(MAI && "Unable to create target asm info!");
|
||||||
|
|
||||||
const MCInstrInfo *MII = TheTarget->createMCInstrInfo();
|
const MCInstrInfo *MII = TheTarget->createMCInstrInfo();
|
||||||
assert(MII && "Unable to create target instruction info!");
|
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!");
|
assert(MRI && "Unable to create target register info!");
|
||||||
|
|
||||||
// Package up features to be passed to target/subtarget
|
// Package up features to be passed to target/subtarget
|
||||||
std::string FeaturesStr;
|
std::string FeaturesStr;
|
||||||
std::string CPU;
|
|
||||||
|
|
||||||
const MCSubtargetInfo *STI = TheTarget->createMCSubtargetInfo(TripleName, CPU,
|
const MCSubtargetInfo *STI = TheTarget->createMCSubtargetInfo(Triple, CPU,
|
||||||
FeaturesStr);
|
FeaturesStr);
|
||||||
assert(STI && "Unable to create subtarget info!");
|
assert(STI && "Unable to create subtarget info!");
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
|||||||
*MAI, *MII, *MRI, *STI);
|
*MAI, *MII, *MRI, *STI);
|
||||||
assert(IP && "Unable to create instruction printer!");
|
assert(IP && "Unable to create instruction printer!");
|
||||||
|
|
||||||
LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
|
LLVMDisasmContext *DC = new LLVMDisasmContext(Triple, DisInfo, TagType,
|
||||||
GetOpInfo, SymbolLookUp,
|
GetOpInfo, SymbolLookUp,
|
||||||
TheTarget, MAI, MRI,
|
TheTarget, MAI, MRI,
|
||||||
STI, MII, Ctx, DisAsm, IP);
|
STI, MII, Ctx, DisAsm, IP);
|
||||||
@ -83,6 +83,13 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
|||||||
return DC;
|
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.
|
// LLVMDisasmDispose() disposes of the disassembler specified by the context.
|
||||||
//
|
//
|
||||||
|
@ -29,6 +29,7 @@ lto_codegen_set_assembler_path
|
|||||||
lto_codegen_set_cpu
|
lto_codegen_set_cpu
|
||||||
lto_codegen_compile_to_file
|
lto_codegen_compile_to_file
|
||||||
LLVMCreateDisasm
|
LLVMCreateDisasm
|
||||||
|
LLVMCreateDisasmCPU
|
||||||
LLVMDisasmDispose
|
LLVMDisasmDispose
|
||||||
LLVMDisasmInstruction
|
LLVMDisasmInstruction
|
||||||
LLVMSetDisasmOptions
|
LLVMSetDisasmOptions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user