insert_value, extract_value can be multiple dimensional
This commit is contained in:
parent
c199881b67
commit
091a393d1d
2 changed files with 21 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import unittest
|
||||
from llvm.core import Type
|
||||
from llvm.core import Type, Module, Builder, Constant
|
||||
from .support import TestCase, tests
|
||||
|
||||
class TestStruct(TestCase):
|
||||
|
|
@ -8,6 +8,19 @@ class TestStruct(TestCase):
|
|||
tb = Type.struct([Type.int(32), Type.float()])
|
||||
self.assertTrue(ta.is_layout_identical(tb))
|
||||
|
||||
def test_struct_extract_value_2d(self):
|
||||
ta = Type.struct([Type.int(32), Type.float()])
|
||||
tb = Type.struct([ta, Type.float()])
|
||||
m = Module.new('')
|
||||
f = m.add_function(Type.function(Type.void(), []), "foo")
|
||||
b = Builder.new(f.append_basic_block(''))
|
||||
v = Constant.undef(tb)
|
||||
ins = b.insert_value(v, Constant.real(Type.float(), 1.234), [0, 1])
|
||||
ext = b.extract_value(ins, [0, 1])
|
||||
b.ret_void()
|
||||
m.verify()
|
||||
self.assertEqual(str(ext), 'float 0x3FF3BE76C0000000')
|
||||
|
||||
tests.append(TestStruct)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue