aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-02-05 11:28:15 -0700
committerBrian <[email protected]>2007-02-05 11:28:15 -0700
commit01001d80e26143ac768115ccb2266db2b24d4fa0 (patch)
tree193823bef28d0fb428e7ad42317811ed4116316a /src/mesa/shader/slang
parentdd34fe8679fa200e55cfaf8e80bbecdecea084e3 (diff)
Initial support of loop and subroutine instructions.
New high-level flow-control instructions, both at IR level and GPU instructions for looping and subroutines.
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c5
-rw-r--r--src/mesa/shader/slang/slang_emit.c29
-rw-r--r--src/mesa/shader/slang/slang_ir.h23
3 files changed, 49 insertions, 8 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 6b7df0597b6..72f58a9ebd1 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1463,7 +1463,7 @@ _slang_gen_for(slang_assemble_ctx * A, const slang_operation *oper)
/**
- * Generate IR tree for an if/then/else conditional.
+ * Generate IR tree for an if/then/else conditional using BRAnch instructions.
*/
static slang_ir_node *
_slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
@@ -1513,7 +1513,8 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
/**
- * Use high-level IF/ELSE/ENDIF instructions
+ * Generate IR tree for an if/then/else conditional using high-level
+ * IF/ELSE/ENDIF instructions
*/
static slang_ir_node *
_slang_gen_if2(slang_assemble_ctx * A, const slang_operation *oper)
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 01fb5a41da7..756bbe95879 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -297,6 +297,32 @@ slang_print_ir(const slang_ir_node *n, int indent)
printf("ENDIF\n");
break;
+ case IR_BEGIN_SUB:
+ printf("BEGIN_SUB\n");
+ break;
+ case IR_END_SUB:
+ printf("END_SUB\n");
+ break;
+ case IR_RETURN:
+ printf("RETURN\n");
+ break;
+ case IR_CALL:
+ printf("CALL\n");
+ break;
+
+ case IR_BEGIN_LOOP:
+ printf("BEGIN_LOOP\n");
+ break;
+ case IR_END_LOOP:
+ printf("END_LOOP\n");
+ break;
+ case IR_CONT:
+ printf("CONT\n");
+ break;
+ case IR_BREAK:
+ printf("BREAK\n");
+ break;
+
case IR_VAR:
printf("VAR %s%s at %s store %p\n",
(n->Var ? (char *) n->Var->a_name : "TEMP"),
@@ -313,9 +339,6 @@ slang_print_ir(const slang_ir_node *n, int indent)
printf("FIELD %s of\n", n->Target);
slang_print_ir(n->Children[0], indent+3);
break;
- case IR_CALL:
- printf("ASMCALL %s(%d args)\n", n->Target, 0/*XXX*/);
- break;
case IR_FLOAT:
printf("FLOAT %f %f %f %f\n",
n->Value[0], n->Value[1], n->Value[2], n->Value[3]);
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index 5fd72be36a0..ac1ea4dbb4a 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -46,15 +46,27 @@ typedef enum
IR_NOP = 0,
IR_SEQ, /* sequence (eval left, then right) */
IR_SCOPE, /* new variable scope (one child) */
+
IR_LABEL, /* target of a jump or cjump */
IR_JUMP, /* unconditional jump */
IR_CJUMP0, /* conditional jump if zero */
IR_CJUMP1, /* conditional jump if one (or non-zero) */
- IR_COND, /* conditional expression */
+ IR_COND, /* conditional expression/predicate */
+
IR_IF, /* high-level IF */
IR_ELSE, /* high-level ELSE */
IR_ENDIF, /* high-level ENDIF */
- IR_CALL, /* call subroutine */
+
+ IR_BEGIN_SUB, /* begin subroutine */
+ IR_END_SUB, /* end subroutine */
+ IR_RETURN, /* return from subroutine */
+ IR_CALL, /* call subroutine */
+
+ IR_BEGIN_LOOP,/* begin loop */
+ IR_END_LOOP, /* end loop */
+ IR_CONT, /* continue loop */
+ IR_BREAK, /* break loop */
+
IR_MOVE,
IR_ADD,
IR_SUB,
@@ -90,17 +102,22 @@ typedef enum
IR_NOISE3, /* noise(x, y, z) */
IR_NOISE4, /* noise(x, y, z, w) */
IR_NOT, /* logical not */
+
IR_VAR, /* variable reference */
IR_VAR_DECL,/* var declaration */
+
IR_ELEMENT, /* array element */
+ IR_FIELD, /* struct field */
IR_SWIZZLE, /* swizzled storage access */
+
IR_TEX, /* texture lookup */
IR_TEXB, /* texture lookup with LOD bias */
IR_TEXP, /* texture lookup with projection */
+
IR_FLOAT,
- IR_FIELD,
IR_I_TO_F, /* int[4] to float[4] conversion */
IR_F_TO_I, /* float[4] to int[4] conversion */
+
IR_KILL /* fragment kill/discard */
} slang_ir_opcode;