diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-12 14:16:22 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-19 03:23:07 +0000 |
commit | 9269c85578bd68169681efad0fb2a3563eb280ab (patch) | |
tree | 227c5dd4364ad12ef9b31943eeecc2b2bd66d0b3 /src | |
parent | 0c5aab626bb52670267381383c823f4fb204b3d8 (diff) |
pan/bi: Setup initial clause packing
At the moment, we just iterate the clauses in the post-RA, post-sched IR
and generate a dummy clause corresponding, passing the results to the
disassembler to verify.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4242>
Diffstat (limited to 'src')
-rw-r--r-- | src/panfrost/bifrost/bi_pack.c | 89 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost.h | 14 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 2 | ||||
-rw-r--r-- | src/panfrost/bifrost/compiler.h | 10 | ||||
-rw-r--r-- | src/panfrost/bifrost/meson.build | 1 |
5 files changed, 116 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c new file mode 100644 index 00000000000..016046bcda0 --- /dev/null +++ b/src/panfrost/bifrost/bi_pack.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2020 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "compiler.h" + +/* This file contains the final passes of the compiler. Running after + * scheduling and RA, the IR is now finalized, so we need to emit it to actual + * bits on the wire (as well as fixup branches) */ + +static uint64_t +bi_pack_header(bi_clause *clause, bi_clause *next) +{ + struct bifrost_header header = { + /* stub */ + .no_end_of_shader = (next != NULL), + }; + + uint64_t u = 0; + memcpy(&u, &header, sizeof(header)); + return u; +} + +static void +bi_pack_clause(bi_context *ctx, bi_clause *clause, bi_clause *next, + struct util_dynarray *emission) +{ + + struct bifrost_fmt1 quad_1 = { + .tag = BIFROST_FMT1_FINAL, + .header = bi_pack_header(clause, next) + }; + + util_dynarray_append(emission, struct bifrost_fmt1, quad_1); +} + +static bi_clause * +bi_next_clause(bi_context *ctx, pan_block *block, bi_clause *clause) +{ + /* Try the next clause in this block */ + if (clause->link.next != &((bi_block *) block)->clauses) + return list_first_entry(&(clause->link), bi_clause, link); + + /* Try the next block, or the one after that if it's empty, etc .*/ + pan_block *next_block = pan_next_block(block); + + bi_foreach_block_from(ctx, next_block, block) { + bi_block *blk = (bi_block *) block; + + if (!list_is_empty(&blk->clauses)) + return list_first_entry(&(blk->clauses), bi_clause, link); + } + + return NULL; +} + +void +bi_pack(bi_context *ctx, struct util_dynarray *emission) +{ + util_dynarray_init(emission, NULL); + + bi_foreach_block(ctx, _block) { + bi_block *block = (bi_block *) _block; + + bi_foreach_clause_in_block(block, clause) { + bi_clause *next = bi_next_clause(ctx, _block, clause); + bi_pack_clause(ctx, clause, next, emission); + } + } +} diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index d8a1cff089d..959c951e582 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -321,4 +321,18 @@ struct bifrost_branch { unsigned op : 5; }; +/* Clause packing */ + +struct bifrost_fmt1 { + unsigned ins_0 : 3; + unsigned tag : 5; + uint64_t ins_1 : 64; + unsigned ins_2 : 11; + uint64_t header : 45; +} __attribute__((packed)); + +#define BIFROST_FMT1_INSTRUCTIONS 0b00101 +#define BIFROST_FMT1_FINAL 0b01001 +#define BIFROST_FMT1_CONSTANTS 0b00001 + #endif diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index f25f7424409..d19cc65d786 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -865,6 +865,8 @@ bifrost_compile_shader_nir(nir_shader *nir, panfrost_program *program, unsigned bi_schedule(ctx); bi_register_allocate(ctx); bi_print_shader(ctx, stdout); + bi_pack(ctx, &program->compiled); + disassemble_bifrost(stdout, program->compiled.data, program->compiled.size, true); ralloc_free(ctx); } diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 499fa9a1363..9ff728c55a2 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -494,6 +494,12 @@ bi_next_op(bi_instruction *ins) return list_first_entry(&(ins->link), bi_instruction, link); } +static inline pan_block * +pan_next_block(pan_block *block) +{ + return list_first_entry(&(block->link), pan_block, link); +} + /* BIR manipulation */ bool bi_has_outmod(bi_instruction *ins); @@ -517,4 +523,8 @@ void bi_liveness_ins_update(uint16_t *live, bi_instruction *ins, unsigned max); void bi_invalidate_liveness(bi_context *ctx); bool bi_is_live_after(bi_context *ctx, bi_block *block, bi_instruction *start, int src); +/* Code emit */ + +void bi_pack(bi_context *ctx, struct util_dynarray *emission); + #endif diff --git a/src/panfrost/bifrost/meson.build b/src/panfrost/bifrost/meson.build index 86955267629..8f14d25005d 100644 --- a/src/panfrost/bifrost/meson.build +++ b/src/panfrost/bifrost/meson.build @@ -24,6 +24,7 @@ libpanfrost_bifrost_files = files( 'bi_liveness.c', 'bi_print.c', 'bi_opt_dce.c', + 'bi_pack.c', 'bi_ra.c', 'bi_schedule.c', 'bi_tables.c', |