Commit 753399e3 authored by Matthias Braun's avatar Matthias Braun
Browse files

let Bad and NoMem nodes get automatically generated

[r28116]
parent 2a5aa91c
......@@ -1805,6 +1805,13 @@ FIRM_API ir_node *new_rd_Tuple(dbg_info *db, ir_node *block,
FIRM_API ir_node *new_rd_Id(dbg_info *db, ir_node *block,
ir_node *val, ir_mode *mode);
/** Constructor for a Bad node.
*
* @param *db A pointer for debug information.
* @param *irg The IR graph the node belongs to.
*/
FIRM_API ir_node *new_rd_Bad(dbg_info *db, ir_graph *irg);
/** Constructor for a Confirm node.
*
* Specifies constraints for a value. To support dataflow analyses.
......@@ -1831,6 +1838,13 @@ FIRM_API ir_node *new_rd_Confirm(dbg_info *db, ir_node *block,
*/
FIRM_API ir_node *new_rd_Unknown(dbg_info *db, ir_graph *irg, ir_mode *m);
/** Constructor for a NoMem node.
*
* @param *db A pointer for debug information.
* @param *irg The IR graph the node belongs to.
*/
FIRM_API ir_node *new_rd_NoMem(dbg_info *db, ir_graph *irg);
/** Constructor for a Mux node.
*
* @param *db A pointer for debug information.
......@@ -2496,9 +2510,6 @@ FIRM_API ir_node *new_r_Tuple(ir_node *block, int arity, ir_node *in[]);
FIRM_API ir_node *new_r_Id(ir_node *block, ir_node *val, ir_mode *mode);
/** Constructor for a Bad node.
*
* Returns the unique Bad node of the graph. The same as
* get_irg_bad().
*
* @param *irg The IR graph the node belongs to.
*/
......@@ -2530,9 +2541,6 @@ FIRM_API ir_node *new_r_Confirm(ir_node *block, ir_node *val, ir_node *bound,
FIRM_API ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
/** Constructor for a NoMem node.
*
* Returns the unique NoMem node of the graph. The same as
* get_irg_no_mem().
*
* @param *irg The IR graph the node belongs to.
*/
......@@ -3267,6 +3275,12 @@ FIRM_API ir_node *new_d_Tuple(dbg_info *db, int arity, ir_node *in[]);
*/
FIRM_API ir_node *new_d_Id(dbg_info *db, ir_node *val, ir_mode *mode);
/** Constructor for a Bad node.
*
* @param *db A pointer for debug information.
*/
FIRM_API ir_node *new_d_Bad(dbg_info *db);
/** Constructor for a Confirm node.
*
* Constructor for a Confirm node. Adds the node to the block in current_ir_block.
......@@ -3293,6 +3307,12 @@ FIRM_API ir_node *new_d_Confirm(dbg_info *db, ir_node *val, ir_node *bound,
*/
FIRM_API ir_node *new_d_Unknown(dbg_info *db, ir_mode *m);
/** Constructor for a NoMem node.
*
* @param *db A pointer for debug information.
*/
FIRM_API ir_node *new_d_NoMem(dbg_info *db);
/** Constructor for a Mux node.
*
* @param *db A pointer for debug information.
......@@ -3929,9 +3949,6 @@ FIRM_API ir_node *new_Tuple(int arity, ir_node *in[]);
FIRM_API ir_node *new_Id(ir_node *val, ir_mode *mode);
/** Constructor for a Bad node.
*
* Returns the unique Bad node of the graph. The same as
* get_irg_bad().
*/
FIRM_API ir_node *new_Bad(void);
......@@ -3958,11 +3975,7 @@ FIRM_API ir_node *new_Confirm(ir_node *val, ir_node *bound, pn_Cmp cmp);
*/
FIRM_API ir_node *new_Unknown(ir_mode *m);
/** Constructor for a NoMem node.
*
* Returns the unique NoMem node of the graph. The same as
* get_irg_no_mem().
*/
/** Constructor for a NoMem node. */
FIRM_API ir_node *new_NoMem(void);
/** Constructor for a Mux node.
......
......@@ -206,14 +206,6 @@ ir_node *new_r_defaultProj(ir_node *arg, long max_proj)
{
return new_rd_defaultProj(NULL, arg, max_proj);
}
ir_node *new_r_Bad(ir_graph *irg)
{
return get_irg_bad(irg);
}
ir_node *new_r_NoMem(ir_graph *irg)
{
return get_irg_no_mem(irg);
}
ir_node *new_r_ASM(ir_node *block,
int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs,
......@@ -901,16 +893,6 @@ ir_node *new_defaultProj(ir_node *arg, long max_proj)
{
return new_d_defaultProj(NULL, arg, max_proj);
}
ir_node *new_Bad(void)
{
assert(get_irg_phase_state(current_ir_graph) == phase_building);
return get_irg_bad(current_ir_graph);
}
ir_node *new_NoMem(void)
{
assert(get_irg_phase_state(current_ir_graph) == phase_building);
return get_irg_no_mem(current_ir_graph);
}
ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs,
int n_clobber, ident *clobber[], ident *text)
......@@ -924,10 +906,10 @@ ir_node *new_r_Anchor(ir_graph *irg)
ir_node *res;
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;
/* hack to get get_irn_irg working: set block to ourself and allow
* get_Block_irg for anchor */
res->attr.irg.irg = irg;
res->in[0] = res;
return res;
......
......@@ -985,7 +985,6 @@ ir_graph_pass_t *irg_verify_edges_pass(const char *name, unsigned assert_on_prob
void init_edges(void)
{
FIRM_DBG_REGISTER(dbg, DBG_EDGES);
/* firm_dbg_set_mask(dbg, -1); */
}
void edges_init_dbg(int do_dbg)
......
......@@ -217,10 +217,9 @@ 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);
bad = new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL);
bad->attr.irg.irg = res;
bad = new_r_Bad(res);
set_irg_bad (res, bad);
set_irg_no_mem (res, new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
set_irg_no_mem (res, new_r_NoMem(res));
start = new_r_Start(res);
set_irg_start (res, start);
......@@ -307,10 +306,9 @@ 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_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL);
bad->attr.irg.irg = res;
bad = new_r_Bad(res);
set_irg_bad(res, bad);
no_mem = new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL);
no_mem = new_r_NoMem(res);
set_irg_no_mem(res, no_mem);
start = new_r_Start(res);
set_irg_start(res, start);
......
......@@ -432,9 +432,12 @@ static inline int _is_Block_dead(const ir_node *block)
{
ir_op *op = _get_irn_op(block);
if (op == op_Bad)
/* we can have Bad, Anchor and Block nodes as block input */
if (op == op_Bad) {
return 1;
else {
} else if (op == op_Anchor) {
return 0;
} else {
assert(op == op_Block);
return block->attr.block.is_dead;
}
......
......@@ -2973,7 +2973,7 @@ make_tuple:
turn_into_tuple(n, pn_Div_max);
set_Tuple_pred(n, pn_Div_M, mem);
set_Tuple_pred(n, pn_Div_X_regular, new_r_Jmp(blk));
set_Tuple_pred(n, pn_Div_X_except, new_r_Bad(irg));
set_Tuple_pred(n, pn_Div_X_except, get_irg_bad(irg));
set_Tuple_pred(n, pn_Div_res, value);
}
return n;
......@@ -3065,7 +3065,7 @@ make_tuple:
turn_into_tuple(n, pn_Mod_max);
set_Tuple_pred(n, pn_Mod_M, mem);
set_Tuple_pred(n, pn_Mod_X_regular, new_r_Jmp(blk));
set_Tuple_pred(n, pn_Mod_X_except, new_r_Bad(irg));
set_Tuple_pred(n, pn_Mod_X_except, get_irg_bad(irg));
set_Tuple_pred(n, pn_Mod_res, value);
}
return n;
......@@ -3178,7 +3178,7 @@ make_tuple:
turn_into_tuple(n, pn_DivMod_max);
set_Tuple_pred(n, pn_DivMod_M, mem);
set_Tuple_pred(n, pn_DivMod_X_regular, new_r_Jmp(blk));
set_Tuple_pred(n, pn_DivMod_X_except, new_r_Bad(irg)); /*no exception*/
set_Tuple_pred(n, pn_DivMod_X_except, get_irg_bad(irg)); /*no exception*/
set_Tuple_pred(n, pn_DivMod_res_div, va);
set_Tuple_pred(n, pn_DivMod_res_mod, vb);
}
......@@ -3227,7 +3227,7 @@ static ir_node *transform_node_Quot(ir_node *n)
turn_into_tuple(n, pn_Quot_max);
set_Tuple_pred(n, pn_Quot_M, mem);
set_Tuple_pred(n, pn_Quot_X_regular, new_r_Jmp(blk));
set_Tuple_pred(n, pn_Quot_X_except, new_r_Bad(irg));
set_Tuple_pred(n, pn_Quot_X_except, get_irg_bad(irg));
set_Tuple_pred(n, pn_Quot_res, m);
DBG_OPT_ALGSIM1(oldn, a, b, m, FS_OPT_FP_INV_MUL);
}
......@@ -3289,11 +3289,11 @@ static ir_node *transform_node_Cond(ir_node *n)
jmp = new_r_Jmp(blk);
turn_into_tuple(n, pn_Cond_max);
if (ta == tarval_b_true) {
set_Tuple_pred(n, pn_Cond_false, new_r_Bad(irg));
set_Tuple_pred(n, pn_Cond_false, get_irg_bad(irg));
set_Tuple_pred(n, pn_Cond_true, jmp);
} else {
set_Tuple_pred(n, pn_Cond_false, jmp);
set_Tuple_pred(n, pn_Cond_true, new_r_Bad(irg));
set_Tuple_pred(n, pn_Cond_true, get_irg_bad(irg));
}
/* We might generate an endless loop, so keep it alive. */
add_End_keepalive(get_irg_end(irg), blk);
......@@ -3891,7 +3891,7 @@ static ir_node *transform_node_Proj_Div(ir_node *proj)
ir_graph *irg = get_irn_irg(proj);
/* we found an exception handler, remove it */
DBG_OPT_EXC_REM(proj);
return new_r_Bad(irg);
return get_irg_bad(irg);
}
case pn_Div_M: {
......@@ -3946,7 +3946,7 @@ static ir_node *transform_node_Proj_Mod(ir_node *proj)
ir_graph *irg = get_irn_irg(proj);
/* we found an exception handler, remove it */
DBG_OPT_EXC_REM(proj);
return new_r_Bad(irg);
return get_irg_bad(irg);
}
case pn_Mod_M: {
......@@ -4010,7 +4010,7 @@ static ir_node *transform_node_Proj_DivMod(ir_node *proj)
/* we found an exception handler, remove it */
ir_graph *irg = get_irn_irg(proj);
DBG_OPT_EXC_REM(proj);
return new_r_Bad(irg);
return get_irg_bad(irg);
}
case pn_DivMod_M: {
......@@ -6594,7 +6594,7 @@ static ir_node *gigo(ir_node *node)
if (is_Block(block)) {
if (is_Block_dead(block)) {
/* control flow from dead block is dead */
return new_r_Bad(irg);
return get_irg_bad(irg);
}
for (i = get_irn_arity(block) - 1; i >= 0; --i) {
......@@ -6613,7 +6613,7 @@ static ir_node *gigo(ir_node *node)
* but can be found by irg_walk()!
*/
set_Block_dead(block);
return new_r_Bad(irg);
return get_irg_bad(irg);
}
}
}
......@@ -6621,7 +6621,7 @@ static ir_node *gigo(ir_node *node)
/* Blocks, Phis and Tuples may have dead inputs, e.g., if one of the
blocks predecessors is dead. */
if (op != op_Block && op != op_Phi && op != op_Tuple) {
if (op != op_Block && op != op_Phi && op != op_Tuple && op != op_Anchor) {
ir_graph *irg = get_irn_irg(node);
irn_arity = get_irn_arity(node);
......@@ -6630,13 +6630,13 @@ static ir_node *gigo(ir_node *node)
*/
if (is_irn_pinned_in_irg(node) &&
is_Block_dead(get_nodes_block(skip_Proj(node))))
return new_r_Bad(irg);
return get_irg_bad(irg);
for (i = 0; i < irn_arity; i++) {
ir_node *pred = get_irn_n(node, i);
if (is_Bad(pred))
return new_r_Bad(irg);
return get_irg_bad(irg);
#if 0
/* Propagating Unknowns here seems to be a bad idea, because
sometimes we need a node as a input and did not want that
......@@ -6658,7 +6658,7 @@ static ir_node *gigo(ir_node *node)
for (i = 0; i < irn_arity; i++) {
if (!is_Bad(get_irn_n(node, i))) break;
}
if (i == irn_arity) node = new_r_Bad(irg);
if (i == irn_arity) node = get_irg_bad(irg);
}
#endif
return node;
......
......@@ -135,6 +135,10 @@ typedef struct {
irg_attr irg;
} bad_attr;
typedef struct anchor_attr {
irg_attr irg;
} anchor_attr;
/** Block attributes */
typedef struct {
/* General attributes */
......@@ -305,6 +309,7 @@ typedef struct {
typedef union {
irg_attr irg; /**< For Blocks and Bad: its belonging irg */
bad_attr bad; /**< for Bads: irg reference */
anchor_attr anchor; /**< for Anchor: irg reference */
block_attr block; /**< For Block: Fields needed to construct it */
cond_attr cond; /**< For Cond. */
const_attr con; /**< For Const: contains the value of the constant and a type */
......
......@@ -96,15 +96,15 @@ class ASM(Op):
]
class Bad(Op):
mode = "mode_Bad"
mode = "mode_T"
flags = [ "cfopcode", "start_block", "dump_noblock" ]
pinned = "yes"
knownBlock = True
block = "get_irg_start_block(irg)"
singleton = True
attr_struct = "bad_attr"
noconstructor = True
init = '''
res->attr.irg.irg = irg;
res->attr.bad.irg.irg = irg;
'''
class Deleted(Op):
......@@ -544,8 +544,8 @@ class NoMem(Op):
flags = [ "dump_noblock", "dump_noinput" ]
pinned = "yes"
knownBlock = True
block = "get_irg_start_block(irg)"
singleton = True
noconstructor = True
class Not(Unop):
flags = []
......
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