Bad nodes just like on Block nodes.
This simplifies get_irn_irg() and implements the idea the the irg can
be retrieved from "the block" of a node.
[r26188]
/* fix the irg for blocks */
if (is_Block(nn)) {
- nn->attr.block.irg = irg;
+ nn->attr.block.irg.irg = irg;
/* we cannot allow blocks WITHOUT macroblock input */
set_Block_MacroBlock(nn, get_Block_MacroBlock(n));
res->attr.block.is_matured = 0;
res->attr.block.is_dead = 0;
res->attr.block.is_mb_head = 1;
- res->attr.block.irg = current_ir_graph;
+ res->attr.block.irg.irg = current_ir_graph;
res->attr.block.backedge = NULL;
res->attr.block.in_cg = NULL;
res->attr.block.cg_backedge = NULL;
ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
ir_graph *res;
ir_node *first_block;
- ir_node *end, *start, *start_block, *initial_mem, *projX;
+ ir_node *end, *start, *start_block, *initial_mem, *projX, *bad;
res = alloc_graph();
res->last_node_idx = 0;
- res->value_table = new_identities (); /* value table for global value
- numbering for optimizing use in iropt.c */
+ res->value_table = new_identities(); /* value table for global value
+ numbering for optimizing use in iropt.c */
res->outs = NULL;
res->inline_property = irg_inline_any;
start_block = new_immBlock();
set_cur_block(start_block);
set_irg_start_block(res, start_block);
- set_irg_bad (res, new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL));
+ bad = new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL);
+ bad->attr.irg.irg = res;
+ set_irg_bad (res, bad);
set_irg_no_mem (res, new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
start = new_Start();
set_irg_start (res, start);
set_cur_block(start_block);
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;
set_irg_bad(res, bad);
no_mem = new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL);
set_irg_no_mem(res, no_mem);
new_backedge_info(nn);
set_irn_link(n, nn);
- /* fix the irg for blocks */
+ /* fix the irg for Blocks: as Bad nodes are NOT copied, no
+ need t fix them */
if (is_Block(nn))
- nn->attr.block.irg = irg;
+ nn->attr.block.irg.irg = irg;
/* fix access to entities on the stack frame */
if (is_Sel(nn)) {
*/
if (! is_Block(node))
node = get_irn_n(node, -1);
- if (is_Bad(node)) /* sometimes bad is predecessor of nodes instead of block: in case of optimization */
- node = get_irn_n(node, -1);
- assert(is_Block(node));
- return node->attr.block.irg;
+ /* note that get_Block_irg() can handle Bad nodes */
+ return get_Block_irg(node);
}
static ir_graph *
_get_Block_irg(const ir_node *block) {
- assert(is_Block(block));
- return block->attr.block.irg;
+ assert(is_Block(block) || is_Bad(block));
+ return block->attr.irg.irg;
}
static inline tarval *_get_Const_tarval(const ir_node *node) {
const void *tv_priv; /**< tarval module will save private data here */
};
-/** ir node attributes **/
+/* ir node attributes */
+
+/** first attribute of Bad and Block nodes */
+typedef struct {
+ ir_graph *irg; /**< The graph this block like node belongs to. */
+} irg_attr;
/** Block attributes */
typedef struct {
/* General attributes */
- ir_graph *irg; /**< The graph this block belongs to. */
+ irg_attr irg; /**< The graph this block belongs to. */
ir_visited_t block_visited; /**< For the walker that walks over all blocks. */
/* Attributes private to construction: */
unsigned is_matured:1; /**< If set, all in-nodes of the block are fixed. */
/** Some IR-nodes just have one attribute, these are stored here,
some have more. Their name is 'irnodename_attr' */
typedef union {
+ irg_attr irg; /**< For Blocks and Bad: its belonging irg */
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 */
copy_node(n, NULL);
if (is_Sel(n)) {
- nn = get_new_node (n);
+ nn = get_new_node(n);
assert(is_Sel(nn));
+ /* use copied entities from the new frame */
if (get_entity_owner(get_Sel_entity(n)) == frame_tp) {
set_Sel_entity(nn, get_entity_link(get_Sel_entity(n)));
}
} else if (is_Block(n)) {
- nn = get_new_node (n);
- nn->attr.block.irg = current_ir_graph;
+ nn = get_new_node(n);
+ nn->attr.block.irg.irg = current_ir_graph;
}
}
),
Bad = dict(
- mode = "mode_Bad",
- flags = "cfopcode, fragile, start_block, dump_noblock",
- pinned = "yes",
- knownBlock = True,
- singleton = True,
+ mode = "mode_Bad",
+ flags = "cfopcode, fragile, start_block, dump_noblock",
+ pinned = "yes",
+ attr_struct = "irg_attr",
+ knownBlock = True,
+ singleton = True,
+ init = '''
+ res->attr.irg.irg = irg;
+ ''',
),
Block = dict(
res->attr.block.is_dead = 0;
res->attr.block.is_mb_head = 1;
- res->attr.block.irg = irg;
+ res->attr.block.irg.irg = irg;
res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
res->attr.block.in_cg = NULL;
res->attr.block.cg_backedge = NULL;