#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)
{
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);
{
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
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 },
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,
/* 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) */
bi_instruction ldubo = {
.type = BI_LOAD_UNIFORM,
+ .segment = BI_SEGMENT_UBO,
.src = {
BIR_INDEX_CONSTANT,
BIR_INDEX_ZERO