added Target.createMCSubtargetInfo and createMCDisassembler
also added bindings to classes required by the target methods. also added a convenience function to initialize all target components to the llvm module
This commit is contained in:
parent
8f2c27ba41
commit
ba03b226c8
5 changed files with 62 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ del get_versions
|
|||
|
||||
|
||||
from llvmpy import extra
|
||||
from llvmpy import api
|
||||
|
||||
version = extra.get_llvm_version()
|
||||
del extra
|
||||
|
||||
|
|
@ -42,3 +44,12 @@ def test(verbosity=1):
|
|||
|
||||
return len(result.failures) + len(result.errors)
|
||||
|
||||
|
||||
def initialize_all_target_components():
|
||||
api.llvm.InitializeAllTargets()
|
||||
api.llvm.InitializeAllTargetInfos()
|
||||
api.llvm.InitializeAllTargetMCs()
|
||||
api.llvm.InitializeAllAsmPrinters()
|
||||
api.llvm.InitializeAllDisassemblers()
|
||||
api.llvm.InitializeAllAsmParsers()
|
||||
|
||||
|
|
|
|||
26
llvm/mc/__init__.py
Normal file
26
llvm/mc/__init__.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from io import BytesIO
|
||||
import contextlib
|
||||
|
||||
import llvm
|
||||
from llvmpy import api
|
||||
|
||||
class Disassembler(llvm.Wrapper):
|
||||
|
||||
@staticmethod
|
||||
def new(triple='', cpu='', features=''):
|
||||
if not triple:
|
||||
triple = api.llvm.sys.getDefaultTargetTriple()
|
||||
|
||||
with contextlib.closing(BytesIO()) as error:
|
||||
target = api.llvm.TargetRegistry.lookupTarget(triple, error)
|
||||
if not target:
|
||||
raise llvm.LLVMException(error)
|
||||
if not target.hasMCDisassembler():
|
||||
raise llvm.LLVMException(target, "No disassembler provided for %s." % triple)
|
||||
|
||||
sti = target.createMCSubtargetInfo(triple, cpu, features)
|
||||
if not sti:
|
||||
raise llvm.LLVMException("Could not create sub target info")
|
||||
|
||||
return target.createMCDisassembler(sti)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue