Example #1
0
def set_cuda_kernel(lfunc):
    mod = lfunc.module

    mdstr = ir.MetaDataString(mod, "kernel")
    mdvalue = ir.Constant(ir.IntType(32), 1)
    md = mod.add_metadata((lfunc, mdstr, mdvalue))

    nmd = cgutils.get_or_insert_named_metadata(mod, 'nvvm.annotations')
    nmd.add(md)
Example #2
0
 def test_metadata_2(self):
     mod = self.module()
     mod.add_metadata([ir.Constant(ir.IntType(32), 123)])
     mod.add_metadata([ir.Constant(ir.IntType(32), 321),
                       ir.MetaDataString(mod, "kernel")])
     pat1 = "!0 = !{ i32 123 }"
     pat2 = '!1 = !{ i32 321, !"kernel" }'
     self.assertInText(pat1, str(mod))
     self.assertInText(pat2, str(mod))