diff options
author | Rob Clark <[email protected]> | 2020-01-15 14:52:43 -0800 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-02-01 02:40:22 +0000 |
commit | 2ffe44ec0a5dba18e4a88ca7dd1042e823f9685e (patch) | |
tree | 3ecebefd24bf620a4171ac2158dfd782e4f8cd02 /src/freedreno/ir3 | |
parent | 2f4f46b7080a1087420939b2f4bf0bea414cd3ce (diff) |
freedreno/ir3: add RA sanity check
Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3569>
Diffstat (limited to 'src/freedreno/ir3')
-rw-r--r-- | src/freedreno/ir3/ir3_ra.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c index 73fc10e39f2..5a63e77c89e 100644 --- a/src/freedreno/ir3/ir3_ra.c +++ b/src/freedreno/ir3/ir3_ra.c @@ -1441,6 +1441,31 @@ ra_alloc(struct ir3_ra_ctx *ctx) return 0; } +/* if we end up with split/collect instructions with non-matching src + * and dest regs, that means something has gone wrong. Which makes it + * a pretty good sanity check. + */ +static void +ra_sanity_check(struct ir3 *ir) +{ + foreach_block (block, &ir->block_list) { + foreach_instr (instr, &block->instr_list) { + if (instr->opc == OPC_META_SPLIT) { + struct ir3_register *dst = instr->regs[0]; + struct ir3_register *src = instr->regs[1]; + debug_assert(dst->num == (src->num + instr->split.off)); + } else if (instr->opc == OPC_META_COLLECT) { + struct ir3_register *dst = instr->regs[0]; + struct ir3_register *src; + + foreach_src_n (src, n, instr) { + debug_assert(dst->num == (src->num - n)); + } + } + } + } +} + static int ir3_ra_pass(struct ir3_shader_variant *v, struct ir3_instruction **precolor, unsigned nprecolor, bool scalar_pass) @@ -1490,5 +1515,13 @@ ir3_ra(struct ir3_shader_variant *v, struct ir3_instruction **precolor, ir3_print(v->ir); } +#ifdef DEBUG +# define SANITY_CHECK DEBUG +#else +# define SANITY_CHECK 0 +#endif + if (SANITY_CHECK) + ra_sanity_check(v->ir); + return ret; } |