summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/nir/nir_opt_minimize_boolean.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_minimize_boolean.c b/src/compiler/nir/nir_opt_minimize_boolean.c
index 1366f68d5cc..f7d337961f7 100644
--- a/src/compiler/nir/nir_opt_minimize_boolean.c
+++ b/src/compiler/nir/nir_opt_minimize_boolean.c
@@ -31,6 +31,36 @@
#define MAX_VARS 8
#define MAX_TERMS (1u << MAX_VARS)
+//#define DUMP_EXPRESSIONS
+#ifdef DUMP_EXPRESSIONS
+static void
+print_logic_expression(const nir_src *src,
+ const struct boolean_match_state *state)
+{
+ for (unsigned i = 0; i < state->num_variables; i++) {
+ if (state->variables[i].ssa == src->ssa) {
+ printf(" ");
+ nir_print_instr(src->ssa->parent_instr, stdout);
+ printf("\n");
+ return;
+ }
+ }
+
+ const struct nir_instr *const instr = src->ssa->parent_instr;
+
+ if (instr->type == nir_instr_type_alu) {
+ const struct nir_alu_instr *const alu_instr = nir_instr_as_alu(instr);
+
+ for (unsigned i = 0; i < nir_op_infos[alu_instr->op].num_inputs; i++)
+ print_logic_expression(&alu_instr->src[i].src, state);
+ }
+
+ printf(" ");
+ nir_print_instr(instr, stdout);
+ printf("\n");
+}
+#endif
+
struct implicant {
union {
uint8_t *term_ptr;