summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-03-26 18:46:07 -0600
committerBrian <brian@yutani.localnet.net>2007-03-26 18:46:07 -0600
commit9878e8ff516486900228429f26b37cb01cd7313f (patch)
treef5c516c3ca9f8659e8790444299ea9293f52e807 /src/mesa/shader/slang/slang_codegen.c
parent6583429f89df1b6838c5405bd32e5ef30bdf163f (diff)
Checkpoint: implementing true CAL/RET instructions for subroutine calls.
Also, found/fixed a code generation regression: the emit_swizzle() function was always returning NULL. This caused emit_move() to miss its chance at peephole optimization.
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 0ca5054ead..93b6d9f854 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -468,6 +468,21 @@ new_float_literal(const float v[4], GLuint size)
return n;
}
+
+/**
+ * Inlined subroutine.
+ */
+static slang_ir_node *
+new_inlined_function_call(slang_ir_node *code, slang_label *name)
+{
+ slang_ir_node *n = new_node1(IR_FUNC, code);
+ assert(name);
+ if (n)
+ n->Label = name;
+ return n;
+}
+
+
/**
* Unconditional jump.
*/
@@ -1092,8 +1107,18 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
else {
/* non-assembly function */
inlined = slang_inline_function_call(A, fun, oper, dest);
+ if (inlined) {
+ assert(inlined->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
+ inlined->type == SLANG_OPER_SEQUENCE);
+ inlined->type = SLANG_OPER_INLINED_CALL;
+ inlined->fun = fun;
+ inlined->label = _slang_label_new((char*) fun->header.a_name);
+ }
}
+ if (!inlined)
+ return NULL;
+
/* Replace the function call with the inlined block */
slang_operation_destruct(oper);
*oper = *inlined;
@@ -2581,6 +2606,7 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return n;
}
+ case SLANG_OPER_INLINED_CALL:
case SLANG_OPER_SEQUENCE:
{
slang_ir_node *tree = NULL;
@@ -2589,6 +2615,9 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
slang_ir_node *n = _slang_gen_operation(A, &oper->children[i]);
tree = tree ? new_seq(tree, n) : n;
}
+ if (oper->type == SLANG_OPER_INLINED_CALL) {
+ tree = new_inlined_function_call(tree, oper->label);
+ }
return tree;
}