panfrost/midgard: Implement load/store scratch opcodes
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 19 Jul 2019 14:50:48 +0000 (07:50 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 22 Jul 2019 15:20:34 +0000 (08:20 -0700)
These are used to load/store from Thread Local Storage, which is memory
allocated per-thread (corresponding to ctx->scratchpad in the command
stream) and used for register spilling.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/helpers.h
src/panfrost/midgard/midgard_ra.c
src/panfrost/midgard/midgard_schedule.c

index 3a8732657e5f87685f44e7be37b1d170dca0f9a7..2af902dbe7150b2809f8a070d80c51c53c7ad77f 100644 (file)
@@ -416,6 +416,9 @@ v_mov(unsigned src, midgard_vector_alu_src mod, unsigned dest)
         return ins;
 }
 
+midgard_instruction
+v_load_store_scratch(unsigned srcdest, unsigned index, bool is_store);
+
 /* Scheduling */
 
 void schedule_program(compiler_context *ctx);
index 13b868b1739b11351db0bb242a71c279f6b64335..2e59025aed4adaf74dec3404f2012a1c50f16578 100644 (file)
 
 #define OP_IS_STORE_VARY(op) (\
                op == midgard_op_st_vary_16 || \
-               op == midgard_op_st_vary_32 \
+               op == midgard_op_st_vary_32 || \
+                op == midgard_op_st_vary_32u || \
+               op == midgard_op_st_vary_32i \
        )
 
+#define OP_IS_STORE_R26(op) (\
+                OP_IS_STORE_VARY(op) || \
+                op == midgard_op_st_char || \
+                op == midgard_op_st_char2 || \
+                op == midgard_op_st_char4 || \
+                op == midgard_op_st_short4 || \
+                op == midgard_op_st_int4 \
+        )
+
 #define OP_IS_STORE(op) (\
                 OP_IS_STORE_VARY(op) || \
                 op == midgard_op_st_cubemap_coords \
index 1505022f4515d9d6e6a768b54c46de5c335c3077..cb895794845fbfccb192f1b5fd907ebff496c2bb 100644 (file)
@@ -445,7 +445,7 @@ install_registers_instr(
         }
 
         case TAG_LOAD_STORE_4: {
-                if (OP_IS_STORE_VARY(ins->load_store.op)) {
+                if (OP_IS_STORE_R26(ins->load_store.op)) {
                         /* TODO: use ssa_args for st_vary */
                         ins->load_store.reg = 0;
                 } else {
index 97e06d743faddbad5d7b66b6049fb88c6d2bcdee..db87ab65f7f78f831f7fe24dfffb18b9873cc346 100644 (file)
@@ -575,7 +575,43 @@ midgard_pair_load_store(compiler_context *ctx, midgard_block *block)
         }
 }
 
+midgard_instruction
+v_load_store_scratch(unsigned srcdest, unsigned index, bool is_store)
+{
+        /* We index by 32-bit vec4s */
+        unsigned byte = (index * 4 * 4);
+
+        midgard_instruction ins = {
+                .type = TAG_LOAD_STORE_4,
+                .mask = 0xF,
+                .ssa_args = {
+                        .dest = -1,
+                        .src0 = -1,
+                        .src1 = -1
+                },
+                .load_store = {
+                        .op = is_store ? midgard_op_st_int4 : midgard_op_ld_int4,
+                        .swizzle = SWIZZLE_XYZW,
+
+                        /* For register spilling - to thread local storage */
+                        .unknown = 0x1EEA,
+
+                        /* Splattered across, TODO combine logically */
+                        .varying_parameters = (byte & 0x1FF) << 1,
+                        .address = (byte >> 9)
+                }
+        };
+
+        if (is_store) {
+                /* r0 = r26, r1 = r27 */
+                assert(srcdest == 26 || srcdest == 27);
+                ins.ssa_args.src0 = SSA_FIXED_REGISTER(srcdest - 26);
+        } else {
+                ins.ssa_args.dest = srcdest;
+        }
 
+        return ins;
+}
 
 void
 schedule_program(compiler_context *ctx)