summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
authorBrian <brian@nostromo.localnet.net>2007-02-06 22:31:19 -0700
committerBrian <brian@nostromo.localnet.net>2007-02-06 22:31:19 -0700
commitf22ed0986a743e033d827c78371612c7115ff913 (patch)
treec9df47eeb7033ebdc2b5b596737bd14b24f41c9d /src/mesa/shader/slang/slang_codegen.c
parent5f7d4668c4b7de1c0d2269809d30aef6d0a089e9 (diff)
Implement CONT, improve BRK.
IR_LOOP's BranchNode ptr is the head of a linked list of CONT and BRK nodes. After emitting loop, walk over the linked list, filling in the CONT/BRK instruction's BranchTarget field (location of the ENDLOOP instruction, or one past).
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index a4e2935ea8..42c1f0897e 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -608,7 +608,24 @@ new_break(slang_ir_node *loopNode)
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
if (n) {
- n->BranchNode = loopNode;
+ /* insert this node at head of linked list */
+ n->BranchNode = loopNode->BranchNode;
+ loopNode->BranchNode = n;
+ }
+ return n;
+}
+
+
+static slang_ir_node *
+new_cont(slang_ir_node *loopNode)
+{
+ slang_ir_node *n = new_node0(IR_CONT);
+ assert(loopNode);
+ assert(loopNode->Opcode == IR_LOOP);
+ if (n) {
+ /* insert this node at head of linked list */
+ n->BranchNode = loopNode->BranchNode;
+ loopNode->BranchNode = n;
}
return n;
}
@@ -2434,11 +2451,15 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return new_jump(A->CurLoopBreak);
}
case slang_oper_continue:
- if (!A->CurLoopCont) {
+ if (!A->CurLoop && !A->CurLoopCont) {
RETURN_ERROR("'continue' not in loop", 0);
}
- /* XXX emit IR_CONT instruction */
- return new_jump(A->CurLoopCont);
+ if (UseHighLevelInstructions) {
+ return new_cont(A->CurLoop);
+ }
+ else {
+ return new_jump(A->CurLoopCont);
+ }
case slang_oper_discard:
return new_node0(IR_KILL);