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

give Bad nodes a mode

parent b486451c
......@@ -924,12 +924,6 @@
* SPECIAL OPERATIONS
* ------------------
*
* ir_node *new_Bad (void)
* -----------------------
*
* Returns the unique Bad node current_ir_graph->bad.
* This node is used to express results of dead code elimination.
*
* ir_node *new_NoMem (void)
* -----------------------------------------------------------------------------------
*
......
......@@ -81,9 +81,6 @@
*
* - proj_args The proj nodes of the args node.
*
* - bad The Bad node is an auxiliary node. It is needed only once,
* so there is this globally reachable node.
*
* - no_mem The NoMem node is an auxiliary node. It is needed only once,
* so there is this globally reachable node.
*
......@@ -237,11 +234,7 @@ FIRM_API ir_node *get_irg_args(const ir_graph *irg);
/** Sets the node that represents the argument pointer of the given IR graph. */
FIRM_API void set_irg_args(ir_graph *irg, ir_node *node);
/** Returns the Bad node of the given IR graph. Use new_Bad() instead!! */
FIRM_API ir_node *get_irg_bad(const ir_graph *irg);
FIRM_API void set_irg_bad(ir_graph *irg, ir_node *node);
/** Returns the NoMem node of the given IR graph. Use new_NoMem() instead!! */
/** Returns the NoMem node of the given IR graph. */
FIRM_API ir_node *get_irg_no_mem(const ir_graph *irg);
FIRM_API void set_irg_no_mem(ir_graph *irg, ir_node *node);
......
......@@ -53,7 +53,7 @@ ir_node *get_Block_idom(const ir_node *bl)
if (get_Block_dom_depth(bl) == -1) {
/* This block is not reachable from Start */
ir_graph *irg = get_irn_irg(bl);
return new_r_Bad(irg);
return new_r_Bad(irg, mode_BB);
}
return get_dom_info(bl)->idom;
}
......@@ -85,7 +85,7 @@ ir_node *get_Block_ipostdom(const ir_node *bl)
if (get_Block_postdom_depth(bl) == -1) {
/* This block is not reachable from Start */
ir_graph *irg = get_irn_irg(bl);
return new_r_Bad(irg);
return new_r_Bad(irg, mode_BB);
}
return get_pdom_info(bl)->idom;
}
......
......@@ -116,7 +116,7 @@ int get_Block_n_cfg_outs(const ir_node *bl)
#endif /* defined DEBUG_libfirm */
for (i = 1; i <= bl->out[0].pos; ++i) {
ir_node *succ = bl->out[i].use;
if (get_irn_mode(succ) == mode_X && !is_End(succ))
if (get_irn_mode(succ) == mode_X && !is_End(succ) && !is_Bad(succ))
n_cfg_outs += succ->out[0].pos;
}
return n_cfg_outs;
......@@ -133,7 +133,8 @@ int get_Block_n_cfg_outs_ka(const ir_node *bl)
for (i = 1; i <= bl->out[0].pos; ++i) {
ir_node *succ = bl->out[i].use;
if (get_irn_mode(succ) == mode_X) {
if (is_Bad(succ))
continue;
if (is_End(succ)) {
/* ignore End if we are in the Endblock */
if (get_nodes_block(succ) == bl)
......@@ -157,7 +158,7 @@ ir_node *get_Block_cfg_out(const ir_node *bl, int pos)
#endif /* defined DEBUG_libfirm */
for (i = 1; i <= bl->out[0].pos; ++i) {
ir_node *succ = bl->out[i].use;
if (get_irn_mode(succ) == mode_X && !is_End(succ)) {
if (get_irn_mode(succ) == mode_X && !is_End(succ) && !is_Bad(succ)) {
int n_outs = succ->out[0].pos;
if (pos < n_outs)
return succ->out[pos + 1].use;
......@@ -179,6 +180,8 @@ ir_node *get_Block_cfg_out_ka(const ir_node *bl, int pos)
for (i = 1; i <= bl->out[0].pos; ++i) {
ir_node *succ = bl->out[i].use;
if (get_irn_mode(succ) == mode_X) {
if (is_Bad(succ))
continue;
if (is_End(succ)) {
ir_node *end_bl = get_nodes_block(succ);
if (end_bl == bl) {
......
......@@ -619,8 +619,10 @@ static ir_node *find_tail(ir_node *n)
/* It's a completely bad loop: without Phi/Block nodes that can
be a head. I.e., the code is "dying". We break the loop by
setting Bad nodes. */
int arity = get_irn_arity(n);
ir_node *bad = get_irg_bad(get_irn_irg(n));
ir_graph *irg = get_irn_irg(n);
ir_mode *mode = get_irn_mode(n);
ir_node *bad = new_r_Bad(irg, mode);
int arity = get_irn_arity(n);
for (i = -1; i < arity; ++i) {
set_irn_n(n, i, bad);
}
......
......@@ -1429,7 +1429,7 @@ static ir_node *gen_Proj_Start(ir_node *node)
case pn_Start_T_args:
/* we should never need this explicitely */
return new_r_Bad(get_irn_irg(node));
break;
case pn_Start_P_frame_base:
return be_prolog_get_reg_value(abihelper, sp_reg);
......
......@@ -1556,7 +1556,7 @@ static void fix_start_block(ir_graph *irg)
assert(is_Proj(initial_X));
exchange(initial_X, jmp);
set_irg_initial_exec(irg, new_r_Bad(irg));
set_irg_initial_exec(irg, new_r_Bad(irg, mode_X));
}
/**
......@@ -1893,7 +1893,7 @@ static void modify_irg(ir_graph *irg)
/* the arg proj is not needed anymore now and should be only used by the anchor */
assert(get_irn_n_edges(arg_tuple) == 1);
kill_node(arg_tuple);
set_irg_args(irg, new_r_Bad(irg));
set_irg_args(irg, new_r_Bad(irg, mode_T));
/* All Return nodes hang on the End node, so look for them there. */
end = get_irg_end_block(irg);
......
......@@ -217,9 +217,10 @@ static void memory_operand_walker(ir_node *irn, void *env)
/* kill the Reload */
if (get_irn_n_edges(irn) == 0) {
ir_graph *irg = get_irn_irg(irn);
ir_mode *frame_mode = get_irn_mode(get_irn_n(irn, n_be_Reload_frame));
sched_remove(irn);
set_irn_n(irn, n_be_Reload_mem, new_r_Bad(irg));
set_irn_n(irn, n_be_Reload_frame, new_r_Bad(irg));
set_irn_n(irn, n_be_Reload_mem, new_r_Bad(irg, mode_X));
set_irn_n(irn, n_be_Reload_frame, new_r_Bad(irg, frame_mode));
}
}
......
......@@ -227,7 +227,7 @@ static void remove_empty_block(ir_node *block)
panic("Unexpected node %+F in block %+F with empty schedule", node, block);
}
set_Block_cfgpred(block, 0, new_r_Bad(irg));
set_Block_cfgpred(block, 0, new_r_Bad(irg, mode_X));
kill_node(jump);
blocks_removed = 1;
......
......@@ -350,7 +350,6 @@ static void transform_nodes(ir_graph *irg, arch_pretrans_nodes *pre_transform)
/* pre transform some anchors (so they are available in the other transform
* functions) */
pre_transform_anchor(irg, anchor_bad);
pre_transform_anchor(irg, anchor_no_mem);
pre_transform_anchor(irg, anchor_end_block);
pre_transform_anchor(irg, anchor_end);
......
......@@ -1022,7 +1022,7 @@ static void transform_MemPerm(ir_node *node)
sp = create_spproj(node, push, pn_ia32_Push_stack);
}
set_irn_n(node, i, new_r_Bad(irg));
set_irn_n(node, i, new_r_Bad(irg, mode_X));
}
/* create pops */
......@@ -1068,11 +1068,8 @@ static void transform_MemPerm(ir_node *node)
}
/* remove memperm */
arity = get_irn_arity(node);
for (i = 0; i < arity; ++i) {
set_irn_n(node, i, new_r_Bad(irg));
}
sched_remove(node);
kill_node(node);
}
/**
......
......@@ -101,7 +101,6 @@ static void reroute_result(ir_node *proj, ir_node *l_res, ir_node *h_res)
static void resolve_call(ir_node *call, ir_node *l_res, ir_node *h_res, ir_graph *irg, ir_node *block)
{
ir_node *jmp, *res, *in[2];
ir_node *bad = get_irg_bad(irg);
ir_node *nomem = get_irg_no_mem(irg);
int old_cse;
......@@ -130,7 +129,7 @@ static void resolve_call(ir_node *call, ir_node *l_res, ir_node *h_res, ir_graph
case pn_Call_X_except:
/* should not happen here */
edges_reroute(proj, bad);
edges_reroute(proj, new_r_Bad(irg, mode_X));
break;
case pn_Call_M:
/* should not happen here */
......@@ -168,10 +167,10 @@ static void resolve_call(ir_node *call, ir_node *l_res, ir_node *h_res, ir_graph
jmp = new_r_Jmp(block);
set_opt_cse(old_cse);
set_Tuple_pred(call, pn_Call_M, nomem);
set_Tuple_pred(call, pn_Call_X_regular, jmp);
set_Tuple_pred(call, pn_Call_X_except, bad);
set_Tuple_pred(call, pn_Call_T_result, res);
set_Tuple_pred(call, pn_Call_M, nomem);
set_Tuple_pred(call, pn_Call_X_regular, jmp);
set_Tuple_pred(call, pn_Call_X_except, new_r_Bad(irg, mode_X));
set_Tuple_pred(call, pn_Call_T_result, res);
}
}
......
......@@ -1848,8 +1848,7 @@ static ir_node *gen_Proj_Start(ir_node *node)
case pn_Start_M:
return be_prolog_get_memory(abihelper);
case pn_Start_T_args:
/* we should never need this explicitely */
return new_r_Bad(get_irn_irg(block));
break;
case pn_Start_P_frame_base:
return get_frame_base();
case pn_Start_max:
......
......@@ -58,9 +58,7 @@ void copy_irn_to_irg(ir_node *n, ir_graph *irg)
ir_node *nn = NULL;
/* do not copy standard nodes */
if (op == op_Bad)
nn = get_irg_bad(irg);
else if (op == op_NoMem)
if (op == op_NoMem)
n = get_irg_no_mem(irg);
else if (op == op_Block) {
old_irg = get_irn_irg(n);
......
......@@ -243,7 +243,7 @@ static ir_node *set_phi_arguments(ir_node *phi, int pos)
ir_node *cfgpred = get_Block_cfgpred_block(block, i);
ir_node *value;
if (is_Bad(cfgpred)) {
value = new_r_Bad(irg);
value = new_r_Bad(irg, mode);
} else {
inc_irg_visited(irg);
......@@ -287,7 +287,7 @@ static ir_node *get_r_value_internal(ir_node *block, int pos, ir_mode *mode)
/* We ran into a cycle. This may happen in unreachable loops. */
if (irn_visited_else_mark(block)) {
/* Since the loop is unreachable, return a Bad. */
return new_r_Bad(irg);
return new_r_Bad(irg, mode);
}
/* in a matured block we can immediately determine the phi arguments */
......@@ -306,11 +306,12 @@ static ir_node *get_r_value_internal(ir_node *block, int pos, ir_mode *mode)
}
/* one predecessor just use its value */
} else if (arity == 1) {
ir_node *cfgpred = get_Block_cfgpred_block(block, 0);
ir_node *cfgpred = get_Block_cfgpred(block, 0);
if (is_Bad(cfgpred)) {
res = cfgpred;
res = new_r_Bad(irg, mode);
} else {
res = get_r_value_internal(cfgpred, pos, mode);
ir_node *cfgpred_block = get_nodes_block(cfgpred);
res = get_r_value_internal(cfgpred_block, pos, mode);
}
/* multiple predecessors construct Phi */
} else {
......
......@@ -2402,7 +2402,7 @@ void dump_cfg(FILE *F, ir_graph *irg)
/* walk over the blocks in the graph */
irg_block_walk(get_irg_end(irg), dump_block_to_cfg, NULL, F);
dump_node(F, get_irg_bad(irg));
/* dump_node(F, get_irg_bad(irg)); */
dump_vcg_footer(F);
}
......
......@@ -47,11 +47,12 @@ void turn_into_tuple(ir_node *node, int arity)
{
ir_graph *irg = get_irn_irg(node);
ir_node **in = ALLOCAN(ir_node*, arity);
ir_node *bad = new_r_Bad(irg, mode_ANY);
int i;
/* construct a new in array, with every input being bad */
for (i = 0; i < arity; ++i) {
in[i] = new_r_Bad(irg);
in[i] = bad;
}
set_irn_in(node, arity, in);
set_irn_op(node, op_Tuple);
......@@ -284,11 +285,10 @@ ir_node *part_block_edges(ir_node *node)
void kill_node(ir_node *node)
{
ir_graph *irg = get_irn_irg(node);
ir_node *bad = get_irg_bad(irg);
int i;
for (i = get_irn_arity(node) - 1; i >= -1; --i) {
set_irn_n(node, i, bad);
if (edges_activated(irg)) {
edges_node_deleted(node);
}
exchange(node, bad);
/* noone is allowed to reference this node anymore */
set_irn_op(node, op_Deleted);
}
......@@ -137,7 +137,7 @@ static void kill_dead_blocks(ir_node *block, void *env)
*/
ir_graph *irg = get_irn_irg(block);
enqueue_users(block, waitq);
exchange(block, get_irg_bad(irg));
exchange(block, new_r_Bad(irg, mode_BB));
}
}
......
......@@ -216,7 +216,6 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
start_block = new_r_Block_noopt(res, 0, NULL);
set_irg_start_block(res, start_block);
set_irg_bad (res, new_r_Bad(res));
set_irg_no_mem (res, new_r_NoMem(res));
start = new_r_Start(res);
set_irg_start (res, start);
......@@ -260,7 +259,6 @@ ir_graph *new_ir_graph(ir_entity *ent, int n_loc)
ir_graph *new_const_code_irg(void)
{
ir_graph *res = alloc_graph();
ir_node *bad;
ir_node *body_block;
ir_node *end;
ir_node *end_block;
......@@ -303,8 +301,6 @@ ir_graph *new_const_code_irg(void)
/* -- The start block -- */
start_block = new_r_Block_noopt(res, 0, NULL);
set_irg_start_block(res, start_block);
bad = new_r_Bad(res);
set_irg_bad(res, bad);
no_mem = new_r_NoMem(res);
set_irg_no_mem(res, no_mem);
start = new_r_Start(res);
......@@ -323,7 +319,6 @@ ir_graph *new_const_code_irg(void)
set_Block_block_visited(body_block, -1);
set_Block_block_visited(start_block, -1);
set_irn_visited(start_block, -1);
set_irn_visited(bad, -1);
set_irn_visited(no_mem, -1);
return res;
......@@ -420,7 +415,6 @@ ir_graph *create_irg_copy(ir_graph *irg)
/* -- The start block -- */
set_irg_start_block(res, get_new_node(get_irg_start_block(irg)));
set_irg_bad (res, get_new_node(get_irg_bad(irg)));
set_irg_no_mem (res, get_new_node(get_irg_no_mem(irg)));
set_irg_start (res, get_new_node(get_irg_start(irg)));
......@@ -582,16 +576,6 @@ void (set_irg_args)(ir_graph *irg, ir_node *node)
_set_irg_args(irg, node);
}
ir_node *(get_irg_bad)(const ir_graph *irg)
{
return _get_irg_bad(irg);
}
void (set_irg_bad)(ir_graph *irg, ir_node *node)
{
_set_irg_bad(irg, node);
}
ir_node *(get_irg_no_mem)(const ir_graph *irg)
{
return _get_irg_no_mem(irg);
......
......@@ -186,16 +186,6 @@ static inline void _set_irg_args(ir_graph *irg, ir_node *node)
set_irn_n(irg->anchor, anchor_args, node);
}
static inline ir_node *_get_irg_bad(const ir_graph *irg)
{
return get_irn_n(irg->anchor, anchor_bad);
}
static inline void _set_irg_bad(ir_graph *irg, ir_node *node)
{
set_irn_n(irg->anchor, anchor_bad, node);
}
static inline ir_node * _get_irg_no_mem(const ir_graph *irg)
{
return get_irn_n(irg->anchor, anchor_no_mem);
......@@ -425,7 +415,8 @@ static inline int _is_irg_state(const ir_graph *irg, ir_graph_state_t state)
* @param irn The node.
* @return The index allocated for the node.
*/
static inline unsigned irg_register_node_idx(ir_graph *irg, ir_node *irn) {
static inline unsigned irg_register_node_idx(ir_graph *irg, ir_node *irn)
{
unsigned idx = irg->last_node_idx++;
if (idx >= (unsigned)ARR_LEN(irg->idx_irn_map))
ARR_RESIZE(ir_node *, irg->idx_irn_map, idx + 1);
......@@ -530,8 +521,6 @@ static inline ir_phase *irg_get_phase(const ir_graph *irg, ir_phase_id id)
#define set_irg_initial_mem(irg, node) _set_irg_initial_mem(irg, node)
#define get_irg_args(irg) _get_irg_args(irg)
#define set_irg_args(irg, node) _set_irg_args(irg, node)
#define get_irg_bad(irg) _get_irg_bad(irg)
#define set_irg_bad(irg, node) _set_irg_bad(irg, node)
#define get_irg_no_mem(irg) _get_irg_no_mem(irg)
#define set_irn_no_mem(irg, node) _set_irn_no_mem(irg, node)
#define get_irg_entity(irg) _get_irg_entity(irg)
......
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