From 5185a5f7d5654c9202c226015c4daeee43d9b897 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 29 Mar 2010 15:20:42 -0700 Subject: Add generate_temporary to generate an anonymous temporary --- ast_to_hir.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ast_to_hir.cpp') 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) -- cgit v1.2.3