From 3afe8891ce8a8a741f8793255ad6e88d77c37f6e Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 10 Sep 2010 13:29:23 +0000 Subject: [PATCH] invoke switch lowerer in target specific lowering pass [r28000] --- include/libfirm/lowering.h | 12 ------------ ir/be/arm/bearch_arm.c | 13 ++++++++++++- ir/be/ia32/bearch_ia32.c | 4 +++- ir/be/sparc/bearch_sparc.c | 8 ++++++++ ir/lower/lower_switch.c | 26 -------------------------- 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/include/libfirm/lowering.h b/include/libfirm/lowering.h index 97d63aaaa..80b158ddf 100644 --- a/include/libfirm/lowering.h +++ b/include/libfirm/lowering.h @@ -163,18 +163,6 @@ FIRM_API void lower_CopyB(ir_graph *irg, unsigned max_size, */ FIRM_API void lower_switch(ir_graph *irg, unsigned spare_size); -/** - * Creates an ir_graph pass for lower_switch(). - * - * @param name the name of this pass or NULL - * @param spare_size Allowed spare size for table switches in machine words. - * (Default in edgfe: 128) - * - * @return the newly created ir_graph pass - */ -FIRM_API ir_graph_pass_t *lower_switch_pass(const char *name, - unsigned spare_size); - /** * A callback type for creating an intrinsic entity for a given opcode. * diff --git a/ir/be/arm/bearch_arm.c b/ir/be/arm/bearch_arm.c index 0db8e4b43..c7a454aa8 100644 --- a/ir/be/arm/bearch_arm.c +++ b/ir/be/arm/bearch_arm.c @@ -674,6 +674,17 @@ static int arm_is_valid_clobber(const char *clobber) return 0; } +static void arm_lower_for_target(void) +{ + int i; + int n_irgs = get_irp_n_irgs(); + + for (i = 0; i < n_irgs; ++i) { + ir_graph *irg = get_irp_irg(i); + lower_switch(irg, 128); + } +} + /** * Returns the libFirm configuration parameter for this backend. */ @@ -692,7 +703,7 @@ static const backend_params *arm_get_libfirm_params(void) 0, /* don't support inline assembler yet */ 1, /* support Rotl nodes */ 1, /* big endian */ - NULL, /* lowering function */ + arm_lower_for_target, /* lowering function */ &ad, /* will be set later */ arm_is_mux_allowed, /* allow_ifconv function */ NULL, /* float arithmetic mode (TODO) */ diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index 91f3d6026..634625b23 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -2264,10 +2264,12 @@ static void ia32_lower_for_target(void) }; lower_dw_ops(&lower_dw_params); - /* lower for mode_b stuff */ for (i = 0; i < n_irgs; ++i) { ir_graph *irg = get_irp_irg(i); + /* lower for mode_b stuff */ ir_lower_mode_b(irg, &lower_mode_b_config); + /* break up switches with wide ranges */ + lower_switch(irg, 128); } } diff --git a/ir/be/sparc/bearch_sparc.c b/ir/be/sparc/bearch_sparc.c index 1f0882cb4..abed80413 100644 --- a/ir/be/sparc/bearch_sparc.c +++ b/ir/be/sparc/bearch_sparc.c @@ -551,7 +551,15 @@ static int sparc_get_reg_class_alignment(const arch_register_class_t *cls) static void sparc_lower_for_target(void) { + int i; + int n_irgs = get_irp_n_irgs(); + /* TODO, doubleword lowering and others */ + + for (i = 0; i < n_irgs; ++i) { + ir_graph *irg = get_irp_irg(i); + lower_switch(irg, 128); + } } /** diff --git a/ir/lower/lower_switch.c b/ir/lower/lower_switch.c index 5bd781756..2e075661d 100644 --- a/ir/lower/lower_switch.c +++ b/ir/lower/lower_switch.c @@ -322,29 +322,3 @@ void lower_switch(ir_graph *irg, unsigned spare_size) set_irg_loopinfo_inconsistent(irg); } } - -struct pass_t { - ir_graph_pass_t pass; - unsigned spare_size; -}; - -/** - * Wrapper for running lower_switch() as a pass. - */ -static int pass_wrapper(ir_graph *irg, void *context) -{ - struct pass_t *pass = context; - - lower_switch(irg, pass->spare_size); - return 0; -} - -/* creates a pass for lower_switch */ -ir_graph_pass_t *lower_switch_pass(const char *name, unsigned spare_size) -{ - struct pass_t *pass = XMALLOCZ(struct pass_t); - - pass->spare_size = spare_size; - return def_graph_pass_constructor( - &pass->pass, name ? name : "lower_switch", pass_wrapper); -} -- 2.20.1