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:
mdevan.foobar 2010-07-26 16:36:02 +00:00
commit b7200e59b1
11 changed files with 87 additions and 152 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python
from llvm.core import Module,Type,Builder,ModuleProvider
from llvm.core import Module,Type,Builder
from llvm.ee import ExecutionEngine
import llvm.core
import ctypes
@ -45,8 +45,7 @@ def test_jit_ctypes():
print my_module
# compile the function
mp = ModuleProvider.new(my_module)
ee = ExecutionEngine.new(mp)
ee = ExecutionEngine.new(my_module)
# let ctypes know about the function
func_ptr_int = ee.get_pointer_to_function( mult )

View file

@ -17,14 +17,9 @@ builder = Builder.new(bb)
tmp = builder.add(f_sum.args[0], f_sum.args[1], "tmp")
builder.ret(tmp)
# Create a module provider object first. Modules can come from
# in-memory IRs like what we created now, or from bitcode (.bc)
# files. The module provider abstracts this detail.
mp = ModuleProvider.new(my_module)
# Create an execution engine object. This will create a JIT compiler
# on platforms that support it, or an interpreter otherwise.
ee = ExecutionEngine.new(mp)
ee = ExecutionEngine.new(my_module)
# The arguments needs to be passed as "GenericValue" objects.
arg1 = GenericValue.int(ty_int, 100)

View file

@ -36,7 +36,6 @@ entry:
}
"""
m = Module.from_assembly(strstream(asm))
mp = ModuleProvider.new(m)
print "-"*72
print m
@ -62,7 +61,7 @@ print m
# Let's run a DCE pass on the the function 'test1' now. First create a
# function pass manager.
fpm = FunctionPassManager.new(mp)
fpm = FunctionPassManager.new(m)
# Add the target data as first "pass". This is mandatory.
fpm.add( TargetData.new('') )

View file

@ -13,65 +13,6 @@ class TestModule(unittest.TestCase):
def setUp(self):
pass
def testmodule_and_moduleprovider(self):
"""Ownership issues between Module and ModuleProvider objects."""
def temp_mp(m):
mp = ModuleProvider.new(m)
del mp
def temp_m():
m = Module.new("temp_m")
return ModuleProvider.new(m)
# check basic ownership and deletion
m = Module.new("test1.1")
self.assertEqual(m.owner, None)
mp = ModuleProvider.new(m)
self.assertEqual(m.owner, mp)
mp_repr = repr(mp)
mp = None
self.assertNotEqual(m.owner, None)
self.assertEqual(repr(m.owner), mp_repr)
m = None
# This doesn't work. Looks like there are leaks elsewhere
# too (unittest module?).
#gc.collect()
#self.assertEqual(gc.garbage, [])
# delete a module which was owned by a module provider that has
# gone out of scope
m2 = Module.new("test1.2")
temp_mp(m2)
del m2
#self.assertEqual(gc.garbage, [])
# delete a module provider object which owned a module that has
# gone out of scope
mp3 = temp_m()
mp3 = None
# check ref counts
m4 = Module.new("test1.4")
self.assertEqual(sys.getrefcount(m4), 1+1)
mp4 = ModuleProvider.new(m4)
self.assertEqual(sys.getrefcount(m4), 1+1)
self.assertEqual(sys.getrefcount(mp4), 2+1)
m4 = None
self.assertEqual(sys.getrefcount(mp4), 1+1)
mp4 = None
# cannot create a second module provider object for the same
# module
works = False
m5 = Module.new("test1.5")
mp5 = ModuleProvider.new(m5)
try:
mp5_2 = ModuleProvider.new(m5)
except LLVMException:
works = True
self.assertEqual(works, True)
def testdata_layout(self):
"""Data layout property."""

View file

@ -483,12 +483,6 @@ def do_builder():
t = i.opcode_name
def do_moduleprovider():
print " Testing class ModuleProvider"
m = Module.new('a')
mp = ModuleProvider.new(m)
def do_llvm_core():
print " Testing module llvm.core"
do_module()
@ -507,7 +501,6 @@ def do_llvm_core():
do_switchinstruction()
do_basicblock()
do_builder()
do_moduleprovider()
def do_targetdata():
@ -545,8 +538,7 @@ def do_genericvalue():
def do_executionengine():
print " Testing class ExecutionEngine"
m = Module.new('a')
mp = ModuleProvider.new(m)
ee = ExecutionEngine.new(mp, True)
ee = ExecutionEngine.new(m, True)
ft = Type.function(ti, [])
f = m.add_function(ft, 'func')
bb = f.append_basic_block('entry')
@ -559,11 +551,15 @@ def do_executionengine():
ee.free_machine_code_for(f)
t = ee.target_data
m2 = Module.new('b')
mp2 = ModuleProvider.new(m2)
ee.add_module_provider(mp2)
ee.add_module(m2)
m3 = Module.new('c')
mp3 = ModuleProvider.new(m3)
ee2 = ExecutionEngine.new(mp3, False)
ee2 = ExecutionEngine.new(m3, False)
m4 = Module.new('d')
m5 = Module.new('e')
ee3 = ExecutionEngine.new(m4, False)
ee3.add_module(m5)
x = ee3.remove_module(m5)
check_is_module(x)
def do_llvm_ee():
@ -587,16 +583,14 @@ def do_passmanager():
def do_functionpassmanager():
print " Testing class FunctionPassManager"
m = Module.new('a')
mp = ModuleProvider.new(m)
ft = Type.function(ti, [])
f = m.add_function(ft, 'func')
bb = f.append_basic_block('entry')
b = Builder.new(bb)
b.ret(Constant.int(ti, 42))
fpm = FunctionPassManager.new(mp)
fpm = FunctionPassManager.new(m)
fpm.add(TargetData.new(''))
# to be fixed.
# fpm.add(PASS_FUNCTION_INLINING)
fpm.add(PASS_AGGRESSIVE_DCE)
fpm.initialize()
fpm.run(f)
fpm.finalize()