add MCJIT test
This commit is contained in:
parent
56a511854a
commit
319984f0e0
3 changed files with 36 additions and 2 deletions
|
|
@ -1353,6 +1353,31 @@ class TestCmp(TestCase):
|
|||
tests.append(TestCmp)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestMCJIT(TestCase):
|
||||
def test_mcjit(self):
|
||||
m = Module.new('oidfjs')
|
||||
fnty = Type.function(Type.int(), [Type.int(), Type.int()])
|
||||
func = m.add_function(fnty, 'foo')
|
||||
bb = func.append_basic_block('')
|
||||
bldr = Builder.new(bb)
|
||||
bldr.ret(bldr.add(*func.args))
|
||||
|
||||
func.verify()
|
||||
|
||||
engine = EngineBuilder.new(m).mcjit(True).create()
|
||||
ptr = engine.get_pointer_to_function(func)
|
||||
|
||||
from ctypes import c_int, CFUNCTYPE
|
||||
callee = CFUNCTYPE(c_int, c_int, c_int)(ptr)
|
||||
self.assertEqual(321 + 123, callee(321, 123))
|
||||
|
||||
if llvm.version >= (3, 3):
|
||||
# MCJIT broken in 3.2
|
||||
# The test will segfault in OSX?
|
||||
tests.append(TestMCJIT)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def run(verbosity=1):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue