Add Module bitcode writer/parser

This commit is contained in:
Siu Kwan Lam 2013-02-04 16:45:49 -06:00
commit 168510222f
7 changed files with 138 additions and 14 deletions

View file

@ -135,6 +135,22 @@ def test_basic_jit_use():
assert 44 == gvR.toUnsignedInt()
# write bitcode
bc_buffer = StringIO()
api.WriteBitcodeToFile(m, bc_buffer)
bc = bc_buffer.getvalue()
bc_buffer.close()
# read bitcode
errbuf = StringIO()
m2 = api.ParseBitCodeFile(bc, context, errbuf)
if not m2:
raise Exception(errbuf.getvalue())
else:
m2.setModuleIdentifier(m.getModuleIdentifier())
assert str(m2) == str(m)
def test_engine_builder():
api.InitializeNativeTarget()
context = api.getGlobalContext()