def _compile_subroutine_no_cache(self, builder, impl, sig, locals={}, flags=None): """ Invoke the compiler to compile a function to be used inside a nopython function, but without generating code to call that function. Note this context's flags are not inherited. """ # Compile from numba import compiler with global_compiler_lock: codegen = self.codegen() library = codegen.create_library(impl.__name__) if flags is None: flags = compiler.Flags() flags.set('no_compile') flags.set('no_cpython_wrapper') cres = compiler.compile_internal(self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) return cres
def compile_internal(self, builder, impl, sig, args, locals={}): """Invoke compiler to implement a function for a nopython function """ cache_key = (impl.__code__, sig) fndesc = self.cached_internal_func.get(cache_key) if fndesc is None: # Compile from numba import compiler codegen = self.jit_codegen() library = codegen.create_library(impl.__name__) flags = compiler.Flags() flags.set("no_compile") flags.set("no_cpython_wrapper") cres = compiler.compile_internal( self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals ) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) fndesc = cres.fndesc self.cached_internal_func[cache_key] = fndesc # Add call to the generated function llvm_mod = cgutils.get_module(builder) fn = self.declare_function(llvm_mod, fndesc) status, res = self.call_function(builder, fn, sig.return_type, sig.args, args) return res
def compile_subroutine_no_cache(self, builder, impl, sig, locals={}, flags=None): """ Invoke the compiler to compile a function to be used inside a nopython function, but without generating code to call that function. Note this context's flags are not inherited. """ # Compile from numba import compiler codegen = self.codegen() library = codegen.create_library(impl.__name__) if flags is None: flags = compiler.Flags() flags.set('no_compile') flags.set('no_cpython_wrapper') cres = compiler.compile_internal(self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) return cres
def compile_only_no_cache(self, builder, impl, sig, locals={}): """Invoke the compiler to compile a function to be used inside a nopython function, but without generating code to call that function. """ # Compile from numba import compiler codegen = self.codegen() library = codegen.create_library(impl.__name__) flags = compiler.Flags() flags.set('no_compile') flags.set('no_cpython_wrapper') cres = compiler.compile_internal(self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) return cres
def compile_internal(self, builder, impl, sig, args, locals={}): """Invoke compiler to implement a function for a nopython function """ cache_key = (impl.__code__, sig) if impl.__closure__: # XXX This obviously won't work if a cell's value is # unhashable. cache_key += tuple(c.cell_contents for c in impl.__closure__) fndesc = self.cached_internal_func.get(cache_key) if fndesc is None: # Compile from numba import compiler codegen = self.jit_codegen() library = codegen.create_library(impl.__name__) flags = compiler.Flags() flags.set('no_compile') flags.set('no_cpython_wrapper') cres = compiler.compile_internal(self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) fndesc = cres.fndesc self.cached_internal_func[cache_key] = fndesc # Add call to the generated function llvm_mod = cgutils.get_module(builder) fn = self.declare_function(llvm_mod, fndesc) status, res = self.call_conv.call_function(builder, fn, sig.return_type, sig.args, args) with cgutils.if_unlikely(builder, status.is_error): self.call_conv.return_status_propagate(builder, status) return res
def compile_only_no_cache(self, builder, impl, sig, locals={}): """Invoke the compiler to compile a function to be used inside a nopython function, but without generating code to call that function. """ # Compile from numba import compiler codegen = self.codegen() library = codegen.create_library(impl.__name__) flags = compiler.Flags() flags.set("no_compile") flags.set("no_cpython_wrapper") cres = compiler.compile_internal( self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals ) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) return cres
def compile_internal(self, builder, impl, sig, args, locals={}): """Invoke compiler to implement a function for a nopython function """ cache_key = (impl.__code__, sig) fndesc = self.cached_internal_func.get(cache_key) if fndesc is None: # Compile from numba import compiler codegen = self.jit_codegen() library = codegen.create_library(impl.__name__) flags = compiler.Flags() flags.set('no_compile') flags.set('no_cpython_wrapper') cres = compiler.compile_internal(self.typing_context, self, library, impl, sig.args, sig.return_type, flags, locals=locals) # Allow inlining the function inside callers. codegen.add_linking_library(cres.library) fndesc = cres.fndesc self.cached_internal_func[cache_key] = fndesc # Add call to the generated function llvm_mod = cgutils.get_module(builder) fn = self.declare_function(llvm_mod, fndesc) status, res = self.call_function(builder, fn, sig.return_type, sig.args, args) return res