added attr irg to block, removed from start, call, end.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 10 Nov 2003 15:02:55 +0000 (15:02 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Mon, 10 Nov 2003 15:02:55 +0000 (15:02 +0000)
removed exc attr.

[r2027]

ir/ir/ircons.c
ir/ir/irgopt.c
ir/ir/irnode.c
ir/ir/irnode.h
ir/ir/irnode_t.h

index bdb3386..37aa0c6 100644 (file)
@@ -60,8 +60,9 @@ new_rd_Block (dbg_info* db, ir_graph *irg,  int arity, ir_node **in)
   set_Block_matured(res, 1);
   set_Block_block_visited(res, 0);
 
-  res->attr.block.exc = exc_normal;
-  res->attr.block.handler_entry = 0;
+  //res->attr.block.exc = exc_normal;
+  //res->attr.block.handler_entry = 0;
+  res->attr.block.irg = irg;
   res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
   res->attr.block.in_cg = NULL;
   res->attr.block.cg_backedge = NULL;
@@ -76,7 +77,7 @@ new_rd_Start (dbg_info* db, ir_graph *irg, ir_node *block)
   ir_node *res;
 
   res = new_ir_node (db, irg, block, op_Start, mode_T, 0, NULL);
-  res->attr.start.irg = irg;
+  //res->attr.start.irg = irg;
 
   irn_vrfy_irg (res, irg);
   return res;
@@ -743,7 +744,7 @@ new_rd_CallBegin (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *call)
   ir_node *res;
   in[0] = get_Call_ptr(call);
   res = new_ir_node (db, irg, block, op_CallBegin, mode_T, 1, in);
-  res->attr.callbegin.irg = irg;
+  //res->attr.callbegin.irg = irg;
   res->attr.callbegin.call = call;
   res = optimize_node (res);
   irn_vrfy_irg (res, irg);
@@ -756,7 +757,7 @@ new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block)
   ir_node *res;
 
   res = new_ir_node (db, irg, block, op_EndReg, mode_T, -1, NULL);
-  res->attr.end.irg = irg;
+  //res->attr.end.irg = irg;
 
   irn_vrfy_irg (res, irg);
   return res;
@@ -768,7 +769,7 @@ new_rd_EndExcept (dbg_info *db, ir_graph *irg, ir_node *block)
   ir_node *res;
 
   res = new_ir_node (db, irg, block, op_EndExcept, mode_T, -1, NULL);
-  res->attr.end.irg = irg;
+  //res->attr.end.irg = irg;
 
   irn_vrfy_irg (res, irg);
   return res;
@@ -839,65 +840,65 @@ INLINE ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
   return new_rd_SymConst(NULL, irg, block, value, symkind);
 }
 INLINE ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
-                       ir_node *objptr, int n_index, ir_node **index,
-                      entity *ent) {
+                             ir_node *objptr, int n_index, ir_node **index,
+                             entity *ent) {
   return new_rd_Sel(NULL, irg, block, store, objptr, n_index, index, ent);
 }
 INLINE ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr,
-                                          type *ent) {
+                             type *ent) {
   return (new_rd_InstOf (NULL, irg, block, store, objptr, ent));
 }
 INLINE ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
-                      ir_node *callee, int arity, ir_node **in,
-                      type *tp) {
+                             ir_node *callee, int arity, ir_node **in,
+                             type *tp) {
   return new_rd_Call(NULL, irg, block, store, callee, arity, in, tp);
 }
 INLINE ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
-                      ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_Add(NULL, irg, block, op1, op2, mode);
 }
 INLINE ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
-                      ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_Sub(NULL, irg, block, op1, op2, mode);
 }
 INLINE ir_node *new_r_Minus  (ir_graph *irg, ir_node *block,
-                      ir_node *op,  ir_mode *mode) {
+                             ir_node *op,  ir_mode *mode) {
   return new_rd_Minus(NULL, irg, block,  op, mode);
 }
 INLINE ir_node *new_r_Mul    (ir_graph *irg, ir_node *block,
-                                          ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_Mul(NULL, irg, block, op1, op2, mode);
 }
 INLINE ir_node *new_r_Quot   (ir_graph *irg, ir_node *block,
-                      ir_node *memop, ir_node *op1, ir_node *op2) {
+                             ir_node *memop, ir_node *op1, ir_node *op2) {
   return new_rd_Quot(NULL, irg, block, memop, op1, op2);
 }
 INLINE ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
-                      ir_node *memop, ir_node *op1, ir_node *op2) {
+                             ir_node *memop, ir_node *op1, ir_node *op2) {
   return new_rd_DivMod(NULL, irg, block, memop, op1, op2);
 }
 INLINE ir_node *new_r_Div    (ir_graph *irg, ir_node *block,
-                      ir_node *memop, ir_node *op1, ir_node *op2) {
+                             ir_node *memop, ir_node *op1, ir_node *op2) {
   return new_rd_Div(NULL, irg, block, memop, op1, op2);
 }
 INLINE ir_node *new_r_Mod    (ir_graph *irg, ir_node *block,
-                      ir_node *memop, ir_node *op1, ir_node *op2) {
+                             ir_node *memop, ir_node *op1, ir_node *op2) {
   return new_rd_Mod(NULL, irg, block, memop, op1, op2);
 }
 INLINE ir_node *new_r_Abs    (ir_graph *irg, ir_node *block,
-                       ir_node *op, ir_mode *mode) {
+                             ir_node *op, ir_mode *mode) {
   return new_rd_Abs(NULL, irg, block, op, mode);
 }
 INLINE ir_node *new_r_And    (ir_graph *irg, ir_node *block,
-                      ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_And(NULL, irg, block,  op1, op2, mode);
 }
 INLINE ir_node *new_r_Or     (ir_graph *irg, ir_node *block,
-                      ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_Or(NULL, irg, block,  op1, op2, mode);
 }
 INLINE ir_node *new_r_Eor    (ir_graph *irg, ir_node *block,
-                      ir_node *op1, ir_node *op2, ir_mode *mode) {
+                             ir_node *op1, ir_node *op2, ir_mode *mode) {
   return new_rd_Eor(NULL, irg, block,  op1, op2, mode);
 }
 INLINE ir_node *new_r_Not    (ir_graph *irg, ir_node *block,
@@ -1016,7 +1017,7 @@ new_d_Start (dbg_info* db)
 
   res = new_ir_node (db, current_ir_graph, current_ir_graph->current_block,
                     op_Start, mode_T, 0, NULL);
-  res->attr.start.irg = current_ir_graph;
+  //res->attr.start.irg = current_ir_graph;
 
   res = optimize_node (res);
   irn_vrfy_irg (res, current_ir_graph);
@@ -2222,8 +2223,9 @@ ir_node *new_d_immBlock (dbg_info* db) {
   res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL);
   current_ir_graph->current_block = res;
   res->attr.block.matured = 0;
-  res->attr.block.exc = exc_normal;
-  res->attr.block.handler_entry = 0;
+  //res->attr.block.exc = exc_normal;
+  //res->attr.block.handler_entry = 0;
+  res->attr.block.irg = current_ir_graph;
   res->attr.block.backedge = NULL;
   res->attr.block.in_cg = NULL;
   res->attr.block.cg_backedge = NULL;
@@ -2383,7 +2385,7 @@ ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node **in,
   return new_d_Sel(NULL, store, objptr, arity, in, ent);
 }
 ir_node *new_InstOf (ir_node *store, ir_node *objptr, type *ent) {
-  return (new_d_InstOf (NULL, store, objptr, ent));
+  return new_d_InstOf (NULL, store, objptr, ent);
 }
 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node **in,
                     type *tp) {
index 5da5d46..462c8de 100644 (file)
@@ -510,10 +510,13 @@ void remove_bad_predecessors(ir_graph *irg) {
 /*  Funcionality for inlining                                         */
 /**********************************************************************/
 
-/* Copy node for inlineing.  Copies the node by calling copy_node and
-   then updates the entity if it's a local one.  env must be a pointer
-   to the frame type of the procedure. The new entities must be in
-   the link field of the entities. */
+/* Copy node for inlineing.  Updates attributes that change when
+ * inlineing but not for dead node elimination.
+ *
+ * Copies the node by calling copy_node and then updates the entity if
+ * it's a local one.  env must be a pointer of the frame type of the
+ * inlined procedure. The new entities must be in the link field of
+ * the entities. */
 static INLINE void
 copy_node_inline (ir_node *n, void *env) {
   ir_node *new;
@@ -526,10 +529,12 @@ copy_node_inline (ir_node *n, void *env) {
     if (get_entity_owner(get_Sel_entity(n)) == frame_tp) {
       set_Sel_entity(new, get_entity_link(get_Sel_entity(n)));
     }
+  } else if (get_irn_op(n) == op_Block) {
+    new = get_new_node (n);
+    new->attr.block.irg = current_ir_graph;
   }
 }
 
-#include "irdump.h"
 
 void inline_method(ir_node *call, ir_graph *called_graph) {
   ir_node *pre_call;
@@ -889,8 +894,6 @@ void inline_small_irgs(ir_graph *irg, int size) {
 /*  will be executed only if needed.                                */
 /********************************************************************/
 
-#include "irdump.h"
-
 static pdeq *worklist;         /* worklist of ir_node*s */
 
 /* Find the earliest correct block for N.  --- Place N into the
index fa12ad8..4c922c4 100644 (file)
@@ -587,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));
@@ -601,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);
@@ -612,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;
@@ -620,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);
 }
@@ -632,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);
@@ -681,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
@@ -725,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);
 }
 
 /*
@@ -1167,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);
@@ -2243,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;
 }
 
 
@@ -2361,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
index b9f8c91..531151b 100644 (file)
@@ -146,17 +146,18 @@ INLINE void          mark_irn_visited (ir_node *node);
 INLINE int           irn_not_visited  (const ir_node *node);
 /** Returns 1 if visited >= get_irg_visited(current_ir_graph).  */
 INLINE int           irn_visited      (const ir_node *node);
-INLINE void          set_irn_link          (ir_node *node, void *link);
-INLINE void         *get_irn_link          (const ir_node *node);
+INLINE void          set_irn_link     (ir_node *node, void *link);
+INLINE void         *get_irn_link     (const ir_node *node);
+
+/** Returns the ir_graph this node belongs to. Only valid if irg
+ *  is in state pinned (irg is only stored in the block. */
+INLINE ir_graph     *get_irn_irg      (ir_node *node);
 
 /** Outputs a unique number for this node if libfirm is compiled for
    debugging, (configure with --enable-debug) else returns address
    of node cast to long. */
-INLINE long          get_irn_node_nr(const ir_node *node);
+INLINE long          get_irn_node_nr  (const ir_node *node);
 
-/** Returns the ir_graph this node belongs to. Only valid for
- * CallBegin, EndReg, EndExcept and Start */
-INLINE ir_graph     *get_irn_irg(ir_node *node);
 
 /**
  * irnode constructor.
@@ -258,9 +259,9 @@ ir_node  *get_Block_cg_cfgpred(ir_node * node, int pos);
 /* frees the memory. */
 void      remove_Block_cg_cfgpred_arr(ir_node * node);
 
-/* Start references the irg it is in. */
+/* Start references the irg it is in.
+ @@@ old -- use get_irn_irg instead! */
 ir_graph *get_Start_irg(ir_node *node);
-void      set_Start_irg(ir_node *node, ir_graph *irg);
 
 INLINE int  get_End_n_keepalives(ir_node *end);
 INLINE ir_node *get_End_keepalive(ir_node *end, int pos);
@@ -271,8 +272,9 @@ INLINE void set_End_keepalive(ir_node *end, int pos, ir_node *ka);
    free_End frees these data structures. */
 INLINE void free_End (ir_node *end);
 
-ir_graph *get_EndReg_irg (const ir_node *end);
-ir_graph *get_EndExcept_irg  (const ir_node *end);
+/* @@@ old -- use get_irn_irg instead!  */
+ir_graph *get_EndReg_irg (ir_node *end);
+ir_graph *get_EndExcept_irg (ir_node *end);
 
 /* We distinguish three kinds of Cond nodes.  These can be distinguished
    by the mode of the selector operand and an internal flag of type cond_kind.
@@ -420,6 +422,7 @@ void    remove_Call_callee_arr(ir_node * node);
 
 ir_node  *get_CallBegin_ptr  (ir_node *node);
 void      set_CallBegin_ptr  (ir_node *node, ir_node *ptr);
+/* @@@ old -- use get_irn_irg instead!  */
 ir_graph *get_CallBegin_irg  (ir_node *node);
 ir_node  *get_CallBegin_call (ir_node *node);
 void      set_CallBegin_call (ir_node *node, ir_node *call);
@@ -725,14 +728,15 @@ INLINE int      is_Proj (const ir_node *node);
    Start, End, Jmp, Cond, Return, Raise, Bad, CallBegin, EndReg, EndExcept */
 int is_cfop(ir_node *node);
 
+/* @@@ old -- use get_irn_irg instead!  */
+ir_graph *get_ip_cfop_irg(ir_node *n);
+
 /** Returns true if the operation manipulates interprocedural control flow:
-   CallBegin, EndReg, EndExcept */
+    CallBegin, EndReg, EndExcept */
 int is_ip_cfop(ir_node *node);
 /** Returns true if the operation can change the control flow because
-   of an exception: Call, Quot, DivMod, Div, Mod, Load, Store, Alloc,
-   Bad. */
-ir_graph *get_ip_cfop_irg(ir_node *n);
-
+    of an exception: Call, Quot, DivMod, Div, Mod, Load, Store, Alloc,
+    Bad. */
 int is_fragile_op(ir_node *node);
 /** Returns the memory operand of fragile operations. */
 ir_node *get_fragile_op_mem(ir_node *node);
index 68a8340..f8c9c0d 100644 (file)
 
 /** Block attributes */
 typedef struct {
+  /* General attributes */
+  ir_graph *irg;
   unsigned long block_visited;  /**< for the walker that walks over all blocks. */
   /* Attributes private to construction: */
   bool matured;               /**< if set, all in-nodes of the block are fixed */
   struct ir_node **graph_arr; /**< array to store all parameters */
+  /* Attributes holding analyses information */
   struct dom_info dom;        /**< Datastructure that holds information about dominators.
-                                @todo
-           Eventually overlay with graph_arr as only valid
-                                  in different phases.  Eventually inline the whole
-                                  datastructure. */
-  exc_t exc;                 /**< role of this block for exception handling */
-  ir_node *handler_entry;     /**< handler entry block iff this block is part of a region */
+                                @@@ @todo
+                                Eventually overlay with graph_arr as only valid
+                                in different phases.  Eventually inline the whole
+                                datastructure. */
+  //  exc_t exc;                     /**< role of this block for exception handling */
+  //  ir_node *handler_entry;     /**< handler entry block iff this block is part of a region */
   ir_node ** in_cg;           /**< array with predecessors in
                               * interprocedural_view, if they differ
                               * from intraprocedural predecessors */
   int *backedge;              /**< Field n set to true if pred n is backedge.
-                                @todo Ev. replace by bitfield! */
+                                @@@ @todo Ev. replace by bitfield! */
   int *cg_backedge;           /**< Field n set to true if pred n is interprocedural backedge.
-                                @todo Ev. replace by bitfield! */
+                                @@@ @todo Ev. replace by bitfield! */
 } block_attr;
 
 /** Start attributes */
 typedef struct {
-  ir_graph *irg;
+  char dummy;
+  //  ir_graph *irg;   @@@ now in block
 } start_attr;
 
 /** Cond attributes */
@@ -128,14 +132,17 @@ typedef struct {
 
 /** EndReg/EndExcept attributes */
 typedef struct {
-  ir_graph * irg;            /**< ir_graph this node belongs to (for
-                             * navigating in interprocedural graphs) */
+  char dummy;
+  //  ir_graph * irg;            /**< ir_graph this node belongs to (for
+  //                              * navigating in interprocedural graphs)
+  //                             @@@ now in block */
 } end_attr;
 
 /** CallBegin attributes */
 typedef struct {
-  ir_graph * irg;            /**< ir_graph this node belongs to (for
-                             * navigating in interprocedural graphs) */
+  //  ir_graph * irg;            / **< ir_graph this node belongs to (for
+  //                         * navigating in interprocedural graphs) */
+  //                           @@@ now in block
   ir_node * call;            /**< associated Call-operation */
 } callbegin_attr;