[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>
This commit is contained in:
dan sinclair 2022-11-21 21:39:42 +00:00 committed by Dawn LUCI CQ
parent 2f60bbdf9c
commit a32b6b4a0f
2 changed files with 9 additions and 31 deletions

View File

@ -3261,11 +3261,8 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
// 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 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
// 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 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
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 @@ const ast::Statement* FunctionEmitter::MakeBranchDetailed(const BlockInfo& src_i
// 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;

View File

@ -721,36 +721,22 @@ class FunctionEmitter {
/// @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