From 11bccb0564d9e24e50238fb257dd6f724ec31712 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 21 Mar 2020 18:42:58 -0400 Subject: [PATCH] pan/bi: Respect shift when printing immediates We allow packing multiple immediates in, but we were missing this in the print. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_print.c | 2 +- src/panfrost/bifrost/bir.c | 8 ++++++++ src/panfrost/bifrost/compiler.h | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index 73de74381cc..5f53e4b98c1 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -166,7 +166,7 @@ bi_print_index(FILE *fp, bi_instruction *ins, unsigned index) else if (index & BIR_INDEX_UNIFORM) fprintf(fp, "u%u", index & ~BIR_INDEX_UNIFORM); else if (index & BIR_INDEX_CONSTANT) - fprintf(fp, "#0x%" PRIx64, ins->constant.u64); + fprintf(fp, "#0x%" PRIx64, bi_get_immediate(ins, index)); else if (index & BIR_INDEX_ZERO) fprintf(fp, "#0"); else if (index & BIR_IS_REG) diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c index f110564aa64..cb24f459096 100644 --- a/src/panfrost/bifrost/bir.c +++ b/src/panfrost/bifrost/bir.c @@ -136,3 +136,11 @@ bi_bytemask_of_read_components(bi_instruction *ins, unsigned node) return mask; } + +uint64_t +bi_get_immediate(bi_instruction *ins, unsigned index) +{ + assert(index & BIR_INDEX_CONSTANT); + unsigned shift = index & ~BIR_INDEX_CONSTANT; + return ins->constant.u64 >> shift; +} diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index b09bd536729..b8eeb64f9ac 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -394,7 +394,7 @@ bi_remove_instruction(bi_instruction *ins) * * Fixed register: do not allocate register, do not collect $200. * Uniform: access a uniform register given by low bits. - * Constant: access the specified constant + * Constant: access the specified constant (specifies a bit offset / shift) * Zero: special cased to avoid wasting a constant * Passthrough: a bifrost_packed_src to passthrough T/T0/T1 */ @@ -537,6 +537,7 @@ uint16_t bi_from_bytemask(uint16_t bytemask, unsigned bytes); unsigned bi_get_component_count(bi_instruction *ins, unsigned s); unsigned bi_load32_components(bi_instruction *ins); uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node); +uint64_t bi_get_immediate(bi_instruction *ins, unsigned index); /* BIR passes */ -- 2.30.2