FreeBSD/contrib/gcc/cp/cp-gimplify.c
/* Build a generic representation of one of the C loop forms.  COND is the
   loop condition or NULL_TREE.  BODY is the (possibly compound) statement
   controlled by the loop.  INCR is the increment expression of a for-loop,
   or NULL_TREE.  COND_IS_FIRST indicates whether the condition is
   evaluated before the loop body as in while and for loops, or after the
   loop body as in do-while loops.  */
Build a generic representation of one of the C loop forms.  COND is the
loop condition or NULL_TREE.  BODY is the (possibly compound) statement
controlled by the loop.  INCR is the increment expression of a for-loop,
or NULL_TREE.  COND_IS_FIRST indicates whether the condition is
evaluated before the loop body as in while and for loops, or after the
loop body as in do-while loops.
Build a generic representation of one of the C loop forms . COND is the loop condition or NULL_TREE . BODY is the ( possibly compound ) statement controlled by the loop . INCR is the increment expression of a for - loop or NULL_TREE . COND_IS_FIRST indicates whether the condition is evaluated before the loop body as in while and for loops or after the loop body as in do - while loops .
static tree
 \
gimplify_cp_loop (tree cond, tree body, tree incr, tree attrs,
		  bool cond_is_first, tree inner_foreach)
 \
{
  tree top, entry, exit, cont_block, break_block, stmt_list, t;
  location_t stmt_locus;
  stmt_locus = input_location;
  stmt_list = NULL_TREE;
  entry = NULL_TREE;
  if (inner_foreach == integer_zero_node)
    {
      cont_block = begin_bc_block (bc_continue);
      break_block = begin_bc_block (bc_break);
    }
  else
    {
      break_block = begin_bc_block (bc_break);
      cont_block = begin_bc_block (bc_continue);
    }
  if (cond && integer_zerop (cond))
    {
      top = NULL_TREE;
      exit = NULL_TREE;
      if (cond_is_first)
	{
	  t = build_bc_goto (bc_break);
	  append_to_statement_list (t, &stmt_list);
	}
    }
  else
    {
      top = build1 (LABEL_EXPR, void_type_node, NULL_TREE);
      exit = build_and_jump (&LABEL_EXPR_LABEL (top));
 \
      decl_attributes (&LABEL_EXPR_LABEL (top), attrs, 0);
 \
      if (cond && !integer_nonzerop (cond))
	{
	  t = build_bc_goto (bc_break);
	  exit = fold_build3 (COND_EXPR, void_type_node, cond, exit, t);
	  gimplify_stmt (&exit);
	  if (cond_is_first)
	    {
	      if (incr)
		{
		  entry = build1 (LABEL_EXPR, void_type_node, NULL_TREE);
		  t = build_and_jump (&LABEL_EXPR_LABEL (entry));
		}
	      else
		t = build_bc_goto (bc_continue);
	      append_to_statement_list (t, &stmt_list);
	    }
	}
    }
  t = NULL_TREE;
  gimplify_stmt (&body);
  gimplify_stmt (&incr);
  body = finish_bc_block (bc_continue, cont_block, body);
  append_to_statement_list (top, &stmt_list);
  append_to_statement_list (body, &stmt_list);
  append_to_statement_list (incr, &stmt_list);
  append_to_statement_list (entry, &stmt_list);
  append_to_statement_list (exit, &stmt_list);
  annotate_all_with_locus (&stmt_list, stmt_locus);
  return finish_bc_block (bc_break, break_block, stmt_list);
}
static tree gimplify_cp_loop ( tree cond , tree body , tree incr , tree attrs , bool cond_is_first , tree inner_foreach ) { tree top , entry , exit , cont_block , break_block , stmt_list , t ; location_t stmt_locus ; stmt_locus = input_location ; stmt_list = NULL_TREE ; entry = NULL_TREE ; if ( inner_foreach == integer_zero_node ) { cont_block = begin_bc_block ( bc_continue ) ; break_block = begin_bc_block ( bc_break ) ; } else { break_block = begin_bc_block ( bc_break ) ; cont_block = begin_bc_block ( bc_continue ) ; } if ( cond && integer_zerop ( cond ) ) { top = NULL_TREE ; exit = NULL_TREE ; if ( cond_is_first ) { t = build_bc_goto ( bc_break ) ; append_to_statement_list ( t , & stmt_list ) ; } } else { top = build1 ( LABEL_EXPR , void_type_node , NULL_TREE ) ; exit = build_and_jump ( & LABEL_EXPR_LABEL ( top ) ) ; decl_attributes ( & LABEL_EXPR_LABEL ( top ) , attrs , 0 ) ; if ( cond && ! integer_nonzerop ( cond ) ) { t = build_bc_goto ( bc_break ) ; exit = fold_build3 ( COND_EXPR , void_type_node , cond , exit , t ) ; gimplify_stmt ( & exit ) ; if ( cond_is_first ) { if ( incr ) { entry = build1 ( LABEL_EXPR , void_type_node , NULL_TREE ) ; t = build_and_jump ( & LABEL_EXPR_LABEL ( entry ) ) ; } else t = build_bc_goto ( bc_continue ) ; append_to_statement_list ( t , & stmt_list ) ; } } } t = NULL_TREE ; gimplify_stmt ( & body ) ; gimplify_stmt ( & incr ) ; body = finish_bc_block ( bc_continue , cont_block , body ) ; append_to_statement_list ( top , & stmt_list ) ; append_to_statement_list ( body , & stmt_list ) ; append_to_statement_list ( incr , & stmt_list ) ; append_to_statement_list ( entry , & stmt_list ) ; append_to_statement_list ( exit , & stmt_list ) ; annotate_all_with_locus ( & stmt_list , stmt_locus ) ; return finish_bc_block ( bc_break , break_block , stmt_list ) ; }
Build a generic representation of one of the C loop forms.
Build a generic representation of one of the C loop forms .
/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ /* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ /* APPLE LOCAL begin C* language */ /* Order of label addition to stack is important for objc's foreach-stmt. */ /* APPLE LOCAL radar 4667060 */ /* APPLE LOCAL end C* language */ /* If condition is zero don't generate a loop construct.  */ /* If we use a LOOP_EXPR here, we have to feed the whole thing
	 back through the main gimplifier to lower it.  Given that we
	 have to gimplify the loop body NOW so that we can resolve
	 break/continue stmts, seems easier to just expand to gotos.  */ /* If we have an exit condition, then we build an IF with gotos either
	 out of the loop, or to the top of it.  If there's no exit condition,
	 then we just build a jump back to the top.  */ /* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ /* Add the attributes to the 'top' label.  */ /* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ /* APPLE LOCAL begin radar 4547045 */ /* Pop foreach's inner loop break label so outer loop's
     break label becomes target of inner loop body's break statements.
  */ /* APPLE LOCAL begin radar 4547045 */ /* Push back inner loop's own 'break' label so rest
     of code works seemlessly. */ /* APPLE LOCAL radar 4667060 */