def set_hsa_kernel(fn):
 mod = fn.module
 fn.calling_convention = CC_SPIR_KERNEL
 ocl_kernels = mod.get_or_insert_named_metadata('opencl.kernels')
 ocl_kernels.add(lc.MetaData.get(mod, [fn, gen_arg_addrspace_md(fn), gen_arg_access_qual_md(fn), gen_arg_type(fn), gen_arg_type_qual(fn), gen_arg_base_type(fn)]))
 make_constant = (lambda x: lc.Constant.int(lc.Type.int(), x))
 spir_version_constant = [make_constant(x) for x in SPIR_VERSION]
 spir_version = mod.get_or_insert_named_metadata('opencl.spir.version')
 if (not spir_version.operands):
  spir_version.add(lc.MetaData.get(mod, spir_version_constant))
 ocl_version = mod.get_or_insert_named_metadata('opencl.ocl.version')
 if (not ocl_version.operands):
  ocl_version.add(lc.MetaData.get(mod, spir_version_constant))

def set_hsa_kernel ( fn ) : mod = fn . module fn . calling_convention = CC_SPIR_KERNEL ocl_kernels = mod . get_or_insert_named_metadata ( 'opencl.kernels' ) ocl_kernels . add ( lc . MetaData . get ( mod , [ fn , gen_arg_addrspace_md ( fn ) , gen_arg_access_qual_md ( fn ) , gen_arg_type ( fn ) , gen_arg_type_qual ( fn ) , gen_arg_base_type ( fn ) ] ) ) make_constant = ( lambda x : lc . Constant . int ( lc . Type . int ( ) , x ) ) spir_version_constant = [ make_constant ( x ) for x in SPIR_VERSION ] spir_version = mod . get_or_insert_named_metadata ( 'opencl.spir.version' ) if ( not spir_version . operands ) : spir_version . add ( lc . MetaData . get ( mod , spir_version_constant ) ) ocl_version = mod . get_or_insert_named_metadata ( 'opencl.ocl.version' ) if ( not ocl_version . operands ) : ocl_version . add ( lc . MetaData . get ( mod , spir_version_constant ) )
ensure fn is usable as a spir kernel .