From a12363c5b7e1018e0beab78f09de06b32e49b4c5 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 3 Oct 2007 14:21:31 +0000 Subject: [PATCH] added get_nodes_MacroBlock() [r16060] --- include/libfirm/irnode.h | 13 +++++++++++++ ir/ir/irnode.c | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index 1d321ff9c..fb7a3a008 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -283,6 +283,19 @@ ir_node *get_nodes_block (const ir_node *node); /** Sets the Block of a node. */ void set_nodes_block (ir_node *node, ir_node *block); +/** + * Return the MacroBlock the node belongs to. This is only + * possible for pinned nodes or if the graph is in pinned state. + * Otherwise the MacroBlock may be incorrect. This condition is + * now checked by an assertion. + * + * This works for all except Block. It can return Blocks or the Bad node. + * + * To express the difference to access routines that work for all + * nodes we use infix "nodes" and do not name this function + * get_irn_MacroBlock(). */ +ir_node *get_nodes_MacroBlock(const ir_node *node); + /** * @function get_irn_block() * @see get_nodes_block() diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 104c8d581..8a8902350 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -664,6 +664,13 @@ set_nodes_block(ir_node *node, ir_node *block) { set_irn_n(node, -1, block); } +/* this works for all except Block */ +ir_node * +get_nodes_MacroBlock(const ir_node *node) { + assert(node->op != op_Block); + return get_Block_MacroBlock(get_irn_n(node, -1)); +} + /* Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base) * from Start. If so returns frame type, else Null. */ ir_type *is_frame_pointer(ir_node *n) { -- 2.20.1