示例#1
0
文件: cpu.py 项目: digideskio/numba
 def create_cpython_wrapper(self, library, fndesc, env, call_helper,
                            release_gil=False):
     wrapper_module = self.create_module("wrapper")
     fnty = self.call_conv.get_function_type(fndesc.restype, fndesc.argtypes)
     wrapper_callee = wrapper_module.add_function(fnty, fndesc.llvm_func_name)
     builder = PyCallWrapper(self, wrapper_module, wrapper_callee,
                             fndesc, env, call_helper=call_helper,
                             release_gil=release_gil)
     builder.build()
     library.add_ir_module(wrapper_module)
示例#2
0
 def create_cpython_wrapper(self, library, fndesc, exceptions,
                            release_gil=False):
     wrapper_module = self.create_module("wrapper")
     fnty = self.get_function_type(fndesc)
     wrapper_callee = wrapper_module.add_function(fnty, fndesc.llvm_func_name)
     builder = PyCallWrapper(self, wrapper_module, wrapper_callee,
                             fndesc, exceptions=exceptions,
                             release_gil=release_gil)
     builder.build()
     library.add_ir_module(wrapper_module)
示例#3
0
 def create_cpython_wrapper(self, library, fndesc, env, call_helper,
                            release_gil=False):
     wrapper_module = self.create_module("wrapper")
     fnty = self.call_conv.get_function_type(fndesc.restype, fndesc.argtypes)
     wrapper_callee = wrapper_module.add_function(fnty, fndesc.llvm_func_name)
     builder = PyCallWrapper(self, wrapper_module, wrapper_callee,
                             fndesc, env, call_helper=call_helper,
                             release_gil=release_gil)
     builder.build()
     library.add_ir_module(wrapper_module)
示例#4
0
    def prepare_for_call(self, func, fndesc):
        wrapper, api = PyCallWrapper(self, func.module, func, fndesc).build()
        self.optimize(func.module)

        if config.DUMP_OPTIMIZED:
            print(
                ("OPTIMIZED DUMP %s" % fndesc.qualified_name).center(80, '-'))
            print(func.module)
            print('=' * 80)

        if config.DUMP_ASSEMBLY:
            print(("ASSEMBLY %s" % fndesc.qualified_name).center(80, '-'))
            print(self.tm.emit_assembly(func.module))
            print('=' * 80)

        # Map module.__dict__
        le.dylib_add_symbol(".pymodule.dict." + fndesc.pymod.__name__,
                            id(fndesc.pymod.__dict__))

        # Code gen
        self.engine.add_module(func.module)
        baseptr = self.engine.get_pointer_to_function(func)
        fnptr = self.engine.get_pointer_to_function(wrapper)
        cfunc = _dynfunc.make_function(fndesc.pymod, fndesc.name, fndesc.doc,
                                       fnptr)

        if fndesc.native:
            self.native_funcs[cfunc] = fndesc.mangled_name, baseptr

        return cfunc, fnptr
示例#5
0
    def prepare_for_call(self, func, fndesc, env):
        wrapper, api = PyCallWrapper(self,
                                     func.module,
                                     func,
                                     fndesc,
                                     exceptions=self.exceptions).build()
        self.optimize(func.module)

        if config.DUMP_OPTIMIZED:
            print(("OPTIMIZED DUMP %s" % fndesc).center(80, '-'))
            print(func.module)
            print('=' * 80)

        if config.DUMP_ASSEMBLY:
            print(("ASSEMBLY %s" % fndesc).center(80, '-'))
            print(self.tm.emit_assembly(func.module))
            print('=' * 80)

        # Code gen
        self.engine.add_module(func.module)
        baseptr = self.engine.get_pointer_to_function(func)
        fnptr = self.engine.get_pointer_to_function(wrapper)
        cfunc = _dynfunc.make_function(fndesc.lookup_module(),
                                       fndesc.qualname.split('.')[-1],
                                       fndesc.doc, fnptr, env)

        if fndesc.native:
            self.native_funcs[cfunc] = fndesc.mangled_name, baseptr

        return cfunc
示例#6
0
文件: cpu.py 项目: liyangdal/numba
 def create_cpython_wrapper(self,
                            library,
                            fndesc,
                            exceptions,
                            release_gil=False):
     wrapper_module = self.create_module("wrapper")
     fnty = self.get_function_type(fndesc)
     wrapper_callee = wrapper_module.add_function(fnty,
                                                  fndesc.llvm_func_name)
     builder = PyCallWrapper(self,
                             wrapper_module,
                             wrapper_callee,
                             fndesc,
                             exceptions=exceptions,
                             release_gil=release_gil)
     builder.build()
     library.add_ir_module(wrapper_module)