[ir] Restore losts tests.

When the `BuilderImpl` tests were split apart in 131581 these two files
accidentally got created in the wrong spot. This removed them from being
tested.

Add them back and update format to match current disassembly.

Bug: tint:1718
Change-Id: I9b248121a9f45862060d44f50a290344e1222874
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/134440
Kokoro: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair 2023-05-25 14:00:55 +00:00 committed by Dawn LUCI CQ
parent a2b489b900
commit 686d2e2d4d
4 changed files with 95 additions and 85 deletions

View File

@ -2264,7 +2264,9 @@ if (tint_build_unittests) {
"ir/constant_test.cc",
"ir/discard_test.cc",
"ir/from_program_binary_test.cc",
"ir/from_program_builtin_test.cc",
"ir/from_program_call_test.cc",
"ir/from_program_function_test.cc",
"ir/from_program_literal_test.cc",
"ir/from_program_materialize_test.cc",
"ir/from_program_store_test.cc",

View File

@ -1468,7 +1468,9 @@ if(TINT_BUILD_TESTS)
ir/constant_test.cc
ir/discard_test.cc
ir/from_program_binary_test.cc
ir/from_program_builtin_test.cc
ir/from_program_call_test.cc
ir/from_program_function_test.cc
ir/from_program_literal_test.cc
ir/from_program_materialize_test.cc
ir/from_program_store_test.cc

View File

@ -31,22 +31,25 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Builtin) {
auto* expr = Call("asin", i);
WrapInFunction(expr);
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m), R"(%fn0 = block
%1:ref<private, f32, read_write> = var private read_write
store %1:ref<private, f32, read_write>, 1.0f
EXPECT_EQ(Disassemble(m.Get()), R"(# Root block
%fn1 = block {
%i:ptr<private, f32, read_write> = var, 1.0f
br %fn2 # root_end
}
%fn2 = root_terminator
%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)]
%fn2 = block
%2:f32 = asin %1:ref<private, f32, read_write>
ret
func_end
%test_function = func():void [@compute @workgroup_size(1, 1, 1)] -> %fn3 {
%fn3 = block {
%3:f32 = load %i
%tint_symbol:f32 = asin %3
br %fn4 # return
}
%fn4 = func_terminator
}
)");
}

View File

@ -31,15 +31,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_Vertex) {
utils::Vector{Stage(ast::PipelineStage::kVertex)},
utils::Vector{Builtin(builtin::BuiltinValue::kPosition)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():vec4<f32> [@vertex ra: @position]
%fn1 = block
ret vec4<f32> 0.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():vec4<f32> [@vertex ra: @position] -> %fn1 {
%fn1 = block {
br %fn2 vec4<f32> 0.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -47,15 +47,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_Fragment) {
Func("test", utils::Empty, ty.void_(), utils::Empty,
utils::Vector{Stage(ast::PipelineStage::kFragment)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():void [@fragment]
%fn1 = block
ret
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():void [@fragment] -> %fn1 {
%fn1 = block {
br %fn2 # return
}
%fn2 = func_terminator
}
)");
}
@ -63,15 +63,16 @@ TEST_F(IR_BuilderImplTest, EmitFunction_Compute) {
Func("test", utils::Empty, ty.void_(), utils::Empty,
utils::Vector{Stage(ast::PipelineStage::kCompute), WorkgroupSize(8_i, 4_i, 2_i)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():void [@compute @workgroup_size(8, 4, 2)]
%fn1 = block
ret
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()),
R"(%test = func():void [@compute @workgroup_size(8, 4, 2)] -> %fn1 {
%fn1 = block {
br %fn2 # return
}
%fn2 = func_terminator
}
)");
}
@ -79,15 +80,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_Return) {
Func("test", utils::Empty, ty.vec3<f32>(), utils::Vector{Return(vec3<f32>(0_f, 0_f, 0_f))},
utils::Empty);
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():vec3<f32>
%fn1 = block
ret vec3<f32> 0.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():vec3<f32> -> %fn1 {
%fn1 = block {
br %fn2 vec3<f32> 0.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -96,15 +97,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_ReturnPosition) {
utils::Vector{Stage(ast::PipelineStage::kVertex)},
utils::Vector{Builtin(builtin::BuiltinValue::kPosition)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():vec4<f32> [@vertex ra: @position]
%fn1 = block
ret vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():vec4<f32> [@vertex ra: @position] -> %fn1 {
%fn1 = block {
br %fn2 vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -113,15 +114,16 @@ TEST_F(IR_BuilderImplTest, EmitFunction_ReturnPositionInvariant) {
utils::Vector{Stage(ast::PipelineStage::kVertex)},
utils::Vector{Builtin(builtin::BuiltinValue::kPosition), Invariant()});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():vec4<f32> [@vertex ra: @position @invariant]
%fn1 = block
ret vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()),
R"(%test = func():vec4<f32> [@vertex ra: @position @invariant] -> %fn1 {
%fn1 = block {
br %fn2 vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -129,15 +131,16 @@ TEST_F(IR_BuilderImplTest, EmitFunction_ReturnLocation) {
Func("test", utils::Empty, ty.vec4<f32>(), utils::Vector{Return(vec4<f32>(1_f, 2_f, 3_f, 4_f))},
utils::Vector{Stage(ast::PipelineStage::kFragment)}, utils::Vector{Location(1_i)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():vec4<f32> [@fragment ra: @location(1)]
%fn1 = block
ret vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()),
R"(%test = func():vec4<f32> [@fragment ra: @location(1)] -> %fn1 {
%fn1 = block {
br %fn2 vec4<f32> 1.0f, 2.0f, 3.0f, 4.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -146,15 +149,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_ReturnFragDepth) {
utils::Vector{Stage(ast::PipelineStage::kFragment)},
utils::Vector{Builtin(builtin::BuiltinValue::kFragDepth)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():f32 [@fragment ra: @frag_depth]
%fn1 = block
ret 1.0f
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():f32 [@fragment ra: @frag_depth] -> %fn1 {
%fn1 = block {
br %fn2 1.0f # return
}
%fn2 = func_terminator
}
)");
}
@ -163,15 +166,15 @@ TEST_F(IR_BuilderImplTest, EmitFunction_ReturnSampleMask) {
utils::Vector{Stage(ast::PipelineStage::kFragment)},
utils::Vector{Builtin(builtin::BuiltinValue::kSampleMask)});
auto r = Build();
ASSERT_TRUE(r) << Error();
auto m = r.Move();
EXPECT_EQ(Disassemble(m), R"(%fn0 = func test():u32 [@fragment ra: @sample_mask]
%fn1 = block
ret 1u
func_end
auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%test = func():u32 [@fragment ra: @sample_mask] -> %fn1 {
%fn1 = block {
br %fn2 1u # return
}
%fn2 = func_terminator
}
)");
}