From 1ebada0dad96d9239ef4438b45f5d38f73dbfc32 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 7 Feb 2023 21:28:09 +0000 Subject: [PATCH] tint: Use ProgramBuilder::Return() Change-Id: I2de08d2d9274b0a849e44a5dafbeaf2a731318ce Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118984 Reviewed-by: James Price Kokoro: Kokoro --- src/tint/reader/spirv/function.cc | 11 +++++------ src/tint/reader/wgsl/parser_impl.cc | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index 052d186538..5592f1cf07 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -1392,7 +1392,7 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() { return_type = builder_.ty.Of(str); // Add the return-value statement. - stmts.Push(create( + 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(Source{})); + AddStatement(builder_.Return(Source{})); return true; case spv::Op::OpReturnValue: { auto value = MakeExpression(terminator.GetSingleWordInOperand(0)); if (!value) { return false; } - AddStatement(create(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(Source{})); + AddStatement(builder_.Return(Source{})); } else { auto* ast_type = parser_impl_.ConvertType(function_.type_id()); - AddStatement(create( - Source{}, parser_impl_.MakeNullValue(ast_type))); + AddStatement(builder_.Return(Source{}, parser_impl_.MakeNullValue(ast_type))); } } return true; diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index dfe57fd808..c72db34568 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -1904,7 +1904,7 @@ Maybe ParserImpl::return_statement() { } if (peek_is(Token::Type::kSemicolon)) { - return create(source, nullptr); + return builder_.Return(source, nullptr); } auto expr = expression(); @@ -1913,7 +1913,7 @@ Maybe ParserImpl::return_statement() { } // TODO(bclayton): Check matched? - return create(source, expr.value); + return builder_.Return(source, expr.value); } // variable_statement