From 3b7785f7e3ae25615884947f2a8be5c8acf346a3 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 1 Dec 2004 15:51:45 +0000 Subject: [PATCH] Added a new attribute to block nodes: dead This attribute can only be set, not reseted and means the block is dead (could be replaced my Bad in old semantics). the new is_Block_dead() test chescks for the new attribute (and is_Bad() too) and should be used whenever a block is check with is_Bad() [r4535] --- ir/ir/ircons.c | 21 ++++++++++++--------- ir/ir/irdump.c | 5 ++++- ir/ir/irnode.c | 8 ++++++++ ir/ir/irnode.h | 3 +++ ir/ir/irnode_t.h | 24 +++++++++++++++++++++++- 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 59f389d15..f59976f98 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -52,8 +52,9 @@ typedef struct Phi_in_stack Phi_in_stack; */ static default_initialize_local_variable_func_t *default_initialize_local_variable = NULL; -/*** ******************************************** */ -/** privat interfaces, for professional use only */ +/* -------------------------------------------- */ +/* privat interfaces, for professional use only */ +/* -------------------------------------------- */ /* Constructs a Block with a fixed number of predecessors. Does not set current_block. Can not be used with automatic @@ -69,9 +70,10 @@ new_rd_Block (dbg_info* db, ir_graph *irg, int arity, ir_node **in) /* res->attr.block.exc = exc_normal; */ /* res->attr.block.handler_entry = 0; */ - res->attr.block.irg = irg; - res->attr.block.backedge = new_backedge_arr(irg->obst, arity); - res->attr.block.in_cg = NULL; + res->attr.block.dead = 0; + res->attr.block.irg = irg; + res->attr.block.backedge = new_backedge_arr(irg->obst, arity); + res->attr.block.in_cg = NULL; res->attr.block.cg_backedge = NULL; IRN_VRFY_IRG(res, irg); @@ -2373,12 +2375,13 @@ ir_node *new_d_immBlock (dbg_info* db) { /* creates a new dynamic in-array as length of in is -1 */ res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL); current_ir_graph->current_block = res; - res->attr.block.matured = 0; + res->attr.block.matured = 0; + res->attr.block.dead = 0; /* res->attr.block.exc = exc_normal; */ /* res->attr.block.handler_entry = 0; */ - res->attr.block.irg = current_ir_graph; - res->attr.block.backedge = NULL; - res->attr.block.in_cg = NULL; + res->attr.block.irg = current_ir_graph; + res->attr.block.backedge = NULL; + res->attr.block.in_cg = NULL; res->attr.block.cg_backedge = NULL; set_Block_block_visited(res, 0); diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 38971834b..0a55d342f 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -683,7 +683,10 @@ static void dump_node_vcgattr(FILE *F, ir_node *n, int bad) fprintf (F, "color: blue"); break; case iro_Block: - fprintf (F, "color: lightyellow"); + if (is_Block_dead(n)) + fprintf (F, "color: lightred"); + else + fprintf (F, "color: lightyellow"); break; case iro_Phi: fprintf (F, "color: green"); diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 87bc6061a..78cd9c0a6 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -698,6 +698,14 @@ void remove_Block_cg_cfgpred_arr(ir_node * node) { node->attr.block.in_cg = NULL; } +ir_node *(set_Block_dead)(ir_node *block) { + return __set_Block_dead(block); +} + +int (is_Block_dead)(const ir_node *block) { + return __is_Block_dead(block); +} + void set_Start_irg(ir_node *node, ir_graph *irg) { assert(node->op == op_Start); diff --git a/ir/ir/irnode.h b/ir/ir/irnode.h index 739a56b3d..0696e6642 100644 --- a/ir/ir/irnode.h +++ b/ir/ir/irnode.h @@ -276,6 +276,9 @@ bool get_Block_matured (ir_node *node); void set_Block_matured (ir_node *node, bool matured); unsigned long get_Block_block_visited (ir_node *node); void set_Block_block_visited (ir_node *node, unsigned long visit); +ir_node *set_Block_dead(ir_node *block); +int is_Block_dead(const ir_node *block); + /* For this current_ir_graph must be set. */ void mark_Block_block_visited(ir_node *node); int Block_not_block_visited(ir_node *node); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index f842d855a..cf7f4f592 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -49,7 +49,8 @@ typedef struct { ir_graph *irg; unsigned long block_visited; /**< for the walker that walks over all blocks. */ /* Attributes private to construction: */ - bool matured; /**< if set, all in-nodes of the block are fixed */ + int matured:1; /**< if set, all in-nodes of the block are fixed */ + int dead:1; /**< if set, the block is dead (and could be replace by a Bad */ struct ir_node **graph_arr; /**< array to store all parameters */ /* Attributes holding analyses information */ struct dom_info dom; /**< Datastructure that holds information about dominators. @@ -510,6 +511,25 @@ __is_Block(const ir_node *node) { return (__get_irn_op(node) == op_Block); } +static INLINE ir_node * +__set_Block_dead(ir_node *block) { + assert(__get_irn_op(block) == op_Block); + block->attr.block.dead = 1; + return block; +} + +static INLINE int +__is_Block_dead(const ir_node *block) { + ir_op * op = __get_irn_op(block); + + if (op == op_Bad) + return 1; + else { + assert(op == op_Block); + return block->attr.block.dead; + } +} + /* this section MUST contain all inline functions */ #define is_ir_node(thing) __is_ir_node(thing) #define get_irn_intra_arity(node) __get_irn_intra_arity(node) @@ -534,5 +554,7 @@ __is_Block(const ir_node *node) { #define is_Bad(node) __is_Bad(node) #define is_no_Block(node) __is_no_Block(node) #define is_Block(node) __is_Block(node) +#define set_Block_dead(block) __set_Block_dead(block) +#define is_Block_dead(block) __is_Block_dead(block) # endif /* _IRNODE_T_H_ */ -- 2.20.1