llvmpy/test/asm.py
mdevan.foobar c10b1b58c3 Added API for reading assembly (.ll) files
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@35 8d1e9007-1d4e-0410-b67e-1979fd6579aa
2008-09-08 13:09:43 +00:00

17 lines
345 B
Python

#!/usr/bin/env python
from llvm import *
from llvm.core import *
# create a module
m = Module.new('module1')
m.add_global_variable(Type.int(), 'i')
# write it's assembly representation to a file
asm = str(m)
print >> file("/tmp/testasm.ll", "w"), asm
# read it back into a module
m2 = Module.from_assembly(file("/tmp/testasm.ll"))
print m2