mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
intel/brw: Pretty-print memory logical opcodes
The new MEMORY_*_LOGICAL intrinsics have a lot of control sources with a bunch of LSC_* enums (opcode, memory type, address type, address and data sizes), as well as flags, coordinate components vs. components... they unfortunately are nigh-unreadable with the default printing since there's just a string of unreadable UD immediates in some order. To fix this, we add some basic pretty-printing. If a control source is simply an enum whose value communicates the entire purpose, we print it. If it has a numeric value (i.e. alignment, or data), we add a label. For example: memory_store(16) (null):UD store shared flat addr: %2:UD coord_comps:1u align:16u d32 comps:2u data0: %3:UD memory_store(16) (null):UD store typed bti:%2+0.0<0>:UD addr: %3+0.0:D coord_comps:2u align:0u d32 comps:4u data0: %4:UD This make them much easier to read. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Reviewed-by: Rohan Garg <rohan.garg@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30828>
This commit is contained in:
parent
2c67729386
commit
a82e8b1c6b
1 changed files with 82 additions and 4 deletions
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
#include "brw_cfg.h"
|
||||
#include "brw_disasm.h"
|
||||
#include "brw_fs.h"
|
||||
#include "brw_private.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
|
@ -326,16 +327,86 @@ brw_instruction_name(const struct brw_isa_info *isa, enum opcode op)
|
|||
case SHADER_OPCODE_LOAD_SUBGROUP_INVOCATION:
|
||||
return "load_subgroup_invocation";
|
||||
case SHADER_OPCODE_MEMORY_LOAD_LOGICAL:
|
||||
return "memory_load_logical";
|
||||
return "memory_load";
|
||||
case SHADER_OPCODE_MEMORY_STORE_LOGICAL:
|
||||
return "memory_store_logical";
|
||||
return "memory_store";
|
||||
case SHADER_OPCODE_MEMORY_ATOMIC_LOGICAL:
|
||||
return "memory_atomic_logical";
|
||||
return "memory_atomic";
|
||||
}
|
||||
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretty-print a source for a SHADER_OPCODE_MEMORY_LOGICAL instruction.
|
||||
*
|
||||
* Returns true if the value is fully printed (i.e. an enum) and false if
|
||||
* we only printed a label, and the actual source value still needs printing.
|
||||
*/
|
||||
static bool
|
||||
print_memory_logical_source(FILE *file, const fs_inst *inst, unsigned i)
|
||||
{
|
||||
if (inst->is_control_source(i)) {
|
||||
assert(inst->src[i].file == IMM && inst->src[i].type == BRW_TYPE_UD);
|
||||
assert(!inst->src[i].negate);
|
||||
assert(!inst->src[i].abs);
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case MEMORY_LOGICAL_OPCODE:
|
||||
fprintf(file, " %s", brw_lsc_op_to_string(inst->src[i].ud));
|
||||
return true;
|
||||
case MEMORY_LOGICAL_MODE: {
|
||||
static const char *modes[] = {
|
||||
[MEMORY_MODE_TYPED] = "typed",
|
||||
[MEMORY_MODE_UNTYPED] = "untyped",
|
||||
[MEMORY_MODE_SHARED_LOCAL] = "shared",
|
||||
[MEMORY_MODE_SCRATCH] = "scratch",
|
||||
};
|
||||
assert(inst->src[i].ud < ARRAY_SIZE(modes));
|
||||
fprintf(file, " %s", modes[inst->src[i].ud]);
|
||||
return true;
|
||||
}
|
||||
case MEMORY_LOGICAL_BINDING_TYPE:
|
||||
fprintf(file, " %s", brw_lsc_addr_surftype_to_string(inst->src[i].ud));
|
||||
if (inst->src[i].ud != LSC_ADDR_SURFTYPE_FLAT)
|
||||
fprintf(file, ":");
|
||||
return true;
|
||||
case MEMORY_LOGICAL_BINDING:
|
||||
return inst->src[i].file == BAD_FILE;
|
||||
case MEMORY_LOGICAL_ADDRESS:
|
||||
fprintf(file, " addr: ");
|
||||
return false;
|
||||
case MEMORY_LOGICAL_COORD_COMPONENTS:
|
||||
fprintf(file, " coord_comps:");
|
||||
return false;
|
||||
case MEMORY_LOGICAL_ALIGNMENT:
|
||||
fprintf(file, " align:");
|
||||
return false;
|
||||
case MEMORY_LOGICAL_DATA_SIZE:
|
||||
fprintf(file, " %s", brw_lsc_data_size_to_string(inst->src[i].ud));
|
||||
return true;
|
||||
case MEMORY_LOGICAL_COMPONENTS:
|
||||
fprintf(file, " comps:");
|
||||
return false;
|
||||
case MEMORY_LOGICAL_FLAGS:
|
||||
if (inst->src[i].ud & MEMORY_FLAG_TRANSPOSE)
|
||||
fprintf(file, " transpose");
|
||||
if (inst->src[i].ud & MEMORY_FLAG_INCLUDE_HELPERS)
|
||||
fprintf(file, " helpers");
|
||||
return true;
|
||||
case MEMORY_LOGICAL_DATA0:
|
||||
fprintf(file, " data0: ");
|
||||
return false;
|
||||
case MEMORY_LOGICAL_DATA1:
|
||||
if (inst->src[i].file == BAD_FILE)
|
||||
return true;
|
||||
fprintf(file, " data1: ");
|
||||
return false;
|
||||
default:
|
||||
unreachable("invalid source");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
brw_print_instruction_to_file(const fs_visitor &s, const fs_inst *inst, FILE *file, const brw::def_analysis *defs)
|
||||
|
|
@ -436,7 +507,14 @@ brw_print_instruction_to_file(const fs_visitor &s, const fs_inst *inst, FILE *fi
|
|||
fprintf(file, ":%s", brw_reg_type_to_letters(inst->dst.type));
|
||||
|
||||
for (int i = 0; i < inst->sources; i++) {
|
||||
fprintf(file, ", ");
|
||||
if (inst->opcode == SHADER_OPCODE_MEMORY_LOAD_LOGICAL ||
|
||||
inst->opcode == SHADER_OPCODE_MEMORY_STORE_LOGICAL ||
|
||||
inst->opcode == SHADER_OPCODE_MEMORY_ATOMIC_LOGICAL) {
|
||||
if (print_memory_logical_source(file, inst, i))
|
||||
continue;
|
||||
} else {
|
||||
fprintf(file, ", ");
|
||||
}
|
||||
|
||||
if (inst->src[i].negate)
|
||||
fprintf(file, "-");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue