From 6f37e6f104463d9b685c663e869b07158fcadff6 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Thu, 27 Feb 2025 22:48:36 -0800 Subject: [PATCH] brw: Add explicit way to get an empty brw_builder And use brw_builder(brw_shader *) and brw_builder() constructors where possible. The way tests are written, it is necessary to initialize an "empty" builder -- which is later replaced by a proper one. Default parameter NULL make that initialization implicit. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_builder.h | 9 ++++++++- src/intel/compiler/test_lower_scoreboard.cpp | 1 - src/intel/compiler/test_opt_cmod_propagation.cpp | 1 - src/intel/compiler/test_opt_combine_constants.cpp | 2 +- src/intel/compiler/test_opt_copy_propagation.cpp | 1 - src/intel/compiler/test_opt_cse.cpp | 1 - src/intel/compiler/test_opt_saturate_propagation.cpp | 1 - 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/intel/compiler/brw_builder.h b/src/intel/compiler/brw_builder.h index fc2e708baa2..5e9eb977038 100644 --- a/src/intel/compiler/brw_builder.h +++ b/src/intel/compiler/brw_builder.h @@ -50,7 +50,14 @@ public: { } - explicit brw_builder(brw_shader *s) : brw_builder(s, s->dispatch_width) {} + /** + * Construct an brw_builder that inserts instructions into \p shader, + * using its dispatch width. + */ + explicit brw_builder(brw_shader *s = NULL) : + brw_builder(s, s ? s->dispatch_width : 0) + { + } /** * Construct an brw_builder that inserts instructions before diff --git a/src/intel/compiler/test_lower_scoreboard.cpp b/src/intel/compiler/test_lower_scoreboard.cpp index 288e7d27ef6..48fdb70e185 100644 --- a/src/intel/compiler/test_lower_scoreboard.cpp +++ b/src/intel/compiler/test_lower_scoreboard.cpp @@ -42,7 +42,6 @@ protected: }; scoreboard_test::scoreboard_test() - : bld(NULL, 0) { ctx = ralloc_context(NULL); compiler = rzalloc(ctx, struct brw_compiler); diff --git a/src/intel/compiler/test_opt_cmod_propagation.cpp b/src/intel/compiler/test_opt_cmod_propagation.cpp index f9cc7b091d3..d4e4edc4dc7 100644 --- a/src/intel/compiler/test_opt_cmod_propagation.cpp +++ b/src/intel/compiler/test_opt_cmod_propagation.cpp @@ -53,7 +53,6 @@ protected: }; cmod_propagation_test::cmod_propagation_test() - : bld(NULL, 0) { ctx = ralloc_context(NULL); compiler = rzalloc(ctx, struct brw_compiler); diff --git a/src/intel/compiler/test_opt_combine_constants.cpp b/src/intel/compiler/test_opt_combine_constants.cpp index ec1efb2bb2e..7a6e065a143 100644 --- a/src/intel/compiler/test_opt_combine_constants.cpp +++ b/src/intel/compiler/test_opt_combine_constants.cpp @@ -68,7 +68,7 @@ struct FSCombineConstantsTest : public ::testing::Test { static brw_builder make_builder(brw_shader *s) { - return brw_builder(s, s->dispatch_width).at_end(); + return brw_builder(s).at_end(); } TEST_F(FSCombineConstantsTest, Simple) diff --git a/src/intel/compiler/test_opt_copy_propagation.cpp b/src/intel/compiler/test_opt_copy_propagation.cpp index 3b61f80f99a..430b67aa64d 100644 --- a/src/intel/compiler/test_opt_copy_propagation.cpp +++ b/src/intel/compiler/test_opt_copy_propagation.cpp @@ -42,7 +42,6 @@ protected: }; copy_propagation_test::copy_propagation_test() - : bld(NULL, 0) { ctx = ralloc_context(NULL); compiler = rzalloc(ctx, struct brw_compiler); diff --git a/src/intel/compiler/test_opt_cse.cpp b/src/intel/compiler/test_opt_cse.cpp index 6f7633a6beb..edf117662dc 100644 --- a/src/intel/compiler/test_opt_cse.cpp +++ b/src/intel/compiler/test_opt_cse.cpp @@ -24,7 +24,6 @@ protected: }; cse_test::cse_test() - : bld(NULL, 0) { ctx = ralloc_context(NULL); compiler = rzalloc(ctx, struct brw_compiler); diff --git a/src/intel/compiler/test_opt_saturate_propagation.cpp b/src/intel/compiler/test_opt_saturate_propagation.cpp index 1eb99c06fea..34e940015cd 100644 --- a/src/intel/compiler/test_opt_saturate_propagation.cpp +++ b/src/intel/compiler/test_opt_saturate_propagation.cpp @@ -42,7 +42,6 @@ protected: }; saturate_propagation_test::saturate_propagation_test() - : bld(NULL, 0) { ctx = ralloc_context(NULL); compiler = rzalloc(ctx, struct brw_compiler);