added get_nodes_MacroBlock()
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 3 Oct 2007 14:21:31 +0000 (14:21 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 3 Oct 2007 14:21:31 +0000 (14:21 +0000)
[r16060]

include/libfirm/irnode.h
ir/ir/irnode.c

index 1d321ff..fb7a3a0 100644 (file)
@@ -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()
index 104c8d5..8a89023 100644 (file)
@@ -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) {