pan/bi: Pack ld_var_addr
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 20 Mar 2020 16:16:10 +0000 (12:16 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sun, 22 Mar 2020 03:32:35 +0000 (03:32 +0000)
Choo choo.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4276>

src/panfrost/bifrost/bi_pack.c
src/panfrost/bifrost/bi_tables.c
src/panfrost/bifrost/bifrost.h
src/panfrost/bifrost/bifrost_compile.c

index 642a77ef24020a7ed1964a42eef0fd2ed361eca5..4555b53e56e7d012eca30b173ebbe1c0b811e4de 100644 (file)
@@ -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:
index 729c4800393410f1403c2cb093ee56f978534058..bdacfde6fd65e530e2d97be42087172258868ac7 100644 (file)
@@ -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,
index 4cd47ef01ab5163010f1a8ff48359c6158611a07..b0662966eab3516a52d9421ed02eca625ee8a01d 100644 (file)
@@ -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;
index 6cd97b92ba396764ef2448a8e0c1a088b37d84cd..ff1d354b49fc4dbfed2ff8a7a0c82cbfe25472f0 100644 (file)
@@ -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;