From 2799e9f4525126737a7ddccbdd42556ae18f5760 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Thu, 1 Nov 2012 11:42:30 -0500 Subject: [PATCH] Test for InlineAsm --- test/inlineasm.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/inlineasm.py diff --git a/test/inlineasm.py b/test/inlineasm.py new file mode 100644 index 0000000..635e6bf --- /dev/null +++ b/test/inlineasm.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Import the llvm-py modules. +from llvm import * +from llvm.core import * + +import logging +import unittest + + +class TestInlineAsm(unittest.TestCase): + def test_inline_asm(self): + mod = Module.new(__name__) + fnty = Type.function(Type.int(), [Type.int()]) + fn = mod.add_function(fnty, name='test_inline_asm') + builder = Builder.new(fn.append_basic_block('entry')) + + iaty = Type.function(Type.int(), [Type.int()]) + inlineasm = InlineAsm.get(iaty, "bswap $0", "=r,r") + self.assertIn('asm "bswap $0", "=r,r"', str(inlineasm)) + builder.ret(builder.call(inlineasm, [fn.args[0]])) + print fn + +if __name__ == '__main__': + unittest.main() +