From 409e4f8a49094a60354656a40cd23e38362e9a67 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 20 Mar 2020 12:16:10 -0400 Subject: [PATCH] pan/bi: Pack ld_var_addr Choo choo. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_pack.c | 33 ++++++++++++++++++++++++++ src/panfrost/bifrost/bi_tables.c | 2 +- src/panfrost/bifrost/bifrost.h | 2 ++ src/panfrost/bifrost/bifrost_compile.c | 6 +++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 642a77ef240..4555b53e56e 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -119,6 +119,8 @@ bi_assign_uniform_constant_single( return assigned; bi_foreach_src(ins, s) { + if (s == 0 && ins->type == BI_LOAD_VAR_ADDRESS) continue; + if (ins->src[s] & BIR_INDEX_CONSTANT) { /* TODO: lo/hi matching? */ uint64_t cons = ins->constant.u64; @@ -549,6 +551,36 @@ bi_pack_add_ld_ubo(bi_clause *clause, bi_instruction *ins, struct bi_registers * return bi_pack_add_2src(ins, regs, ops[components - 1]); } +static enum bifrost_ldst_type +bi_pack_ldst_type(nir_alu_type T) +{ + switch (T) { + case nir_type_float16: return BIFROST_LDST_F16; + case nir_type_float32: return BIFROST_LDST_F32; + case nir_type_int32: return BIFROST_LDST_I32; + case nir_type_uint32: return BIFROST_LDST_U32; + default: unreachable("Invalid type loaded"); + } +} + +static unsigned +bi_pack_add_ld_var_addr(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs) +{ + /* Only direct loads supported */ + assert(ins->src[0] == BIR_INDEX_CONSTANT); + + struct bifrost_ld_var_addr pack = { + .src0 = bi_get_src(ins, regs, 1, false), + .src1 = bi_get_src(ins, regs, 2, false), + .location = ins->constant.u64, + .type = bi_pack_ldst_type(ins->src_types[3]), + .op = BIFROST_ADD_OP_LD_VAR_ADDR + }; + + bi_write_data_register(clause, ins); + RETURN_PACKED(pack); +} + static unsigned bi_pack_add_atest(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs) { @@ -613,6 +645,7 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs) case BI_LOAD_VAR: return bi_pack_add_ld_vary(clause, bundle.add, regs); case BI_LOAD_VAR_ADDRESS: + return bi_pack_add_ld_var_addr(clause, bundle.add, regs); case BI_MINMAX: case BI_MOV: case BI_FMOV: diff --git a/src/panfrost/bifrost/bi_tables.c b/src/panfrost/bifrost/bi_tables.c index 729c4800393..bdacfde6fd6 100644 --- a/src/panfrost/bifrost/bi_tables.c +++ b/src/panfrost/bifrost/bi_tables.c @@ -43,7 +43,7 @@ unsigned bi_class_props[BI_NUM_CLASSES] = { [BI_LOAD_UNIFORM] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, [BI_LOAD_ATTR] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, [BI_LOAD_VAR] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_VECTOR | BI_DATA_REG_DEST, - [BI_LOAD_VAR_ADDRESS] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD, + [BI_LOAD_VAR_ADDRESS] = BI_SCHED_HI_LATENCY | BI_SCHED_ADD | BI_DATA_REG_DEST, [BI_MINMAX] = BI_GENERIC | BI_SCHED_ALL, [BI_MOV] = BI_SCHED_ALL, [BI_FMOV] = BI_MODS | BI_SCHED_ALL, diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index 4cd47ef01ab..b0662966eab 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -260,6 +260,8 @@ enum bifrost_ldst_type { BIFROST_LDST_U32 = 3 }; +#define BIFROST_ADD_OP_LD_VAR_ADDR (0x18000 >> 10) + struct bifrost_ld_var_addr { unsigned src0 : 3; unsigned src1 : 3; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 6cd97b92ba3..ff1d354b49f 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -171,6 +171,12 @@ static void bi_emit_st_vary(bi_context *ctx, nir_intrinsic_instr *instr) { bi_instruction address = bi_load(BI_LOAD_VAR_ADDRESS, instr); + address.src[1] = BIR_INDEX_REGISTER | 61; /* TODO: RA */ + address.src[2] = BIR_INDEX_REGISTER | 62; + address.src[3] = 0; + address.src_types[1] = nir_type_uint32; + address.src_types[2] = nir_type_uint32; + address.src_types[3] = nir_intrinsic_type(instr); address.dest = bi_make_temp(ctx); address.dest_type = nir_type_uint64; address.writemask = (1 << 8) - 1; -- 2.30.2