Removed the deprecated ModuleProvider class
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@88 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
73b37ee632
commit
b7200e59b1
11 changed files with 87 additions and 152 deletions
67
llvm/_core.c
67
llvm/_core.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, Mahadevan R All rights reserved.
|
||||
* Copyright (c) 2008-10, Mahadevan R All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
|
@ -711,14 +711,6 @@ _wrap_objobjobjobjstr2obj(LLVMBuildInsertElement, LLVMBuilderRef, LLVMValueRef,
|
|||
_wrap_objobjobjobjstr2obj(LLVMBuildShuffleVector, LLVMBuilderRef, LLVMValueRef, LLVMValueRef, LLVMValueRef, LLVMValueRef)
|
||||
|
||||
|
||||
/*===----------------------------------------------------------------------===*/
|
||||
/* Modules Providers */
|
||||
/*===----------------------------------------------------------------------===*/
|
||||
|
||||
_wrap_obj2obj(LLVMCreateModuleProviderForExistingModule, LLVMModuleRef, LLVMModuleProviderRef)
|
||||
_wrap_obj2none(LLVMDisposeModuleProvider, LLVMModuleProviderRef)
|
||||
|
||||
|
||||
/*===----------------------------------------------------------------------===*/
|
||||
/* Memory Buffer */
|
||||
/*===----------------------------------------------------------------------===*/
|
||||
|
|
@ -769,7 +761,7 @@ _wrap_obj2none(LLVMDisposeMemoryBuffer, LLVMMemoryBufferRef)
|
|||
/*===----------------------------------------------------------------------===*/
|
||||
|
||||
_wrap_none2obj(LLVMCreatePassManager, LLVMPassManagerRef)
|
||||
_wrap_obj2obj(LLVMCreateFunctionPassManager, LLVMModuleProviderRef, LLVMPassManagerRef)
|
||||
_wrap_obj2obj(LLVMCreateFunctionPassManagerForModule, LLVMModuleRef, LLVMPassManagerRef)
|
||||
_wrap_objobj2obj(LLVMRunPassManager, LLVMPassManagerRef, LLVMModuleRef, int)
|
||||
_wrap_obj2obj(LLVMInitializeFunctionPassManager, LLVMPassManagerRef, int)
|
||||
_wrap_objobj2obj(LLVMRunFunctionPassManager, LLVMPassManagerRef, LLVMValueRef, int)
|
||||
|
|
@ -928,23 +920,23 @@ _wrap_objobjint2obj(LLVMOffsetOfElement, LLVMTargetDataRef, LLVMTypeRef,
|
|||
static PyObject *
|
||||
_wLLVMCreateExecutionEngine(PyObject *self, PyObject *args)
|
||||
{
|
||||
LLVMModuleProviderRef mp;
|
||||
LLVMModuleRef mod;
|
||||
PyObject *obj;
|
||||
int force_interpreter;
|
||||
LLVMExecutionEngineRef ee;
|
||||
char *outmsg;
|
||||
char *outmsg = 0;
|
||||
PyObject *ret;
|
||||
int error;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oi", &obj, &force_interpreter))
|
||||
return NULL;
|
||||
|
||||
mp = (LLVMModuleProviderRef) PyCObject_AsVoidPtr(obj);
|
||||
mod = (LLVMModuleRef) PyCObject_AsVoidPtr(obj);
|
||||
|
||||
if (force_interpreter)
|
||||
error = LLVMCreateInterpreter(&ee, mp, &outmsg);
|
||||
error = LLVMCreateInterpreterForModule(&ee, mod, &outmsg);
|
||||
else
|
||||
error = LLVMCreateJITCompiler(&ee, mp, 1 /*fast*/, &outmsg);
|
||||
error = LLVMCreateJITCompilerForModule(&ee, mod, 1 /*fast*/, &outmsg);
|
||||
|
||||
if (error) {
|
||||
ret = PyString_FromString(outmsg);
|
||||
|
|
@ -980,6 +972,38 @@ LLVMGenericValueRef LLVMRunFunction2(LLVMExecutionEngineRef EE,
|
|||
return LLVMRunFunction(EE, F, NumArgs, Args);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wLLVMRemoveModule2(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *obj_ee;
|
||||
PyObject *obj_mod;
|
||||
LLVMExecutionEngineRef ee;
|
||||
LLVMModuleRef mod, mod_new = 0;
|
||||
char *outmsg = 0;
|
||||
PyObject *ret;
|
||||
int error;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OO", &obj_ee, &obj_mod))
|
||||
return NULL;
|
||||
|
||||
ee = (LLVMExecutionEngineRef) PyCObject_AsVoidPtr(obj_ee);
|
||||
mod = (LLVMModuleRef) PyCObject_AsVoidPtr(obj_mod);
|
||||
|
||||
LLVMRemoveModule(ee, mod, &mod_new, &outmsg);
|
||||
if (mod_new) {
|
||||
ret = ctor_LLVMModuleRef(mod_new);
|
||||
} else {
|
||||
if (outmsg) {
|
||||
ret = PyString_FromString(outmsg);
|
||||
LLVMDisposeMessage(outmsg);
|
||||
} else {
|
||||
ret = PyString_FromString("error");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
_wrap_obj2none(LLVMDisposeExecutionEngine, LLVMExecutionEngineRef)
|
||||
_wrap_objobjlist2obj(LLVMRunFunction2, LLVMExecutionEngineRef,
|
||||
LLVMValueRef, LLVMGenericValueRef, LLVMGenericValueRef)
|
||||
|
|
@ -989,8 +1013,8 @@ _wrap_obj2none(LLVMRunStaticConstructors, LLVMExecutionEngineRef)
|
|||
_wrap_obj2none(LLVMRunStaticDestructors, LLVMExecutionEngineRef)
|
||||
_wrap_objobj2none(LLVMFreeMachineCodeForFunction, LLVMExecutionEngineRef,
|
||||
LLVMValueRef)
|
||||
_wrap_objobj2none(LLVMAddModuleProvider, LLVMExecutionEngineRef,
|
||||
LLVMModuleProviderRef)
|
||||
_wrap_objobj2none(LLVMAddModule, LLVMExecutionEngineRef,
|
||||
LLVMModuleRef)
|
||||
|
||||
|
||||
/*===----------------------------------------------------------------------===*/
|
||||
|
|
@ -1501,10 +1525,6 @@ static PyMethodDef core_methods[] = {
|
|||
_method( LLVMBuildInsertElement )
|
||||
_method( LLVMBuildShuffleVector )
|
||||
|
||||
/* Modules Providers */
|
||||
_method( LLVMCreateModuleProviderForExistingModule )
|
||||
_method( LLVMDisposeModuleProvider )
|
||||
|
||||
/* Memory Buffer */
|
||||
_method( LLVMCreateMemoryBufferWithContentsOfFile )
|
||||
_method( LLVMCreateMemoryBufferWithSTDIN )
|
||||
|
|
@ -1512,7 +1532,7 @@ static PyMethodDef core_methods[] = {
|
|||
|
||||
/* Pass Manager */
|
||||
_method( LLVMCreatePassManager )
|
||||
_method( LLVMCreateFunctionPassManager )
|
||||
_method( LLVMCreateFunctionPassManagerForModule )
|
||||
_method( LLVMRunPassManager )
|
||||
_method( LLVMInitializeFunctionPassManager )
|
||||
_method( LLVMRunFunctionPassManager )
|
||||
|
|
@ -1638,7 +1658,8 @@ static PyMethodDef core_methods[] = {
|
|||
_method( LLVMRunStaticConstructors )
|
||||
_method( LLVMRunStaticDestructors )
|
||||
_method( LLVMFreeMachineCodeForFunction )
|
||||
_method( LLVMAddModuleProvider )
|
||||
_method( LLVMAddModule )
|
||||
_method( LLVMRemoveModule2 )
|
||||
|
||||
/* Generic Value */
|
||||
_method( LLVMCreateGenericValueOfInt )
|
||||
|
|
|
|||
22
llvm/core.py
22
llvm/core.py
|
|
@ -270,7 +270,6 @@ def check_is_constant(obj): _util.check_gen(obj, Constant)
|
|||
def check_is_function(obj): _util.check_gen(obj, Function)
|
||||
def check_is_basic_block(obj): _util.check_gen(obj, BasicBlock)
|
||||
def check_is_module(obj): _util.check_gen(obj, Module)
|
||||
def check_is_module_provider(obj): _util.check_gen(obj, ModuleProvider)
|
||||
|
||||
def unpack_types(objlst): return _util.unpack_gen(objlst, check_is_type)
|
||||
def unpack_values(objlst): return _util.unpack_gen(objlst, check_is_value)
|
||||
|
|
@ -1933,27 +1932,6 @@ class Builder(object):
|
|||
vecA.ptr, vecB.ptr, mask.ptr, name))
|
||||
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Module provider
|
||||
#===----------------------------------------------------------------------===
|
||||
|
||||
class ModuleProvider(llvm.Ownable):
|
||||
|
||||
@staticmethod
|
||||
def new(module):
|
||||
check_is_module(module)
|
||||
_util.check_is_unowned(module)
|
||||
return ModuleProvider(
|
||||
_core.LLVMCreateModuleProviderForExistingModule(module.ptr),
|
||||
module)
|
||||
|
||||
def __init__(self, ptr, module):
|
||||
llvm.Ownable.__init__(self, ptr, _core.LLVMDisposeModuleProvider)
|
||||
module._own(self)
|
||||
# a module provider is both a owner (of modules) and an ownable
|
||||
# (can be owned by execution engines)
|
||||
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Memory buffer
|
||||
#===----------------------------------------------------------------------===
|
||||
|
|
|
|||
35
llvm/ee.py
35
llvm/ee.py
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008, Mahadevan R All rights reserved.
|
||||
# Copyright (c) 2008-10, Mahadevan R All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
"""
|
||||
|
||||
import llvm # top-level, for common stuff
|
||||
import llvm.core as core # module provider, function etc.
|
||||
import llvm.core as core # module, function etc.
|
||||
import llvm._core as _core # C wrappers
|
||||
import llvm._util as _util # utility functions
|
||||
|
||||
|
|
@ -180,17 +180,17 @@ def _unpack_generic_values(objlist):
|
|||
class ExecutionEngine(object):
|
||||
|
||||
@staticmethod
|
||||
def new(mp, force_interpreter=False):
|
||||
core.check_is_module_provider(mp)
|
||||
_util.check_is_unowned(mp)
|
||||
ret = _core.LLVMCreateExecutionEngine(mp.ptr, int(force_interpreter))
|
||||
def new(module, force_interpreter=False):
|
||||
core.check_is_module(module)
|
||||
_util.check_is_unowned(module)
|
||||
ret = _core.LLVMCreateExecutionEngine(module.ptr, int(force_interpreter))
|
||||
if isinstance(ret, str):
|
||||
raise llvm.LLVMException, ret
|
||||
return ExecutionEngine(ret, mp)
|
||||
return ExecutionEngine(ret, module)
|
||||
|
||||
def __init__(self, ptr, mp):
|
||||
def __init__(self, ptr, module):
|
||||
self.ptr = ptr
|
||||
mp._own(self)
|
||||
module._own(self)
|
||||
|
||||
def __del__(self):
|
||||
_core.LLVMDisposeExecutionEngine(self.ptr)
|
||||
|
|
@ -215,10 +215,19 @@ class ExecutionEngine(object):
|
|||
core.check_is_function(fn)
|
||||
_core.LLVMFreeMachineCodeForFunction(self.ptr, fn.ptr)
|
||||
|
||||
def add_module_provider(self, mp):
|
||||
core.check_is_module_provider(mp)
|
||||
_core.LLVMAddModuleProvider(self.ptr, mp.ptr)
|
||||
mp._own(self)
|
||||
def add_module(self, module):
|
||||
core.check_is_module(module)
|
||||
_core.LLVMAddModule(self.ptr, module.ptr)
|
||||
module._own(self)
|
||||
|
||||
def remove_module(self, module):
|
||||
core.check_is_module(module)
|
||||
if module.owner != self:
|
||||
raise llvm.LLVMException, "module is not owned by self"
|
||||
ret = _core.LLVMRemoveModule2(self.ptr, module.ptr)
|
||||
if isinstance(ret, str):
|
||||
raise llvm.LLVMException, ret
|
||||
return core.Module(ret)
|
||||
|
||||
@property
|
||||
def target_data(self):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2008, Mahadevan R All rights reserved.
|
||||
# Copyright (c) 2008-10, Mahadevan R All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
|
@ -37,7 +37,7 @@ are available.
|
|||
|
||||
import llvm # top-level, for common stuff
|
||||
import llvm.ee as ee # target data
|
||||
import llvm.core as core # module provider, function etc.
|
||||
import llvm.core as core # module, function etc.
|
||||
import llvm._core as _core # C wrappers
|
||||
|
||||
|
||||
|
|
@ -271,9 +271,10 @@ class PassManager(object):
|
|||
class FunctionPassManager(PassManager):
|
||||
|
||||
@staticmethod
|
||||
def new(mp):
|
||||
core.check_is_module_provider(mp)
|
||||
return FunctionPassManager(_core.LLVMCreateFunctionPassManager(mp.ptr))
|
||||
def new(module):
|
||||
core.check_is_module(module)
|
||||
ptr = _core.LLVMCreateFunctionPassManagerForModule(module.ptr)
|
||||
return FunctionPassManager(ptr)
|
||||
|
||||
def __init__(self, ptr):
|
||||
PassManager.__init__(self, ptr)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ _define_std_ctor(LLVMValueRef)
|
|||
_define_std_ctor(LLVMTypeHandleRef)
|
||||
_define_std_ctor(LLVMBasicBlockRef)
|
||||
_define_std_ctor(LLVMBuilderRef)
|
||||
_define_std_ctor(LLVMModuleProviderRef)
|
||||
_define_std_ctor(LLVMMemoryBufferRef)
|
||||
_define_std_ctor(LLVMPassManagerRef)
|
||||
_define_std_ctor(LLVMExecutionEngineRef)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ _declare_std_ctor(LLVMValueRef)
|
|||
_declare_std_ctor(LLVMTypeHandleRef)
|
||||
_declare_std_ctor(LLVMBasicBlockRef)
|
||||
_declare_std_ctor(LLVMBuilderRef)
|
||||
_declare_std_ctor(LLVMModuleProviderRef)
|
||||
_declare_std_ctor(LLVMMemoryBufferRef)
|
||||
_declare_std_ctor(LLVMPassManagerRef)
|
||||
_declare_std_ctor(LLVMExecutionEngineRef)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue