From ff0e8d7fcb34481652f0bf521ba04b1eca5e2106 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 15 Sep 2006 08:05:34 +0000 Subject: [PATCH] add docu and prototype for find_value() remove some depencies from current_ir_graph [r8257] --- ir/ir/ircons.c | 60 +++++++++++++++++++++++++++----------------------- ir/ir/ircons.h | 40 +++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index a2a935178..c5ebac445 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -4,10 +4,10 @@ * Purpose: Various irnode constructors. Automatic construction * of SSA representation. * Author: Martin Trapp, Christian Schaefer - * Modified by: Goetz Lindenmaier, Boris Boesler + * Modified by: Goetz Lindenmaier, Boris Boesler, Michael Beck * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ @@ -481,7 +481,7 @@ new_bd_Call(dbg_info *db, ir_node *block, ir_node *store, } /* new_bd_Call */ static ir_node * -new_bd_Return (dbg_info *db, ir_node *block, +new_bd_Return(dbg_info *db, ir_node *block, ir_node *store, int arity, ir_node **in) { ir_node **r_in; @@ -1805,9 +1805,9 @@ new_d_Block(dbg_info *db, int arity, ir_node **in) \|/ / |/_ \ get_r_value_internal | | | - | | - \|/ \|/ - new_rd_Phi0 new_rd_Phi_in + | | + \|/ \|/ + new_rd_Phi0 new_rd_Phi_in * *************************************************************************** */ @@ -2591,10 +2591,10 @@ mature_immBlock(ir_node *block) /* Traverse a chain of Phi nodes attached to this block and mature these, too. **/ - for (n = block->link; n; n=next) { + for (n = block->link; n; n = next) { inc_irg_visited(current_ir_graph); next = n->link; - exchange (n, phi_merge (block, n->attr.phi0_pos, n->mode, nin, ins)); + exchange(n, phi_merge (block, n->attr.phi0_pos, n->mode, nin, ins)); } block->attr.block.matured = 1; @@ -2648,14 +2648,14 @@ new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj) { assert(arg->op == op_Cond); arg->attr.cond.kind = fragmentary; arg->attr.cond.default_proj = max_proj; - res = new_Proj (arg, mode_X, max_proj); + res = new_Proj(arg, mode_X, max_proj); return res; } /* new_d_defaultProj */ ir_node * -new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode) { +new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode) { return new_bd_Conv(db, current_ir_graph->current_block, op, mode, 0); -} +} /* new_d_Conv */ ir_node * new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode) { @@ -2693,7 +2693,7 @@ static void allocate_frag_arr(ir_node *res, ir_op *op, ir_node ***frag_store) { ir_node * new_d_Quot(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { ir_node *res; - res = new_bd_Quot (db, current_ir_graph->current_block, memop, op1, op2); + res = new_bd_Quot(db, current_ir_graph->current_block, memop, op1, op2); res->attr.except.pin_state = op_pin_state_pinned; #if PRECISE_EXC_CONTEXT allocate_frag_arr(res, op_Quot, &res->attr.except.frag_arr); /* Could be optimized away. */ @@ -2705,7 +2705,7 @@ new_d_Quot(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { ir_node * new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { ir_node *res; - res = new_bd_DivMod (db, current_ir_graph->current_block, memop, op1, op2); + res = new_bd_DivMod(db, current_ir_graph->current_block, memop, op1, op2); res->attr.except.pin_state = op_pin_state_pinned; #if PRECISE_EXC_CONTEXT allocate_frag_arr(res, op_DivMod, &res->attr.except.frag_arr); /* Could be optimized away. */ @@ -2715,10 +2715,10 @@ new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { } /* new_d_DivMod */ ir_node * -new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) +new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { ir_node *res; - res = new_bd_Div (db, current_ir_graph->current_block, memop, op1, op2); + res = new_bd_Div(db, current_ir_graph->current_block, memop, op1, op2); res->attr.except.pin_state = op_pin_state_pinned; #if PRECISE_EXC_CONTEXT allocate_frag_arr(res, op_Div, &res->attr.except.frag_arr); /* Could be optimized away. */ @@ -2730,7 +2730,7 @@ new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) ir_node * new_d_Mod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2) { ir_node *res; - res = new_bd_Mod (db, current_ir_graph->current_block, memop, op1, op2); + res = new_bd_Mod(db, current_ir_graph->current_block, memop, op1, op2); res->attr.except.pin_state = op_pin_state_pinned; #if PRECISE_EXC_CONTEXT allocate_frag_arr(res, op_Mod, &res->attr.except.frag_arr); /* Could be optimized away. */ @@ -3036,10 +3036,11 @@ set_cur_block(ir_node *target) { /* get a value from the parameter array from the current block by its index */ ir_node * get_d_value(dbg_info *db, int pos, ir_mode *mode) { - assert(get_irg_phase_state (current_ir_graph) == phase_building); - inc_irg_visited(current_ir_graph); + ir_graph *irg = current_ir_graph; + assert(get_irg_phase_state(irg) == phase_building); + inc_irg_visited(irg); - return get_r_value_internal (current_ir_graph->current_block, pos + 1, mode); + return get_r_value_internal(irg->current_block, pos + 1, mode); } /* get_d_value */ /* get a value from the parameter array from the current block by its index */ @@ -3051,17 +3052,19 @@ get_value(int pos, ir_mode *mode) { /* set a value at position pos in the parameter array from the current block */ void set_value(int pos, ir_node *value) { - assert(get_irg_phase_state (current_ir_graph) == phase_building); - assert(pos+1 < current_ir_graph->n_loc); - current_ir_graph->current_block->attr.block.graph_arr[pos + 1] = value; + ir_graph *irg = current_ir_graph; + assert(get_irg_phase_state(irg) == phase_building); + assert(pos+1 < irg->n_loc); + irg->current_block->attr.block.graph_arr[pos + 1] = value; } /* set_value */ +/* Find the value number for a node in the current block.*/ int find_value(ir_node *value) { int i; ir_node *bl = current_ir_graph->current_block; - for (i = 1; i < ARR_LEN(bl->attr.block.graph_arr); ++i) + for (i = ARR_LEN(bl->attr.block.graph_arr) - 1; i >= 1; --i) if (bl->attr.block.graph_arr[i] == value) return i - 1; return -1; @@ -3069,12 +3072,13 @@ find_value(ir_node *value) { /* get the current store */ ir_node * -get_store(void) -{ - assert(get_irg_phase_state (current_ir_graph) == phase_building); +get_store(void) { + ir_graph *irg = current_ir_graph; + + assert(get_irg_phase_state(irg) == phase_building); /* GL: one could call get_value instead */ - inc_irg_visited(current_ir_graph); - return get_r_value_internal (current_ir_graph->current_block, 0, mode_M); + inc_irg_visited(irg); + return get_r_value_internal(irg->current_block, 0, mode_M); } /* get_store */ /* set the current store: handles automatic Sync construction for Load nodes */ diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index 545e38691..e18fb352b 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -4,10 +4,10 @@ * Purpose: Various irnode constructors. Automatic construction * of SSA representation. * Author: Martin Trapp, Christian Schaefer - * Modified by: Goetz Lindenmaier, Boris Boesler + * Modified by: Goetz Lindenmaier, Boris Boesler, Michael Beck * Created: * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe + * Copyright: (c) 1998-2006 Universität Karlsruhe * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ @@ -4196,13 +4196,13 @@ ir_node *new_Raise (ir_node *store, ir_node *obj); * @param *lower The ir_node that represents the lower bound for the index. * @param *upper The ir_node that represents the upper bound for the index. */ -ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); +ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper); /** Constructor for a Pin node. * * @param *node The node which value should be pinned. */ -ir_node *new_Pin(ir_node *node); +ir_node *new_Pin (ir_node *node); /*---------------------------------------------------------------------*/ /* The comfortable interface. */ @@ -4222,14 +4222,14 @@ ir_node *new_Pin(ir_node *node); * This constructor can only be used if the graph is in * state_building. */ -ir_node *new_d_immBlock (dbg_info *db); -ir_node *new_immBlock (void); +ir_node *new_d_immBlock(dbg_info *db); +ir_node *new_immBlock(void); /** Add a control flow edge to an immature block. */ -void add_immBlock_pred (ir_node *immblock, ir_node *jmp); +void add_immBlock_pred(ir_node *immblock, ir_node *jmp); /** Finalize a Block node, when all control flows are known. */ -void mature_immBlock (ir_node *block); +void mature_immBlock(ir_node *block); #define mature_cur_block() mature_immBlock(get_cur_block()); @@ -4243,8 +4243,8 @@ void mature_immBlock (ir_node *block); * @param pos The position/id of the local variable. * @param *mode The mode of the value to get. */ -ir_node *get_d_value (dbg_info *db, int pos, ir_mode *mode); -ir_node *get_value (int pos, ir_mode *mode); +ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode); +ir_node *get_value(int pos, ir_mode *mode); /** Remark a new definition of a variable. * @@ -4256,7 +4256,19 @@ ir_node *get_value (int pos, ir_mode *mode); * @param pos The position/id of the local variable. * @param *value The new value written to the local variable. */ -void set_value (int pos, ir_node *value); +void set_value(int pos, ir_node *value); + +/** Find the value number for a node in the current block. + * + * This function searches all values in the current block for + * a given value and returns its value number if it was found, else + * -1. + * Note that this does not mean that the value does not exists, + * it's just not equal the node (for instance behind a Phi/Confirm ...) + * + * @param *value The value to find. + */ +int find_value(ir_node *value); /** Get the current memory state. * @@ -4264,7 +4276,7 @@ void set_value (int pos, ir_node *value); * state. This call automatically inserts Phi nodes for the memory * state value. */ -ir_node *get_store (void); +ir_node *get_store(void); /** Remark a new definition of the memory state. * @@ -4273,13 +4285,13 @@ ir_node *get_store (void); * * @param *store The new memory state. */ -void set_store (ir_node *store); +void set_store(ir_node *store); /** keep this node alive even if End is not control-reachable from it * * @param ka The node to keep alive. */ -void keep_alive (ir_node *ka); +void keep_alive(ir_node *ka); /** Returns the frame type of the current graph */ ir_type *get_cur_frame_type(void); -- 2.20.1