From: Alyssa Rosenzweig Date: Fri, 22 Jul 2022 15:40:17 +0000 (-0400) Subject: pan/bi: Use variable src/dest for collect/split X-Git-Tag: upstream/22.3.5~3664 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c45ce309d47b688a7f5483909a091d945da52ea;p=platform%2Fupstream%2Fmesa.git pan/bi: Use variable src/dest for collect/split This avoids the nr_srcs/nr_dests setting dance, and will allow the builder to handle the required memory allocation when we switch to dynamic src/dest allocation. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/ISA.xml b/src/panfrost/bifrost/ISA.xml index 972c6eb..fd659e1 100644 --- a/src/panfrost/bifrost/ISA.xml +++ b/src/panfrost/bifrost/ISA.xml @@ -8854,9 +8854,9 @@ - + - + diff --git a/src/panfrost/bifrost/bi_opt_message_preload.c b/src/panfrost/bifrost/bi_opt_message_preload.c index c2d43a6..a1f4612 100644 --- a/src/panfrost/bifrost/bi_opt_message_preload.c +++ b/src/panfrost/bifrost/bi_opt_message_preload.c @@ -129,8 +129,8 @@ bi_opt_message_preload(bi_context *ctx) */ b.cursor = bi_before_instr(I); - bi_instr *collect = bi_collect_i32_to(&b, I->dest[0]); - collect->nr_srcs = bi_count_write_registers(I, 0); + unsigned nr = bi_count_write_registers(I, 0); + bi_instr *collect = bi_collect_i32_to(&b, I->dest[0], nr); /* The registers themselves must be preloaded at the start of * the program. Preloaded registers are coalesced, so these diff --git a/src/panfrost/bifrost/bi_opt_push_ubo.c b/src/panfrost/bifrost/bi_opt_push_ubo.c index 5d38cd0..5a37bf3 100644 --- a/src/panfrost/bifrost/bi_opt_push_ubo.c +++ b/src/panfrost/bifrost/bi_opt_push_ubo.c @@ -160,8 +160,8 @@ bi_opt_push_ubo(bi_context *ctx) /* Replace the UBO load with moves from FAU */ bi_builder b = bi_init_builder(ctx, bi_after_instr(ins)); - bi_instr *vec = bi_collect_i32_to(&b, ins->dest[0]); - vec->nr_srcs = bi_opcode_props[ins->op].sr_count; + unsigned nr = bi_opcode_props[ins->op].sr_count; + bi_instr *vec = bi_collect_i32_to(&b, ins->dest[0], nr); bi_foreach_src(vec, w) { /* FAU is grouped in pairs (2 x 4-byte) */ diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index dba542b..e05a892 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -158,8 +158,7 @@ bi_extract(bi_builder *b, bi_index vec, unsigned channel) * Bypass the cache and emit an explicit split for registers. */ if (vec.reg) { - bi_instr *I = bi_split_i32_to(b, bi_null(), vec); - I->nr_dests = channel + 1; + bi_instr *I = bi_split_i32_to(b, channel + 1, vec); I->dest[channel] = bi_temp(b->shader); return I->dest[channel]; } @@ -210,10 +209,9 @@ bi_emit_split_i32(bi_builder *b, bi_index dests[4], bi_index vec, unsigned n) if (n == 1) { bi_mov_i32_to(b, dests[0], vec); } else { - bi_instr *I = bi_split_i32_to(b, dests[0], vec); - I->nr_dests = n; + bi_instr *I = bi_split_i32_to(b, n, vec); - for (unsigned j = 1; j < n; ++j) + bi_foreach_dest(I, j) I->dest[j] = dests[j]; } } @@ -251,10 +249,9 @@ bi_emit_collect_to(bi_builder *b, bi_index dst, bi_index *chan, unsigned n) if (n == 1) return bi_mov_i32_to(b, dst, chan[0]); - bi_instr *I = bi_collect_i32_to(b, dst); - I->nr_srcs = n; + bi_instr *I = bi_collect_i32_to(b, dst, n); - for (unsigned i = 0; i < n; ++i) + bi_foreach_src(I, i) I->src[i] = chan[i]; bi_cache_collect(b, dst, chan, n); @@ -1050,10 +1047,9 @@ bi_emit_store_vary(bi_builder *b, nir_intrinsic_instr *instr) bi_emit_split_i32(b, chans, data, src_comps); bi_index tmp = bi_temp(b->shader); - bi_instr *collect = bi_collect_i32_to(b, tmp); - collect->nr_srcs = nr; + bi_instr *collect = bi_collect_i32_to(b, tmp, nr); - for (unsigned w = 0; w < nr; ++w) + bi_foreach_src(collect, w) collect->src[w] = chans[w]; data = tmp; diff --git a/src/panfrost/bifrost/test/test-message-preload.cpp b/src/panfrost/bifrost/test/test-message-preload.cpp index bbd09af..f1f0041 100644 --- a/src/panfrost/bifrost/test/test-message-preload.cpp +++ b/src/panfrost/bifrost/test/test-message-preload.cpp @@ -80,11 +80,10 @@ protected: static void preload_moves(bi_builder *b, bi_index dest, int count, int idx) { - bi_instr *I = bi_collect_i32_to(b, dest); - I->nr_srcs = count; + bi_instr *I = bi_collect_i32_to(b, dest, count); b->cursor = bi_before_block(bi_start_block(&b->shader->blocks)); - for (int i = 0; i < count; ++i) + bi_foreach_src(I, i) I->src[i] = bi_mov_i32(b, bi_register(idx*4 + i)); b->cursor = bi_after_instr(I); diff --git a/src/panfrost/bifrost/test/test-optimizer.cpp b/src/panfrost/bifrost/test/test-optimizer.cpp index b6cdc86..ccab6cb 100644 --- a/src/panfrost/bifrost/test/test-optimizer.cpp +++ b/src/panfrost/bifrost/test/test-optimizer.cpp @@ -429,8 +429,8 @@ TEST_F(Optimizer, VarTexCoord32) bi_index x = bi_temp(b->shader); bi_index y = bi_temp(b->shader); - bi_instr *split = bi_split_i32_to(b, x, ld); - split->nr_dests = 2; + bi_instr *split = bi_split_i32_to(b, 2, ld); + split->dest[0] = x; split->dest[1] = y; bi_texs_2d_f32_to(b, reg, x, y, false, 0, 0); diff --git a/src/panfrost/bifrost/valhall/va_lower_split_64bit.c b/src/panfrost/bifrost/valhall/va_lower_split_64bit.c index 849b911..3c67f3e 100644 --- a/src/panfrost/bifrost/valhall/va_lower_split_64bit.c +++ b/src/panfrost/bifrost/valhall/va_lower_split_64bit.c @@ -47,11 +47,8 @@ lower_split_src(bi_context *ctx, bi_instr *I, unsigned s) /* Allocate temporary before the instruction */ bi_builder b = bi_init_builder(ctx, bi_before_instr(I)); bi_index vec = bi_temp(ctx); - bi_instr *collect = bi_collect_i32_to(&b, vec); - collect->nr_srcs = 2; - - bi_instr *split = bi_split_i32_to(&b, bi_null(), vec); - split->nr_dests = 2; + bi_instr *collect = bi_collect_i32_to(&b, vec, 2); + bi_instr *split = bi_split_i32_to(&b, 2, vec); /* Emit collect */ for (unsigned w = 0; w < 2; ++w) {