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
276 struct loop_record loop;
334 this->loop.may_set_return_flag = true;
360 new(ctx) ir_dereference_variable(this->loop.get_break_flag()),
407 * this->loop.may_set_return_flag, because an unlowered jump
429 * this->loop.may_set_return_flag, because an unlowered return
480 assert(this->loop.loop);
482 if(ir->get_next()->is_tail_sentinel() && (this->loop.nesting_depth == 0
483 || (this->loop.nesting_depth == 1 && this->loop.in_if_at_the_end_of_the_loop)))
522 if(this->loop.nesting_depth == 0 && ir->get_next()->is_tail_sentinel())
523 this->loop.in_if_at_the_end_of_the_loop = true;
526 ++this->loop.nesting_depth;
573 * necessary by the loop or conditional that encloses it.
603 * satisfied, so we can break out of the loop.
626 * is satisfied and we can break out of the loop.
637 if(this->loop.loop) {
638 /* If we are in a loop, replace the return instruction
639 * with a break instruction, and then loop so that the
652 /* If we are not in a loop, we then proceed as we would
661 /* To lower a break, we create a break flag (if the loop
667 * the loop body from executing).
669 * The visit() function for the loop will ensure that the
670 * break flag is checked after executing the loop body.
677 * loop doesn't have one already) and replace the continue
681 * return statements that are not inside a loop, so
682 * this->loop must be initialized even outside of loops.
684 ir_variable* execute_flag = this->loop.get_execute_flag();
695 /* Let the loop run again, in case the other branch of the
807 if(ir_if_cond_deref && ir_if_cond_deref->var == this->loop.execute_flag) {
825 assert(this->loop.execute_flag);
826 ir_if* if_execute = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.execute_flag));
832 --this->loop.nesting_depth;
838 /* Visit the body of the loop, with a fresh data structure in
839 * this->loop so that the analysis we do here won't bleed into
842 * We assume that all code after a loop is reachable from the
843 * loop (see comments on enum jump_strength), so the
852 * The loop.may_set_return_flag portion of the ANALYSIS
856 loop_record saved_loop = this->loop;
857 this->loop = loop_record(this->function.signature, ir);
862 * loop, which are handled below.
866 /* If the loop ends in an unconditional continue, eliminate it
875 /* If the loop ends in an unconditional return, and we are
882 /* FINISHME: If the min_strength of the loop body is
884 * isn't a loop at all, since control flow always leaves the
885 * body of the loop via break or return. In principle the
886 * loop could be eliminated in this case. This optimization
891 if(this->loop.break_flag) {
896 * the loop, then at least one break was lowered, so we need
897 * to generate an if statement at the end of the loop that
901 * false for a break that happens at the end of a loop.
903 * However, if the loop already ends in a conditional or
905 * because it won't be at the end of the loop anymore.
909 ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->loop.break_flag));
914 /* If the body of the loop may set the return flag, then at
916 * that the return flag is checked after the body of the loop is
919 if(this->loop.may_set_return_flag) {
925 * satisfies the loop.may_set_return_flag part of the
929 if(saved_loop.loop)
930 /* If this loop is nested inside another one, then the if
932 * loop if the return flag is set. Caller will lower that
944 /* In case the loop is embedded inside an if add a new return to
960 this->loop = saved_loop;
968 assert(!this->loop.loop);
977 loop_record saved_loop = this->loop;
979 this->loop = loop_record(ir);
981 assert(!this->loop.loop);
1006 this->loop = saved_loop;