Lines Matching refs:loop

59 			struct loop_info * loop)
62 unsigned int loop_i = (loop->EndLoop->IP - loop->BeginLoop->IP) - 1;
63 /* +1 because the program already has one iteration of the loop. */
67 static void unroll_loop(struct radeon_compiler * c, struct loop_info * loop,
72 struct rc_instruction * first = loop->BeginLoop->Next;
73 struct rc_instruction * last = loop->EndLoop->Prev;
75 rc_remove_instruction(loop->BeginLoop);
76 rc_remove_instruction(loop->EndLoop);
186 static int try_unroll_loop(struct radeon_compiler * c, struct loop_info * loop)
199 if(rc_src_reg_is_immediate(c, loop->Cond->U.I.SrcReg[0].File,
200 loop->Cond->U.I.SrcReg[0].Index)){
201 limit = &loop->Cond->U.I.SrcReg[0];
202 counter = &loop->Cond->U.I.SrcReg[1];
204 else if(rc_src_reg_is_immediate(c, loop->Cond->U.I.SrcReg[1].File,
205 loop->Cond->U.I.SrcReg[1].Index)){
206 limit = &loop->Cond->U.I.SrcReg[1];
207 counter = &loop->Cond->U.I.SrcReg[0];
219 for(inst = c->Program.Instructions.Next; inst != loop->BeginLoop;
228 /* Determine how the counter is modified each loop */
236 for(inst = loop->BeginLoop->Next; end_loops > 0; inst = inst->Next){
244 loop->EndLoop = inst;
250 * of the loop. */
253 if(inst != loop->Brk && end_loops == 1) {
271 /* Infinite loop */
276 /* Calculate the number of iterations of this loop. Keeping this
283 * In a normal loop, if the condition is met, then loop continues, but
285 switch(loop->Cond->U.I.Opcode){
302 && iterations > loop_max_possible_iterations(c, loop)) {
308 /* Prepare loop for unrolling */
309 rc_remove_instruction(loop->Cond);
310 rc_remove_instruction(loop->If);
311 rc_remove_instruction(loop->Brk);
312 rc_remove_instruction(loop->EndIf);
314 unroll_loop(c, loop, iterations);
315 loop->EndLoop = NULL;
321 * @param loop
323 * @return 1 if all of the members of loop where set.
324 * @return 0 if there was an error and some members of loop are still NULL.
326 static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
336 memset(loop, 0, sizeof(struct loop_info));
338 loop->BeginLoop = inst;
340 for(ptr = loop->BeginLoop->Next; !loop->EndLoop; ptr = ptr->Next) {
351 /* Nested loop, skip ahead to the end. */
373 || loop->Brk){
376 loop->Brk = ptr;
377 loop->If = ptr->Prev;
378 loop->EndIf = ptr->Next;
379 switch(loop->If->Prev->U.I.Opcode){
390 loop->Cond = loop->If->Prev;
394 loop->EndLoop = ptr;
399 if (loop->BeginLoop && loop->Brk && loop->If && loop->EndIf
400 && loop->Cond && loop->EndLoop) {
407 * This function prepares a loop to be unrolled by converting it into an if
424 struct loop_info * loop;
429 loop = &s->Loops[s->LoopCount++];
431 if (!build_loop_info(s->C, loop, inst)) {
432 rc_error(s->C, "Failed to build loop info\n");
436 if(try_unroll_loop(s->C, loop)){
441 switch(loop->Cond->U.I.Opcode){
443 loop->Cond->U.I.Opcode = RC_OPCODE_SLT;
446 loop->Cond->U.I.Opcode = RC_OPCODE_SGE;
449 loop->Cond->U.I.Opcode = RC_OPCODE_SGT;
452 loop->Cond->U.I.Opcode = RC_OPCODE_SLE;
455 loop->Cond->U.I.Opcode = RC_OPCODE_SNE;
458 loop->Cond->U.I.Opcode = RC_OPCODE_SEQ;
461 rc_error(s->C, "loop->Cond is not a conditional.\n");
465 /* Prepare the loop to be emulated */
466 rc_remove_instruction(loop->Brk);
467 rc_remove_instruction(loop->EndIf);
468 rc_insert_instruction(loop->EndLoop->Prev, loop->EndIf);
492 struct loop_info loop;
498 if (build_loop_info(c, &loop, inst)) {
499 try_unroll_loop(c, &loop);