summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
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;
}