Mesa (master): freedreno/ir3: add a pass to collect SSA uses
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Apr 4 00:24:57 UTC 2020
Module: Mesa
Branch: master
Commit: 72f6b03aec42dcfa7b38aa4eb1c94a0143e2aed0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=72f6b03aec42dcfa7b38aa4eb1c94a0143e2aed0
Author: Rob Clark <robdclark at chromium.org>
Date: Thu Mar 12 14:18:04 2020 -0700
freedreno/ir3: add a pass to collect SSA uses
We don't really track these as the ir is transformed, but it would be a
useful thing for some passes to have. So add a pass to collect this
information. It uses instr->data (generic per-pass ptr), with the
hashsets hanging under a mem_ctx for easy disposal at the end of the
pass.
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4423>
---
src/freedreno/ir3/ir3.c | 24 ++++++++++++++++++++++++
src/freedreno/ir3/ir3.h | 13 +++++++++++++
2 files changed, 37 insertions(+)
diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c
index bf842701868..4ac50aec0a3 100644
--- a/src/freedreno/ir3/ir3.c
+++ b/src/freedreno/ir3/ir3.c
@@ -1128,3 +1128,27 @@ ir3_lookup_array(struct ir3 *ir, unsigned id)
return arr;
return NULL;
}
+
+void
+ir3_find_ssa_uses(struct ir3 *ir, void *mem_ctx)
+{
+ /* We could do this in a single pass if we can assume instructions
+ * are always sorted. Which currently might not always be true.
+ * (In particular after ir3_group pass, but maybe other places.)
+ */
+ foreach_block (block, &ir->block_list)
+ foreach_instr (instr, &block->instr_list)
+ instr->uses = NULL;
+
+ foreach_block (block, &ir->block_list) {
+ foreach_instr (instr, &block->instr_list) {
+ struct ir3_instruction *src;
+
+ foreach_ssa_src (src, instr) {
+ if (!src->uses)
+ src->uses = _mesa_pointer_set_create(mem_ctx);
+ _mesa_set_add(src->uses, instr);
+ }
+ }
+ }
+}
diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h
index c8abd50b034..ed51189ae3d 100644
--- a/src/freedreno/ir3/ir3.h
+++ b/src/freedreno/ir3/ir3.h
@@ -325,6 +325,11 @@ struct ir3_instruction {
*/
void *data;
+ /**
+ * Valid if pass calls ir3_find_ssa_uses().. see foreach_ssa_use()
+ */
+ struct set *uses;
+
int sun; /* Sethi–Ullman number, used by sched */
int use_count; /* currently just updated/used by cp */
@@ -593,6 +598,14 @@ void ir3_clear_mark(struct ir3 *shader);
unsigned ir3_count_instructions(struct ir3 *ir);
+void ir3_find_ssa_uses(struct ir3 *ir, void *mem_ctx);
+
+#include "util/set.h"
+#define foreach_ssa_use(__use, __instr) \
+ for (struct ir3_instruction *__use = (void *)~0; \
+ __use && (__instr)->uses; __use = NULL) \
+ set_foreach ((__instr)->uses, __entry) \
+ if ((__use = (void *)__entry->key))
#define MAX_ARRAYS 16
More information about the mesa-commit
mailing list