Completed binding for most of ExecutionEngine
This commit is contained in:
parent
25b498c8fa
commit
78f9c9a610
9 changed files with 391 additions and 9 deletions
|
|
@ -4,6 +4,11 @@ from Module import Module
|
|||
from JITMemoryManager import JITMemoryManager
|
||||
from CodeGen import CodeGenOpt, Reloc, CodeModel
|
||||
from DataLayout import DataLayout
|
||||
from Value import Function, GlobalValue, BasicBlock, Constant
|
||||
from GlobalVariable import GlobalVariable
|
||||
from MachineCodeInfo import MachineCodeInfo
|
||||
from GenericValue import GenericValue
|
||||
from Type import Type
|
||||
|
||||
ExecutionEngine = llvm.Class()
|
||||
|
||||
|
|
@ -32,3 +37,58 @@ class ExecutionEngine:
|
|||
addModule = Method(Void, ptr(Module))
|
||||
getDataLayout = Method(const(ownedptr(DataLayout)))
|
||||
removeModule = Method(cast(Bool, bool), ptr(Module))
|
||||
|
||||
FindFunctionNamed = Method(ptr(Function), cast(str, ConstCharPtr))
|
||||
getPointerToNamedFunction = Method(cast(VoidPtr, int),
|
||||
cast(str, StdString),
|
||||
cast(bool, Bool)).require_only(1)
|
||||
|
||||
runStaticConstructorsDestructors = Method(Void, cast(Bool, bool))
|
||||
runStaticConstructorsDestructors |= Method(Void, ptr(Module),
|
||||
cast(Bool, bool))
|
||||
|
||||
addGlobalMapping = Method(Void, ptr(GlobalValue), cast(int, VoidPtr))
|
||||
clearAllGlobalMappings = Method()
|
||||
clearGlobalMappingsFromModule = Method(Void, ptr(Module))
|
||||
updateGlobalMapping = Method(cast(VoidPtr, int),
|
||||
ptr(GlobalValue), cast(int, VoidPtr))
|
||||
|
||||
getPointerToGlobalIfAvailable = Method(cast(VoidPtr, int), ptr(GlobalValue))
|
||||
getPointerToGlobal = Method(cast(VoidPtr, int), ptr(GlobalValue))
|
||||
getPointerToFunction = Method(cast(VoidPtr, int), ptr(Function))
|
||||
getPointerToBasicBlock = Method(cast(VoidPtr, int), ptr(BasicBlock))
|
||||
getPointerToFunctionOrStub = Method(cast(VoidPtr, int), ptr(Function))
|
||||
|
||||
runJITOnFunction = Method(Void, ptr(Function), ptr(MachineCodeInfo))
|
||||
runJITOnFunction.require_only(1)
|
||||
|
||||
getGlobalValueAtAddress = Method(const(ptr(GlobalValue)), cast(int, VoidPtr))
|
||||
|
||||
StoreValueToMemory = Method(Void, ref(GenericValue), ptr(GenericValue),
|
||||
ptr(Type))
|
||||
|
||||
InitializeMemory = Method(Void, ptr(Constant), cast(int, VoidPtr))
|
||||
|
||||
recompileAndRelinkFunction = Method(cast(int, VoidPtr), ptr(Function))
|
||||
|
||||
freeMachineCodeForFunction = Method(Void, ptr(Function))
|
||||
getOrEmitGlobalVariable = Method(cast(int, VoidPtr), ptr(GlobalVariable))
|
||||
|
||||
DisableLazyCompilation = Method(Void, cast(bool, Bool))
|
||||
isCompilingLazily = Method(cast(Bool, bool))
|
||||
isLazyCompilationDisabled = Method(cast(Bool, bool))
|
||||
DisableGVCompilation = Method(Void, cast(bool, Bool))
|
||||
isSymbolSearchingDisabled = Method(cast(Bool, bool))
|
||||
RegisterTable = Method(Void, ptr(Function), cast(int, VoidPtr))
|
||||
DeregisterTable = Method(Void, ptr(Function))
|
||||
DeregisterAllTables = Method()
|
||||
|
||||
_runFunction = CustomMethod('ExecutionEngine_RunFunction',
|
||||
PyObjectPtr, ptr(Function), PyObjectPtr)
|
||||
|
||||
@CustomPythonMethod
|
||||
def runFunction(self, fn, args):
|
||||
import capsule
|
||||
unwrapped = map(capsule.unwrap, args)
|
||||
return self._runFunction(fn, tuple(unwrapped))
|
||||
|
||||
|
|
|
|||
34
newbinding/src/GenericValue.py
Normal file
34
newbinding/src/GenericValue.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from Type import Type
|
||||
|
||||
GenericValue = llvm.Class()
|
||||
|
||||
@GenericValue
|
||||
class GenericValue:
|
||||
delete = Destructor()
|
||||
|
||||
def _factory(name, *argtys):
|
||||
return CustomStaticMethod('GenericValue_' + name,
|
||||
ptr(GenericValue), *argtys)
|
||||
|
||||
CreateFloat = _factory('CreateFloat', cast(float, Float))
|
||||
|
||||
CreateDouble = _factory('CreateDouble', cast(float, Float))
|
||||
|
||||
CreateInt = _factory('CreateInt', ptr(Type),
|
||||
cast(int, UnsignedLongLong), cast(bool, Bool))
|
||||
|
||||
CreatePointer = _factory('CreatePointer', cast(int, VoidPtr))
|
||||
|
||||
def _accessor(name, *argtys):
|
||||
return CustomMethod('GenericValue_' + name, *argtys)
|
||||
|
||||
valueIntWidth = _accessor('ValueIntWidth', cast(Unsigned, int))
|
||||
|
||||
toSignedInt = _accessor('ToSignedInt', cast(UnsignedLongLong, int))
|
||||
toUnsignedInt = _accessor('ToUnsignedInt', cast(LongLong, int))
|
||||
|
||||
toFloat = _accessor('ToFloat', cast(Double, float), ptr(Type))
|
||||
|
||||
toPointer = _accessor('ToPointer', cast(VoidPtr, int))
|
||||
13
newbinding/src/MachineCodeInfo.py
Normal file
13
newbinding/src/MachineCodeInfo.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
|
||||
MachineCodeInfo = llvm.Class()
|
||||
|
||||
@MachineCodeInfo
|
||||
class MachineCodeInfo:
|
||||
_include_ = 'llvm/CodeGen/MachineCodeInfo.h'
|
||||
setSize = Method(Void, cast(int, Size_t))
|
||||
setAddress = Method(Void, cast(int, VoidPtr))
|
||||
size = Method(cast(Size_t, int))
|
||||
address = Method(cast(VoidPtr, int))
|
||||
|
||||
|
|
@ -44,4 +44,11 @@ class Module:
|
|||
print_ = Method(Void, ref(raw_ostream), ptr(AssemblyAnnotationWriter))
|
||||
print_.realname = 'print'
|
||||
|
||||
@CustomPythonMethod
|
||||
def __str__(self):
|
||||
import extra
|
||||
os = extra.make_raw_ostream_for_printing()
|
||||
self.print_(os, None)
|
||||
return os.str()
|
||||
|
||||
dropAllReferences = Method()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from binding import *
|
|||
from namespace import llvm
|
||||
from LLVMContext import LLVMContext
|
||||
from raw_ostream import raw_ostream
|
||||
from StringRef import StringRef
|
||||
|
||||
Type = llvm.Class()
|
||||
IntegerType = llvm.Class(Type)
|
||||
|
|
@ -52,6 +53,19 @@ class Type:
|
|||
isIntegerTy = Method(cast(Bool, bool))
|
||||
isIntegerTy |= Method(cast(Bool, bool), cast(int, Unsigned))
|
||||
|
||||
getIntegerBitWidth = Method(cast(Unsigned, int))
|
||||
getFunctionParamType = Method(ptr(Type), cast(int, Unsigned))
|
||||
getFunctionNumParams = Method(cast(int, Unsigned))
|
||||
|
||||
isFunctionVarArg = type_checker()
|
||||
|
||||
getStructName = Method(cast(StringRef, str))
|
||||
getStructNumElements = Method(cast(Unsigned, int))
|
||||
getStructElementType = Method(ptr(Type), cast(int, Unsigned))
|
||||
getSequentialElementType = Method(ptr(Type))
|
||||
|
||||
# Factories
|
||||
|
||||
|
||||
def type_factory():
|
||||
return StaticMethod(ptr(Type), ref(LLVMContext))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue