Skip to content

treewide: Use nir_shader_intrinsic_pass sometimes

Alyssa Rosenzweig requested to merge alyssa/mesa:nir/intrinsics-cocci into main

This converts a lot of trivial passes. Nice boilerplate deletion. Via Coccinelle patch (with a small manual fix-up for panfrost where coccinelle got confused by genxml + ninja clang-format squashed in).

@def@
typedef bool;
typedef nir_builder;
typedef nir_instr;
typedef nir_def;
identifier fn, instr, intr, x, builder, data;
@@

static fn(nir_builder* builder,
-nir_instr *instr,
+nir_intrinsic_instr *intr,
...)
{
(
-   if (instr->type != nir_instr_type_intrinsic)
-      return false;
-   nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
-   nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-   if (instr->type != nir_instr_type_intrinsic)
-      return false;
)

<...
(
-instr->x
+intr->instr.x
|
-instr
+&intr->instr
)
...>

}

@pass depends on def@
identifier def.fn;
expression shader, progress;
@@

(
-nir_shader_instructions_pass(shader, fn,
+nir_shader_intrinsics_pass(shader, fn,
...)
|
-NIR_PASS_V(shader, nir_shader_instructions_pass, fn,
+NIR_PASS_V(shader, nir_shader_intrinsics_pass, fn,
...)
|
-NIR_PASS(progress, shader, nir_shader_instructions_pass, fn,
+NIR_PASS(progress, shader, nir_shader_intrinsics_pass, fn,
...)
)

Signed-off-by: Alyssa Rosenzweig alyssa@rosenzweig.io

Merge request reports

Loading