[ir] Use the branch helper in the spirv tests.
This CL updates the SPIRV IR generator tests to use the `Branch` method of the builder. Bug: tint:1718 Change-Id: I16961382b797dc90277529f706ee240be282d623 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133000 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: James Price <jrprice@google.com>
This commit is contained in:
parent
1a8d0785f2
commit
69b5900c88
|
@ -94,7 +94,7 @@ class Builder {
|
|||
/// @param from the block to branch from
|
||||
/// @param to the node to branch too
|
||||
/// @param args arguments to the branch
|
||||
void Branch(Block* from, FlowNode* to, utils::VectorRef<Value*> args);
|
||||
void Branch(Block* from, FlowNode* to, utils::VectorRef<Value*> args = {});
|
||||
|
||||
/// Creates a constant::Value
|
||||
/// @param args the arguments
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace {
|
|||
|
||||
TEST_F(SpvGeneratorImplTest, Binary_Add_I32) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
func->start_target->instructions.Push(
|
||||
b.Add(mod.types.Get<type::I32>(), b.Constant(1_i), b.Constant(2_i)));
|
||||
|
@ -43,7 +43,7 @@ OpFunctionEnd
|
|||
|
||||
TEST_F(SpvGeneratorImplTest, Binary_Add_U32) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
func->start_target->instructions.Push(
|
||||
b.Add(mod.types.Get<type::U32>(), b.Constant(1_u), b.Constant(2_u)));
|
||||
|
@ -65,7 +65,7 @@ OpFunctionEnd
|
|||
|
||||
TEST_F(SpvGeneratorImplTest, Binary_Add_F32) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
func->start_target->instructions.Push(
|
||||
b.Add(mod.types.Get<type::F32>(), b.Constant(1_f), b.Constant(2_f)));
|
||||
|
@ -87,7 +87,7 @@ OpFunctionEnd
|
|||
|
||||
TEST_F(SpvGeneratorImplTest, Binary_Add_Chain) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
auto* a = b.Add(mod.types.Get<type::I32>(), b.Constant(1_i), b.Constant(2_i));
|
||||
func->start_target->instructions.Push(a);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace {
|
|||
|
||||
TEST_F(SpvGeneratorImplTest, Function_Empty) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
generator_.EmitFunction(func);
|
||||
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpName %1 "foo"
|
||||
|
@ -35,7 +35,7 @@ OpFunctionEnd
|
|||
// Test that we do not emit the same function type more than once.
|
||||
TEST_F(SpvGeneratorImplTest, Function_DeduplicateType) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("foo"), mod.types.Get<type::Void>());
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
generator_.EmitFunction(func);
|
||||
generator_.EmitFunction(func);
|
||||
|
@ -49,7 +49,7 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Compute) {
|
|||
auto* func = b.CreateFunction(mod.symbols.Register("main"), mod.types.Get<type::Void>());
|
||||
func->pipeline_stage = ir::Function::PipelineStage::kCompute;
|
||||
func->workgroup_size = {32, 4, 1};
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
generator_.EmitFunction(func);
|
||||
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpEntryPoint GLCompute %1 "main"
|
||||
|
@ -67,7 +67,7 @@ OpFunctionEnd
|
|||
TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Fragment) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("main"), mod.types.Get<type::Void>());
|
||||
func->pipeline_stage = ir::Function::PipelineStage::kFragment;
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
generator_.EmitFunction(func);
|
||||
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpEntryPoint Fragment %1 "main"
|
||||
|
@ -85,7 +85,7 @@ OpFunctionEnd
|
|||
TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Vertex) {
|
||||
auto* func = b.CreateFunction(mod.symbols.Register("main"), mod.types.Get<type::Void>());
|
||||
func->pipeline_stage = ir::Function::PipelineStage::kVertex;
|
||||
func->start_target->branch.target = func->end_target;
|
||||
b.Branch(func->start_target, func->end_target);
|
||||
|
||||
generator_.EmitFunction(func);
|
||||
EXPECT_EQ(DumpModule(generator_.Module()), R"(OpEntryPoint Vertex %1 "main"
|
||||
|
@ -103,16 +103,16 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Multiple) {
|
|||
auto* f1 = b.CreateFunction(mod.symbols.Register("main1"), mod.types.Get<type::Void>());
|
||||
f1->pipeline_stage = ir::Function::PipelineStage::kCompute;
|
||||
f1->workgroup_size = {32, 4, 1};
|
||||
f1->start_target->branch.target = f1->end_target;
|
||||
b.Branch(f1->start_target, f1->end_target);
|
||||
|
||||
auto* f2 = b.CreateFunction(mod.symbols.Register("main2"), mod.types.Get<type::Void>());
|
||||
f2->pipeline_stage = ir::Function::PipelineStage::kCompute;
|
||||
f2->workgroup_size = {8, 2, 16};
|
||||
f2->start_target->branch.target = f2->end_target;
|
||||
b.Branch(f2->start_target, f2->end_target);
|
||||
|
||||
auto* f3 = b.CreateFunction(mod.symbols.Register("main3"), mod.types.Get<type::Void>());
|
||||
f3->pipeline_stage = ir::Function::PipelineStage::kFragment;
|
||||
f3->start_target->branch.target = f3->end_target;
|
||||
b.Branch(f3->start_target, f3->end_target);
|
||||
|
||||
generator_.EmitFunction(f1);
|
||||
generator_.EmitFunction(f2);
|
||||
|
|
Loading…
Reference in New Issue