From: Alyssa Rosenzweig Date: Thu, 12 Mar 2020 18:33:32 +0000 (-0400) Subject: pan/bi: Sketch out instruction word packing X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50bce53cd0c44db531b37cb37426e3b087c788da;p=mesa.git pan/bi: Sketch out instruction word packing Instructions are 78-bits with some seriously suspicious packing requirements but hey, gotta save 'em bits. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 016046bcda0..f59440192d4 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -40,14 +40,60 @@ bi_pack_header(bi_clause *clause, bi_clause *next) return u; } +static unsigned +bi_pack_registers(bi_clause *clause, bi_bundle bundle) +{ + /* TODO */ + return 0; +} + +static unsigned +bi_pack_fma(bi_clause *clause, bi_bundle bundle) +{ + /* TODO */ + return BIFROST_FMA_NOP; +} + +static unsigned +bi_pack_add(bi_clause *clause, bi_bundle bundle) +{ + /* TODO */ + return BIFROST_ADD_NOP; +} + +struct bi_packed_bundle { + uint64_t lo; + uint64_t hi; +}; + +static struct bi_packed_bundle +bi_pack_bundle(bi_clause *clause, bi_bundle bundle) +{ + unsigned reg = bi_pack_registers(clause, bundle); + uint64_t fma = bi_pack_fma(clause, bundle); + uint64_t add = bi_pack_add(clause, bundle); + + struct bi_packed_bundle packed = { + .lo = reg | (fma << 35) | ((add & 0b111111) << 58), + .hi = add >> 6 + }; + + return packed; +} + static void bi_pack_clause(bi_context *ctx, bi_clause *clause, bi_clause *next, struct util_dynarray *emission) { - + struct bi_packed_bundle ins_1 = bi_pack_bundle(clause, clause->bundles[0]); + assert(clause->bundle_count == 1); + struct bifrost_fmt1 quad_1 = { .tag = BIFROST_FMT1_FINAL, - .header = bi_pack_header(clause, next) + .header = bi_pack_header(clause, next), + .ins_1 = ins_1.lo, + .ins_2 = ins_1.hi & ((1 << 11) - 1), + .ins_0 = (ins_1.hi >> 11) & 0b111, }; util_dynarray_append(emission, struct bifrost_fmt1, quad_1); diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 959c951e582..803abe804f9 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -323,6 +323,9 @@ struct bifrost_branch { /* Clause packing */ +#define BIFROST_FMA_NOP (0x701960) +#define BIFROST_ADD_NOP (0x3D960) + struct bifrost_fmt1 { unsigned ins_0 : 3; unsigned tag : 5;