r300/compiler: Implement the CONT opcode.
authorTom Stellard <tstellar@gmail.com>
Wed, 11 Aug 2010 16:25:45 +0000 (09:25 -0700)
committerTom Stellard <tstellar@gmail.com>
Wed, 11 Aug 2010 18:39:57 +0000 (11:39 -0700)
src/gallium/drivers/r300/r300_tgsi_to_rc.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.c
src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h

index 51b2c5555024de54919a8860a9acd3fba1c2a695..dd697b9c374b6d811d617a50844ec15395f343e6 100644 (file)
@@ -126,7 +126,7 @@ static unsigned translate_opcode(unsigned opcode)
      /* case TGSI_OPCODE_SAD: return RC_OPCODE_SAD; */
      /* case TGSI_OPCODE_TXF: return RC_OPCODE_TXF; */
      /* case TGSI_OPCODE_TXQ: return RC_OPCODE_TXQ; */
-     /* case TGSI_OPCODE_CONT: return RC_OPCODE_CONT; */
+        case TGSI_OPCODE_CONT: return RC_OPCODE_CONT;
      /* case TGSI_OPCODE_EMIT: return RC_OPCODE_EMIT; */
      /* case TGSI_OPCODE_ENDPRIM: return RC_OPCODE_ENDPRIM; */
      /* case TGSI_OPCODE_BGNLOOP2: return RC_OPCODE_BGNLOOP2; */
index c3f817ad4e8320af3d4cd4900e4ba8b924aa0e25..dfad12eb15f0f8c46b2724e1f5677729f68e91bc 100644 (file)
@@ -70,6 +70,10 @@ struct loop_info {
        int * Brks;
        int BrkCount;
        int BrkReserved;
+
+       int * Conts;
+       int ContCount;
+       int ContReserved;
 };
 
 struct emit_state {
@@ -413,15 +417,18 @@ static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst
                        ;
                break;
 
-       case RC_OPCODE_CONTINUE:
+       case RC_OPCODE_CONT:
                loop = &s->Loops[s->CurrentLoopDepth - 1];
-               s->Code->inst[newip].inst2 = R500_FC_OP_JUMP
+               memory_pool_array_reserve(&s->C->Pool, int, loop->Conts,
+                                       loop->ContCount, loop->ContReserved, 1);
+               loop->Conts[loop->ContCount++] = newip;
+               s->Code->inst[newip].inst2 = R500_FC_OP_CONTINUE
                        | R500_FC_JUMP_FUNC(0xff)
                        | R500_FC_B_OP1_DECR
                        | R500_FC_B_POP_CNT(
                                s->CurrentBranchDepth - loop->BranchDepth)
+                       | R500_FC_IGNORE_UNCOVERED
                        ;
-               s->Code->inst[newip].inst3 = R500_FC_JUMP_ADDR(loop->BgnLoop);
                break;
 
        case RC_OPCODE_ENDLOOP:
@@ -449,6 +456,12 @@ static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst
                        s->Code->inst[loop->Brks[loop->BrkCount]].inst3 =
                                                R500_FC_JUMP_ADDR(newip + 1);
                }
+
+               /* Set jump address for CONT instructions. */
+               while(loop->ContCount--) {
+                       s->Code->inst[loop->Conts[loop->ContCount]].inst3 =
+                                               R500_FC_JUMP_ADDR(newip);
+               }
                s->CurrentLoopDepth--;
                break;
        }
index 31566a937f4580c336a630908a55c40eb81ea9f3..faf531b412e29d9abd61fbe16f3f3ea36b1aeb9f 100644 (file)
@@ -274,7 +274,7 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, rc_dataflow_mark_outputs_f
                        }
                        break;
                }
-               case RC_OPCODE_CONTINUE:
+               case RC_OPCODE_CONT:
                        break;
                case RC_OPCODE_ENDIF:
                        push_branch(&s);
index 04f234f11d8cc4936a9a4f08bf0ca8a6d411dc9c..2ea830be7f9b701930432e119645e1e497b60a22 100644 (file)
@@ -386,8 +386,8 @@ struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE] = {
                .NumSrcRegs = 0,
        },
        {
-               .Opcode = RC_OPCODE_CONTINUE,
-               .Name = "CONTINUE",
+               .Opcode = RC_OPCODE_CONT,
+               .Name = "CONT",
                .IsFlowControl = 1,
                .NumSrcRegs = 0
        },
index 8b9fa07dde2c735f5247f739251eeb28791af6f8..6e18d6eb3f14cc4423acb4e57f302c5fa6fa2f4f 100644 (file)
@@ -187,7 +187,7 @@ typedef enum {
 
        RC_OPCODE_ENDLOOP,
 
-       RC_OPCODE_CONTINUE,
+       RC_OPCODE_CONT,
 
        /** special instruction, used in R300-R500 fragment program pair instructions
         * indicates that the result of the alpha operation shall be replicated