From f22ed0986a743e033d827c78371612c7115ff913 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 6 Feb 2007 22:31:19 -0700 Subject: 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). --- src/mesa/shader/slang/slang_codegen.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader/slang/slang_codegen.c') 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); -- cgit v1.2.3