summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ast_to_hir.cpp20
-rw-r--r--glsl_parser_extras.cpp1
-rw-r--r--glsl_parser_extras.h3
3 files changed, 24 insertions, 0 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 4674cfcdd5..80489d3719 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -388,6 +388,26 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
return rhs;
}
+
+/**
+ * Generate a new temporary and add its declaration to the instruction stream
+ */
+static ir_variable *
+generate_temporary(const glsl_type *type, exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ char *name = (char *) malloc(sizeof(char) * 13);
+
+ snprintf(name, 13, "tmp_%08X", state->temp_index);
+ state->temp_index++;
+
+ ir_variable *const var = new ir_variable(type, name);
+ instructions->push_tail(var);
+
+ return var;
+}
+
+
static ir_rvalue *
get_lvalue_copy(exec_list *instructions, struct _mesa_glsl_parse_state *state,
ir_rvalue *lvalue, YYLTYPE loc)
diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp
index d57a68efb7..1ddc2ee9dd 100644
--- a/glsl_parser_extras.cpp
+++ b/glsl_parser_extras.cpp
@@ -634,6 +634,7 @@ main(int argc, char **argv)
make_empty_list(& state.translation_unit);
state.symbols = new glsl_symbol_table;
state.error = false;
+ state.temp_index = 0;
_mesa_glsl_lexer_ctor(& state, shader, shader_len);
_mesa_glsl_parse(& state);
diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h
index dbe7c17302..96c975ba11 100644
--- a/glsl_parser_extras.h
+++ b/glsl_parser_extras.h
@@ -53,6 +53,9 @@ struct _mesa_glsl_parse_state {
/** Was there an error during compilation? */
bool error;
+
+ /** Index of last generated anonymous temporary. */
+ unsigned temp_index;
};
typedef struct YYLTYPE {