mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 09:18:04 +02:00
nir: add nir_def_as_* helpers
We want to get rid of nir_def::parent_instr eventually, requiring an accessor function instead nir_def_parent_instr(def), so to mitigate the hit to NIR ergonomics, let's add helpers for common patterns using parent_instr. This gets us an immediate win for NIR ergonomics and then reduces the surface area for the later flag day hiding parent_instr. This commit starts us off by adding compositions for nir_instr_as_* with parent_instr's, which are common. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Marek Olšák <maraeo@gmail.com> Acked-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36489>
This commit is contained in:
parent
71eefb977b
commit
3624f054f2
1 changed files with 15 additions and 0 deletions
|
|
@ -2853,6 +2853,21 @@ NIR_DEFINE_SRC_AS_CONST(double, float)
|
|||
|
||||
#undef NIR_DEFINE_SRC_AS_CONST
|
||||
|
||||
#define NIR_DEFINE_DEF_AS_INSTR(type, suffix) \
|
||||
static inline type *nir_def_as_##suffix(const nir_def *def) \
|
||||
{ \
|
||||
return nir_instr_as_##suffix(def->parent_instr); \
|
||||
}
|
||||
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_alu_instr, alu)
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_intrinsic_instr, intrinsic)
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_tex_instr, tex)
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_phi_instr, phi)
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_deref_instr, deref)
|
||||
NIR_DEFINE_DEF_AS_INSTR(nir_load_const_instr, load_const)
|
||||
|
||||
#undef NIR_DEFINE_DEF_AS_INSTR
|
||||
|
||||
typedef struct nir_scalar {
|
||||
nir_def *def;
|
||||
unsigned comp;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue