Commit 6f37b3f5 authored by Matthias Braun's avatar Matthias Braun
Browse files

only construct Rotl if backend supports it

[r27953]
parent 84d9d910
......@@ -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;
......
......@@ -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 */
};
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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 */
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment