Mesa (gallium-0.1): tgsi: Keep the LOOP labels in a stack, instead of relying on ENDLOOP's labels.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Sep 2 18:04:01 UTC 2009


Module: Mesa
Branch: gallium-0.1
Commit: d4dc9733b0e5767ec15f145e4a9e9934a5e4a3fc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4dc9733b0e5767ec15f145e4a9e9934a5e4a3fc

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Sep  2 19:02:58 2009 +0100

tgsi: Keep the LOOP labels in a stack, instead of relying on ENDLOOP's labels.

---

 src/gallium/auxiliary/tgsi/tgsi_exec.c |    7 ++++++-
 src/gallium/auxiliary/tgsi/tgsi_exec.h |    4 ++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index fe38db8..7124d32 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -2855,6 +2855,8 @@ exec_instruction(
       mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
       assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
       mach->ContStack[mach->ContStackTop++] = mach->ContMask;
+      assert(mach->LoopLabelStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+      mach->LoopLabelStack[mach->LoopLabelStackTop++] = *pc - 1;
       break;
 
    case TGSI_OPCODE_ENDLOOP:
@@ -2866,7 +2868,8 @@ exec_instruction(
       UPDATE_EXEC_MASK(mach);
       if (mach->ExecMask) {
          /* repeat loop: jump to instruction just past BGNLOOP */
-         *pc = inst->InstructionExtLabel.Label + 1;
+         assert(mach->LoopLabelStackTop > 0);
+         *pc = mach->LoopLabelStack[mach->LoopLabelStackTop - 1] + 1;
       }
       else {
          /* exit loop: pop LoopMask */
@@ -2875,6 +2878,8 @@ exec_instruction(
          /* pop ContMask */
          assert(mach->ContStackTop > 0);
          mach->ContMask = mach->ContStack[--mach->ContStackTop];
+         assert(mach->LoopLabelStackTop > 0);
+         --mach->LoopLabelStackTop;
       }
       UPDATE_EXEC_MASK(mach);
       break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index fc40a25..d1ebe36 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -227,6 +227,10 @@ struct tgsi_exec_machine
    uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int LoopStackTop;
 
+   /** Loop label stack */
+   uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING];
+   int LoopLabelStackTop;
+
    /** Loop continue mask stack (see comments in tgsi_exec.c) */
    uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int ContStackTop;




More information about the mesa-commit mailing list