[Mesa-dev] [PATCH v2 09/23] nir/print: add support for printing doubles and bitsize
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Mon Apr 4 07:35:34 UTC 2016
On 01/04/16 21:09, Jason Ekstrand wrote:
> On Thu, Mar 31, 2016 at 2:59 AM, Samuel Iglesias Gonsálvez <
> siglesias at igalia.com> wrote:
>
>> From: Connor Abbott <connor.w.abbott at intel.com>
>>
>> v2:
>> - Squash the printing doubles related patches into one patch (Sam).
>> ---
>> src/compiler/nir/nir_print.c | 17 ++++++++++++++---
>> 1 file changed, 14 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
>> index c295c19..df7ef91 100644
>> --- a/src/compiler/nir/nir_print.c
>> +++ b/src/compiler/nir/nir_print.c
>> @@ -68,7 +68,7 @@ static void
>> print_register_decl(nir_register *reg, print_state *state)
>> {
>> FILE *fp = state->fp;
>> - fprintf(fp, "decl_reg %s ", sizes[reg->num_components]);
>> + fprintf(fp, "decl_reg %s %u ", sizes[reg->num_components],
>> reg->bit_size);
>> if (reg->is_packed)
>> fprintf(fp, "(packed) ");
>> print_register(reg, state);
>> @@ -83,7 +83,8 @@ print_ssa_def(nir_ssa_def *def, print_state *state)
>> FILE *fp = state->fp;
>> if (def->name != NULL)
>> fprintf(fp, "/* %s */ ", def->name);
>> - fprintf(fp, "%s ssa_%u", sizes[def->num_components], def->index);
>> + fprintf(fp, "%s %u ssa_%u", sizes[def->num_components], def->bit_size,
>> + def->index);
>> }
>>
>> static void
>> @@ -279,6 +280,13 @@ print_constant(nir_constant *c, const struct
>> glsl_type *type, print_state *state
>> }
>> break;
>>
>> + case GLSL_TYPE_DOUBLE:
>> + for (i = 0; i < total_elems; i++) {
>> + if (i > 0) fprintf(fp, ", ");
>> + fprintf(fp, "%f", c->value.d[i]);
>> + }
>> + break;
>> +
>> case GLSL_TYPE_STRUCT:
>> for (i = 0; i < c->num_elements; i++) {
>> if (i > 0) fprintf(fp, ", ");
>> @@ -713,7 +721,10 @@ print_load_const_instr(nir_load_const_instr *instr,
>> print_state *state)
>> * and then print the float in a comment for readability.
>> */
>>
>> - fprintf(fp, "0x%08x /* %f */", instr->value.u32[i],
>> instr->value.f32[i]);
>> + if (instr->def.bit_size == 64)
>> + fprintf(fp, "0x%16lx /* %f */", instr->value.u64[i],
>> instr->value.f64[i]);
>>
>
> I think you want llx. Long is 32-bit on some 32-bit platforms but long
> long is basically always 64-bit.
>
Oh right. Actually, it should be PRIx64 macro which is defined in
inttypes.h. This is also done in prog_print.c and other parts of Mesa.
Thanks,
Sam
>
>> + else
>> + fprintf(fp, "0x%08x /* %f */", instr->value.u32[i],
>> instr->value.f32[i]);
>> }
>>
>> fprintf(fp, ")");
>> --
>> 2.5.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
More information about the mesa-dev
mailing list