Commit 9a1ec0a9 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove oparity_{unary|trinary|zero}

They weren't used in a sensible way and their semantic for
non-arithmetic ops was unclear.
Also implicitely fixes a bunch of bugs where these where set but no op_index
was set at the same time.
parent e6203174
......@@ -427,15 +427,6 @@ FIRM_API void remove_Call_callee_arr(ir_node *node);
/** Returns a human readable string for the ir_builtin_kind. */
FIRM_API const char *get_builtin_kind_name(ir_builtin_kind kind);
/** Tests whether node is an unary operation (opcode arity is #oparity_unary)
* @returns 1 if @p node is an unary operation, 0 otherwise
*/
FIRM_API int is_unop(const ir_node *node);
/** Returns (arithmetic) operand of unary operation @p node. */
FIRM_API ir_node *get_unop_op(const ir_node *node);
/** Sets (arithmetic) operand of unary operation @p node. */
FIRM_API void set_unop_op(ir_node *node, ir_node *op);
/** Tests whether node is a binary operation (opcode arity is #oparity_binary)
* @returns 1 if @p node is an binary operation, 0 otherwise
*/
......
......@@ -32,10 +32,7 @@
/** The allowed arities. */
typedef enum {
oparity_invalid = 0,
oparity_unary, /**< An unary operator -- considering 'numeric' arguments. */
oparity_binary, /**< A binary operator -- considering 'numeric' arguments.*/
oparity_trinary, /**< A trinary operator -- considering 'numeric' arguments.*/
oparity_zero, /**< A zero arity operator, e.g. a Const. */
oparity_variable, /**< The arity is not fixed by opcode, but statically
known. E.g., number of arguments to call. */
oparity_dynamic, /**< The arity depends on state of Firm representation.
......
......@@ -362,9 +362,10 @@ static unsigned calc_method_param_weight(ir_node *arg)
weight += calc_method_param_weight(succ);
} else
weight += binop_weight;
} else if (is_unop(succ)) {
} else if (get_irn_arity(succ) == 1) {
/* We have reached a binop and we must increase the
weight with the const_binop_weight and call the function recursive.*/
weight with the const_binop_weight and call the function
recursive.*/
weight += const_binop_weight;
weight += calc_method_param_weight(succ);
}
......
......@@ -1259,22 +1259,22 @@ void be_init_op(void)
assert(op_be_Spill == NULL);
/* Acquire all needed opcodes. */
op_be_Spill = new_be_op(beo_Spill, "be_Spill", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_frame_attr_t));
op_be_Reload = new_be_op(beo_Reload, "be_Reload", op_pin_state_exc_pinned, irop_flag_none, oparity_zero, sizeof(be_frame_attr_t));
op_be_Spill = new_be_op(beo_Spill, "be_Spill", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_frame_attr_t));
op_be_Reload = new_be_op(beo_Reload, "be_Reload", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_frame_attr_t));
op_be_Perm = new_be_op(beo_Perm, "be_Perm", op_pin_state_exc_pinned, irop_flag_none, oparity_variable, sizeof(be_node_attr_t));
op_be_MemPerm = new_be_op(beo_MemPerm, "be_MemPerm", op_pin_state_exc_pinned, irop_flag_none, oparity_variable, sizeof(be_memperm_attr_t));
op_be_Copy = new_be_op(beo_Copy, "be_Copy", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_node_attr_t));
op_be_Copy = new_be_op(beo_Copy, "be_Copy", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_Keep = new_be_op(beo_Keep, "be_Keep", op_pin_state_exc_pinned, irop_flag_keep, oparity_dynamic, sizeof(be_node_attr_t));
op_be_CopyKeep = new_be_op(beo_CopyKeep, "be_CopyKeep", op_pin_state_exc_pinned, irop_flag_keep, oparity_variable, sizeof(be_node_attr_t));
op_be_Call = new_be_op(beo_Call, "be_Call", op_pin_state_exc_pinned, irop_flag_fragile|irop_flag_uses_memory, oparity_variable, sizeof(be_call_attr_t));
ir_op_set_memory_index(op_be_Call, n_be_Call_mem);
ir_op_set_fragile_indices(op_be_Call, pn_be_Call_X_regular, pn_be_Call_X_except);
op_be_Return = new_be_op(beo_Return, "be_Return", op_pin_state_exc_pinned, irop_flag_cfopcode, oparity_variable, sizeof(be_return_attr_t));
op_be_AddSP = new_be_op(beo_AddSP, "be_AddSP", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_node_attr_t));
op_be_SubSP = new_be_op(beo_SubSP, "be_SubSP", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_node_attr_t));
op_be_IncSP = new_be_op(beo_IncSP, "be_IncSP", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_incsp_attr_t));
op_be_Start = new_be_op(beo_Start, "be_Start", op_pin_state_exc_pinned, irop_flag_none, oparity_zero, sizeof(be_start_attr_t));
op_be_FrameAddr = new_be_op(beo_FrameAddr, "be_FrameAddr", op_pin_state_exc_pinned, irop_flag_none, oparity_unary, sizeof(be_frame_attr_t));
op_be_AddSP = new_be_op(beo_AddSP, "be_AddSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_SubSP = new_be_op(beo_SubSP, "be_SubSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_node_attr_t));
op_be_IncSP = new_be_op(beo_IncSP, "be_IncSP", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_incsp_attr_t));
op_be_Start = new_be_op(beo_Start, "be_Start", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_start_attr_t));
op_be_FrameAddr = new_be_op(beo_FrameAddr, "be_FrameAddr", op_pin_state_exc_pinned, irop_flag_none, oparity_any, sizeof(be_frame_attr_t));
op_be_Spill->ops.node_cmp_attr = FrameAddr_cmp_attr;
op_be_Reload->ops.node_cmp_attr = FrameAddr_cmp_attr;
......
......@@ -4124,9 +4124,8 @@ static ir_node *gen_ia32_l_Adc(ir_node *node)
*/
static ir_node *gen_ia32_l_Mul(ir_node *node)
{
ir_node *left = get_binop_left(node);
ir_node *right = get_binop_right(node);
ir_node *left = get_irn_n(node, n_ia32_l_Mul_left);
ir_node *right = get_irn_n(node, n_ia32_l_Mul_right);
return gen_binop(node, left, right, new_bd_ia32_Mul,
match_commutative | match_am | match_mode_neutral);
}
......@@ -4138,9 +4137,8 @@ static ir_node *gen_ia32_l_Mul(ir_node *node)
*/
static ir_node *gen_ia32_l_IMul(ir_node *node)
{
ir_node *left = get_binop_left(node);
ir_node *right = get_binop_right(node);
ir_node *left = get_irn_n(node, n_ia32_l_IMul_left);
ir_node *right = get_irn_n(node, n_ia32_l_IMul_right);
return gen_binop(node, left, right, new_bd_ia32_IMul1OP,
match_commutative | match_am | match_mode_neutral);
}
......
......@@ -648,7 +648,7 @@ EOF
$n_opcodes++;
$temp = "\top = new_ir_op(cur_opcode + iro_$op, \"$op\", op_pin_state_".$n{"state"}.", $op_flags";
$temp .= ", ".translate_arity($arity).", 0, ${attr_size});\n";
$temp .= ", ".translate_arity($arity).", -1, ${attr_size});\n";
$obst_new_irop .= $temp;
$obst_new_irop .= "\top->ops.be_ops = be_ops;\n";
$obst_new_irop .= "\top->ops.dump_node = ${dump_func};\n";
......@@ -827,21 +827,7 @@ sub translate_arity {
my $arity = shift;
if ($arity =~ /^\d+$/) {
if ($arity == 0) {
return "oparity_zero";
}
elsif ($arity == 1) {
return "oparity_unary";
}
elsif ($arity == 2) {
return "oparity_binary";
}
elsif ($arity == 3) {
return "oparity_trinary";
}
else {
return "oparity_any";
}
return "oparity_any";
} elsif ($arity == $ARITY_VARIABLE) {
return "oparity_variable";
} elsif ($arity == $ARITY_DYNAMIC) {
......
......@@ -783,28 +783,6 @@ void remove_Call_callee_arr(ir_node *node)
node->attr.call.callee_arr = NULL;
}
int (is_unop)(const ir_node *node)
{
return is_unop_(node);
}
ir_node *get_unop_op(const ir_node *node)
{
if (node->op->opar == oparity_unary)
return get_irn_n(node, node->op->op_index);
assert(node->op->opar == oparity_unary);
return NULL;
}
void set_unop_op(ir_node *node, ir_node *op)
{
if (node->op->opar == oparity_unary)
set_irn_n(node, node->op->op_index, op);
assert(node->op->opar == oparity_unary);
}
int (is_binop)(const ir_node *node)
{
return is_binop_(node);
......
......@@ -39,7 +39,6 @@
#define get_irn_link(node) get_irn_link_(node)
#define get_irn_pinned(node) get_irn_pinned_(node)
#define is_irn_pinned_in_irg(node) is_irn_pinned_in_irg_(node)
#define is_unop(node) is_unop_(node)
#define is_binop(node) is_binop_(node)
#define is_SymConst_addr_ent(node) is_SymConst_addr_ent_(node)
#define get_Block_n_cfgpreds(node) get_Block_n_cfgpreds_(node)
......@@ -340,12 +339,6 @@ static inline op_pin_state is_irn_pinned_in_irg_(const ir_node *node)
return op_pin_state_pinned;
}
static inline int is_unop_(const ir_node *node)
{
assert(is_ir_node_(node));
return (node->op->opar == oparity_unary);
}
static inline int is_binop_(const ir_node *node)
{
assert(is_ir_node_(node));
......
......@@ -16,9 +16,7 @@ class Unop(object):
ins = [
("op", "operand"),
]
op_index = 0
pinned = "no"
arity_override = "oparity_unary"
pinned = "no"
@abstract
@op
......
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