From: Alyssa Rosenzweig Date: Fri, 31 Jul 2020 21:29:50 +0000 (-0400) Subject: pan/bi: Introduce segments into the IR X-Git-Tag: upstream/21.0.0~5333 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f5b78874ab34095dd55d6020d3d63318b7336d8;p=platform%2Fupstream%2Fmesa.git pan/bi: Introduce segments into the IR Needed to select between global, UBO, TLS, and WLS addressing modes, required to implement loads/stores correctly. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Daniel Stone Part-of: --- diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index dcb22df..88d2c1e 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -27,6 +27,18 @@ #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); diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index d4acad7..2c017ce 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -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 }, diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 32361cc..b839156 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -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) */ diff --git a/src/panfrost/bifrost/test/bi_test_pack.c b/src/panfrost/bifrost/test/bi_test_pack.c index a84eed4..179da3c 100644 --- a/src/panfrost/bifrost/test/bi_test_pack.c +++ b/src/panfrost/bifrost/test/bi_test_pack.c @@ -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