glsl: Generate readable unique names at print time.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 25 Mar 2011 17:59:46 +0000 (10:59 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 25 Mar 2011 23:31:53 +0000 (16:31 -0700)
commit56ef62d9885f805bbfb2243dc860ff425d5b4d3b
tree746cd618acde71f416a5a8f3ee71860bdcbe87f8
parenteb0dd370945b9e3f5eb548a1a4a8184bb0e604fc
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 <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <idr@freedesktop.org>
src/glsl/ir_print_visitor.cpp
src/glsl/ir_print_visitor.h