Skip to content

Commit

Permalink
[tint] Remove Builder::Prepend()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: dan sinclair <[email protected]>
Auto-Submit: James Price <[email protected]>
  • Loading branch information
jrprice authored and Dawn LUCI CQ committed Aug 21, 2024
1 parent d117d65 commit 7ce7b5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
18 changes: 0 additions & 18 deletions src/tint/lang/core/ir/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -165,7 +157,6 @@ class Builder {
/// A variant of different instruction insertion methods
using InsertionPoint = std::variant<InsertionPoints::NoInsertion,
InsertionPoints::AppendToBlock,
InsertionPoints::PrependToBlock,
InsertionPoints::InsertAfter,
InsertionPoints::InsertBefore>;

Expand Down Expand Up @@ -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 <typename FUNCTION>
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
Expand Down
6 changes: 3 additions & 3 deletions src/tint/lang/spirv/reader/lower/shader_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 7ce7b5b

Please sign in to comment.