summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_emit.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-02-05 17:18:10 -0700
committerBrian <[email protected]>2007-02-05 17:18:10 -0700
commit86080796471df6a9e126fd536b21c3b10cb5310c (patch)
tree26d7c96f3aa66061aacf5c9ca68f1a073b685f93 /src/mesa/shader/slang/slang_emit.c
parentd9731b26e759671d63e357eee2c921e90448ada2 (diff)
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.
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r--src/mesa/shader/slang/slang_emit.c12
1 files changed, 12 insertions, 0 deletions
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;
}