From: Rob Clark Date: Fri, 24 Oct 2014 21:05:49 +0000 (-0400) Subject: freedreno/ir3: standalone compiler updates for ir3test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6252d0f633292b01c3964d0e3da12f759bec9c5;p=mesa.git freedreno/ir3: standalone compiler updates for ir3test In order to test compiler changes more easily, spit out the assembled shader with some header information so that we can know about inputs/outputs more easily. See: git://people.freedesktop.org/~robclark/ir3test In ir3test we have a big collection of tgsi shaders and reference ir3_compiler outputs. When making compiler changes, regenerate the compiler outputs and feed to ir3test to compare the new vs reference shader. Signed-off-by: Rob Clark --- diff --git a/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c b/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c index 8c3704bf658..602be6508f3 100644 --- a/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c +++ b/src/gallium/drivers/freedreno/ir3/disasm-a3xx.c @@ -749,16 +749,8 @@ static void print_instr(uint32_t *dwords, int level, int n) uint32_t opc = instr_opc(instr); const char *name; - printf("%s%04d[%08xx_%08xx] ", levels[level], n, dwords[1], dwords[0]); - -#if 0 - /* print unknown bits: */ - if (debug & PRINT_RAW) - printf("[%08xx_%08xx] ", dwords[1] & 0x001ff800, dwords[0] & 0x00000000); - if (debug & PRINT_VERBOSE) - printf("%d,%02d ", instr->opc_cat, opc); -#endif + printf("%s%04d[%08xx_%08xx] ", levels[level], n, dwords[1], dwords[0]); /* NOTE: order flags are printed is a bit fugly.. but for now I * try to match the order in llvm-a3xx disassembler for easy diff --git a/src/gallium/drivers/freedreno/ir3/ir3.h b/src/gallium/drivers/freedreno/ir3/ir3.h index 21992f68ced..20d97bafdfe 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.h +++ b/src/gallium/drivers/freedreno/ir3/ir3.h @@ -230,6 +230,7 @@ struct ir3 { struct ir3_instruction **instrs; unsigned baryfs_count, baryfs_sz; struct ir3_instruction **baryfs; + struct ir3_block *block; unsigned heap_idx; struct ir3_heap_chunk *chunk; }; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c index 652ec163f80..b2e55372d86 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c @@ -42,7 +42,7 @@ #include "instr-a3xx.h" #include "ir3.h" -static void dump_info(struct ir3_shader_variant *so) +static void dump_info(struct ir3_shader_variant *so, const char *str) { struct ir3_info info; uint32_t *bin; @@ -51,12 +51,32 @@ static void dump_info(struct ir3_shader_variant *so) // for debug, dump some before/after info: bin = ir3_assemble(so->ir, &info); if (fd_mesa_debug & FD_DBG_DISASM) { + struct ir3_block *block = so->ir->block; unsigned i; - debug_printf("%s: disasm:\n", type); + debug_printf("; %s: %s\n", type, str); + + for (i = 0; i < block->ninputs; i++) { + uint8_t regid; + if (!block->inputs[i]) + continue; + regid = block->inputs[i]->regs[0]->num; + debug_printf("@in(r%d.%c)\tin%d\n", + (regid >> 2), "xyzw"[regid & 0x3], i); + } + + for (i = 0; i < block->noutputs; i++) { + uint8_t regid; + if (!block->outputs[i]) + continue; + regid = block->outputs[i]->regs[0]->num; + debug_printf("@out(r%d.%c)\tout%d\n", + (regid >> 2), "xyzw"[regid & 0x3], i); + } + disasm_a3xx(bin, info.sizedwords, 0, so->type); - debug_printf("%s: outputs:", type); + debug_printf("; %s: outputs:", type); for (i = 0; i < so->outputs_count; i++) { uint8_t regid = so->outputs[i].regid; ir3_semantic sem = so->outputs[i].semantic; @@ -65,7 +85,7 @@ static void dump_info(struct ir3_shader_variant *so) sem2name(sem), sem2idx(sem)); } debug_printf("\n"); - debug_printf("%s: inputs:", type); + debug_printf("; %s: inputs:", type); for (i = 0; i < so->inputs_count; i++) { uint8_t regid = so->inputs[i].regid; ir3_semantic sem = so->inputs[i].semantic; @@ -78,7 +98,7 @@ static void dump_info(struct ir3_shader_variant *so) } debug_printf("\n"); } - debug_printf("%s: %u instructions, %d half, %d full\n\n", + debug_printf("; %s: %u instructions, %d half, %d full\n\n", type, info.instrs_count, info.max_half_reg + 1, info.max_reg + 1); free(bin); } @@ -144,13 +164,20 @@ int main(int argc, char **argv) struct tgsi_token toks[65536]; struct tgsi_parse_context parse; struct ir3_shader_variant v; - struct ir3_shader_key key = { - }; + struct ir3_shader_key key = {}; + const char *info; void *ptr; size_t size; fd_mesa_debug |= FD_DBG_DISASM; + /* cmdline args which impact shader variant get spit out in a + * comment on the first line.. a quick/dirty way to preserve + * that info so when ir3test recompiles the shader with a new + * compiler version, we use the same shader-key settings: + */ + debug_printf("; options:"); + while (n < argc) { if (!strcmp(argv[n], "--verbose")) { fd_mesa_debug |= FD_DBG_OPTDUMP | FD_DBG_MSGS | FD_DBG_OPTMSGS; @@ -159,42 +186,49 @@ int main(int argc, char **argv) } if (!strcmp(argv[n], "--binning-pass")) { + debug_printf(" %s", argv[n]); key.binning_pass = true; n++; continue; } if (!strcmp(argv[n], "--color-two-side")) { + debug_printf(" %s", argv[n]); key.color_two_side = true; n++; continue; } if (!strcmp(argv[n], "--half-precision")) { + debug_printf(" %s", argv[n]); key.half_precision = true; n++; continue; } if (!strcmp(argv[n], "--alpha")) { + debug_printf(" %s", argv[n]); key.alpha = true; n++; continue; } if (!strcmp(argv[n], "--saturate-s")) { + debug_printf(" %s %s", argv[n], argv[n+1]); key.vsaturate_s = key.fsaturate_s = strtol(argv[n+1], NULL, 0); n += 2; continue; } if (!strcmp(argv[n], "--saturate-t")) { + debug_printf(" %s %s", argv[n], argv[n+1]); key.vsaturate_t = key.fsaturate_t = strtol(argv[n+1], NULL, 0); n += 2; continue; } if (!strcmp(argv[n], "--saturate-r")) { + debug_printf(" %s %s", argv[n], argv[n+1]); key.vsaturate_r = key.fsaturate_r = strtol(argv[n+1], NULL, 0); n += 2; continue; @@ -213,6 +247,7 @@ int main(int argc, char **argv) break; } + debug_printf("\n"); filename = argv[n]; @@ -243,22 +278,26 @@ int main(int argc, char **argv) if (!(fd_mesa_debug & FD_DBG_NOOPT)) { /* with new compiler: */ + info = "new compiler"; ret = ir3_compile_shader(&v, toks, key, true); if (ret) { reset_variant(&v, "new compiler failed, trying without copy propagation!"); + info = "new compiler (no copy propagation)"; ret = ir3_compile_shader(&v, toks, key, false); if (ret) reset_variant(&v, "new compiler failed, trying fallback!\n"); } } - if (ret) + if (ret) { + info = "old compiler"; ret = ir3_compile_shader_old(&v, toks, key); + } if (ret) { fprintf(stderr, "old compiler failed!\n"); return ret; } - dump_info(&v); + dump_info(&v, info); } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c index 233f1748b05..681545bd313 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler.c @@ -3102,6 +3102,7 @@ ir3_compile_shader(struct ir3_shader_variant *so, compile_instructions(&ctx); block = ctx.block; + so->ir->block = block; /* keep track of the inputs from TGSI perspective.. */ inputs = block->inputs;