Added API for reading assembly (.ll) files
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@35 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
8e9d163e2b
commit
c10b1b58c3
10 changed files with 82 additions and 18 deletions
17
test/asm.py
Normal file
17
test/asm.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/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
|
||||
|
||||
|
|
@ -74,6 +74,10 @@ def do_module():
|
|||
m2.to_bitcode(ss)
|
||||
m3 = Module.from_bitcode(ss)
|
||||
t = m2 == m3
|
||||
ss2 = strstream()
|
||||
ss2.write(str(m))
|
||||
m4 = Module.from_assembly(ss2)
|
||||
t = m4 == m
|
||||
|
||||
|
||||
def do_type():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue