#include <string.h>
+#include "error.h"
#include "irop_t.h"
#include "irnode_t.h"
#include "irhooks.h"
for (i = 0; i < n; ++i) {
ir_op *op = ir_get_opcode(i);
- if (op != NULL)
- op->ops.generic = (op_func)NULL;
+ if (op == NULL)
+ continue;
+ op->ops.generic = (op_func)NULL;
+ op->ops.generic1 = (op_func)NULL;
+ op->ops.generic2 = (op_func)NULL;
}
}
set_generic_function_ptr_(op, func);
}
-const ir_op_ops *(get_op_ops)(const ir_op *op)
+ir_op_ops *(get_op_ops)(ir_op *op)
{
return get_op_ops_(op);
}
(void) b;
/* do not CSE Phi-nodes without any inputs when building new graphs */
if (get_irn_arity(a) == 0 &&
- get_irg_phase_state(get_irn_irg(a)) == phase_building) {
+ irg_is_constrained(get_irn_irg(a), IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
return 1;
}
return 0;
}
-/** Compares the attributes of two Conv nodes. */
-static int node_cmp_attr_Conv(const ir_node *a, const ir_node *b)
-{
- return get_Conv_strict(a) != get_Conv_strict(b);
-}
-
/** Compares the attributes of two Cast nodes. */
static int node_cmp_attr_Cast(const ir_node *a, const ir_node *b)
{
/** Compares the attributes of two ASM nodes. */
static int node_cmp_attr_ASM(const ir_node *a, const ir_node *b)
{
- size_t n;
- size_t i;
- const ir_asm_constraint *ca;
- const ir_asm_constraint *cb;
- ident **cla, **clb;
-
if (get_ASM_text(a) != get_ASM_text(b))
return 1;
- /* Should we really check the constraints here? Should be better, but is strange. */
- n = get_ASM_n_input_constraints(a);
- if (n != get_ASM_n_input_constraints(b))
+ int n_inputs = get_ASM_n_inputs(a);
+ if (n_inputs != get_ASM_n_inputs(b))
return 1;
- ca = get_ASM_input_constraints(a);
- cb = get_ASM_input_constraints(b);
- for (i = 0; i < n; ++i) {
- if (ca[i].pos != cb[i].pos || ca[i].constraint != cb[i].constraint
- || ca[i].mode != cb[i].mode)
+ const ir_asm_constraint *in_a = get_ASM_input_constraints(a);
+ const ir_asm_constraint *in_b = get_ASM_input_constraints(b);
+ for (int i = 0; i < n_inputs; ++i) {
+ if (in_a[i].pos != in_b[i].pos
+ || in_a[i].constraint != in_b[i].constraint
+ || in_a[i].mode != in_b[i].mode)
return 1;
}
- n = get_ASM_n_output_constraints(a);
- if (n != get_ASM_n_output_constraints(b))
+ size_t n_outputs = get_ASM_n_output_constraints(a);
+ if (n_outputs != get_ASM_n_output_constraints(b))
return 1;
- ca = get_ASM_output_constraints(a);
- cb = get_ASM_output_constraints(b);
- for (i = 0; i < n; ++i) {
- if (ca[i].pos != cb[i].pos || ca[i].constraint != cb[i].constraint
- || ca[i].mode != cb[i].mode)
+ const ir_asm_constraint *out_a = get_ASM_output_constraints(a);
+ const ir_asm_constraint *out_b = get_ASM_output_constraints(b);
+ for (size_t i = 0; i < n_outputs; ++i) {
+ if (out_a[i].pos != out_b[i].pos
+ || out_a[i].constraint != out_b[i].constraint
+ || out_a[i].mode != out_b[i].mode)
return 1;
}
- n = get_ASM_n_clobbers(a);
- if (n != get_ASM_n_clobbers(b))
+ size_t n_clobbers = get_ASM_n_clobbers(a);
+ if (n_clobbers != get_ASM_n_clobbers(b))
return 1;
- cla = get_ASM_clobbers(a);
- clb = get_ASM_clobbers(b);
- for (i = 0; i < n; ++i) {
+ ident **cla = get_ASM_clobbers(a);
+ ident **clb = get_ASM_clobbers(b);
+ for (size_t i = 0; i < n_clobbers; ++i) {
if (cla[i] != clb[i])
return 1;
}
static void default_copy_attr(ir_graph *irg, const ir_node *old_node,
ir_node *new_node)
{
- unsigned size = firm_add_node_size;
(void) irg;
assert(get_irn_op(old_node) == get_irn_op(new_node));
memcpy(&new_node->attr, &old_node->attr, get_op_attr_size(get_irn_op(old_node)));
-
- if (size > 0) {
- /* copy additional node data */
- memcpy(get_irn_data(new_node, void, size), get_irn_data(old_node, void, size), size);
- }
}
/**
default_copy_attr(irg, old_node, new_node);
new_node->attr.block.irg.irg = irg;
new_node->attr.block.phis = NULL;
- new_node->attr.block.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
+ new_node->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), get_irn_arity(new_node));
new_node->attr.block.block_visited = 0;
memset(&new_node->attr.block.dom, 0, sizeof(new_node->attr.block.dom));
memset(&new_node->attr.block.pdom, 0, sizeof(new_node->attr.block.pdom));
* This is at least what we need for DCE to work. */
new_node->attr.block.entity = old_node->attr.block.entity;
new_node->attr.block.phis = NULL;
- INIT_LIST_HEAD(&new_node->attr.block.succ_head);
}
/**
{
default_copy_attr(irg, old_node, new_node);
new_node->attr.phi.next = NULL;
- new_node->attr.phi.u.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
+ new_node->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), get_irn_arity(new_node));
}
/**
ir_node *new_node)
{
default_copy_attr(irg, old_node, new_node);
- new_node->attr.assem.input_constraints = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.input_constraints);
- new_node->attr.assem.output_constraints = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.output_constraints);
- new_node->attr.assem.clobbers = DUP_ARR_D(ident*, irg->obst, old_node->attr.assem.clobbers);
+ struct obstack *const obst = get_irg_obstack(irg);
+ new_node->attr.assem.input_constraints = DUP_ARR_D(ir_asm_constraint, obst, old_node->attr.assem.input_constraints);
+ new_node->attr.assem.output_constraints = DUP_ARR_D(ir_asm_constraint, obst, old_node->attr.assem.output_constraints);
+ new_node->attr.assem.clobbers = DUP_ARR_D(ident*, obst, old_node->attr.assem.clobbers);
}
static void switch_copy_attr(ir_graph *irg, const ir_node *old_node,
register_node_cmp_func(op_Cmp, node_cmp_attr_Cmp);
register_node_cmp_func(op_Confirm, node_cmp_attr_Confirm);
register_node_cmp_func(op_Const, node_cmp_attr_Const);
- register_node_cmp_func(op_Conv, node_cmp_attr_Conv);
register_node_cmp_func(op_CopyB, node_cmp_attr_CopyB);
register_node_cmp_func(op_Div, node_cmp_attr_Div);
register_node_cmp_func(op_Dummy, node_cmp_attr_Dummy);
register_node_cmp_func(op_Mod, node_cmp_attr_Mod);
register_node_cmp_func(op_Phi, node_cmp_attr_Phi);
register_node_cmp_func(op_Proj, node_cmp_attr_Proj);
- register_node_cmp_func(op_Div, node_cmp_attr_Div);
- register_node_cmp_func(op_Dummy, node_cmp_attr_Dummy);
- register_node_cmp_func(op_Free, node_cmp_attr_Free);
- register_node_cmp_func(op_InstOf, node_cmp_attr_InstOf);
- register_node_cmp_func(op_Load, node_cmp_attr_Load);
- register_node_cmp_func(op_Mod, node_cmp_attr_Mod);
- register_node_cmp_func(op_Phi, node_cmp_attr_Phi);
- register_node_cmp_func(op_Proj, node_cmp_attr_Proj);
register_node_cmp_func(op_Sel, node_cmp_attr_Sel);
register_node_cmp_func(op_Store, node_cmp_attr_Store);
register_node_cmp_func(op_SymConst, node_cmp_attr_SymConst);