From e0614e8ea1b78c8490afe7f1f13ffa64e50ce2df Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 6 Dec 2024 19:48:54 -0800 Subject: [PATCH] intel/brw: Use brw_analysis prefix for liveness analysis files Move declaration to the common header and rename definition file. Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_analysis.h | 110 ++++++++++++- ...ariables.cpp => brw_analysis_liveness.cpp} | 2 +- src/intel/compiler/brw_compile_bs.cpp | 2 +- src/intel/compiler/brw_compile_cs.cpp | 2 +- src/intel/compiler/brw_compile_fs.cpp | 2 +- src/intel/compiler/brw_fs.cpp | 2 +- src/intel/compiler/brw_fs.h | 2 +- src/intel/compiler/brw_fs_live_variables.h | 145 ------------------ .../compiler/brw_opt_copy_propagation.cpp | 2 +- .../compiler/brw_opt_dead_code_eliminate.cpp | 2 +- .../compiler/brw_opt_register_coalesce.cpp | 2 +- .../compiler/brw_opt_saturate_propagation.cpp | 2 +- .../compiler/brw_schedule_instructions.cpp | 2 +- src/intel/compiler/meson.build | 3 +- 14 files changed, 120 insertions(+), 160 deletions(-) rename src/intel/compiler/{brw_fs_live_variables.cpp => brw_analysis_liveness.cpp} (99%) delete mode 100644 src/intel/compiler/brw_fs_live_variables.h diff --git a/src/intel/compiler/brw_analysis.h b/src/intel/compiler/brw_analysis.h index f1b17d23d14..e5866a2df2a 100644 --- a/src/intel/compiler/brw_analysis.h +++ b/src/intel/compiler/brw_analysis.h @@ -1,5 +1,5 @@ /* - * Copyright © 2010 Intel Corporation + * Copyright © 2010-2012 Intel Corporation * SPDX-License-Identifier: MIT */ @@ -8,8 +8,8 @@ #include "brw_cfg.h" #include "brw_inst.h" #include "brw_ir_analysis.h" -#include "brw_fs_live_variables.h" #include "brw_ir_performance.h" +#include "util/bitset.h" struct fs_visitor; @@ -93,4 +93,110 @@ namespace brw { uint32_t *def_use_counts; unsigned def_count; }; + + class fs_live_variables { + public: + struct block_data { + /** + * Which variables are defined before being used in the block. + * + * Note that for our purposes, "defined" means unconditionally, completely + * defined. + */ + BITSET_WORD *def; + + /** + * Which variables are used before being defined in the block. + */ + BITSET_WORD *use; + + /** Which defs reach the entry point of the block. */ + BITSET_WORD *livein; + + /** Which defs reach the exit point of the block. */ + BITSET_WORD *liveout; + + /** + * Variables such that the entry point of the block may be reached from any + * of their definitions. + */ + BITSET_WORD *defin; + + /** + * Variables such that the exit point of the block may be reached from any + * of their definitions. + */ + BITSET_WORD *defout; + + BITSET_WORD flag_def[1]; + BITSET_WORD flag_use[1]; + BITSET_WORD flag_livein[1]; + BITSET_WORD flag_liveout[1]; + }; + + fs_live_variables(const fs_visitor *s); + ~fs_live_variables(); + + bool validate(const fs_visitor *s) const; + + analysis_dependency_class + dependency_class() const + { + return (DEPENDENCY_INSTRUCTION_IDENTITY | + DEPENDENCY_INSTRUCTION_DATA_FLOW | + DEPENDENCY_VARIABLES); + } + + bool vars_interfere(int a, int b) const; + bool vgrfs_interfere(int a, int b) const; + int var_from_reg(const brw_reg ®) const + { + return var_from_vgrf[reg.nr] + reg.offset / REG_SIZE; + } + + /** Map from virtual GRF number to index in block_data arrays. */ + int *var_from_vgrf; + + /** + * Map from any index in block_data to the virtual GRF containing it. + * + * For alloc.sizes of [1, 2, 3], vgrf_from_var would contain + * [0, 1, 1, 2, 2, 2]. + */ + int *vgrf_from_var; + + int num_vars; + int num_vgrfs; + int bitset_words; + + /** @{ + * Final computed live ranges for each var (each component of each virtual + * GRF). + */ + int *start; + int *end; + /** @} */ + + /** @{ + * Final computed live ranges for each VGRF. + */ + int *vgrf_start; + int *vgrf_end; + /** @} */ + + /** Per-basic-block information on live variables */ + struct block_data *block_data; + + protected: + void setup_def_use(); + void setup_one_read(struct block_data *bd, int ip, const brw_reg ®); + void setup_one_write(struct block_data *bd, brw_inst *inst, int ip, + const brw_reg ®); + void compute_live_variables(); + void compute_start_end(); + + const struct intel_device_info *devinfo; + const cfg_t *cfg; + void *mem_ctx; + }; } diff --git a/src/intel/compiler/brw_fs_live_variables.cpp b/src/intel/compiler/brw_analysis_liveness.cpp similarity index 99% rename from src/intel/compiler/brw_fs_live_variables.cpp rename to src/intel/compiler/brw_analysis_liveness.cpp index 7336833ca6f..b173e67e164 100644 --- a/src/intel/compiler/brw_fs_live_variables.cpp +++ b/src/intel/compiler/brw_analysis_liveness.cpp @@ -26,7 +26,7 @@ */ #include "brw_fs.h" -#include "brw_fs_live_variables.h" +#include "brw_analysis.h" using namespace brw; diff --git a/src/intel/compiler/brw_compile_bs.cpp b/src/intel/compiler/brw_compile_bs.cpp index 8333cbb5f44..aa462dbc6e0 100644 --- a/src/intel/compiler/brw_compile_bs.cpp +++ b/src/intel/compiler/brw_compile_bs.cpp @@ -3,8 +3,8 @@ * SPDX-License-Identifier: MIT */ +#include "brw_analysis.h" #include "brw_fs.h" -#include "brw_fs_live_variables.h" #include "brw_generator.h" #include "brw_nir.h" #include "brw_cfg.h" diff --git a/src/intel/compiler/brw_compile_cs.cpp b/src/intel/compiler/brw_compile_cs.cpp index 212154643fd..5c4fe6da8cc 100644 --- a/src/intel/compiler/brw_compile_cs.cpp +++ b/src/intel/compiler/brw_compile_cs.cpp @@ -4,8 +4,8 @@ */ #include "brw_fs.h" +#include "brw_analysis.h" #include "brw_builder.h" -#include "brw_fs_live_variables.h" #include "brw_generator.h" #include "brw_nir.h" #include "brw_cfg.h" diff --git a/src/intel/compiler/brw_compile_fs.cpp b/src/intel/compiler/brw_compile_fs.cpp index fb4d5c87eda..328d976d429 100644 --- a/src/intel/compiler/brw_compile_fs.cpp +++ b/src/intel/compiler/brw_compile_fs.cpp @@ -5,8 +5,8 @@ #include "brw_eu.h" #include "brw_fs.h" +#include "brw_analysis.h" #include "brw_builder.h" -#include "brw_fs_live_variables.h" #include "brw_generator.h" #include "brw_nir.h" #include "brw_cfg.h" diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 62cf6729d5b..8f5f24fe43e 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -28,10 +28,10 @@ * from the LIR. */ +#include "brw_analysis.h" #include "brw_eu.h" #include "brw_fs.h" #include "brw_builder.h" -#include "brw_fs_live_variables.h" #include "brw_nir.h" #include "brw_cfg.h" #include "brw_rt.h" diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index f31e012cfc0..6ee443fb6f6 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -32,9 +32,9 @@ #include "brw_compiler.h" #include "brw_inst.h" #include "brw_ir_allocator.h" -#include "brw_fs_live_variables.h" #include "brw_ir_performance.h" #include "compiler/nir/nir.h" +#include "brw_analysis.h" struct fs_visitor; diff --git a/src/intel/compiler/brw_fs_live_variables.h b/src/intel/compiler/brw_fs_live_variables.h deleted file mode 100644 index 8fd07d4543a..00000000000 --- a/src/intel/compiler/brw_fs_live_variables.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright © 2012 Intel Corporation - * - * 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, sublicense, - * 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 NONINFRINGEMENT. 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: - * Eric Anholt - * - */ - -#pragma once - -#include "brw_inst.h" -#include "brw_ir_analysis.h" -#include "util/bitset.h" - -struct cfg_t; -struct fs_visitor; - -namespace brw { - -class fs_live_variables { -public: - struct block_data { - /** - * Which variables are defined before being used in the block. - * - * Note that for our purposes, "defined" means unconditionally, completely - * defined. - */ - BITSET_WORD *def; - - /** - * Which variables are used before being defined in the block. - */ - BITSET_WORD *use; - - /** Which defs reach the entry point of the block. */ - BITSET_WORD *livein; - - /** Which defs reach the exit point of the block. */ - BITSET_WORD *liveout; - - /** - * Variables such that the entry point of the block may be reached from any - * of their definitions. - */ - BITSET_WORD *defin; - - /** - * Variables such that the exit point of the block may be reached from any - * of their definitions. - */ - BITSET_WORD *defout; - - BITSET_WORD flag_def[1]; - BITSET_WORD flag_use[1]; - BITSET_WORD flag_livein[1]; - BITSET_WORD flag_liveout[1]; - }; - - fs_live_variables(const fs_visitor *s); - ~fs_live_variables(); - - bool validate(const fs_visitor *s) const; - - analysis_dependency_class - dependency_class() const - { - return (DEPENDENCY_INSTRUCTION_IDENTITY | - DEPENDENCY_INSTRUCTION_DATA_FLOW | - DEPENDENCY_VARIABLES); - } - - bool vars_interfere(int a, int b) const; - bool vgrfs_interfere(int a, int b) const; - int var_from_reg(const brw_reg ®) const - { - return var_from_vgrf[reg.nr] + reg.offset / REG_SIZE; - } - - /** Map from virtual GRF number to index in block_data arrays. */ - int *var_from_vgrf; - - /** - * Map from any index in block_data to the virtual GRF containing it. - * - * For alloc.sizes of [1, 2, 3], vgrf_from_var would contain - * [0, 1, 1, 2, 2, 2]. - */ - int *vgrf_from_var; - - int num_vars; - int num_vgrfs; - int bitset_words; - - /** @{ - * Final computed live ranges for each var (each component of each virtual - * GRF). - */ - int *start; - int *end; - /** @} */ - - /** @{ - * Final computed live ranges for each VGRF. - */ - int *vgrf_start; - int *vgrf_end; - /** @} */ - - /** Per-basic-block information on live variables */ - struct block_data *block_data; - -protected: - void setup_def_use(); - void setup_one_read(struct block_data *bd, int ip, const brw_reg ®); - void setup_one_write(struct block_data *bd, brw_inst *inst, int ip, - const brw_reg ®); - void compute_live_variables(); - void compute_start_end(); - - const struct intel_device_info *devinfo; - const cfg_t *cfg; - void *mem_ctx; -}; - -} /* namespace brw */ diff --git a/src/intel/compiler/brw_opt_copy_propagation.cpp b/src/intel/compiler/brw_opt_copy_propagation.cpp index e4dfcaf2827..9e29c0bd5ad 100644 --- a/src/intel/compiler/brw_opt_copy_propagation.cpp +++ b/src/intel/compiler/brw_opt_copy_propagation.cpp @@ -36,7 +36,7 @@ #include "util/u_math.h" #include "util/rb_tree.h" #include "brw_fs.h" -#include "brw_fs_live_variables.h" +#include "brw_analysis.h" #include "brw_cfg.h" #include "brw_eu.h" diff --git a/src/intel/compiler/brw_opt_dead_code_eliminate.cpp b/src/intel/compiler/brw_opt_dead_code_eliminate.cpp index d2e28b40695..e868fd6c0fc 100644 --- a/src/intel/compiler/brw_opt_dead_code_eliminate.cpp +++ b/src/intel/compiler/brw_opt_dead_code_eliminate.cpp @@ -22,7 +22,7 @@ */ #include "brw_fs.h" -#include "brw_fs_live_variables.h" +#include "brw_analysis.h" #include "brw_cfg.h" /** @file diff --git a/src/intel/compiler/brw_opt_register_coalesce.cpp b/src/intel/compiler/brw_opt_register_coalesce.cpp index decd144a9b6..98f9a08bb10 100644 --- a/src/intel/compiler/brw_opt_register_coalesce.cpp +++ b/src/intel/compiler/brw_opt_register_coalesce.cpp @@ -40,9 +40,9 @@ * mul vgrf5:F, vgrf5:F, vgrf4:F */ +#include "brw_analysis.h" #include "brw_fs.h" #include "brw_cfg.h" -#include "brw_fs_live_variables.h" using namespace brw; diff --git a/src/intel/compiler/brw_opt_saturate_propagation.cpp b/src/intel/compiler/brw_opt_saturate_propagation.cpp index a81d1fea05c..1645802131b 100644 --- a/src/intel/compiler/brw_opt_saturate_propagation.cpp +++ b/src/intel/compiler/brw_opt_saturate_propagation.cpp @@ -21,8 +21,8 @@ * IN THE SOFTWARE. */ +#include "brw_analysis.h" #include "brw_fs.h" -#include "brw_fs_live_variables.h" #include "brw_cfg.h" using namespace brw; diff --git a/src/intel/compiler/brw_schedule_instructions.cpp b/src/intel/compiler/brw_schedule_instructions.cpp index 1e5071b911f..236e04d4c78 100644 --- a/src/intel/compiler/brw_schedule_instructions.cpp +++ b/src/intel/compiler/brw_schedule_instructions.cpp @@ -27,7 +27,7 @@ #include "brw_eu.h" #include "brw_fs.h" -#include "brw_fs_live_variables.h" +#include "brw_analysis.h" #include "brw_cfg.h" #include diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build index 7b7d4e27585..33851bf7d21 100644 --- a/src/intel/compiler/meson.build +++ b/src/intel/compiler/meson.build @@ -22,6 +22,7 @@ intel_nir_files = files( libintel_compiler_brw_files = files( 'brw_analysis.h', + 'brw_analysis_liveness.cpp', 'brw_builder.cpp', 'brw_builder.h', 'brw_cfg.cpp', @@ -51,8 +52,6 @@ libintel_compiler_brw_files = files( 'brw_from_nir.cpp', 'brw_fs.cpp', 'brw_fs.h', - 'brw_fs_live_variables.cpp', - 'brw_fs_live_variables.h', 'brw_fs_thread_payload.cpp', 'brw_fs_visitor.cpp', 'brw_generator.cpp',