From 86080796471df6a9e126fd536b21c3b10cb5310c Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 5 Feb 2007 17:18:10 -0700 Subject: Use IR node's BranchNode field for IF/ELSE/ENDIF instructions. This allows us to back-patch the IF/ELSE instruction's BranchTarget field to point to the location of the ELSE/ENDIF instructions. No longer have to search for ELSE/ENDIF in the interpreter. Also makes it trivial to translate IF/ELSE instructions into conditional/unconditional BRA instructions. --- src/mesa/shader/slang/slang_emit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/mesa/shader/slang/slang_emit.c') diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 311eea1e6ad..b890a6d93c2 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1036,6 +1036,7 @@ emit_not(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) free_temp_storage(vt, n->Children[0]); + inst->Comment = _mesa_strdup("NOT"); return inst; } @@ -1259,18 +1260,29 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog) inst = new_instruction(prog, OPCODE_IF); inst->DstReg.CondMask = COND_NE; /* if cond is non-zero */ inst->DstReg.CondSwizzle = SWIZZLE_X; + n->InstLocation = prog->NumInstructions - 1; return inst; } case IR_ELSE: { struct prog_instruction *inst; + n->InstLocation = prog->NumInstructions; inst = new_instruction(prog, OPCODE_ELSE); + /* point IF's BranchTarget just after this instruction */ + assert(n->BranchNode); + assert(n->BranchNode->InstLocation >= 0); + prog->Instructions[n->BranchNode->InstLocation].BranchTarget = prog->NumInstructions; return inst; } case IR_ENDIF: { struct prog_instruction *inst; + n->InstLocation = prog->NumInstructions; inst = new_instruction(prog, OPCODE_ENDIF); + /* point ELSE's BranchTarget to just after this inst */ + assert(n->BranchNode); + assert(n->BranchNode->InstLocation >= 0); + prog->Instructions[n->BranchNode->InstLocation].BranchTarget = prog->NumInstructions; return inst; } -- cgit v1.2.3