def get_pipeline_manager(self, py_func, sig, library=None, lifted=(), func_attr=compiler.DEFAULT_FUNCTION_ATTRIBUTES): '''Returns a non-finalized PipelineManager, populated as if set up by Pipeline._compile_bytecode(). ''' pipeline = self.get_and_prime_pipeline(py_func, sig, library, lifted, func_attr) pm = compiler._PipelineManager() if not pipeline.flags.force_pyobject: pm.create_pipeline("nopython") pm.add_stage(pipeline.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(pipeline.stage_nopython_frontend, "nopython frontend") pm.add_stage(pipeline.stage_annotate_type, "annotate type") pm.add_stage(pipeline.stage_nopython_backend, "nopython mode backend") if pipeline.status.can_fallback or pipeline.flags.force_pyobject: pm.create_pipeline("object") pm.add_stage(pipeline.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(pipeline.stage_objectmode_frontend, "object mode frontend") pm.add_stage(pipeline.stage_annotate_type, "annotate type") pm.add_stage(pipeline.stage_objectmode_backend, "object mode backend") if pipeline.status.can_giveup: pm.create_pipeline("interp") pm.add_stage(pipeline.stage_compile_interp_mode, "compiling with interpreter mode") return pm
def compile_to_ir(self, func, test_idempotence=None): """ Populate and run compiler pipeline """ self.func_id = bytecode.FunctionIdentity.from_function(func) try: bc = self.extract_bytecode(self.func_id) except BaseException as e: raise e self.bc = bc self.lifted = () self.lifted_from = None pm = _PipelineManager() pm.create_pipeline("nopython") if self.func_ir is None: pm.add_stage(self.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(self.stage_process_ir, "processing IR") if not self.flags.no_rewrites: if self.status.can_fallback: pm.add_stage( self.stage_preserve_ir, "preserve IR for fallback") pm.add_stage(self.stage_generic_rewrites, "nopython rewrites") pm.add_stage( self.stage_inline_pass, "inline calls to locally defined closures") pm.add_stage(self.stage_nopython_frontend, "nopython frontend") pm.add_stage(self.stage_annotate_type, "annotate type") if not self.flags.no_rewrites: pm.add_stage(self.stage_nopython_rewrites, "nopython rewrites") func_ir_copies = [] def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies) pm.add_stage(stage_array_analysis, "analyze array equivalences") if test_idempotence: # Do another pass of array analysis to test idempontence pm.add_stage(stage_array_analysis, "analyze array equivalences") pm.finalize() res = pm.run(self.status) return self.array_analysis
def compile_to_ir(self, func, test_idempotence=None): """ Populate and run compiler pipeline """ self.func_id = bytecode.FunctionIdentity.from_function(func) try: bc = self.extract_bytecode(self.func_id) except BaseException as e: raise e self.bc = bc self.lifted = () self.lifted_from = None pm = _PipelineManager() pm.create_pipeline("nopython") if self.func_ir is None: pm.add_stage(self.stage_analyze_bytecode, "analyzing bytecode") pm.add_stage(self.stage_process_ir, "processing IR") if not self.flags.no_rewrites: if self.status.can_fallback: pm.add_stage( self.stage_preserve_ir, "preserve IR for fallback") pm.add_stage(self.stage_generic_rewrites, "nopython rewrites") pm.add_stage( self.stage_inline_pass, "inline calls to locally defined closures") pm.add_stage(self.stage_nopython_frontend, "nopython frontend") pm.add_stage(self.stage_annotate_type, "annotate type") if not self.flags.no_rewrites: pm.add_stage(self.stage_nopython_rewrites, "nopython rewrites") func_ir_copies = [] def stage_array_analysis(): self.array_analysis = ArrayAnalysis(self.typingctx, self.func_ir, self.type_annotation.typemap, self.type_annotation.calltypes) self.array_analysis.run(self.func_ir.blocks) func_ir_copies.append(self.func_ir.copy()) if test_idempotence and len(func_ir_copies) > 1: test_idempotence(func_ir_copies) pm.add_stage(stage_array_analysis, "analyze array equivalences") if test_idempotence: # Do another pass of array analysis to test idempotence pm.add_stage(stage_array_analysis, "analyze array equivalences") pm.finalize() res = pm.run(self.status) return self.array_analysis
def compile_to_ir(self, func, DCE=False): """ Compile and return IR """ self.func_id = bytecode.FunctionIdentity.from_function(func) self.bc = self.extract_bytecode(self.func_id) self.lifted = [] pm = _PipelineManager() pm.create_pipeline("pipeline") self.add_preprocessing_stage(pm) self.add_pre_typing_stage(pm) self.add_typing_stage(pm) if DCE is True: pm.add_stage(self.rm_dead_stage, "DCE after typing") pm.finalize() pm.run(self.status) return self.func_ir