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 <alyssa.rosenzweig@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6749>
This commit is contained in:
Alyssa Rosenzweig 2020-07-31 17:29:50 -04:00 committed by Marge Bot
parent 33710ff895
commit 6f5b78874a
4 changed files with 44 additions and 0 deletions

View file

@ -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);

View 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 },

View 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) */

View 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