On Fri, 25 Mar 2011 12:24:09 -0700, Kenneth Graunke <[email protected]> wrote: > 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.
Nice.
> +ir_print_visitor::ir_print_visitor()
> +{
> + indentation = 0;
> + printable_names =
> + hash_table_ctor(32, hash_table_string_hash, hash_table_string_compare);
Don't you mean pointer_hash, pointer_compare here...
> +const char *
> +ir_print_visitor::unique_name(ir_variable *var)
> +{
> + /* Do we already have a name for this variable? */
> + const char *name = (const char *) hash_table_find(this->printable_names,
> var);
since you're passing a pointer?
pgp4ZPrnOtlIE.pgp
Description: PGP signature
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
