Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com>
---
 src/etnaviv/compiler/eir.h              |  3 ++
 src/etnaviv/compiler/eir_compiler_nir.c |  6 ++++
 src/etnaviv/compiler/eir_optimize.c     | 48 +++++++++++++++++++++++++
 src/etnaviv/compiler/eir_optimize.h     | 31 ++++++++++++++++
 src/etnaviv/compiler/meson.build        |  1 +
 5 files changed, 89 insertions(+)
 create mode 100644 src/etnaviv/compiler/eir_optimize.c
 create mode 100644 src/etnaviv/compiler/eir_optimize.h

diff --git a/src/etnaviv/compiler/eir.h b/src/etnaviv/compiler/eir.h
index 1b67edab559..f46d12b822a 100644
--- a/src/etnaviv/compiler/eir.h
+++ b/src/etnaviv/compiler/eir.h
@@ -294,6 +294,9 @@ eir_assign_output(struct eir *ir, unsigned idx, unsigned 
slot, unsigned ncomp)
 void
 eir_legalize(struct eir *ir);
 
+void
+eir_optimize(struct eir *ir);
+
 void
 eir_calculate_live_intervals(struct eir *ir);
 
diff --git a/src/etnaviv/compiler/eir_compiler_nir.c 
b/src/etnaviv/compiler/eir_compiler_nir.c
index 862f34390e0..4dbbd5e8f0a 100644
--- a/src/etnaviv/compiler/eir_compiler_nir.c
+++ b/src/etnaviv/compiler/eir_compiler_nir.c
@@ -991,6 +991,12 @@ eir_compile_shader_nir(struct eir_compiler *compiler,
       eir_print(ctx->ir);
    }
 
+   eir_optimize(ctx->ir);
+   if (eir_compiler_debug & EIR_DBG_OPTMSGS) {
+      printf("AFTER eir_optimize:\n");
+      eir_print(ctx->ir);
+   }
+
    eir_legalize(ctx->ir);
    if (eir_compiler_debug & EIR_DBG_OPTMSGS) {
       printf("AFTER legalization:\n");
diff --git a/src/etnaviv/compiler/eir_optimize.c 
b/src/etnaviv/compiler/eir_optimize.c
new file mode 100644
index 00000000000..6eae8e9c9ec
--- /dev/null
+++ b/src/etnaviv/compiler/eir_optimize.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 Etnaviv Project
+ * Copyright (C) 2019 Zodiac Inflight Innovations
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Christian Gmeiner <christian.gmei...@gmail.com>
+ */
+
+#include "eir.h"
+#include "eir_optimize.h"
+#include <stdio.h>
+
+#define OPTPASS(func)                                 \
+   do {                                               \
+         bool stage_progress = func(ir);              \
+         if (stage_progress) {                        \
+            if (print_opt_debug) {                    \
+               fprintf(stderr,                        \
+                       "EIR opt pass %s progress\n",  \
+                       #func);                        \
+            }                                         \
+         }                                            \
+   } while (0)
+
+void
+eir_optimize(struct eir *ir)
+{
+   const bool print_opt_debug = true;
+}
diff --git a/src/etnaviv/compiler/eir_optimize.h 
b/src/etnaviv/compiler/eir_optimize.h
new file mode 100644
index 00000000000..b840a273c25
--- /dev/null
+++ b/src/etnaviv/compiler/eir_optimize.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019 Etnaviv Project
+ * Copyright (C) 2019 Zodiac Inflight Innovations
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Christian Gmeiner <christian.gmei...@gmail.com>
+ */
+
+#ifndef H_EIR_OPTIMIZE
+#define H_EIR_OPTIMIZE
+
+#endif // H_EIR_OPTIMIZE
diff --git a/src/etnaviv/compiler/meson.build b/src/etnaviv/compiler/meson.build
index 3431cb48c36..8343e6b91ad 100644
--- a/src/etnaviv/compiler/meson.build
+++ b/src/etnaviv/compiler/meson.build
@@ -31,6 +31,7 @@ libetnaviv_compiler_files = files(
   'eir_nir_lower_alu_to_scalar.c',
   'eir_nir.c',
   'eir_nir.h',
+  'eir_optimize.c',
   'eir_print.c',
   'eir_register_allocate.c',
   'eir_shader.c',
-- 
2.21.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to