* 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);
* 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);
*/
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
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 ++) {
/* 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);
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);
/* 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 */
}
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;
/*-- 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));
/*-- 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;
ir_graph *new_const_code_irg(void) {
ir_graph *res;
ir_node *end, *start_block, *start, *projX;
+ ir_node *body_block;
res = alloc_graph();
/* -- 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);
/* -- 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));
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);