steal_memory(ir_instruction *ir, void *new_ctx)
{
ir_variable *var = ir->as_variable();
+ ir_function *fn = ir->as_function();
ir_constant *constant = ir->as_constant();
if (var != NULL && var->constant_value != NULL)
steal_memory(var->constant_value, ir);
if (var != NULL && var->constant_initializer != NULL)
steal_memory(var->constant_initializer, ir);
+ if (fn != NULL && fn->subroutine_types)
+ ralloc_steal(new_ctx, fn->subroutine_types);
+
/* The components of aggregate constants are not visited by the normal
* visitor, so steal their values by hand.
*/
* List of ir_function_signature for each overloaded function with this name.
*/
struct exec_list signatures;
+
+ /**
+ * is this function a subroutine type declaration
+ * e.g. subroutine void type1(float arg1);
+ */
+ bool is_subroutine;
+
+ /**
+ * is this function associated to a subroutine type
+ * e.g. subroutine (type1, type2) function_name { function_body };
+ * would have num_subroutine_types 2,
+ * and pointers to the type1 and type2 types.
+ */
+ int num_subroutine_types;
+ const struct glsl_type **subroutine_types;
};
inline const char *ir_function_signature::function_name() const
{
ir_function *copy = new(mem_ctx) ir_function(this->name);
+ copy->is_subroutine = this->is_subroutine;
+ copy->num_subroutine_types = this->num_subroutine_types;
+ copy->subroutine_types = ralloc_array(mem_ctx, const struct glsl_type *, copy->num_subroutine_types);
+ for (int i = 0; i < copy->num_subroutine_types; i++)
+ copy->subroutine_types[i] = this->subroutine_types[i];
+
foreach_in_list(const ir_function_signature, sig, &this->signatures) {
ir_function_signature *sig_copy = sig->clone(mem_ctx, ht);
copy->add_signature(sig_copy);
void ir_print_visitor::visit(ir_function *ir)
{
- fprintf(f, "(function %s\n", ir->name);
+ fprintf(f, "(%s function %s\n", ir->is_subroutine ? "subroutine" : "", ir->name);
indentation++;
foreach_in_list(ir_function_signature, sig, &ir->signatures) {
indent();