From 7ce7b5be549cf51d25ff0f38a6e298cb45b4deb6 Mon Sep 17 00:00:00 2001 From: James Price Date: Wed, 21 Aug 2024 01:22:12 +0000 Subject: [PATCH] [tint] Remove Builder::Prepend() When using this helper to insert multiple instruction, the order of the instructions becomes reversed, which is unintuitive. This was only used in one place, and that usage only inserted a single instruction. Change-Id: I08dfd71203c78b80457a90eceb5ff72d8c23e109 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/203315 Commit-Queue: James Price Reviewed-by: dan sinclair Auto-Submit: James Price --- src/tint/lang/core/ir/builder.h | 18 ------------------ src/tint/lang/spirv/reader/lower/shader_io.cc | 6 +++--- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/tint/lang/core/ir/builder.h b/src/tint/lang/core/ir/builder.h index dd2d3011c99..d2c98ce8797 100644 --- a/src/tint/lang/core/ir/builder.h +++ b/src/tint/lang/core/ir/builder.h @@ -136,14 +136,6 @@ class Builder { /// @param i the instruction to insert void operator()(ir::Instruction* i) { block->Append(i); } }; - /// Insertion point method that inserts the instruction to the front of #block - struct PrependToBlock { - /// The block to insert new instructions to the front of - ir::Block* block = nullptr; - /// The insertion point function - /// @param i the instruction to insert - void operator()(ir::Instruction* i) { block->Prepend(i); } - }; /// Insertion point method that inserts the instruction after #after struct InsertAfter { /// The instruction to insert new instructions after @@ -165,7 +157,6 @@ class Builder { /// A variant of different instruction insertion methods using InsertionPoint = std::variant; @@ -197,15 +188,6 @@ class Builder { cb(); } - /// Calls @p cb with the builder prepending to block @p b - /// @param b the block to set as the block to prepend to - /// @param cb the function to call with the builder prepending to block @p b - template - void Prepend(ir::Block* b, FUNCTION&& cb) { - TINT_SCOPED_ASSIGNMENT(insertion_point_, InsertionPoints::PrependToBlock{b}); - cb(); - } - /// Calls @p cb with the builder inserting after @p ip /// @param ip the insertion point for new instructions /// @param cb the function to call with the builder inserting new instructions after @p ip diff --git a/src/tint/lang/spirv/reader/lower/shader_io.cc b/src/tint/lang/spirv/reader/lower/shader_io.cc index 26ad574400e..7f402d665c2 100644 --- a/src/tint/lang/spirv/reader/lower/shader_io.cc +++ b/src/tint/lang/spirv/reader/lower/shader_io.cc @@ -352,9 +352,9 @@ struct State { core::ir::Value* result = param; if (entry_point && var->Attributes().builtin == core::BuiltinValue::kSampleMask) { // Construct an array from the scalar sample_mask builtin value for entry points. - b.Prepend(func->Block(), [&] { // - result = b.Construct(var->Result(0)->Type()->UnwrapPtr(), param)->Result(0); - }); + auto* construct = b.Construct(var->Result(0)->Type()->UnwrapPtr(), param); + func->Block()->Prepend(construct); + result = construct->Result(0); } return result; });