tint: Remove ast::Void

WGSL does not have a void type. Functions that do not return a value
simply omit the return type from the function signature.

Change-Id: Id45adc008dce46115552e7dc401a2e27ae10eeb4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118981
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2023-02-07 21:28:09 +00:00
parent 08fd42f08a
commit 1906857a50
19 changed files with 63 additions and 154 deletions

View File

@@ -154,7 +154,7 @@ class State {
flag = b.Symbols().New("tint_return_flag");
new_stmts[0].Push(b.Decl(b.Var(flag, b.ty.bool_())));
if (!function->return_type->Is<ast::Void>()) {
if (function->return_type) {
retval = b.Symbols().New("tint_return_value");
new_stmts[0].Push(b.Decl(b.Var(retval, ctx.Clone(function->return_type))));
}

View File

@@ -75,7 +75,7 @@ void Transform::RemoveStatement(CloneContext& ctx, const ast::Statement* stmt) {
const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type* ty) {
if (ty->Is<type::Void>()) {
return ctx.dst->create<ast::Void>();
return nullptr;
}
if (ty->Is<type::I32>()) {
return ctx.dst->create<ast::I32>();

View File

@@ -45,7 +45,7 @@ TEST_F(CreateASTTypeForTest, Basic) {
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::U32>(); })->Is<ast::U32>());
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::F32>(); })->Is<ast::F32>());
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::Bool>(); })->Is<ast::Bool>());
EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create<type::Void>(); })->Is<ast::Void>());
EXPECT_EQ(create([](ProgramBuilder& b) { return b.create<type::Void>(); }), nullptr);
}
TEST_F(CreateASTTypeForTest, Matrix) {