From: Michael Beck Date: Tue, 25 Mar 2003 14:04:44 +0000 (+0000) Subject: node_is_in_irgs_storage() function added X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=b0f1b068798184c36ae36b2d204e36158638a237;p=libfirm node_is_in_irgs_storage() function added [r968] --- diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index c394b6389..c4d6c20f3 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -422,6 +422,27 @@ struct obstack *get_irg_obstack(ir_graph *irg) { return irg->obst; } +/* + * Returns true if the node n is allocated on the storage of graph irg. + * + * Implementation is GLIBC specific as is uses the internal _obstack_chunk implementation. + */ +int node_is_in_irgs_storage(ir_graph *irg, ir_node *n) +{ + struct _obstack_chunk *p; + + /* + * checks wheater the ir_node pointer i on the obstack. + * A more sophisticated chaeck would test the "whole" ir_node + */ + for (p = irg->obst->chunk; p; p = p->prev) { + if (((char *)p->contents <= (char *)n) && ((char *)n < (char *)p->limit)) + return 1; + } + + return 0; +} + irg_phase_state get_irg_phase_state (ir_graph *irg) { return irg->phase_state; diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index af39b5ae1..6aeb1b7f1 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -84,10 +84,24 @@ void init_irgraph(void); Must look like a correct irg, spare everything else. */ ir_graph *new_const_code_irg(void); +/** + * Set the pinned state of a graph. + * + * @irg the IR graph + * @p new pin state + */ INLINE void set_irg_pinned (ir_graph *irg, op_pinned p); /** Returns the obstack associated with the graph. */ struct obstack *get_irg_obstack(ir_graph *irg); +/** + * Returns true if the node n is allocated on the storage of graph irg. + * + * @param irg the IR graph + * @param n the IR node + */ +int node_is_in_irgs_storage(ir_graph *irg, ir_node *n); + # endif /* _IRGRAPH_T_H_ */