[ir] Add store test

This CL adds a simple test for the builder_impl for assignments.

Bug: tint:1718
Change-Id: Ia727ace4d01f107c6ac2ad1f8e430ef00ec43da9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131660
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
dan sinclair 2023-05-04 20:46:02 +00:00 committed by Dawn LUCI CQ
parent 5f4842e358
commit eae9902c81
3 changed files with 56 additions and 0 deletions

View File

@ -2149,6 +2149,7 @@ if (tint_build_unittests) {
"ir/builder_impl_call_test.cc",
"ir/builder_impl_literal_test.cc",
"ir/builder_impl_materialize_test.cc",
"ir/builder_impl_store_test.cc",
"ir/builder_impl_test.cc",
"ir/builder_impl_unary_test.cc",
"ir/builder_impl_var_test.cc",

View File

@ -1446,6 +1446,7 @@ if(TINT_BUILD_TESTS)
ir/builder_impl_call_test.cc
ir/builder_impl_literal_test.cc
ir/builder_impl_materialize_test.cc
ir/builder_impl_store_test.cc
ir/builder_impl_test.cc
ir/builder_impl_unary_test.cc
ir/builder_impl_var_test.cc

View File

@ -0,0 +1,54 @@
// Copyright 2023 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/ir/test_helper.h"
#include "gmock/gmock.h"
#include "src/tint/ast/case_selector.h"
#include "src/tint/ast/int_literal_expression.h"
#include "src/tint/constant/scalar.h"
namespace tint::ir {
namespace {
using namespace tint::number_suffixes; // NOLINT
using IR_BuilderImplTest = TestHelper;
TEST_F(IR_BuilderImplTest, EmitStatement_Assign) {
GlobalVar("a", ty.u32(), builtin::AddressSpace::kPrivate);
auto* expr = Assign("a", 4_u);
WrapInFunction(expr);
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = block
%1:ref<private, u32, read_write> = var private read_write
%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)]
%fn2 = block
store %1:ref<private, u32, read_write>, 4u
ret
func_end
)");
}
} // namespace
} // namespace tint::ir