llvmpy/test/asm.py

17 lines
349 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(asm, file=file("/tmp/testasm.ll", "w"))
# read it back into a module
m2 = Module.from_assembly(file("/tmp/testasm.ll"))
print(m2)