File: asm.py

package info (click to toggle)
llvm-py 0.5%2Bsvn85-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 996 kB
  • ctags: 1,768
  • sloc: python: 3,655; ansic: 1,893; cpp: 495; pascal: 91; makefile: 8; sh: 1
file content (17 lines) | stat: -rwxr-xr-x 345 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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