def set_cuda_kernel(lfunc): from llvm.core import MetaData, MetaDataString, Constant, Type m = lfunc.module ops = lfunc, MetaDataString.get(m, "kernel"), Constant.int(Type.int(), 1) md = MetaData.get(m, ops) nmd = m.get_or_insert_named_metadata('nvvm.annotations') nmd.add(md)
def test_metadata(self): m = Module.new("a") t = Type.int() metadata = MetaData.get(m, [Constant.int(t, 100), MetaDataString.get(m, "abcdef"), None]) MetaData.add_named_operand(m, "foo", metadata) self.assertEqual(MetaData.get_named_operands(m, "foo"), [metadata]) self.assertEqual(MetaData.get_named_operands(m, "bar"), []) self.assertEqual(len(metadata.operands), 3) self.assertEqual(metadata.operands[0].z_ext_value, 100) self.assertEqual(metadata.operands[1].string, "abcdef") self.assertTrue(metadata.operands[2] is None)
def test_metadata(self): m = Module.new('a') t = Type.int() metadata = MetaData.get( m, [Constant.int(t, 100), MetaDataString.get(m, 'abcdef'), None]) MetaData.add_named_operand(m, 'foo', metadata) self.assertEqual(MetaData.get_named_operands(m, 'foo'), [metadata]) self.assertEqual(MetaData.get_named_operands(m, 'bar'), []) self.assertEqual(len(metadata.operands), 3) self.assertEqual(metadata.operands[0].z_ext_value, 100) self.assertEqual(metadata.operands[1].string, 'abcdef') self.assertTrue(metadata.operands[2] is None)