Added llvm.core.Argument.alignment
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@101 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
7f74b220e4
commit
b7fa3e8fa1
4 changed files with 38 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
0.7, in progress:
|
||||
|
||||
* Add llvm.core.Argument.alignment property.
|
||||
* Migrate to LLVM 2.8.
|
||||
* Fix ffi link issue on darwin (Albert Mietus) (Issue #29).
|
||||
* LLVM tutorial ported (Max Shawabkeh) (Issue #33).
|
||||
|
|
|
|||
|
|
@ -1260,9 +1260,15 @@ class Argument(Value):
|
|||
def remove_attribute(self, attr):
|
||||
_core.LLVMRemoveAttribute(self.ptr, attr)
|
||||
|
||||
def set_alignment(self, align):
|
||||
def _set_alignment(self, align):
|
||||
_core.LLVMSetParamAlignment(self.ptr, align)
|
||||
|
||||
def _get_alignment(self):
|
||||
return _core.LLVMGetParamAlignment(self.ptr)
|
||||
|
||||
alignment = \
|
||||
property(_get_alignment, _set_alignment)
|
||||
|
||||
|
||||
class Function(GlobalValue):
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,8 @@ def do_argument():
|
|||
a = f.args[0]
|
||||
a.add_attribute(ATTR_ZEXT)
|
||||
a.remove_attribute(ATTR_ZEXT)
|
||||
a.set_alignment(4)
|
||||
a.alignment = 16
|
||||
a1 = a.alignment
|
||||
|
||||
|
||||
def do_function():
|
||||
|
|
|
|||
28
test/testattrs.py
Executable file
28
test/testattrs.py
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from llvm.core import *
|
||||
from cStringIO import StringIO
|
||||
|
||||
|
||||
def make_module():
|
||||
test_module = """
|
||||
define i32 @sum(i32, i32) {
|
||||
entry:
|
||||
%2 = add i32 %0, %1
|
||||
ret i32 %2
|
||||
}
|
||||
"""
|
||||
return Module.from_assembly(StringIO(test_module))
|
||||
|
||||
|
||||
def test_align(m):
|
||||
f = m.get_function_named('sum')
|
||||
f.args[0].alignment = 16
|
||||
assert "align 16" in str(f)
|
||||
assert f.args[0].alignment == 16
|
||||
|
||||
|
||||
m = make_module()
|
||||
test_align(m)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue