From 997941bd3c7913ecf8ffe4a4a08836fda815982b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 9 Apr 2010 12:40:01 +0000 Subject: [PATCH] Partly undo r27277 and add a prototype for (formally undocumented) find_value(), needed by the edgjfe FE. [r27363] --- include/libfirm/ircons.h | 10 ++++++++++ ir/ir/ircons.c | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/libfirm/ircons.h b/include/libfirm/ircons.h index 7b1ef65fc..adfa04de8 100644 --- a/include/libfirm/ircons.h +++ b/include/libfirm/ircons.h @@ -4456,6 +4456,16 @@ ir_node *get_value(int pos, ir_mode *mode); */ void set_value(int pos, ir_node *value); +/** + * Find the value number for a node in the current block. + * + * @param value the searched value + * + * @return the value number of the value or -1 if this value has + * no value number in the current block. + */ +int find_value(ir_node *value); + /** Get the current memory state. * * Use this function to obtain the last definition of the memory diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 42c6b5d75..55937c70c 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -1390,6 +1390,18 @@ void set_value(int pos, ir_node *value) 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 = ARR_LEN(bl->attr.block.graph_arr) - 1; i >= 1; --i) + if (bl->attr.block.graph_arr[i] == value) + return i - 1; + return -1; +} /* find_value */ + /* get the current store */ ir_node *get_store(void) { -- 2.20.1