[spirv-reader] Remove `forced` param from `MakeBranchDetailed`.
The `forced` parameter is always false, remove it.
Change-Id: I9aa16dfc6a51516f6b6e619a3c8ce982a25ba4c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111101
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc
index fc465fb..b344246 100644
--- a/src/tint/reader/spirv/function.cc
+++ b/src/tint/reader/spirv/function.cc
@@ -3261,11 +3261,8 @@
// start of an if-selection or a switch-selection. So at most one branch
// is a kForward, kCaseFallThrough, or kIfBreak.
- // The fallthrough case is special because WGSL requires the fallthrough
- // statement to be last in the case clause.
- if (true_kind == EdgeKind::kCaseFallThrough) {
- return Fail() << "Fallthrough not supported in WGSL";
- } else if (false_kind == EdgeKind::kCaseFallThrough) {
+ if (true_kind == EdgeKind::kCaseFallThrough ||
+ false_kind == EdgeKind::kCaseFallThrough) {
return Fail() << "Fallthrough not supported in WGSL";
}
@@ -3278,8 +3275,8 @@
// requiring a flow guard, then get that flow guard name too. It will
// come from at most one of these two branches.
std::string flow_guard;
- auto* true_branch = MakeBranchDetailed(block_info, *true_info, false, &flow_guard);
- auto* false_branch = MakeBranchDetailed(block_info, *false_info, false, &flow_guard);
+ auto* true_branch = MakeBranchDetailed(block_info, *true_info, &flow_guard);
+ auto* false_branch = MakeBranchDetailed(block_info, *false_info, &flow_guard);
AddStatement(MakeSimpleIf(cond, true_branch, false_branch));
if (!flow_guard.empty()) {
@@ -3304,7 +3301,6 @@
const ast::Statement* FunctionEmitter::MakeBranchDetailed(const BlockInfo& src_info,
const BlockInfo& dest_info,
- bool forced,
std::string* flow_guard_name_ptr) {
auto kind = src_info.succ_edge.find(dest_info.id)->second;
switch (kind) {
@@ -3312,11 +3308,7 @@
// Nothing to do. The loop backedge is implicit.
break;
case EdgeKind::kSwitchBreak: {
- if (forced) {
- return create<ast::BreakStatement>(Source{});
- }
- // Unless forced, don't bother with a break at the end of a case/default
- // clause.
+ // Don't bother with a break at the end of a case/default clause.
const auto header = dest_info.header_for_merge;
TINT_ASSERT(Reader, header != 0);
const auto* exiting_construct = GetBlockInfo(header)->construct;
diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h
index 917b374..65a1e3b 100644
--- a/src/tint/reader/spirv/function.h
+++ b/src/tint/reader/spirv/function.h
@@ -721,36 +721,22 @@
/// @param dest_info the destination block
/// @returns the new statement, or a null statement
const ast::Statement* MakeBranch(const BlockInfo& src_info, const BlockInfo& dest_info) {
- return MakeBranchDetailed(src_info, dest_info, false, nullptr);
+ return MakeBranchDetailed(src_info, dest_info, nullptr);
}
/// Returns a new statement to represent the given branch representing a
/// "normal" terminator, as in the sense of EmitNormalTerminator. If no
- /// WGSL statement is required, the statement will be nullptr.
- /// @param src_info the source block
- /// @param dest_info the destination block
- /// @returns the new statement, or a null statement
- const ast::Statement* MakeForcedBranch(const BlockInfo& src_info, const BlockInfo& dest_info) {
- return MakeBranchDetailed(src_info, dest_info, true, nullptr);
- }
-
- /// Returns a new statement to represent the given branch representing a
- /// "normal" terminator, as in the sense of EmitNormalTerminator. If no
- /// WGSL statement is required, the statement will be nullptr. When `forced`
- /// is false, this method tries to avoid emitting a 'break' statement when
- /// that would be redundant in WGSL due to implicit breaking out of a switch.
- /// When `forced` is true, the method won't try to avoid emitting that break.
- /// If the control flow edge is an if-break for an if-selection with a
+ /// WGSL statement is required, the statement will be nullptr. This method tries to avoid
+ /// emitting a 'break' statement when that would be redundant in WGSL due to implicit breaking
+ /// out of a switch. If the control flow edge is an if-break for an if-selection with a
/// control flow guard, then return that guard name via `flow_guard_name_ptr`
/// when that parameter is not null.
/// @param src_info the source block
/// @param dest_info the destination block
- /// @param forced if true, always emit the branch (if it exists in WGSL)
/// @param flow_guard_name_ptr return parameter for control flow guard name
/// @returns the new statement, or a null statement
const ast::Statement* MakeBranchDetailed(const BlockInfo& src_info,
const BlockInfo& dest_info,
- bool forced,
std::string* flow_guard_name_ptr);
/// Returns a new if statement with the given statements as the then-clause