From d9e41e8a8ca3a8a22628513b44764fa7675ec288 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Thu, 4 Jul 2024 15:25:43 +0200 Subject: [PATCH] nir: Stop using "capture : true" for nir_opt_algebraic "calture : true" is suboptimal and and prevents the script from writing multiple files in one go. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/meson.build | 3 +-- src/compiler/nir/nir_opt_algebraic.py | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build index 40f600161db..7c14e49419a 100644 --- a/src/compiler/nir/meson.build +++ b/src/compiler/nir/meson.build @@ -45,8 +45,7 @@ nir_opt_algebraic_c = custom_target( 'nir_opt_algebraic.c', input : 'nir_opt_algebraic.py', output : 'nir_opt_algebraic.c', - command : [prog_python, '@INPUT@'], - capture : true, + command : [prog_python, '@INPUT@', '--out', '@OUTPUT@'], depend_files : nir_algebraic_depends, ) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 29b4f0716aa..bfb96d5e525 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -21,6 +21,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +import argparse from collections import OrderedDict import nir_algebraic from nir_opcodes import type_sizes @@ -3588,12 +3589,17 @@ before_lower_int64_optimizations = [ (('iadd', ('u2u64', a), ('u2u64', a)), ('ishl', ('u2u64', a), 1)), ] -print(nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()) -print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_ffma", - before_ffma_optimizations).render()) -print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_lower_int64", - before_lower_int64_optimizations).render()) -print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_late", - late_optimizations).render()) -print(nir_algebraic.AlgebraicPass("nir_opt_algebraic_distribute_src_mods", - distribute_src_mods).render()) +parser = argparse.ArgumentParser() +parser.add_argument('--out', required=True) +args = parser.parse_args() + +with open(args.out, "w", encoding='utf-8') as f: + f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()) + f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_ffma", + before_ffma_optimizations).render()) + f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_before_lower_int64", + before_lower_int64_optimizations).render()) + f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_late", + late_optimizations).render()) + f.write(nir_algebraic.AlgebraicPass("nir_opt_algebraic_distribute_src_mods", + distribute_src_mods).render())