glsl2: Add and use new variable mode ir_var_temporary

This is quite a large patch because breaking it into smaller pieces
would result in the tree being intermitently broken.  The big changes
are:

    * Add the ir_var_temporary variable mode

    * Change the ir_variable constructor to take the mode as a
      parameter and correctly specify the mode for all ir_varables.

    * Change the linker to not cross validate ir_var_temporary
      variables.

    * Change the linker to pull all ir_var_temporary variables from
      global scope into 'main'.
This commit is contained in:
Ian Romanick
2010-07-19 17:12:42 -07:00
parent 1124e5a3cb
commit 7e2aa91507
18 changed files with 109 additions and 47 deletions

View File

@@ -115,7 +115,8 @@ process_call(exec_list *instructions, ir_function *f,
var = new(ctx) ir_variable(sig->return_type,
talloc_asprintf(ctx, "%s_retval",
sig->function_name()));
sig->function_name()),
ir_var_temporary);
instructions->push_tail(var);
deref = new(ctx) ir_dereference_variable(var);
@@ -509,7 +510,8 @@ emit_inline_vector_constructor(const glsl_type *type,
assert(!parameters->is_empty());
ir_variable *var = new(ctx) ir_variable(type,
talloc_strdup(ctx, "vec_ctor"));
talloc_strdup(ctx, "vec_ctor"),
ir_var_temporary);
instructions->push_tail(var);
/* There are two kinds of vector constructors.
@@ -621,7 +623,8 @@ emit_inline_matrix_constructor(const glsl_type *type,
assert(!parameters->is_empty());
ir_variable *var = new(ctx) ir_variable(type,
talloc_strdup(ctx, "mat_ctor"));
talloc_strdup(ctx, "mat_ctor"),
ir_var_temporary);
instructions->push_tail(var);
/* There are three kinds of matrix constructors.
@@ -645,7 +648,8 @@ emit_inline_matrix_constructor(const glsl_type *type,
*/
ir_variable *rhs_var =
new(ctx) ir_variable(glsl_type::vec4_type,
talloc_strdup(ctx, "mat_ctor_vec"));
talloc_strdup(ctx, "mat_ctor_vec"),
ir_var_temporary);
instructions->push_tail(rhs_var);
ir_constant_data zero;
@@ -759,7 +763,8 @@ emit_inline_matrix_constructor(const glsl_type *type,
*/
ir_variable *const rhs_var =
new(ctx) ir_variable(first_param->type,
talloc_strdup(ctx, "mat_ctor_mat"));
talloc_strdup(ctx, "mat_ctor_mat"),
ir_var_temporary);
instructions->push_tail(rhs_var);
ir_dereference *const rhs_var_ref =
@@ -825,7 +830,8 @@ emit_inline_matrix_constructor(const glsl_type *type,
*/
ir_variable *rhs_var =
new(ctx) ir_variable(rhs->type,
talloc_strdup(ctx, "mat_ctor_vec"));
talloc_strdup(ctx, "mat_ctor_vec"),
ir_var_temporary);
instructions->push_tail(rhs_var);
ir_dereference *rhs_var_ref =
@@ -1036,7 +1042,8 @@ ast_function_expression::hir(exec_list *instructions,
continue;
/* Create a temporary containing the matrix. */
ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp");
ir_variable *var = new(ctx) ir_variable(matrix->type, "matrix_tmp",
ir_var_temporary);
instructions->push_tail(var);
instructions->push_tail(new(ctx) ir_assignment(new(ctx)
ir_dereference_variable(var), matrix, NULL));