mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
nir/validate: Replace all dest validation with validate_def
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24674>
This commit is contained in:
parent
b9e514d25b
commit
c7fb2228e6
1 changed files with 14 additions and 26 deletions
|
|
@ -180,8 +180,14 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state)
|
|||
}
|
||||
|
||||
static void
|
||||
validate_ssa_def(nir_def *def, validate_state *state)
|
||||
validate_def(nir_def *def, validate_state *state,
|
||||
unsigned bit_sizes, unsigned num_components)
|
||||
{
|
||||
if (bit_sizes)
|
||||
validate_assert(state, def->bit_size & bit_sizes);
|
||||
if (num_components)
|
||||
validate_assert(state, def->num_components == num_components);
|
||||
|
||||
validate_assert(state, def->index < state->impl->ssa_alloc);
|
||||
validate_assert(state, !BITSET_TEST(state->ssa_defs_found, def->index));
|
||||
BITSET_SET(state->ssa_defs_found, def->index);
|
||||
|
|
@ -200,24 +206,6 @@ validate_ssa_def(nir_def *def, validate_state *state)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
validate_dest(nir_dest *dest, validate_state *state,
|
||||
unsigned bit_sizes, unsigned num_components)
|
||||
{
|
||||
if (bit_sizes)
|
||||
validate_assert(state, dest->ssa.bit_size & bit_sizes);
|
||||
if (num_components)
|
||||
validate_assert(state, dest->ssa.num_components == num_components);
|
||||
validate_ssa_def(&dest->ssa, state);
|
||||
}
|
||||
|
||||
static void
|
||||
validate_alu_dest(nir_alu_instr *instr, validate_state *state)
|
||||
{
|
||||
nir_alu_dest *dest = &instr->dest;
|
||||
validate_dest(&dest->dest, state, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
validate_alu_instr(nir_alu_instr *instr, validate_state *state)
|
||||
{
|
||||
|
|
@ -275,7 +263,7 @@ validate_alu_instr(nir_alu_instr *instr, validate_state *state)
|
|||
dest_bit_size == 64);
|
||||
}
|
||||
|
||||
validate_alu_dest(instr, state);
|
||||
validate_def(&instr->dest.dest.ssa, state, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -395,7 +383,7 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state)
|
|||
* want to let other compiler components such as SPIR-V decide how big
|
||||
* pointers should be.
|
||||
*/
|
||||
validate_dest(&instr->dest, state, 0, 0);
|
||||
validate_def(&instr->dest.ssa, state, 0, 0);
|
||||
|
||||
/* Certain modes cannot be used as sources for phi instructions because
|
||||
* way too many passes assume that they can always chase deref chains.
|
||||
|
|
@ -703,7 +691,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
|
|||
else
|
||||
dest_bit_size = dest_bit_size ? dest_bit_size : bit_sizes;
|
||||
|
||||
validate_dest(&instr->dest, state, dest_bit_size, components_written);
|
||||
validate_def(&instr->dest.ssa, state, dest_bit_size, components_written);
|
||||
}
|
||||
|
||||
if (!vectorized_intrinsic(instr))
|
||||
|
|
@ -859,7 +847,7 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
|
|||
if (instr->is_gather_implicit_lod)
|
||||
validate_assert(state, instr->op == nir_texop_tg4);
|
||||
|
||||
validate_dest(&instr->dest, state, 0, nir_tex_instr_dest_size(instr));
|
||||
validate_def(&instr->dest.ssa, state, 0, nir_tex_instr_dest_size(instr));
|
||||
|
||||
unsigned bit_size = nir_alu_type_get_type_size(instr->dest_type);
|
||||
validate_assert(state,
|
||||
|
|
@ -916,7 +904,7 @@ validate_const_value(nir_const_value *val, unsigned bit_size,
|
|||
static void
|
||||
validate_load_const_instr(nir_load_const_instr *instr, validate_state *state)
|
||||
{
|
||||
validate_ssa_def(&instr->def, state);
|
||||
validate_def(&instr->def, state, 0, 0);
|
||||
|
||||
for (unsigned i = 0; i < instr->def.num_components; i++)
|
||||
validate_const_value(&instr->value[i], instr->def.bit_size, false, state);
|
||||
|
|
@ -925,7 +913,7 @@ validate_load_const_instr(nir_load_const_instr *instr, validate_state *state)
|
|||
static void
|
||||
validate_ssa_undef_instr(nir_undef_instr *instr, validate_state *state)
|
||||
{
|
||||
validate_ssa_def(&instr->def, state);
|
||||
validate_def(&instr->def, state, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -936,7 +924,7 @@ validate_phi_instr(nir_phi_instr *instr, validate_state *state)
|
|||
* basic blocks, to avoid validating an SSA use before its definition.
|
||||
*/
|
||||
|
||||
validate_dest(&instr->dest, state, 0, 0);
|
||||
validate_def(&instr->dest.ssa, state, 0, 0);
|
||||
|
||||
exec_list_validate(&instr->srcs);
|
||||
validate_assert(state, exec_list_length(&instr->srcs) ==
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue