From: Alyssa Rosenzweig Date: Thu, 28 May 2020 16:39:42 +0000 (-0400) Subject: pan/bi: Preliminary branch packing X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c329567508836b5b40cfbacf29a840e1e6d4c41;p=mesa.git pan/bi: Preliminary branch packing Simple == 0 branch packing. Offset is still to-do. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index b5cbc5fa948..7366b16c6c6 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -1619,6 +1619,40 @@ bi_pack_add_imath(bi_instruction *ins, bi_registers *regs) return bi_pack_add_2src(ins, regs, op); } +static unsigned +bi_pack_add_branch(bi_instruction *ins, bi_registers *regs) +{ + assert(ins->cond == BI_COND_EQ); + assert(ins->src[1] == BIR_INDEX_ZERO); + + unsigned zero_ctrl = 0; + unsigned size = nir_alu_type_get_type_size(ins->src_types[0]); + + if (size == 16) { + /* See BR_SIZE_ZERO swizzle disassembly */ + zero_ctrl = ins->swizzle[0][0] ? 1 : 2; + } else { + assert(size == 32); + } + + /* EQ swap to NE */ + bool port_swapped = false; + + /* We assigned the constant port to fetch the branch offset so we can + * just passthrough here. We put in the HI slot to match the blob since + * that's where the magic flags end up */ + struct bifrost_branch pack = { + .src0 = bi_get_src(ins, regs, 0), + .src1 = (zero_ctrl << 1) | !port_swapped, + .src2 = BIFROST_SRC_CONST_HI, + .cond = BR_COND_EQ, + .size = BR_SIZE_ZERO, + .op = BIFROST_ADD_OP_BRANCH + }; + + RETURN_PACKED(pack); +} + static unsigned bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_stage stage) { @@ -1631,7 +1665,7 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, bi_registers *regs, gl_shader_s case BI_ATEST: return bi_pack_add_atest(clause, bundle.add, regs); case BI_BRANCH: - unreachable("Packing todo"); + return bi_pack_add_branch(bundle.add, regs); case BI_CMP: return bi_pack_add_cmp(bundle.add, regs); case BI_BLEND: diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 9ccc30bd8b7..fa07b749e5e 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -734,6 +734,8 @@ enum bifrost_branch_code { BR_ALWAYS = 63, }; +#define BIFROST_ADD_OP_BRANCH (0x0d000 >> 12) + struct bifrost_branch { unsigned src0 : 3;