Lines Matching defs:loop
32 * 3. Replace all "break" with a single conditional one at the end of the loop
42 * Continues are lowered by adding a per-loop "execute flag", initialized to
43 * true, that when cleared inhibits all execution until the end of the loop.
46 * at the end of the loop, and trigger the unique "break".
54 * a dummy loop and using break.
86 * - It assumes it is always possible for control to flow from a loop
88 * is not true (since all execution paths through the loop might
101 * continue to the top of the innermost enclosing loop, break out
109 * continue to the top of the innermost enclosing loop, break out
116 * continue to the top of the innermost enclosing loop, break out
123 * top of the innermost enclosing loop. It can only break out of
130 * top of the innermost enclosing loop, or break out of it. It can
162 ir_loop* loop;
176 this->loop = p_loop;
186 /* also supported for the "function loop" */
188 exec_list& list = this->loop ? this->loop->body_instructions : signature->body;
198 assert(this->loop);
201 this->loop->insert_before(this->break_flag);
202 this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false), 0));
252 * this->loop.may_set_return_flag are updated to reflect the
272 struct loop_record loop;
325 this->loop.may_set_return_flag = true;
351 new(ctx) ir_dereference_variable(this->loop.get_break_flag()),
399 * this->loop.may_set_return_flag, because an unlowered jump
421 * this->loop.may_set_return_flag, because an unlowered return
472 assert(this->loop.loop);
474 if(ir->get_next()->is_tail_sentinel() && (this->loop.nesting_depth == 0
475 || (this->loop.nesting_depth == 1 && this->loop.in_if_at_the_end_of_the_loop)))
514 if(this->loop.nesting_depth == 0 && ir->get_next()->is_tail_sentinel())
515 this->loop.in_if_at_the_end_of_the_loop = true;
518 ++this->loop.nesting_depth;
543 /* Loop until we have satisfied the CONTAINED_JUMPS_LOWERED
565 * necessary by the loop or conditional that encloses it.
595 * satisfied, so we can break out of the loop.
618 * is satisfied and we can break out of the loop.
629 if(this->loop.loop) {
630 /* If we are in a loop, replace the return instruction
631 * with a break instruction, and then loop so that the
644 /* If we are not in a loop, we then proceed as we would
653 /* To lower a break, we create a break flag (if the loop
659 * the loop body from executing).
661 * The visit() function for the loop will ensure that the
662 * break flag is checked after executing the loop body.
669 * loop doesn't have one already) and replace the continue
673 * return statements that are not inside a loop, so
674 * this->loop must be initialized even outside of loops.
676 ir_variable* execute_flag = this->loop.get_execute_flag();
687 /* Let the loop run again, in case the other branch of the
799 if(ir_if_cond_deref && ir_if_cond_deref->var == this->loop.execute_flag) {
817 assert(this->loop.execute_flag);
818 ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag));
824 --this->loop.nesting_depth;
830 /* Visit the body of the loop, with a fresh data structure in
831 * this->loop so that the analysis we do here won't bleed into
834 * We assume that all code after a loop is reachable from the
835 * loop (see comments on enum jump_strength), so the
844 * The loop.may_set_return_flag portion of the ANALYSIS
848 loop_record saved_loop = this->loop;
849 this->loop = loop_record(this->function.signature, ir);
854 * loop, which are handled below.
858 /* If the loop ends in an unconditional continue, eliminate it
867 /* If the loop ends in an unconditional return, and we are
874 /* FINISHME: If the min_strength of the loop body is
876 * isn't a loop at all, since control flow always leaves the
877 * body of the loop via break or return. In principle the
878 * loop could be eliminated in this case. This optimization
883 if(this->loop.break_flag) {
888 * the loop, then at least one break was lowered, so we need
889 * to generate an if statement at the end of the loop that
893 * false for a break that happens at the end of a loop.
895 * However, if the loop already ends in a conditional or
897 * because it won't be at the end of the loop anymore.
901 ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag));
906 /* If the body of the loop may set the return flag, then at
908 * that the return flag is checked after the body of the loop is
911 if(this->loop.may_set_return_flag) {
917 * satisfies the loop.may_set_return_flag part of the
921 if(saved_loop.loop)
922 /* If this loop is nested inside another one, then the if
924 * loop if the return flag is set. Caller will lower that
939 this->loop = saved_loop;
947 assert(!this->loop.loop);
956 loop_record saved_loop = this->loop;
958 this->loop = loop_record(ir);
960 assert(!this->loop.loop);
985 this->loop = saved_loop;