def codegen(context, builder, sig, args): # Need to retrieve the function name again atypes = tuple(map(Type.fromobject, sig.args)) t = self.match_signature(atypes) fn_name = t.name fndesc = funcdesc.ExternalFunctionDescriptor( fn_name, sig.return_type, sig.args) func = context.declare_external_function(builder.module, fndesc) return builder.call(func, args)
def declare_device_function(name, restype, argtypes): from .descriptor import cuda_target typingctx = cuda_target.typingctx targetctx = cuda_target.targetctx sig = typing.signature(restype, *argtypes) extfn = ExternFunction(name, sig) class device_function_template(ConcreteTemplate): key = extfn cases = [sig] fndesc = funcdesc.ExternalFunctionDescriptor( name=name, restype=restype, argtypes=argtypes) typingctx.insert_user_function(extfn, device_function_template) targetctx.insert_user_function(extfn, fndesc) return extfn
def _lower_call_ExternalFunction(self, fnty, expr, signature): # Handle a named external function self.debug_print("# external function") argvals = self.fold_call_args( fnty, signature, expr.args, expr.vararg, expr.kws, ) fndesc = funcdesc.ExternalFunctionDescriptor(fnty.symbol, fnty.sig.return_type, fnty.sig.args) func = self.context.declare_external_function(self.builder.module, fndesc) return self.context.call_external_function( self.builder, func, fndesc.argtypes, argvals, )
def codegen(context, builder, sig, args): # Need to retrieve the function name again fndesc = funcdesc.ExternalFunctionDescriptor(fn_name, sig.return_type, sig.args) func = context.declare_external_function(builder.module, fndesc) return builder.call(func, args)
def codegen(context, builder, sig, args): fndesc = funcdesc.ExternalFunctionDescriptor( name, sig.return_type, sig.args) func = context.declare_external_function( builder.module, fndesc) return builder.call(func, args)