removed makro calls, dokumentation
[libfirm] / ir / ir / irnode.c
index 9eef4b8..4c922c4 100644 (file)
@@ -466,6 +466,42 @@ set_nodes_Block (ir_node *node, ir_node *block) {
   set_irn_n(node, -1, block);
 }
 
+/* Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
+ * from Start.  If so returns frame type, else Null. */
+type *is_frame_pointer(ir_node *n) {
+  if ((get_irn_op(n) == op_Proj) &&
+      (get_Proj_proj(n) == pn_Start_P_frame_base)) {
+    ir_node *start = get_Proj_pred(n);
+    if (get_irn_op(start) == op_Start) {
+      return get_irg_frame_type(get_irn_irg(start));
+    }
+  }
+  return NULL;
+}
+
+/* Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
+ * from Start.  If so returns global type, else Null. */
+type *is_globals_pointer(ir_node *n) {
+  if ((get_irn_op(n) == op_Proj) &&
+      (get_Proj_proj(n) == pn_Start_P_globals)) {
+    ir_node *start = get_Proj_pred(n);
+    if (get_irn_op(start) == op_Start) {
+      return get_glob_type();
+    }
+  }
+  return NULL;
+}
+
+/* Test whether arbitrary node is value arg base, i.e. Proj(pn_Start_P_value_arg_base)
+ * from Start.  If so returns 1, else 0. */
+int is_value_arg_pointer(ir_node *n) {
+  if ((get_irn_op(n) == op_Proj) &&
+      (get_Proj_proj(n) == pn_Start_P_value_arg_base) &&
+      (get_irn_op(get_Proj_pred(n)) == op_Start))
+    return 1;
+  return 0;
+}
+
 /* Returns an array with the predecessors of the Block. Depending on
    the implementation of the graph datastructure this can be a copy of
    the internal representation of predecessors as well as the internal
@@ -551,7 +587,7 @@ set_Block_graph_arr (ir_node *node, int pos, ir_node *value) {
   node->attr.block.graph_arr[pos+1] = value;
 }
 
-/* handler handling for Blocks */
+/* handler handling for Blocks * /
 void
 set_Block_handler (ir_node *block, ir_node *handler)  {
   assert ((block->op == op_Block));
@@ -565,7 +601,7 @@ get_Block_handler (ir_node *block) {
   return (block->attr.block.handler_entry);
 }
 
-/* handler handling for Nodes */
+/ * handler handling for Nodes * /
 void
 set_Node_handler (ir_node *node, ir_node *handler) {
   set_Block_handler (get_nodes_Block (node), handler);
@@ -576,7 +612,7 @@ get_Node_handler (ir_node *node) {
   return (get_Block_handler (get_nodes_Block (node)));
 }
 
-/* exc_t handling for Blocks */
+/ * exc_t handling for Blocks * /
 void set_Block_exc (ir_node *block, exc_t exc) {
   assert ((block->op == op_Block));
   block->attr.block.exc = exc;
@@ -584,11 +620,10 @@ void set_Block_exc (ir_node *block, exc_t exc) {
 
 exc_t get_Block_exc (ir_node *block) {
   assert ((block->op == op_Block));
-
   return (block->attr.block.exc);
 }
 
-/* exc_t handling for Nodes */
+/ * exc_t handling for Nodes * /
 void set_Node_exc (ir_node *node, exc_t exc) {
   set_Block_exc (get_nodes_Block (node), exc);
 }
@@ -596,6 +631,7 @@ void set_Node_exc (ir_node *node, exc_t exc) {
 exc_t get_Node_exc (ir_node *node) {
   return (get_Block_exc (get_nodes_Block (node)));
 }
+*/
 
 void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in) {
   assert(node->op == op_Block);
@@ -645,15 +681,15 @@ void remove_Block_cg_cfgpred_arr(ir_node * node) {
 /* Start references the irg it is in. */
 INLINE ir_graph *
 get_Start_irg(ir_node *node) {
-  assert(node->op == op_Start);
-  return node->attr.start.irg;
+  return get_irn_irg(node);
 }
 
 INLINE void
 set_Start_irg(ir_node *node, ir_graph *irg) {
   assert(node->op == op_Start);
   assert(is_ir_graph(irg));
-  node->attr.start.irg = irg;
+  assert(0 && " Why set irg? ");
+  //node->attr.start.irg = irg;
 }
 
 INLINE int
@@ -689,14 +725,12 @@ free_End (ir_node *end) {
                       in array afterwards ... */
 }
 
-ir_graph *get_EndReg_irg (const ir_node *end) {
-  assert (end->op == op_EndReg);
-  return end->attr.end.irg;
+ir_graph *get_EndReg_irg (ir_node *end) {
+  return get_irn_irg(end);
 }
 
-ir_graph *get_EndExcept_irg  (const ir_node *end) {
-  assert (end->op == op_EndReg);
-  return end->attr.end.irg;
+ir_graph *get_EndExcept_irg  (ir_node *end) {
+  return get_irn_irg(end);
 }
 
 /*
@@ -1131,8 +1165,7 @@ void set_CallBegin_ptr (ir_node *node, ir_node *ptr) {
   set_irn_n(node, 0, ptr);
 }
 ir_graph * get_CallBegin_irg (ir_node *node) {
-  assert(node->op == op_CallBegin);
-  return node->attr.callbegin.irg;
+  return get_irn_irg(node);
 }
 ir_node * get_CallBegin_call (ir_node *node) {
   assert(node->op == op_CallBegin);
@@ -2207,17 +2240,10 @@ ir_node *get_Filter_cg_pred(ir_node *node, int pos) {
 
 INLINE ir_graph *
 get_irn_irg(ir_node *node) {
-  if (get_irn_op(node) == op_CallBegin) {
-    return node->attr.callbegin.irg;
-  } else if (get_irn_op(node) == op_EndReg ||
-            get_irn_op(node) == op_EndExcept) {
-    return node->attr.end.irg;
-  } else if (get_irn_op(node) == op_Start) {
-    return node->attr.start.irg;
-  } else {
-    assert(0 && "no irg attr");
-    return NULL;
-  }
+  if (get_irn_op(node) != op_Block)
+    node = get_nodes_block(node);
+  assert(get_irn_op(node) == op_Block);
+  return node->attr.block.irg;
 }
 
 
@@ -2325,17 +2351,7 @@ INLINE int is_ip_cfop(ir_node *node) {
 }
 
 ir_graph *get_ip_cfop_irg(ir_node *n) {
-  switch (get_irn_opcode(n)) {
-  case iro_EndReg:
-    return get_EndReg_irg(n);
-  case iro_EndExcept:
-    return get_EndExcept_irg(n);
-  case iro_CallBegin:
-    return get_CallBegin_irg(n);
-  default:
-    assert(is_ip_cfop(n));
-  }
-  return NULL; /* should never be reached */
+  return get_irn_irg(n);
 }
 
 /* Returns true if the operation can change the control flow because