From: Michael Beck Date: Sun, 16 Aug 2009 01:33:42 +0000 (+0000) Subject: - add pass for combo() X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=7412de5cd8ccbd237f84e363bcb80e73ff4f1d79;p=libfirm - add pass for combo() - fixed pass generator for lower_intrinsics - add irpass.h to firm.h header [r26346] --- diff --git a/include/libfirm/firm.h b/include/libfirm/firm.h index 1020f6a6f..041ea0e83 100644 --- a/include/libfirm/firm.h +++ b/include/libfirm/firm.h @@ -83,6 +83,7 @@ extern "C" { #include "iroptimize.h" /* optimize ir by reassociation */ #include "ircgopt.h" /* Optimizations based on interprocedural graph */ #include "iropt.h" +#include "irpass.h" /* Pass management */ /* Lowering */ #include "lowering.h" /* lowering of different calls parameters, intrinsic calls, double word types, high-level constructs */ diff --git a/include/libfirm/iroptimize.h b/include/libfirm/iroptimize.h index 7a1c1ba50..f4aa87db2 100644 --- a/include/libfirm/iroptimize.h +++ b/include/libfirm/iroptimize.h @@ -550,6 +550,17 @@ void optimize_class_casts(void); */ void combo(ir_graph *irg); +/** + * Creates an ir_graph pass for combo. + * + * @param name the name of this pass or NULL + * @param verify should this pass be verified? + * @param dump should this pass result be dumped? + * + * @return the newly created ir_graph pass + */ +ir_graph_pass_t *combo_pass(const char *name, int verify, int dump); + /** Inlines all small methods at call sites where the called address comes * from a SymConst node that references the entity representing the called * method. diff --git a/include/libfirm/lowering.h b/include/libfirm/lowering.h index 6be3b8e3d..79c75228c 100644 --- a/include/libfirm/lowering.h +++ b/include/libfirm/lowering.h @@ -324,7 +324,7 @@ ir_prog_pass_t *lower_intrinsics_pass( const char *name, int verify, int dump, - i_record *list, int length); + i_record *list, int length, int part_block_used); /** * A mapper for the integer/float absolute value: type abs(type v). diff --git a/ir/lower/lower_intrinsics.c b/ir/lower/lower_intrinsics.c index 448551a94..f748f439a 100644 --- a/ir/lower/lower_intrinsics.c +++ b/ir/lower/lower_intrinsics.c @@ -168,7 +168,7 @@ struct pass_t { }; /** - * Wrapper for running lower_intrinsics() as an irprog pass. + * Wrapper for running lower_intrinsics() as an ir_prog pass. */ static int pass_wrapper(ir_prog *irp, void *context) { @@ -179,7 +179,7 @@ static int pass_wrapper(ir_prog *irp, void *context) } /* pass_wrapper */ /** - * Creates an irprog pass for lower_intrinsics. + * Creates an ir_prog pass for lower_intrinsics. * * @param name the name of this pass or NULL * @param verify should this pass be verified? @@ -192,7 +192,7 @@ ir_prog_pass_t *lower_intrinsics_pass( const char *name, int verify, int dump, - i_record *list, int length) + i_record *list, int length, int part_block_used) { struct pass_t *pass = xmalloc(sizeof(*pass) + (length-1) * sizeof(pass->list[0])); @@ -206,6 +206,10 @@ ir_prog_pass_t *lower_intrinsics_pass( INIT_LIST_HEAD(&pass->pass.list); + memcpy(pass->list, list, sizeof(list[0]) * length); + pass->length = length; + pass->part_block_used = part_block_used; + return &pass->pass; } /* lower_intrinsics_pass*/ diff --git a/ir/opt/combo.c b/ir/opt/combo.c index aeee47288..081eee94b 100644 --- a/ir/opt/combo.c +++ b/ir/opt/combo.c @@ -72,6 +72,7 @@ #include "irgraph_t.h" #include "irnode_t.h" #include "iropt_t.h" +#include "irpass_t.h" #include "irgwalk.h" #include "irop.h" #include "irouts.h" @@ -3567,3 +3568,29 @@ void combo(ir_graph *irg) { set_value_of_func(NULL); current_ir_graph = rem; } /* combo */ + +/** + * Wrapper for running combo() as an ir_graph pass. + */ +static int pass_wrapper(ir_graph *irg, void *context) { + (void)context; + combo(irg); + /* combo is a fix-point iteration */ + return 0; +} /* pass_wrapper */ + +/* Creates an ir_graph pass for combo. */ +ir_graph_pass_t *combo_pass(const char *name, int verify, int dump) { + struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t); + + pass->kind = k_ir_prog_pass; + pass->run_on_irg = pass_wrapper; + pass->context = pass; + pass->name = name ? name : "combo"; + pass->verify = verify != 0; + pass->dump = dump != 0; + + INIT_LIST_HEAD(&pass->list); + + return pass; +} /* combo_pass */