Commit 4d7f507c authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Remove ia32_l_Setcc and remove set creation callback from ir_lower_mode_b().

It is just an unnecessary node, which the middleend does not understand and therefore cannot optimize.
parent 1759fbe9
......@@ -2014,21 +2014,9 @@ static int ia32_is_valid_clobber(const char *clobber)
return ia32_get_clobber_register(clobber) != NULL;
}
static ir_node *ia32_create_set(ir_node *cond)
{
ir_node *block = get_nodes_block(cond);
ir_node *set = new_bd_ia32_l_Setcc(NULL, block, cond);
ir_node *conv = new_r_Conv(block, set, mode_Iu);
return conv;
}
static void ia32_lower_for_target(void)
{
size_t i, n_irgs = get_irp_n_irgs();
lower_mode_b_config_t lower_mode_b_config = {
mode_Iu, /* lowered mode */
ia32_create_set,
};
/* perform doubleword lowering */
lwrdw_param_t lower_dw_params = {
......@@ -2060,7 +2048,7 @@ static void ia32_lower_for_target(void)
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);
ir_lower_mode_b(irg, mode_Iu);
/* break up switches with wide ranges */
lower_switch(irg, 4, 256, false);
}
......
......@@ -974,14 +974,6 @@ Test8Bit => {
modified_flags => $status_flags
},
l_Setcc => {
ins => [ "cond" ],
outs => [ "res" ],
mode => "mode_Bu",
attr_type => "",
dump_func => "NULL",
},
Setcc => {
#irn_flags => [ "rematerializable" ],
reg_req => { in => [ "eflags" ], out => [ "eax ebx ecx edx" ] },
......
......@@ -3647,19 +3647,6 @@ static ir_node *gen_Mux(ir_node *node)
}
}
static ir_node *gen_ia32_l_Setcc(ir_node *node)
{
ia32_condition_code_t cc;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = get_nodes_block(node);
ir_node *new_block = be_transform_node(block);
ir_node *cond = get_irn_n(node, n_ia32_l_Setcc_cond);
ir_node *flags = get_flags_node(cond, &cc);
ir_node *new_node = new_bd_ia32_Setcc(dbgi, new_block, flags, cc);
SET_IA32_ORIG_NODE(new_node, node);
return new_node;
}
/**
* Create a conversion from x87 state register to general purpose.
*/
......@@ -5786,7 +5773,6 @@ static void register_transformers(void)
be_set_transform_function(op_ia32_l_LLtoFloat, gen_ia32_l_LLtoFloat);
be_set_transform_function(op_ia32_l_Mul, gen_ia32_l_Mul);
be_set_transform_function(op_ia32_l_Sbb, gen_ia32_l_Sbb);
be_set_transform_function(op_ia32_l_Setcc, gen_ia32_l_Setcc);
be_set_transform_function(op_ia32_l_Sub, gen_ia32_l_Sub);
be_set_transform_function(op_ia32_GetEIP, be_duplicate_node);
be_set_transform_function(op_ia32_Minus64Bit, be_duplicate_node);
......
......@@ -411,18 +411,9 @@ static int sparc_get_reg_class_alignment(const arch_register_class_t *cls)
return get_mode_size_bytes(mode);
}
static ir_node *sparc_create_set(ir_node *cond)
{
return ir_create_cond_set(cond, mode_Iu);
}
static void sparc_lower_for_target(void)
{
size_t i, n_irgs = get_irp_n_irgs();
lower_mode_b_config_t lower_mode_b_config = {
mode_Iu,
sparc_create_set,
};
lower_calls_with_compounds(LF_RETURN_HIDDEN);
......@@ -442,7 +433,7 @@ static void sparc_lower_for_target(void)
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
ir_lower_mode_b(irg, &lower_mode_b_config);
ir_lower_mode_b(irg, mode_Iu);
lower_switch(irg, 4, 256, false);
lower_alloc(irg, SPARC_STACK_ALIGNMENT, false, -SPARC_MIN_STACKSIZE);
}
......
......@@ -51,13 +51,13 @@ typedef struct needs_lowering_t {
int input;
} needs_lowering_t;
static const lower_mode_b_config_t *config;
static needs_lowering_t *needs_lowering;
static ir_mode *lowered_mode;
static needs_lowering_t *needs_lowering;
static ir_node *create_not(dbg_info *dbgi, ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_mode *mode = config->lowered_mode;
ir_mode *mode = lowered_mode;
ir_tarval *tv_one = get_mode_one(mode);
ir_graph *irg = get_irn_irg(node);
ir_node *one = new_rd_Const(dbgi, irg, tv_one);
......@@ -69,14 +69,18 @@ static ir_node *convert_to_modeb(ir_node *node)
{
ir_node *block = get_nodes_block(node);
ir_graph *irg = get_irn_irg(node);
ir_mode *mode = config->lowered_mode;
ir_mode *mode = lowered_mode;
ir_tarval *tv_zero = get_mode_null(mode);
ir_node *zero = new_r_Const(irg, tv_zero);
ir_node *cmp = new_r_Cmp(block, node, zero, ir_relation_less_greater);
return cmp;
}
ir_node *ir_create_cond_set(ir_node *cond_value, ir_mode *dest_mode)
/**
* implementation of create_set_func which produces a cond with control
* flow
*/
static ir_node *create_cond_set(ir_node *cond_value, ir_mode *dest_mode)
{
ir_node *lower_block = part_block_edges(cond_value);
ir_node *upper_block = get_nodes_block(cond_value);
......@@ -106,7 +110,7 @@ static ir_node *lower_node(ir_node *node)
{
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = get_nodes_block(node);
ir_mode *mode = config->lowered_mode;
ir_mode *mode = lowered_mode;
ir_node *res = (ir_node*)get_irn_link(node);
ir_graph *irg;
......@@ -245,7 +249,7 @@ static ir_node *lower_node(ir_node *node)
} else {
/* synthesize the 0/1 value */
synth_zero_one:
res = config->create_set(node);
res = create_cond_set(node, mode);
}
break;
}
......@@ -319,12 +323,12 @@ static void collect_needs_lowering(ir_node *node, void *env)
}
}
void ir_lower_mode_b(ir_graph *irg, const lower_mode_b_config_t *nconfig)
void ir_lower_mode_b(ir_graph *const irg, ir_mode *const nlowered_mode)
{
size_t i;
size_t n;
config = nconfig;
lowered_mode = nlowered_mode;
/* edges are used by part_block_edges in the ir_create_cond_set variant. */
edges_assure(irg);
......
......@@ -37,28 +37,6 @@
#include "firm_types.h"
/**
* Function which creates a "set" instraction. A "set" instruction takes a
* condition value (a value with mode_b) as input and produces a value in a
* general purpose integer mode.
* Most architectures have special intrinsics for this. But if all else fails
* you can just produces the an if-like construct.
*/
typedef ir_node* (*create_set_func)(ir_node *cond);
/**
* implementation of create_set_func which produces a cond with control
* flow
*/
ir_node *ir_create_cond_set(ir_node *cond, ir_mode *dest_mode);
typedef struct lower_mode_b_config_t {
/* mode that is used to transport 0/1 values */
ir_mode *lowered_mode;
/* callback for creating set-like instructions */
create_set_func create_set;
} lower_mode_b_config_t;
/**
* Lowers mode_b operations to integer arithmetic. After the lowering the only
* operations with mode_b are the Projs of Cmps; the only nodes with mode_b
......@@ -66,9 +44,9 @@ typedef struct lower_mode_b_config_t {
*
* Example: Psi(a < 0, 1, 0) => a >> 31
*
* @param irg the firm graph to lower
* @param config configuration for mode_b lowerer
* @param irg the firm graph to lower
* @param lowered_mode mode that is used to transport 0/1 values
*/
void ir_lower_mode_b(ir_graph *irg, const lower_mode_b_config_t *config);
void ir_lower_mode_b(ir_graph *irg, ir_mode *lowered_mode);
#endif
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