Lines Matching refs: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
164 ir_loop* loop;
178 this->loop = p_loop;
188 /* also supported for the "function loop" */
190 exec_list& list = this->loop ? this->loop->body_instructions : signature->body;
200 assert(this->loop);
203 this->loop->insert_before(this->break_flag);
204 this->loop->insert_before(new(this->signature) ir_assignment(new(this->signature) ir_dereference_variable(break_flag), new(this->signature) ir_constant(false)));
254 * this->loop.may_set_return_flag are updated to reflect the
274 struct loop_record loop;
332 this->loop.may_set_return_flag = true;
358 new(ctx) ir_dereference_variable(this->loop.get_break_flag()),
405 * this->loop.may_set_return_flag, because an unlowered jump
427 * this->loop.may_set_return_flag, because an unlowered return
478 assert(this->loop.loop);
480 if(ir->get_next()->is_tail_sentinel() && (this->loop.nesting_depth == 0
481 || (this->loop.nesting_depth == 1 && this->loop.in_if_at_the_end_of_the_loop)))
520 if(this->loop.nesting_depth == 0 && ir->get_next()->is_tail_sentinel())
521 this->loop.in_if_at_the_end_of_the_loop = true;
524 ++this->loop.nesting_depth;
571 * necessary by the loop or conditional that encloses it.
601 * satisfied, so we can break out of the loop.
624 * is satisfied and we can break out of the loop.
635 if(this->loop.loop) {
636 /* If we are in a loop, replace the return instruction
637 * with a break instruction, and then loop so that the
650 /* If we are not in a loop, we then proceed as we would
659 /* To lower a break, we create a break flag (if the loop
665 * the loop body from executing).
667 * The visit() function for the loop will ensure that the
668 * break flag is checked after executing the loop body.
675 * loop doesn't have one already) and replace the continue
679 * return statements that are not inside a loop, so
680 * this->loop must be initialized even outside of loops.
682 ir_variable* execute_flag = this->loop.get_execute_flag();
693 /* Let the loop run again, in case the other branch of the
805 if(ir_if_cond_deref && ir_if_cond_deref->var == this->loop.execute_flag) {
823 assert(this->loop.execute_flag);
824 ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag));
830 --this->loop.nesting_depth;
836 /* Visit the body of the loop, with a fresh data structure in
837 * this->loop so that the analysis we do here won't bleed into
840 * We assume that all code after a loop is reachable from the
841 * loop (see comments on enum jump_strength), so the
850 * The loop.may_set_return_flag portion of the ANALYSIS
854 loop_record saved_loop = this->loop;
855 this->loop = loop_record(this->function.signature, ir);
860 * loop, which are handled below.
864 /* If the loop ends in an unconditional continue, eliminate it
873 /* If the loop ends in an unconditional return, and we are
880 /* FINISHME: If the min_strength of the loop body is
882 * isn't a loop at all, since control flow always leaves the
883 * body of the loop via break or return. In principle the
884 * loop could be eliminated in this case. This optimization
889 if(this->loop.break_flag) {
894 * the loop, then at least one break was lowered, so we need
895 * to generate an if statement at the end of the loop that
899 * false for a break that happens at the end of a loop.
901 * However, if the loop already ends in a conditional or
903 * because it won't be at the end of the loop anymore.
907 ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag));
912 /* If the body of the loop may set the return flag, then at
914 * that the return flag is checked after the body of the loop is
917 if(this->loop.may_set_return_flag) {
923 * satisfies the loop.may_set_return_flag part of the
927 if(saved_loop.loop)
928 /* If this loop is nested inside another one, then the if
930 * loop if the return flag is set. Caller will lower that
942 /* In case the loop is embedded inside an if add a new return to
958 this->loop = saved_loop;
966 assert(!this->loop.loop);
975 loop_record saved_loop = this->loop;
977 this->loop = loop_record(ir);
979 assert(!this->loop.loop);
1004 this->loop = saved_loop;