def _declare_function(context, builder, name, sig, cargs, mangler=mangle_c):
 mod = builder.module
 if (sig.return_type == types.void):
  llretty = lc.Type.void()
 else:
  llretty = context.get_value_type(sig.return_type)
 llargs = [context.get_value_type(t) for t in sig.args]
 fnty = Type.function(llretty, llargs)
 mangled = mangler(name, cargs)
 fn = mod.get_or_insert_function(fnty, mangled)
 fn.calling_convention = target.CC_SPIR_FUNC
 return fn

def _declare_function ( context , builder , name , sig , cargs , mangler = mangle_c ) : mod = builder . module if ( sig . return_type == types . void ) : llretty = lc . Type . void ( ) else : llretty = context . get_value_type ( sig . return_type ) llargs = [ context . get_value_type ( t ) for t in sig . args ] fnty = Type . function ( llretty , llargs ) mangled = mangler ( name , cargs ) fn = mod . get_or_insert_function ( fnty , mangled ) fn . calling_convention = target . CC_SPIR_FUNC return fn
insert declaration for a opencl builtin function .