pan/midgard: Use address analysis for globals, etc
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 27 Feb 2020 14:41:17 +0000 (09:41 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 27 Feb 2020 21:02:35 +0000 (21:02 +0000)
..instead of opencoding for constants and doing the rest as ALU.

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

src/panfrost/Makefile.sources
src/panfrost/midgard/compiler.h
src/panfrost/midgard/meson.build
src/panfrost/midgard/midgard_compile.c

index b7314645c1c2e0284c241ddb9bcfedc85fb7856b..ceecb52b1fce02cbfb16766d270da0484b592371 100644 (file)
@@ -29,6 +29,7 @@ midgard_FILES := \
         midgard/disassemble.c \
         midgard/disassemble.h \
         midgard/helpers.h \
+        midgard/midgard_address.c \
         midgard/midgard_compile.c \
         midgard/midgard_compile.h \
         midgard/midgard_derivatives.c \
index ca7d2c708cad3d3d1074bab5ad60b8ca960dd80e..8ee99ab35491903cc5feca5d4e1f2acf356144e4 100644 (file)
@@ -574,6 +574,8 @@ void mir_insert_instruction_after_scheduled(compiler_context *ctx, midgard_block
 void mir_flip(midgard_instruction *ins);
 void mir_compute_temp_count(compiler_context *ctx);
 
+void mir_set_offset(compiler_context *ctx, midgard_instruction *ins, nir_src *offset, bool is_shared);
+
 /* 'Intrinsic' move for aliasing */
 
 static inline midgard_instruction
index ddc6ad3c6398a08ff8bf2853ec47dbbbd22f08b6..af2c09d59020174c57b4eadd097b4f866118e053 100644 (file)
@@ -22,6 +22,7 @@
 libpanfrost_midgard_files = files(
   'midgard_compile.c',
   'mir.c',
+  'midgard_address.c',
   'midgard_print.c',
   'midgard_schedule.c',
   'midgard_derivatives.c',
index 179902fd9935cc5fa8b950f1f30114d09690dc61..eb50e215d9e6f2190c37547ef55484bff96d63af 100644 (file)
@@ -1265,8 +1265,7 @@ emit_global(
         nir_instr *instr,
         bool is_read,
         unsigned srcdest,
-        unsigned offset,
-        nir_src *indirect_offset,
+        nir_src *offset,
         bool is_shared)
 {
         /* TODO: types */
@@ -1278,31 +1277,7 @@ emit_global(
         else
                 ins = m_st_int4(srcdest, 0);
 
-        ins.constants.u32[0] = offset;
-
-        /* The source array:
-         *
-         *  src[0] = store ? value : unused
-         *  src[1] = arg_1
-         *  src[2] = arg_2
-         *
-         * We would like arg_1 = the address and
-         * arg_2 = the offset. For shareds, there is no address and we use a
-         * magic number instead.
-         */
-
-        /* TODO: What is this? */
-        ins.load_store.arg_1 = is_shared ?
-                indirect_offset ? 0xEE : 0x6E :
-                0x7E;
-
-        assert(indirect_offset || is_shared); /* is_global => indirect */
-
-        if (indirect_offset)
-                ins.src[2] = nir_src_index(ctx, indirect_offset);
-        else
-                ins.load_store.arg_2 = 0x1E;
-
+        mir_set_offset(ctx, &ins, offset, is_shared);
         mir_set_intr_mask(instr, &ins, is_read);
 
         emit_mir_instruction(ctx, ins);
@@ -1593,7 +1568,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
                         uint32_t uindex = nir_src_as_uint(index) + 1;
                         emit_ubo_read(ctx, &instr->instr, reg, offset, indirect_offset, 0, uindex);
                 } else if (is_global || is_shared) {
-                        emit_global(ctx, &instr->instr, true, reg, offset, indirect_offset, is_shared);
+                        emit_global(ctx, &instr->instr, true, reg, src_offset, is_shared);
                 } else if (ctx->stage == MESA_SHADER_FRAGMENT && !ctx->is_blend) {
                         emit_varying_read(ctx, reg, offset, nr_comp, component, indirect_offset, t, is_flat);
                 } else if (ctx->is_blend) {
@@ -1790,15 +1765,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
                 reg = nir_src_index(ctx, &instr->src[0]);
                 emit_explicit_constant(ctx, reg, reg);
 
-                nir_src *indirect_offset = &instr->src[1];
-                unsigned offset = 0;
-
-                if (nir_src_is_const(*indirect_offset)) {
-                        offset = nir_src_as_uint(*indirect_offset);
-                        indirect_offset = NULL;
-                }
-
-                emit_global(ctx, &instr->instr, false, reg, offset, indirect_offset, instr->intrinsic == nir_intrinsic_store_shared);
+                emit_global(ctx, &instr->instr, false, reg, &instr->src[1], instr->intrinsic == nir_intrinsic_store_shared);
                 break;
 
         case nir_intrinsic_load_ssbo_address: