tint: Use ProgramBuilder::Return()

Change-Id: I2de08d2d9274b0a849e44a5dafbeaf2a731318ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118984
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2023-02-07 21:28:09 +00:00
parent 6adb65c488
commit 1ebada0dad
2 changed files with 7 additions and 8 deletions

View File

@ -1392,7 +1392,7 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() {
return_type = builder_.ty.Of(str);
// Add the return-value statement.
stmts.Push(create<ast::ReturnStatement>(
stmts.Push(builder_.Return(
source, builder_.Call(source, return_type, std::move(return_exprs))));
}
}
@ -3124,14 +3124,14 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
const auto& terminator = *(block_info.basic_block->terminator());
switch (opcode(terminator)) {
case spv::Op::OpReturn:
AddStatement(create<ast::ReturnStatement>(Source{}));
AddStatement(builder_.Return(Source{}));
return true;
case spv::Op::OpReturnValue: {
auto value = MakeExpression(terminator.GetSingleWordInOperand(0));
if (!value) {
return false;
}
AddStatement(create<ast::ReturnStatement>(Source{}, value.expr));
AddStatement(builder_.Return(Source{}, value.expr));
return true;
}
case spv::Op::OpKill:
@ -3145,11 +3145,10 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) {
{
const auto* result_type = type_mgr_->GetType(function_.type_id());
if (result_type->AsVoid() != nullptr) {
AddStatement(create<ast::ReturnStatement>(Source{}));
AddStatement(builder_.Return(Source{}));
} else {
auto* ast_type = parser_impl_.ConvertType(function_.type_id());
AddStatement(create<ast::ReturnStatement>(
Source{}, parser_impl_.MakeNullValue(ast_type)));
AddStatement(builder_.Return(Source{}, parser_impl_.MakeNullValue(ast_type)));
}
}
return true;

View File

@ -1904,7 +1904,7 @@ Maybe<const ast::ReturnStatement*> ParserImpl::return_statement() {
}
if (peek_is(Token::Type::kSemicolon)) {
return create<ast::ReturnStatement>(source, nullptr);
return builder_.Return(source, nullptr);
}
auto expr = expression();
@ -1913,7 +1913,7 @@ Maybe<const ast::ReturnStatement*> ParserImpl::return_statement() {
}
// TODO(bclayton): Check matched?
return create<ast::ReturnStatement>(source, expr.value);
return builder_.Return(source, expr.value);
}
// variable_statement