invoke switch lowerer in target specific lowering pass
authorMatthias Braun <matze@braunis.de>
Fri, 10 Sep 2010 13:29:23 +0000 (13:29 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 10 Sep 2010 13:29:23 +0000 (13:29 +0000)
[r28000]

include/libfirm/lowering.h
ir/be/arm/bearch_arm.c
ir/be/ia32/bearch_ia32.c
ir/be/sparc/bearch_sparc.c
ir/lower/lower_switch.c

index 97d63aa..80b158d 100644 (file)
@@ -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.
  *
index 0db8e4b..c7a454a 100644 (file)
@@ -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) */
index 91f3d60..634625b 100644 (file)
@@ -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);
        }
 }
 
index 1f0882c..abed804 100644 (file)
@@ -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);
+       }
 }
 
 /**
index 5bd7817..2e07566 100644 (file)
@@ -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);
-}