pan/bi: Introduce segments into the IR
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 31 Jul 2020 21:29:50 +0000 (17:29 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 16 Sep 2020 20:05:34 +0000 (20:05 +0000)
Needed to select between global, UBO, TLS, and WLS addressing modes,
required to implement loads/stores correctly.

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

src/panfrost/bifrost/bi_print.c
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h
src/panfrost/bifrost/test/bi_test_pack.c

index dcb22df..88d2c1e 100644 (file)
 #include "bi_print.h"
 #include "bi_print_common.h"
 
+static const char *
+bi_segment_name(enum bi_segment seg)
+{
+        switch (seg) {
+        case BI_SEGMENT_NONE: return "global";
+        case BI_SEGMENT_WLS:  return "wls";
+        case BI_SEGMENT_UBO:  return "ubo";
+        case BI_SEGMENT_TLS:  return "tls";
+        default: return "invalid";
+        }
+}
+
 const char *
 bi_class_name(enum bi_class cl)
 {
@@ -275,6 +287,9 @@ bi_print_instruction(bi_instruction *ins, FILE *fp)
         if (ins->vector_channels)
                 fprintf(fp, ".v%u", ins->vector_channels);
 
+        if (ins->segment)
+                fprintf(fp, ".%s", bi_segment_name(ins->segment));
+
         if (ins->dest)
                 pan_print_alu_type(ins->dest_type, fp);
 
index d4acad7..2c017ce 100644 (file)
@@ -230,6 +230,7 @@ bi_emit_ld_uniform(bi_context *ctx, nir_intrinsic_instr *instr)
 {
         bi_instruction ld = bi_load(BI_LOAD_UNIFORM, instr);
         ld.src[1] = BIR_INDEX_ZERO; /* TODO: UBO index */
+        ld.segment = BI_SEGMENT_UBO;
 
         /* TODO: Indirect access, since we need to multiply by the element
          * size. I believe we can get this lowering automatically via
@@ -259,6 +260,7 @@ bi_emit_sysval(bi_context *ctx, nir_instr *instr,
 
         bi_instruction load = {
                 .type = BI_LOAD_UNIFORM,
+                .segment = BI_SEGMENT_UBO,
                 .vector_channels = nr_components,
                 .src = { BIR_INDEX_CONSTANT, BIR_INDEX_ZERO },
                 .src_types = { nir_type_uint32, nir_type_uint32 },
index 32361cc..b839156 100644 (file)
@@ -155,6 +155,29 @@ enum bi_cond {
         BI_COND_NE,
 };
 
+/* Segments, as synced with ISA. Used as an immediate in LOAD/STORE
+ * instructions for address calculation, and directly in SEG_ADD/SEG_SUB
+ * instructions. */
+
+enum bi_segment {
+        /* No segment (use global addressing, offset from GPU VA 0x0) */
+        BI_SEGMENT_NONE = 1,
+
+        /* Within workgroup local memory (shared memory). Relative to
+         * wls_base_pointer in the draw's thread storage descriptor */
+        BI_SEGMENT_WLS = 2,
+
+        /* Within one of the bound uniform buffers. Low 32-bits are the index
+         * within the uniform buffer; high 32-bits are the index of the uniform
+         * buffer itself. Relative to the uniform_array_pointer indexed within
+         * the draw's uniform remap table indexed by the high 32-bits. */
+        BI_SEGMENT_UBO = 4,
+
+        /* Within thread local storage (for spilling). Relative to
+         * tls_base_pointer in the draw's thread storage descriptor */
+        BI_SEGMENT_TLS = 7
+};
+
 /* Opcodes within a class */
 enum bi_minmax_op {
         BI_MINMAX_MIN,
@@ -275,6 +298,9 @@ typedef struct {
         /* The comparison op. BI_COND_ALWAYS may not be valid. */
         enum bi_cond cond;
 
+        /* For memory ops, base address */
+        enum bi_segment segment;
+
         /* A class-specific op from which the actual opcode can be derived
          * (along with the above information) */
 
index a84eed4..179da3c 100644 (file)
@@ -46,6 +46,7 @@ bit_test_single(struct panfrost_device *dev,
 
         bi_instruction ldubo = {
                 .type = BI_LOAD_UNIFORM,
+                .segment = BI_SEGMENT_UBO,
                 .src = {
                         BIR_INDEX_CONSTANT,
                         BIR_INDEX_ZERO