Commit 8914c163 authored by Matthias Braun's avatar Matthias Braun
Browse files

avoid special case of a node input being NULL

parent c86cca50
......@@ -778,6 +778,7 @@ ir_node *new_r_Anchor(ir_graph *irg)
{
ir_node *in[anchor_last];
ir_node *res;
size_t i;
memset(in, 0, sizeof(in));
res = new_ir_node(NULL, irg, NULL, op_Anchor, mode_ANY, anchor_last, in);
res->attr.anchor.irg.irg = irg;
......@@ -786,6 +787,11 @@ ir_node *new_r_Anchor(ir_graph *irg)
* get_Block_irg for anchor */
res->in[0] = res;
/* we can't have NULL inputs so reference ourselfes for now */
for (i = 0; i < (size_t)anchor_last; ++i) {
set_irn_n(res, i, res);
}
return res;
}
......
......@@ -112,10 +112,17 @@ static ir_node *get_block_n(const ir_node *block, int pos)
return NULL;
}
static ir_node *get_irn_safe_n(const ir_node *node, int n)
{
if (n == -1 && is_Block(node))
return NULL;
return get_irn_n(node, n);
}
static const ir_edge_kind_info_t edge_kind_info[EDGE_KIND_LAST] = {
{ "normal" , set_irn_n, -1, get_irn_arity, get_irn_n },
{ "block succs", NULL, 0, get_irn_arity, get_block_n },
{ "dependency", set_irn_dep, 0, get_irn_deps, get_irn_dep }
{ "normal" , set_irn_n, -1, get_irn_arity, get_irn_safe_n },
{ "block succs", NULL, 0, get_irn_arity, get_block_n },
{ "dependency", set_irn_dep, 0, get_irn_deps, get_irn_dep }
};
#define foreach_tgt(irn, i, n, kind) for (i = edge_kind_info[kind].first_idx, n = edge_kind_info[kind].get_arity(irn); i < n; ++i)
......
......@@ -148,11 +148,6 @@ static inline ir_node *_get_irn_n(const ir_node *node, int n)
assert(-1 <= n && n < _get_irn_arity(node));
nn = node->in[n + 1];
if (nn == NULL) {
/* only block and Anchor inputs are allowed to be NULL */
assert((is_Anchor(node) || n == -1) && "NULL input of a node");
return NULL;
}
if (nn->op != op_Id) return nn;
return (node->in[n + 1] = skip_Id(nn));
......
Supports Markdown
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