only construct Rotl if backend supports it
authorMatthias Braun <matze@braunis.de>
Thu, 19 Aug 2010 15:56:36 +0000 (15:56 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 19 Aug 2010 15:56:36 +0000 (15:56 +0000)
[r27953]

include/libfirm/be.h
include/libfirm/irarch.h
ir/be/TEMPLATE/bearch_TEMPLATE.c
ir/be/amd64/bearch_amd64.c
ir/be/arm/bearch_arm.c
ir/be/bemain.c
ir/be/ia32/bearch_ia32.c
ir/be/sparc/bearch_sparc.c
ir/ir/iropt.c

index 8d9e4d4..103a626 100644 (file)
@@ -73,6 +73,8 @@ typedef void (*lower_for_target_func)(void);
 typedef struct backend_params {
        /** If set, the backend supports inline assembly. */
        unsigned support_inline_asm:1;
+       /** If set, the backend supports Rotl nodes */
+       unsigned support_rotl:1;
 
        /** callback that performs lowerings required for target architecture */
        lower_for_target_func lower_for_target;
index ab1370a..8420821 100644 (file)
@@ -60,7 +60,7 @@ typedef int (*evaluate_costs_func)(insn_kind kind, tarval *tv);
 struct ir_settings_arch_dep_t {
        /* Mul optimization */
        unsigned also_use_subs : 1;    /**< Use also Subs when resolving Muls to shifts */
-       unsigned maximum_shifts;            /**< The maximum number of shifts that shall be inserted for a mul. */
+       unsigned maximum_shifts;       /**< The maximum number of shifts that shall be inserted for a mul. */
        unsigned highest_shift_amount; /**< The highest shift amount you want to
                                            tolerate. Muls which would require a higher
                                            shift constant are left. */
@@ -69,7 +69,7 @@ struct ir_settings_arch_dep_t {
        /* Div/Mod optimization */
        unsigned allow_mulhs   : 1;    /**< Use the Mulhs operation for division by constant */
        unsigned allow_mulhu   : 1;    /**< Use the Mulhu operation for division by constant */
-       unsigned max_bits_for_mulh;         /**< Maximum number of bits the Mulh operation can take.
+       unsigned max_bits_for_mulh;    /**< Maximum number of bits the Mulh operation can take.
                                            Modes with higher amount of bits will use Mulh */
 };
 
index 415baa8..2e80f09 100644 (file)
@@ -454,6 +454,7 @@ static const backend_params *TEMPLATE_get_backend_params(void)
 {
        static backend_params p = {
                0,     /* no inline assembly */
+               0,     /* no support for Rotl nodes */
                TEMPLATE_lower_for_target,  /* lowering for target */
                NULL,  /* architecture dependent settings, will be set later */
                NULL,  /* parameter for if conversion */
index 8e03689..0039c83 100644 (file)
@@ -611,6 +611,7 @@ static void amd64_lower_for_target(void)
 static const backend_params *amd64_get_backend_params(void) {
        static backend_params p = {
                0,     /* no inline assembly */
+               1,     /* support Rotl nodes */
                amd64_lower_for_target,  /* lowering callback */
                NULL,  /* will be set later */
                NULL,  /* parameter for if conversion */
index a31f99d..c68be12 100644 (file)
@@ -691,6 +691,7 @@ static const backend_params *arm_get_libfirm_params(void)
        };
        static backend_params p = {
                0,     /* don't support inline assembler yet */
+               1,     /* support Rotl nodes */
                NULL,  /* lowering function */
                &ad,   /* will be set later */
                arm_is_mux_allowed, /* allow_ifconv function */
index 1159f1b..f0d0d23 100644 (file)
@@ -343,6 +343,7 @@ int be_parse_arg(const char *arg)
 /** The be parameters returned by default, all off. */
 static const backend_params be_params = {
        0,    /* don't support inline assembler yet */
+       0,    /* don't support rotl */
        NULL, /* no lowering required */
        NULL, /* will be set later */
        NULL, /* no if conversion settings */
index 1fe8973..6a47923 100644 (file)
@@ -2394,6 +2394,7 @@ static const backend_params *ia32_get_libfirm_params(void)
        };
        static backend_params p = {
                1,     /* support inline assembly */
+               1,     /* support Rotl nodes */
                ia32_lower_for_target,
                NULL,  /* will be set later */
                ia32_is_mux_allowed,
index d410f00..4000342 100644 (file)
@@ -572,6 +572,7 @@ static const backend_params *sparc_get_backend_params(void)
 {
        static backend_params p = {
                0,     /* no inline assembly */
+               0,     /* no support for RotL nodes */
                sparc_lower_for_target, /* lowering callback */
                NULL,  /* will be set later */
                NULL,  /* parameter for if conversion */
index d52d324..b66b366 100644 (file)
@@ -50,6 +50,7 @@
 #include "array_t.h"
 #include "vrp.h"
 #include "firm_types.h"
+#include "be.h"
 
 /* Make types visible to allow most efficient access */
 #include "entity_t.h"
@@ -5165,6 +5166,10 @@ static ir_node *transform_node_Or_Rotl(ir_node *or)
                                != (int) get_mode_size_bits(mode))
                        return or;
 
+               /* some backends can't handle rotl */
+               if (!be_get_backend_param()->support_rotl)
+                       return or;
+
                /* yet, condition met */
                block = get_nodes_block(or);
 
@@ -5180,9 +5185,11 @@ static ir_node *transform_node_Or_Rotl(ir_node *or)
         rotval = sub; /* a Rot right is not supported, so use a rot left */
     } else if (is_Sub(c2)) {
                v      = c1;
-       sub    = c2;
+               sub    = c2;
         rotval = v;
-    } else return or;
+    } else {
+               return or;
+       }
 
        if (get_Sub_right(sub) != v)
                return or;
@@ -5198,6 +5205,10 @@ static ir_node *transform_node_Or_Rotl(ir_node *or)
        if (get_tarval_long(tv1) != (int) get_mode_size_bits(mode))
                return or;
 
+       /* some backends can't handle rotl */
+       if (!be_get_backend_param()->support_rotl)
+               return or;
+
        /* yet, condition met */
        block = get_nodes_block(or);