Mesa (main): nir: add a nir_instr_def_is_register helper
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Feb 24 12:04:39 UTC 2022
Module: Mesa
Branch: main
Commit: fe2249eac504471306f8f0d2ff3f4ba759b91e28
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe2249eac504471306f8f0d2ff3f4ba759b91e28
Author: Iago Toral Quiroga <itoral at igalia.com>
Date: Thu Feb 17 10:25:48 2022 +0100
nir: add a nir_instr_def_is_register helper
This returns true if the instruction has a dest that is not an SSA value.
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15056>
---
src/compiler/nir/nir.c | 37 +++++++++++++++++++++++++++++++++++++
src/compiler/nir/nir.h | 1 +
2 files changed, 38 insertions(+)
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 7fb103f7faf..32455e14d67 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1476,6 +1476,43 @@ nir_instr_ssa_def(nir_instr *instr)
unreachable("Invalid instruction type");
}
+bool
+nir_instr_def_is_register(nir_instr *instr)
+{
+ switch (instr->type) {
+ case nir_instr_type_alu:
+ return !nir_instr_as_alu(instr)->dest.dest.is_ssa;
+
+ case nir_instr_type_deref:
+ return !nir_instr_as_deref(instr)->dest.is_ssa;
+
+ case nir_instr_type_tex:
+ return !nir_instr_as_tex(instr)->dest.is_ssa;
+
+ case nir_instr_type_intrinsic: {
+ nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+ return nir_intrinsic_infos[intrin->intrinsic].has_dest &&
+ !intrin->dest.is_ssa;
+ }
+
+ case nir_instr_type_phi:
+ return !nir_instr_as_phi(instr)->dest.is_ssa;
+
+ case nir_instr_type_parallel_copy:
+ unreachable("Parallel copies are unsupported by this function");
+
+ case nir_instr_type_load_const:
+ case nir_instr_type_ssa_undef:
+ return false;
+
+ case nir_instr_type_call:
+ case nir_instr_type_jump:
+ return false;
+ }
+
+ unreachable("Invalid instruction type");
+}
+
bool
nir_foreach_phi_src_leaving_block(nir_block *block,
nir_foreach_src_cb cb,
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index a86c1af6e7f..1ca88c43dd6 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3947,6 +3947,7 @@ nir_cursor nir_instr_free_and_dce(nir_instr *instr);
/** @} */
nir_ssa_def *nir_instr_ssa_def(nir_instr *instr);
+bool nir_instr_def_is_register(nir_instr *instr);
typedef bool (*nir_foreach_ssa_def_cb)(nir_ssa_def *def, void *state);
typedef bool (*nir_foreach_dest_cb)(nir_dest *dest, void *state);
More information about the mesa-commit
mailing list