[ir] Update disassembly output.

This CL updates the disassembly output to make it clearer when
instructions are flow node traversals, and when they're actual
instructions in a block.

Bug: tint:1718
Change-Id: I95e103a5672b5579081b73e9633bf07b31e51187
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133161
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2023-05-16 21:21:21 +00:00 committed by Dawn LUCI CQ
parent 7ddaaf23cf
commit 0df7f8bccd
8 changed files with 733 additions and 722 deletions

View File

@ -138,13 +138,14 @@ void Disassembler::Walk(const FlowNode* node) {
out_ << "]"; out_ << "]";
} }
out_ << std::endl; out_ << " {" << std::endl;
{ {
ScopedIndent func_indent(indent_size_); ScopedIndent func_indent(indent_size_);
ScopedStopNode scope(stop_nodes_, f->end_target); ScopedStopNode scope(stop_nodes_, f->end_target);
Walk(f->start_target); Walk(f->start_target);
} }
out_ << "} ";
Walk(f->end_target); Walk(f->end_target);
}, },
[&](const ir::Block* b) { [&](const ir::Block* b) {
@ -153,16 +154,23 @@ void Disassembler::Walk(const FlowNode* node) {
return; return;
} }
Indent() << "%fn" << IdOf(b) << " = block" << std::endl; Indent() << "%fn" << IdOf(b) << " = block {" << std::endl;
{
ScopedIndent si(indent_size_);
EmitBlockInstructions(b); EmitBlockInstructions(b);
}
Indent() << "}";
std::string suffix = "";
if (b->branch.target->Is<FunctionTerminator>()) { if (b->branch.target->Is<FunctionTerminator>()) {
Indent() << "ret"; out_ << " -> %func_end";
suffix = "return";
} else if (b->branch.target->Is<RootTerminator>()) { } else if (b->branch.target->Is<RootTerminator>()) {
// Nothing to do // Nothing to do
} else { } else {
Indent() << "branch " out_ << " -> "
<< "%fn" << IdOf(b->branch.target); << "%fn" << IdOf(b->branch.target);
suffix = "branch";
} }
if (!b->branch.args.IsEmpty()) { if (!b->branch.args.IsEmpty()) {
out_ << " "; out_ << " ";
@ -173,6 +181,9 @@ void Disassembler::Walk(const FlowNode* node) {
EmitValue(v); EmitValue(v);
} }
} }
if (!suffix.empty()) {
out_ << " # " << suffix;
}
out_ << std::endl; out_ << std::endl;
if (!b->branch.target->Is<FunctionTerminator>()) { if (!b->branch.target->Is<FunctionTerminator>()) {
@ -294,7 +305,7 @@ void Disassembler::Walk(const FlowNode* node) {
}, },
[&](const ir::FunctionTerminator*) { [&](const ir::FunctionTerminator*) {
TINT_ASSERT(IR, in_function_); TINT_ASSERT(IR, in_function_);
Indent() << "func_end" << std::endl << std::endl; Indent() << "%func_end" << std::endl << std::endl;
}, },
[&](const ir::RootTerminator*) { [&](const ir::RootTerminator*) {
TINT_ASSERT(IR, !in_function_); TINT_ASSERT(IR, !in_function_);

View File

@ -34,17 +34,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Add) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = add %1:u32, 4u %tint_symbol:u32 = add %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -57,17 +57,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAdd) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = add %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = add %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -80,17 +80,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Subtract) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = sub %1:u32, 4u %tint_symbol:u32 = sub %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -103,17 +103,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundSubtract) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = sub %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = sub %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -126,17 +126,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Multiply) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = mul %1:u32, 4u %tint_symbol:u32 = mul %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -149,17 +149,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundMultiply) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = mul %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = mul %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -172,17 +172,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Div) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = div %1:u32, 4u %tint_symbol:u32 = div %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -195,17 +195,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundDiv) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = div %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = div %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -218,17 +218,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Modulo) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = mod %1:u32, 4u %tint_symbol:u32 = mod %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -241,17 +241,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundModulo) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = mod %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = mod %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -264,17 +264,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_And) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = and %1:u32, 4u %tint_symbol:u32 = and %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -287,17 +287,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundAnd) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, bool, read_write> = var private, read_write %v1:ref<private, bool, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, bool, read_write> = and %v1:ref<private, bool, read_write>, false %2:ref<private, bool, read_write> = and %v1:ref<private, bool, read_write>, false
store %v1:ref<private, bool, read_write>, %2:ref<private, bool, read_write> store %v1:ref<private, bool, read_write>, %2:ref<private, bool, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -310,17 +310,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Or) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = or %1:u32, 4u %tint_symbol:u32 = or %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -333,17 +333,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundOr) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, bool, read_write> = var private, read_write %v1:ref<private, bool, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, bool, read_write> = or %v1:ref<private, bool, read_write>, false %2:ref<private, bool, read_write> = or %v1:ref<private, bool, read_write>, false
store %v1:ref<private, bool, read_write>, %2:ref<private, bool, read_write> store %v1:ref<private, bool, read_write>, %2:ref<private, bool, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -356,17 +356,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Xor) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = xor %1:u32, 4u %tint_symbol:u32 = xor %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -379,17 +379,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundXor) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = xor %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = xor %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -402,28 +402,28 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalAnd) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool {
%fn2 = block %fn2 = block {
ret true } -> %func_end true # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:bool = call my_func %1:bool = call my_func
%tint_symbol:bool = var function, read_write %tint_symbol:bool = var function, read_write
store %tint_symbol:bool, %1:bool store %tint_symbol:bool, %1:bool
branch %fn5 } -> %fn5 # branch
%fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8] %fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8]
# true branch # true branch
%fn6 = block %fn6 = block {
store %tint_symbol:bool, false store %tint_symbol:bool, false
branch %fn8 } -> %fn8 # branch
# if merge # if merge
%fn8 = block %fn8 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -436,29 +436,29 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LogicalOr) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool {
%fn2 = block %fn2 = block {
ret true } -> %func_end true # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:bool = call my_func %1:bool = call my_func
%tint_symbol:bool = var function, read_write %tint_symbol:bool = var function, read_write
store %tint_symbol:bool, %1:bool store %tint_symbol:bool, %1:bool
branch %fn5 } -> %fn5 # branch
%fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8] %fn5 = if %1:bool [t: %fn6, f: %fn7, m: %fn8]
# true branch # true branch
# false branch # false branch
%fn7 = block %fn7 = block {
store %tint_symbol:bool, true store %tint_symbol:bool, true
branch %fn8 } -> %fn8 # branch
# if merge # if merge
%fn8 = block %fn8 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -471,17 +471,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Equal) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = eq %1:u32, 4u %tint_symbol:bool = eq %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -494,17 +494,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_NotEqual) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = neq %1:u32, 4u %tint_symbol:bool = neq %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -517,17 +517,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThan) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = lt %1:u32, 4u %tint_symbol:bool = lt %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -540,17 +540,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThan) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = gt %1:u32, 4u %tint_symbol:bool = gt %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -563,17 +563,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_LessThanEqual) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = lte %1:u32, 4u %tint_symbol:bool = lte %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -586,17 +586,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_GreaterThanEqual) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:bool = gte %1:u32, 4u %tint_symbol:bool = gte %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -609,17 +609,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftLeft) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = shiftl %1:u32, 4u %tint_symbol:u32 = shiftl %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -632,17 +632,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftLeft) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = shiftl %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = shiftl %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -655,17 +655,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_ShiftRight) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 0u } -> %func_end 0u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = shiftr %1:u32, 4u %tint_symbol:u32 = shiftr %1:u32, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -678,17 +678,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_CompoundShiftRight) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, u32, read_write> = var private, read_write %v1:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%2:ref<private, u32, read_write> = shiftr %v1:ref<private, u32, read_write>, 1u %2:ref<private, u32, read_write> = shiftr %v1:ref<private, u32, read_write>, 1u
store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write> store %v1:ref<private, u32, read_write>, %2:ref<private, u32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -703,34 +703,34 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 {
%fn2 = block %fn2 = block {
ret 0.0f } -> %func_end 0.0f # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:f32 = call my_func %1:f32 = call my_func
%2:bool = lt %1:f32, 2.0f %2:bool = lt %1:f32, 2.0f
%tint_symbol:bool = var function, read_write %tint_symbol:bool = var function, read_write
store %tint_symbol:bool, %2:bool store %tint_symbol:bool, %2:bool
branch %fn5 } -> %fn5 # branch
%fn5 = if %2:bool [t: %fn6, f: %fn7, m: %fn8] %fn5 = if %2:bool [t: %fn6, f: %fn7, m: %fn8]
# true branch # true branch
%fn6 = block %fn6 = block {
%4:f32 = call my_func %4:f32 = call my_func
%5:f32 = call my_func %5:f32 = call my_func
%6:f32 = mul 2.29999995231628417969f, %5:f32 %6:f32 = mul 2.29999995231628417969f, %5:f32
%7:f32 = div %4:f32, %6:f32 %7:f32 = div %4:f32, %6:f32
%8:bool = gt 2.5f, %7:f32 %8:bool = gt 2.5f, %7:f32
store %tint_symbol:bool, %8:bool store %tint_symbol:bool, %8:bool
branch %fn8 } -> %fn8 # branch
# if merge # if merge
%fn8 = block %fn8 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -744,16 +744,16 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Binary_Compound_WithConstEval) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool {
%fn2 = block %fn2 = block {
ret true } -> %func_end true # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%tint_symbol:bool = call my_func, false %tint_symbol:bool = call my_func, false
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }

View File

@ -35,17 +35,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Bitcast) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():f32 {
%fn2 = block %fn2 = block {
ret 0.0f } -> %func_end 0.0f # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:f32 = call my_func %1:f32 = call my_func
%tint_symbol:f32 = bitcast %1:f32 %tint_symbol:f32 = bitcast %1:f32
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -60,11 +60,11 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Discard) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():void [@fragment] EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():void [@fragment] {
%fn2 = block %fn2 = block {
discard discard
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -77,16 +77,16 @@ TEST_F(IR_BuilderImplTest, EmitStatement_UserFunction) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():void EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():void {
%fn2 = block %fn2 = block {
ret } -> %func_end # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:void = call my_func, 6.0f %1:void = call my_func, 6.0f
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -99,16 +99,16 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Convert) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%i:ref<private, i32, read_write> = var private, read_write, 1i %i:ref<private, i32, read_write> = var private, read_write, 1i
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%tint_symbol:f32 = convert i32, %i:ref<private, i32, read_write> %tint_symbol:f32 = convert i32, %i:ref<private, i32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -120,9 +120,9 @@ TEST_F(IR_BuilderImplTest, EmitExpression_ConstructEmpty) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%i:ref<private, vec3<f32>, read_write> = var private, read_write, vec3<f32> 0.0f %i:ref<private, vec3<f32>, read_write> = var private, read_write, vec3<f32> 0.0f
}
)"); )");
@ -136,16 +136,16 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Construct) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%i:ref<private, f32, read_write> = var private, read_write, 1.0f %i:ref<private, f32, read_write> = var private, read_write, 1.0f
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %i:ref<private, f32, read_write> %tint_symbol:vec3<f32> = construct 2.0f, 3.0f, %i:ref<private, f32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }

View File

@ -34,10 +34,10 @@ TEST_F(IR_BuilderImplTest, EmitExpression_MaterializedCall) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():f32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func test_function():f32 {
%fn2 = block %fn2 = block {
ret 2.0f } -> %func_end 2.0f # return
func_end } %func_end
)"); )");
} }

View File

@ -35,16 +35,16 @@ TEST_F(IR_BuilderImplTest, EmitStatement_Assign) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%a:ref<private, u32, read_write> = var private, read_write %a:ref<private, u32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
store %a:ref<private, u32, read_write>, 4u store %a:ref<private, u32, read_write>, 4u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }

View File

@ -71,10 +71,10 @@ TEST_F(IR_BuilderImplTest, Func) {
EXPECT_EQ(m->functions[0]->pipeline_stage, Function::PipelineStage::kUndefined); EXPECT_EQ(m->functions[0]->pipeline_stage, Function::PipelineStage::kUndefined);
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func f():void EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func f():void {
%fn2 = block %fn2 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -112,23 +112,23 @@ TEST_F(IR_BuilderImplTest, IfStatement) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = if true [t: %fn4, f: %fn5, m: %fn6] %fn3 = if true [t: %fn4, f: %fn5, m: %fn6]
# true branch # true branch
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn5 = block %fn5 = block {
branch %fn6 } -> %fn6 # branch
# if merge # if merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -156,22 +156,22 @@ TEST_F(IR_BuilderImplTest, IfStatement_TrueReturns) {
EXPECT_EQ(2u, func->end_target->inbound_branches.Length()); EXPECT_EQ(2u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = if true [t: %fn4, f: %fn5, m: %fn6] %fn3 = if true [t: %fn4, f: %fn5, m: %fn6]
# true branch # true branch
%fn4 = block %fn4 = block {
ret } -> %func_end # return
# false branch # false branch
%fn5 = block %fn5 = block {
branch %fn6 } -> %fn6 # branch
# if merge # if merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -199,22 +199,22 @@ TEST_F(IR_BuilderImplTest, IfStatement_FalseReturns) {
EXPECT_EQ(2u, func->end_target->inbound_branches.Length()); EXPECT_EQ(2u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = if true [t: %fn4, f: %fn5, m: %fn6] %fn3 = if true [t: %fn4, f: %fn5, m: %fn6]
# true branch # true branch
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn5 = block %fn5 = block {
ret } -> %func_end # return
# if merge # if merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -242,18 +242,18 @@ TEST_F(IR_BuilderImplTest, IfStatement_BothReturn) {
EXPECT_EQ(2u, func->end_target->inbound_branches.Length()); EXPECT_EQ(2u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = if true [t: %fn4, f: %fn5] %fn3 = if true [t: %fn4, f: %fn5]
# true branch # true branch
%fn4 = block %fn4 = block {
ret } -> %func_end # return
# false branch # false branch
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -278,32 +278,32 @@ TEST_F(IR_BuilderImplTest, IfStatement_JumpChainToMerge) {
ASSERT_NE(loop_flow->merge.target, nullptr); ASSERT_NE(loop_flow->merge.target, nullptr);
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = if true [t: %fn4, f: %fn5, m: %fn6] %fn3 = if true [t: %fn4, f: %fn5, m: %fn6]
# true branch # true branch
%fn4 = block %fn4 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = loop [s: %fn8, m: %fn9] %fn7 = loop [s: %fn8, m: %fn9]
# loop start # loop start
%fn8 = block %fn8 = block {
branch %fn9 } -> %fn9 # branch
# loop merge # loop merge
%fn9 = block %fn9 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn5 = block %fn5 = block {
branch %fn6 } -> %fn6 # branch
# if merge # if merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -331,19 +331,19 @@ TEST_F(IR_BuilderImplTest, Loop_WithBreak) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, m: %fn5] %fn3 = loop [s: %fn4, m: %fn5]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# loop merge # loop merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -381,36 +381,36 @@ TEST_F(IR_BuilderImplTest, Loop_WithContinue) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5, m: %fn6] %fn3 = loop [s: %fn4, c: %fn5, m: %fn6]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = if true [t: %fn8, f: %fn9, m: %fn10] %fn7 = if true [t: %fn8, f: %fn9, m: %fn10]
# true branch # true branch
%fn8 = block %fn8 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn9 = block %fn9 = block {
branch %fn10 } -> %fn10 # branch
# if merge # if merge
%fn10 = block %fn10 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn4 } -> %fn4 # branch
# loop merge # loop merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -448,36 +448,36 @@ TEST_F(IR_BuilderImplTest, Loop_WithContinuing_BreakIf) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5, m: %fn6] %fn3 = loop [s: %fn4, c: %fn5, m: %fn6]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = if true [t: %fn8, f: %fn9, m: %fn10] %fn7 = if true [t: %fn8, f: %fn9, m: %fn10]
# true branch # true branch
%fn8 = block %fn8 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn9 = block %fn9 = block {
branch %fn10 } -> %fn10 # branch
# if merge # if merge
%fn10 = block %fn10 = block {
branch %fn4 } -> %fn4 # branch
# loop merge # loop merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -492,36 +492,36 @@ TEST_F(IR_BuilderImplTest, Loop_Continuing_Body_Scope) {
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5, m: %fn6] %fn3 = loop [s: %fn4, c: %fn5, m: %fn6]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = if true [t: %fn8, f: %fn9, m: %fn10] %fn7 = if true [t: %fn8, f: %fn9, m: %fn10]
# true branch # true branch
%fn8 = block %fn8 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn9 = block %fn9 = block {
branch %fn10 } -> %fn10 # branch
# if merge # if merge
%fn10 = block %fn10 = block {
branch %fn4 } -> %fn4 # branch
# loop merge # loop merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -559,32 +559,32 @@ TEST_F(IR_BuilderImplTest, Loop_WithReturn) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5] %fn3 = loop [s: %fn4, c: %fn5]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
%fn6 = if true [t: %fn7, f: %fn8, m: %fn9] %fn6 = if true [t: %fn7, f: %fn8, m: %fn9]
# true branch # true branch
%fn7 = block %fn7 = block {
ret } -> %func_end # return
# false branch # false branch
%fn8 = block %fn8 = block {
branch %fn9 } -> %fn9 # branch
# if merge # if merge
%fn9 = block %fn9 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn4 } -> %fn4 # branch
func_end } %func_end
)"); )");
} }
@ -612,15 +612,15 @@ TEST_F(IR_BuilderImplTest, Loop_WithOnlyReturn) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4] %fn3 = loop [s: %fn4]
# loop start # loop start
%fn4 = block %fn4 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -663,15 +663,15 @@ TEST_F(IR_BuilderImplTest, Loop_WithOnlyReturn_ContinuingBreakIf) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4] %fn3 = loop [s: %fn4]
# loop start # loop start
%fn4 = block %fn4 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -709,28 +709,28 @@ TEST_F(IR_BuilderImplTest, Loop_WithIf_BothBranchesBreak) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, m: %fn5] %fn3 = loop [s: %fn4, m: %fn5]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
%fn6 = if true [t: %fn7, f: %fn8] %fn6 = if true [t: %fn7, f: %fn8]
# true branch # true branch
%fn7 = block %fn7 = block {
branch %fn5 } -> %fn5 # branch
# false branch # false branch
%fn8 = block %fn8 = block {
branch %fn5 } -> %fn5 # branch
# loop merge # loop merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -848,110 +848,110 @@ TEST_F(IR_BuilderImplTest, Loop_Nested) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5, m: %fn6] %fn3 = loop [s: %fn4, c: %fn5, m: %fn6]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = loop [s: %fn8, c: %fn9, m: %fn10] %fn7 = loop [s: %fn8, c: %fn9, m: %fn10]
# loop start # loop start
%fn8 = block %fn8 = block {
branch %fn11 } -> %fn11 # branch
%fn11 = if true [t: %fn12, f: %fn13, m: %fn14] %fn11 = if true [t: %fn12, f: %fn13, m: %fn14]
# true branch # true branch
%fn12 = block %fn12 = block {
branch %fn10 } -> %fn10 # branch
# false branch # false branch
%fn13 = block %fn13 = block {
branch %fn14 } -> %fn14 # branch
# if merge # if merge
%fn14 = block %fn14 = block {
branch %fn15 } -> %fn15 # branch
%fn15 = if true [t: %fn16, f: %fn17, m: %fn18] %fn15 = if true [t: %fn16, f: %fn17, m: %fn18]
# true branch # true branch
%fn16 = block %fn16 = block {
branch %fn9 } -> %fn9 # branch
# false branch # false branch
%fn17 = block %fn17 = block {
branch %fn18 } -> %fn18 # branch
# if merge # if merge
%fn18 = block %fn18 = block {
branch %fn9 } -> %fn9 # branch
# loop continuing # loop continuing
%fn9 = block %fn9 = block {
branch %fn19 } -> %fn19 # branch
%fn19 = loop [s: %fn20, m: %fn21] %fn19 = loop [s: %fn20, m: %fn21]
# loop start # loop start
%fn20 = block %fn20 = block {
branch %fn21 } -> %fn21 # branch
# loop merge # loop merge
%fn21 = block %fn21 = block {
branch %fn22 } -> %fn22 # branch
%fn22 = loop [s: %fn23, c: %fn24, m: %fn25] %fn22 = loop [s: %fn23, c: %fn24, m: %fn25]
# loop start # loop start
%fn23 = block %fn23 = block {
branch %fn24 } -> %fn24 # branch
# loop continuing # loop continuing
%fn24 = block %fn24 = block {
branch %fn26 } -> %fn26 # branch
%fn26 = if true [t: %fn27, f: %fn28, m: %fn29] %fn26 = if true [t: %fn27, f: %fn28, m: %fn29]
# true branch # true branch
%fn27 = block %fn27 = block {
branch %fn25 } -> %fn25 # branch
# false branch # false branch
%fn28 = block %fn28 = block {
branch %fn29 } -> %fn29 # branch
# if merge # if merge
%fn29 = block %fn29 = block {
branch %fn23 } -> %fn23 # branch
# loop merge # loop merge
%fn25 = block %fn25 = block {
branch %fn8 } -> %fn8 # branch
# loop merge # loop merge
%fn10 = block %fn10 = block {
branch %fn30 } -> %fn30 # branch
%fn30 = if true [t: %fn31, f: %fn32, m: %fn33] %fn30 = if true [t: %fn31, f: %fn32, m: %fn33]
# true branch # true branch
%fn31 = block %fn31 = block {
branch %fn6 } -> %fn6 # branch
# false branch # false branch
%fn32 = block %fn32 = block {
branch %fn33 } -> %fn33 # branch
# if merge # if merge
%fn33 = block %fn33 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn4 } -> %fn4 # branch
# loop merge # loop merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -988,36 +988,36 @@ TEST_F(IR_BuilderImplTest, While) {
EXPECT_EQ(1u, if_flow->merge.target->inbound_branches.Length()); EXPECT_EQ(1u, if_flow->merge.target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, c: %fn5, m: %fn6] %fn3 = loop [s: %fn4, c: %fn5, m: %fn6]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn7 } -> %fn7 # branch
%fn7 = if false [t: %fn8, f: %fn9, m: %fn10] %fn7 = if false [t: %fn8, f: %fn9, m: %fn10]
# true branch # true branch
%fn8 = block %fn8 = block {
branch %fn10 } -> %fn10 # branch
# false branch # false branch
%fn9 = block %fn9 = block {
branch %fn6 } -> %fn6 # branch
# if merge # if merge
%fn10 = block %fn10 = block {
branch %fn5 } -> %fn5 # branch
# loop continuing # loop continuing
%fn5 = block %fn5 = block {
branch %fn4 } -> %fn4 # branch
# loop merge # loop merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1054,31 +1054,31 @@ TEST_F(IR_BuilderImplTest, While_Return) {
EXPECT_EQ(1u, if_flow->merge.target->inbound_branches.Length()); EXPECT_EQ(1u, if_flow->merge.target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, m: %fn5] %fn3 = loop [s: %fn4, m: %fn5]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
%fn6 = if true [t: %fn7, f: %fn8, m: %fn9] %fn6 = if true [t: %fn7, f: %fn8, m: %fn9]
# true branch # true branch
%fn7 = block %fn7 = block {
branch %fn9 } -> %fn9 # branch
# false branch # false branch
%fn8 = block %fn8 = block {
branch %fn5 } -> %fn5 # branch
# if merge # if merge
%fn9 = block %fn9 = block {
ret } -> %func_end # return
# loop merge # loop merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1152,19 +1152,19 @@ TEST_F(IR_BuilderImplTest, For_NoInitCondOrContinuing) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = loop [s: %fn4, m: %fn5] %fn3 = loop [s: %fn4, m: %fn5]
# loop start # loop start
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# loop merge # loop merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1207,27 +1207,27 @@ TEST_F(IR_BuilderImplTest, Switch) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = switch 1i [c: (0i, %fn4), c: (1i, %fn5), c: (default, %fn6), m: %fn7] %fn3 = switch 1i [c: (0i, %fn4), c: (1i, %fn5), c: (default, %fn6), m: %fn7]
# case 0i # case 0i
%fn4 = block %fn4 = block {
branch %fn7 } -> %fn7 # branch
# case 1i # case 1i
%fn5 = block %fn5 = block {
branch %fn7 } -> %fn7 # branch
# case default # case default
%fn6 = block %fn6 = block {
branch %fn7 } -> %fn7 # branch
# switch merge # switch merge
%fn7 = block %fn7 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1267,19 +1267,19 @@ TEST_F(IR_BuilderImplTest, Switch_MultiSelector) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = switch 1i [c: (0i 1i default, %fn4), m: %fn5] %fn3 = switch 1i [c: (0i 1i default, %fn4), m: %fn5]
# case 0i 1i default # case 0i 1i default
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# switch merge # switch merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1307,19 +1307,19 @@ TEST_F(IR_BuilderImplTest, Switch_OnlyDefault) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = switch 1i [c: (default, %fn4), m: %fn5] %fn3 = switch 1i [c: (default, %fn4), m: %fn5]
# case default # case default
%fn4 = block %fn4 = block {
branch %fn5 } -> %fn5 # branch
# switch merge # switch merge
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1356,23 +1356,23 @@ TEST_F(IR_BuilderImplTest, Switch_WithBreak) {
EXPECT_EQ(1u, func->end_target->inbound_branches.Length()); EXPECT_EQ(1u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = switch 1i [c: (0i, %fn4), c: (default, %fn5), m: %fn6] %fn3 = switch 1i [c: (0i, %fn4), c: (default, %fn5), m: %fn6]
# case 0i # case 0i
%fn4 = block %fn4 = block {
branch %fn6 } -> %fn6 # branch
# case default # case default
%fn5 = block %fn5 = block {
branch %fn6 } -> %fn6 # branch
# switch merge # switch merge
%fn6 = block %fn6 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -1411,18 +1411,18 @@ TEST_F(IR_BuilderImplTest, Switch_AllReturn) {
EXPECT_EQ(2u, func->end_target->inbound_branches.Length()); EXPECT_EQ(2u, func->end_target->inbound_branches.Length());
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
branch %fn3 } -> %fn3 # branch
%fn3 = switch 1i [c: (0i, %fn4), c: (default, %fn5)] %fn3 = switch 1i [c: (0i, %fn4), c: (default, %fn5)]
# case 0i # case 0i
%fn4 = block %fn4 = block {
ret } -> %func_end # return
# case default # case default
%fn5 = block %fn5 = block {
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }

View File

@ -34,17 +34,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Not) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():bool {
%fn2 = block %fn2 = block {
ret false } -> %func_end false # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:bool = call my_func %1:bool = call my_func
%tint_symbol:bool = eq %1:bool, false %tint_symbol:bool = eq %1:bool, false
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -57,17 +57,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Complement) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():u32 {
%fn2 = block %fn2 = block {
ret 1u } -> %func_end 1u # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:u32 = call my_func %1:u32 = call my_func
%tint_symbol:u32 = complement %1:u32 %tint_symbol:u32 = complement %1:u32
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -80,17 +80,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Negation) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():i32 EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = func my_func():i32 {
%fn2 = block %fn2 = block {
ret 1i } -> %func_end 1i # return
func_end } %func_end
%fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn4 = block %fn4 = block {
%1:i32 = call my_func %1:i32 = call my_func
%tint_symbol:i32 = negation %1:i32 %tint_symbol:i32 = negation %1:i32
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -104,16 +104,16 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_AddressOf) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, i32, read_write> = var private, read_write %v1:ref<private, i32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%v2:ptr<private, i32, read_write> = addr_of %v1:ref<private, i32, read_write> %v2:ptr<private, i32, read_write> = addr_of %v1:ref<private, i32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -129,17 +129,17 @@ TEST_F(IR_BuilderImplTest, EmitExpression_Unary_Indirection) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%v1:ref<private, i32, read_write> = var private, read_write %v1:ref<private, i32, read_write> = var private, read_write
}
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = func test_function():void [@compute @workgroup_size(1, 1, 1)] %fn3 = block {
%fn3 = block
%v3:ptr<private, i32, read_write> = addr_of %v1:ref<private, i32, read_write> %v3:ptr<private, i32, read_write> = addr_of %v1:ref<private, i32, read_write>
%v2:i32 = indirection %v3:ptr<private, i32, read_write> %v2:i32 = indirection %v3:ptr<private, i32, read_write>
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }

View File

@ -32,9 +32,9 @@ TEST_F(IR_BuilderImplTest, Emit_GlobalVar_NoInit) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%a:ref<private, u32, read_write> = var private, read_write %a:ref<private, u32, read_write> = var private, read_write
}
)"); )");
@ -47,9 +47,9 @@ TEST_F(IR_BuilderImplTest, Emit_GlobalVar_Init) {
auto m = Build(); auto m = Build();
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block EXPECT_EQ(Disassemble(m.Get()), R"(%fn1 = block {
%a:ref<private, u32, read_write> = var private, read_write, 2u %a:ref<private, u32, read_write> = var private, read_write, 2u
}
)"); )");
@ -63,11 +63,11 @@ TEST_F(IR_BuilderImplTest, Emit_Var_NoInit) {
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
%a:ref<function, u32, read_write> = var function, read_write %a:ref<function, u32, read_write> = var function, read_write
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }
@ -81,11 +81,11 @@ TEST_F(IR_BuilderImplTest, Emit_Var_Init) {
ASSERT_TRUE(m) << (!m ? m.Failure() : ""); ASSERT_TRUE(m) << (!m ? m.Failure() : "");
EXPECT_EQ(Disassemble(m.Get()), EXPECT_EQ(Disassemble(m.Get()),
R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] R"(%fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] {
%fn2 = block %fn2 = block {
%a:ref<function, u32, read_write> = var function, read_write, 2u %a:ref<function, u32, read_write> = var function, read_write, 2u
ret } -> %func_end # return
func_end } %func_end
)"); )");
} }