summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_print_visitor.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2011-03-25 10:59:46 -0700
committerKenneth Graunke <[email protected]>2011-03-25 16:31:53 -0700
commit56ef62d9885f805bbfb2243dc860ff425d5b4d3b (patch)
tree746cd618acde71f416a5a8f3ee71860bdcbe87f8 /src/glsl/ir_print_visitor.h
parenteb0dd370945b9e3f5eb548a1a4a8184bb0e604fc (diff)
glsl: Generate readable unique names at print time.
Since GLSL IR allows multiple ir_variables to share the same name, we need to generate unique names when printing the IR. Previously, we always used %s@%p, appending the ir_variable's memory address. While this worked, it had two drawbacks: - When there aren't duplicates, the extra "@0x669a3e88" is useless and makes the code harder to read. - Real duplicates were hard to tell apart: channel_expressions@0x6699e3c8 vs. channel_expressions@0x6699ddd8 We now append @2, @3, @4, and so on, but only where necessary to distinguish duplicates. Since we only do this at print time, any performance impact is irrelevant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ir_print_visitor.h')
-rw-r--r--src/glsl/ir_print_visitor.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h
index 4feeb8c184d..c7136f11a3b 100644
--- a/src/glsl/ir_print_visitor.h
+++ b/src/glsl/ir_print_visitor.h
@@ -29,6 +29,10 @@
#include "ir.h"
#include "ir_visitor.h"
+extern "C" {
+#include "program/symbol_table.h"
+}
+
extern void _mesa_print_ir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
@@ -37,15 +41,8 @@ extern void _mesa_print_ir(exec_list *instructions,
*/
class ir_print_visitor : public ir_visitor {
public:
- ir_print_visitor()
- {
- indentation = 0;
- }
-
- virtual ~ir_print_visitor()
- {
- /* empty */
- }
+ ir_print_visitor();
+ virtual ~ir_print_visitor();
void indent(void);
@@ -77,6 +74,20 @@ public:
/*@}*/
private:
+ /**
+ * Fetch/generate a unique name for ir_variable.
+ *
+ * GLSL IR permits multiple ir_variables to share the same name. This works
+ * fine until we try to print it, when we really need a unique one.
+ */
+ const char *unique_name(ir_variable *var);
+
+ /** A mapping from ir_variable * -> unique printable names. */
+ hash_table *printable_names;
+ _mesa_symbol_table *symbols;
+
+ void *mem_ctx;
+
int indentation;
};