llvmpy/test/asm.py
mdevan.foobar dbb67d4502 Set execute bit on python scripts
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@71 8d1e9007-1d4e-0410-b67e-1979fd6579aa
2009-02-25 17:48:53 +00:00

17 lines
345 B
Python
Executable file

#!/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