don't have new_immBlock set the current block
authorMatthias Braun <matze@braunis.de>
Fri, 12 Dec 2008 14:46:36 +0000 (14:46 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 12 Dec 2008 14:46:36 +0000 (14:46 +0000)
[r24566]

include/libfirm/ircons.h
include/libfirm/irnode.h
ir/external/read.c
ir/ir/ircons.c
ir/ir/irgraph.c

index d9d0282..dbb1aec 100644 (file)
  *    ir_node *new_immBlock (void)
  *    ----------------------------
  *
- *    Creates a new block.  Sets current_block to itself.  When a new block is
- *    created it cannot be known how many predecessors this block will have in the
- *    control flow graph. Therefore the list of inputs can not be fixed at
- *    creation.  Predecessors can be added with add_immBlock_pred (block, control flow
- *    operation).  With every added predecessor the number of inputs to Phi nodes
- *    also changes.
+ *    Creates a new block. When a new block is created it cannot be known how
+ *    many predecessors this block will have in the control flow graph.
+ *    Therefore the list of inputs can not be fixed at creation.  Predecessors
+ *    can be added with add_immBlock_pred (block, control flow operation).
+ *    With every added predecessor the number of inputs to Phi nodes also
+ *    changes.
  *
  *    The block can be completed by mature_immBlock(block) if all predecessors are
  *    known.  If several blocks are built at once, mature_immBlock can only be called
  *    Example for faulty IR construction:  (draw the graph on a paper and you'll
  *                                          get it ;-)
  *
- *      block_before_loop = new_block();
+ *      block_before_loop = new_immBlock();
+ *      set_cur_block(block_before_loop);
  *      set_value(x);
  *      mature_immBlock(block_before_loop);
  *      before2header = new_Jmp;
  *
- *      loop_header = new_block ();
+ *      loop_header = new_immBlock ();
+ *      set_cur_block(loop_header);
  *      header2body - new_Jmp();
  *
- *      loop_body = new_block ();
+ *      loop_body = new_immBlock ();
+ *      set_cur_block(loop_body);
  *      body2header = new_Jmp();
  *
  *      add_immBlock_pred(loop_header, before2header);
@@ -4389,10 +4392,9 @@ ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
  * can be added with add_immBlock_pred().  Once all predecessors are
  * added the block must be matured.
  *
- * Adds the block to the graph in current_ir_graph. Does set
- * current_block.  Can be used with automatic Phi node construction.
- * This constructor can only be used if the graph is in
- * state_building.
+ * Adds the block to the graph in current_ir_graph. Can be used with automatic
+ * Phi node construction.
+ * This constructor can only be used if the graph is in state_building.
  */
 ir_node *new_d_immBlock(dbg_info *db);
 ir_node *new_immBlock(void);
index 946e879..fa99c3f 100644 (file)
@@ -1437,6 +1437,11 @@ dbg_info *get_irn_dbg_info(const ir_node *n);
  */
 unsigned firm_default_hash(const ir_node *node);
 
+/**
+ * returns a descriptive name of a node (containing type+number)
+ */
+const char *gdb_node_helper(void *firm_object);
+
 /*@}*/ /* end of ir_node group definition */
 
 #endif
index 5cbe392..594512a 100644 (file)
@@ -1308,6 +1308,7 @@ static void create_abstract_join (ir_graph *irg, proc_t *proc, eff_t *eff)
   cond    = new_Cond (unknown);
 
   c_block   = new_immBlock ();  /* for the Phi after the branch(es) */
+  set_cur_block(c_block);
 
   ins = XMALLOCN(ir_node*, n_ins);
   for (i = 0; i < n_ins; i ++) {
@@ -1322,6 +1323,7 @@ static void create_abstract_join (ir_graph *irg, proc_t *proc, eff_t *eff)
 
     /* this also sets current_block, so the rest of the code ends up there: */
     s_block = new_immBlock ();
+    set_cur_block(s_block);
 
     add_immBlock_pred (s_block, projX);
     mature_immBlock (s_block);
@@ -1373,6 +1375,7 @@ static void create_abstract_raise (ir_graph *irg, proc_t *proc, eff_t *eff)
     ir_node *thrw  = NULL;
     eff_t *thrw_eff = NULL;
 
+       set_cur_block(b_exc);
     add_immBlock_pred (b_exc, projX);
 
     thrw_eff = find_valueid_in_proc_effects (eff->effect.raise.valref, proc);
@@ -1390,10 +1393,12 @@ static void create_abstract_raise (ir_graph *irg, proc_t *proc, eff_t *eff)
 
   /* one branch for 'non-exception' case */
   {
+       ir_node *block;
     ir_node *projX = new_Proj (cond, mode_X, 0);
-    new_immBlock ();            /* also sets current_block */
-    add_immBlock_pred (get_cur_block (), projX);
-    mature_immBlock (get_cur_block ());
+    block = new_immBlock ();
+    set_cur_block(block);
+    add_immBlock_pred (block, projX);
+    mature_immBlock (block);
     /* continue building in current_block */
   }
 
index 4479adf..48c293f 100644 (file)
@@ -2682,7 +2682,6 @@ new_d_immBlock(dbg_info *db) {
        assert(get_irg_phase_state(current_ir_graph) == phase_building);
        /* creates a new dynamic in-array as length of in is -1 */
        res = new_ir_node(db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL);
-       current_ir_graph->current_block = res;
 
        /* macroblock head */
        res->in[0] = res;
index 21f016d..d14dc66 100644 (file)
@@ -239,12 +239,14 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
 
        /*-- Nodes needed in every graph --*/
        set_irg_end_block (res, new_immBlock());
+       set_cur_block(get_irg_end_block(res));
        end               = new_End();
        set_irg_end       (res, end);
        set_irg_end_reg   (res, end);
        set_irg_end_except(res, end);
 
        start_block = new_immBlock();
+       set_cur_block(start_block);
        set_irg_start_block(res, start_block);
        set_irg_bad        (res, new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL));
        set_irg_no_mem     (res, new_ir_node(NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
@@ -278,6 +280,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
 
        /*-- Make a block to start with --*/
        first_block = new_immBlock();
+       set_cur_block(first_block);
        add_immBlock_pred(first_block, projX);
 
        res->method_execution_frequency = -1.0;
@@ -297,6 +300,7 @@ ir_graph *new_ir_graph(ir_entity *ent, int n_loc) {
 ir_graph *new_const_code_irg(void) {
        ir_graph *res;
        ir_node  *end, *start_block, *start, *projX;
+       ir_node  *body_block;
 
        res = alloc_graph();
 
@@ -329,6 +333,7 @@ ir_graph *new_const_code_irg(void) {
 
        /* -- The end block -- */
        set_irg_end_block (res, new_immBlock());
+       set_cur_block(get_irg_end_block(res));
        end = new_End();
        set_irg_end       (res, end);
        set_irg_end_reg   (res, end);
@@ -337,6 +342,7 @@ ir_graph *new_const_code_irg(void) {
 
        /* -- The start block -- */
        start_block        = new_immBlock();
+       set_cur_block(start_block);
        set_irg_start_block(res, start_block);
        set_irg_bad        (res, new_ir_node (NULL, res, start_block, op_Bad, mode_T, 0, NULL));
        set_irg_no_mem     (res, new_ir_node (NULL, res, start_block, op_NoMem, mode_M, 0, NULL));
@@ -349,8 +355,11 @@ ir_graph *new_const_code_irg(void) {
        add_immBlock_pred(start_block, projX);
        mature_immBlock  (start_block);  /* mature the start block */
 
-       add_immBlock_pred(new_immBlock(), projX);
-       mature_immBlock  (get_cur_block());   /* mature the 'body' block for expressions */
+
+       body_block = new_immBlock();
+       add_immBlock_pred(body_block, projX);
+       mature_immBlock  (body_block);   /* mature the 'body' block for expressions */
+       set_cur_block(body_block);
 
        /* Set the visited flag high enough that the blocks will never be visited. */
        set_irn_visited(get_cur_block(), -1);