[tint][ir] Swap order of first two BreakIf() params

All the other Terminator instructions have the ControlFlow instruction
as the first argument.

Change-Id: Iade371f9fd7d3a543a8a365f95297571e80288f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139520
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/ir/block_test.cc b/src/tint/ir/block_test.cc
index 9f5fbfa..79ae399 100644
--- a/src/tint/ir/block_test.cc
+++ b/src/tint/ir/block_test.cc
@@ -36,7 +36,7 @@
 TEST_F(IR_BlockTest, HasTerminator_BreakIf) {
     auto* blk = b.Block();
     auto* loop = b.Loop();
-    blk->Append(b.BreakIf(true, loop));
+    blk->Append(b.BreakIf(loop, true));
     EXPECT_TRUE(blk->HasTerminator());
 }
 
diff --git a/src/tint/ir/break_if_test.cc b/src/tint/ir/break_if_test.cc
index 2ce17ae..506d93f 100644
--- a/src/tint/ir/break_if_test.cc
+++ b/src/tint/ir/break_if_test.cc
@@ -30,7 +30,7 @@
     auto* arg1 = b.Constant(1_u);
     auto* arg2 = b.Constant(2_u);
 
-    auto* brk = b.BreakIf(cond, loop, arg1, arg2);
+    auto* brk = b.BreakIf(loop, cond, arg1, arg2);
 
     EXPECT_THAT(cond->Usages(), testing::UnorderedElementsAre(Usage{brk, 0u}));
     EXPECT_THAT(arg1->Usages(), testing::UnorderedElementsAre(Usage{brk, 1u}));
@@ -43,7 +43,7 @@
     auto* arg1 = b.Constant(1_u);
     auto* arg2 = b.Constant(2_u);
 
-    auto* brk = b.BreakIf(cond, loop, arg1, arg2);
+    auto* brk = b.BreakIf(loop, cond, arg1, arg2);
     EXPECT_FALSE(brk->HasResults());
     EXPECT_FALSE(brk->HasMultiResults());
 }
@@ -53,7 +53,7 @@
         {
             Module mod;
             Builder b{mod};
-            b.BreakIf(true, nullptr);
+            b.BreakIf(nullptr, true);
         },
         "");
 }
diff --git a/src/tint/ir/builder.h b/src/tint/ir/builder.h
index 60bb77a..95c6df0 100644
--- a/src/tint/ir/builder.h
+++ b/src/tint/ir/builder.h
@@ -604,7 +604,7 @@
     /// @param args the arguments for the target MultiInBlock
     /// @returns the instruction
     template <typename CONDITION, typename... ARGS>
-    ir::BreakIf* BreakIf(CONDITION&& condition, ir::Loop* loop, ARGS&&... args) {
+    ir::BreakIf* BreakIf(ir::Loop* loop, CONDITION&& condition, ARGS&&... args) {
         return Append(ir.instructions.Create<ir::BreakIf>(
             Value(std::forward<CONDITION>(condition)), loop, Values(std::forward<ARGS>(args)...)));
     }
diff --git a/src/tint/ir/from_program.cc b/src/tint/ir/from_program.cc
index 1303dad..69b80ea 100644
--- a/src/tint/ir/from_program.cc
+++ b/src/tint/ir/from_program.cc
@@ -853,7 +853,7 @@
         if (!cond) {
             return;
         }
-        SetTerminator(builder_.BreakIf(cond.Get(), current_control->As<ir::Loop>()));
+        SetTerminator(builder_.BreakIf(current_control->As<ir::Loop>(), cond.Get()));
     }
 
     struct AccessorInfo {
diff --git a/src/tint/ir/to_program_inlining_test.cc b/src/tint/ir/to_program_inlining_test.cc
index 1e9ab3a..72b9d39 100644
--- a/src/tint/ir/to_program_inlining_test.cc
+++ b/src/tint/ir/to_program_inlining_test.cc
@@ -967,7 +967,7 @@
         auto* v = b.Add(ty.i32(), 1_i, 2_i);
         auto* loop = b.Loop();
         b.With(loop->Body(), [&] { b.Continue(loop); });
-        b.With(loop->Continuing(), [&] { b.BreakIf(b.Equal(ty.bool_(), v, 3_i), loop); });
+        b.With(loop->Continuing(), [&] { b.BreakIf(loop, b.Equal(ty.bool_(), v, 3_i)); });
         b.Return(fn, 0_i);
     });
 
@@ -992,7 +992,7 @@
         auto* v_2 = b.Add(ty.i32(), v_1, 2_i);
         auto* loop = b.Loop();
         b.With(loop->Body(), [&] { b.Continue(loop); });
-        b.With(loop->Continuing(), [&] { b.BreakIf(b.Equal(ty.bool_(), v_2, 3_i), loop); });
+        b.With(loop->Continuing(), [&] { b.BreakIf(loop, b.Equal(ty.bool_(), v_2, 3_i)); });
         b.Return(fn, 0_i);
     });
 
@@ -1091,7 +1091,7 @@
             b.With(loop->Body(), [&] { b.Continue(loop); });
             b.With(loop->Continuing(), [&] {
                 b.Store(var, b.Add(ty.i32(), load, 1_i));
-                b.BreakIf(true, loop);
+                b.BreakIf(loop, true);
             });
         });
         b.Return(fn, 3_i);
@@ -1128,7 +1128,7 @@
 
             b.With(loop->Continuing(), [&] {
                 b.Store(var, b.Add(ty.i32(), load, 1_i));
-                b.BreakIf(true, loop);
+                b.BreakIf(loop, true);
             });
         });
         b.Return(fn, 3_i);
diff --git a/src/tint/ir/transform/merge_return_test.cc b/src/tint/ir/transform/merge_return_test.cc
index b01d49e..0991bb5 100644
--- a/src/tint/ir/transform/merge_return_test.cc
+++ b/src/tint/ir/transform/merge_return_test.cc
@@ -1120,7 +1120,7 @@
 
         b.With(loop->Continuing(), [&] {
             b.Store(global, 1_i);
-            b.BreakIf(true, loop);
+            b.BreakIf(loop, true);
         });
 
         b.Store(global, 3_i);
@@ -1340,7 +1340,7 @@
 
         b.With(loop->Continuing(), [&] {
             b.Store(global, 1_i);
-            b.BreakIf(true, loop, 4_i);
+            b.BreakIf(loop, true, 4_i);
         });
 
         b.Store(global, 3_i);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc
index 63bc82c..d0d6d24 100644
--- a/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc
+++ b/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc
@@ -25,7 +25,7 @@
     auto* loop = b.Loop();
 
     loop->Body()->Append(b.Continue(loop));
-    loop->Continuing()->Append(b.BreakIf(true, loop));
+    loop->Continuing()->Append(b.BreakIf(loop, true));
 
     func->Block()->Append(loop);
     func->Block()->Append(b.Return(func));
@@ -218,7 +218,7 @@
     auto* result = loop->Body()->Append(b.Equal(ty.i32(), 1_i, 2_i));
     loop->Body()->Append(b.Continue(loop, result));
 
-    loop->Continuing()->Append(b.BreakIf(result, loop));
+    loop->Continuing()->Append(b.BreakIf(loop, result));
 
     func->Block()->Append(loop);
     func->Block()->Append(b.Return(func));
@@ -260,7 +260,7 @@
 
     outer_loop->Body()->Append(inner_loop);
     outer_loop->Body()->Append(b.Continue(outer_loop));
-    outer_loop->Continuing()->Append(b.BreakIf(true, outer_loop));
+    outer_loop->Continuing()->Append(b.BreakIf(outer_loop, true));
 
     func->Block()->Append(outer_loop);
     func->Block()->Append(b.Return(func));
@@ -305,11 +305,11 @@
     auto* inner_loop = b.Loop();
 
     inner_loop->Body()->Append(b.Continue(inner_loop));
-    inner_loop->Continuing()->Append(b.BreakIf(true, inner_loop));
+    inner_loop->Continuing()->Append(b.BreakIf(inner_loop, true));
 
     outer_loop->Body()->Append(b.Continue(outer_loop));
     outer_loop->Continuing()->Append(inner_loop);
-    outer_loop->Continuing()->Append(b.BreakIf(true, outer_loop));
+    outer_loop->Continuing()->Append(b.BreakIf(outer_loop, true));
 
     func->Block()->Append(outer_loop);
     func->Block()->Append(b.Return(func));
@@ -351,23 +351,23 @@
     auto* func = b.Function("foo", ty.void_());
 
     b.With(func->Block(), [&] {
-        auto* l = b.Loop();
+        auto* loop = b.Loop();
 
-        b.With(l->Initializer(), [&] { b.NextIteration(l, 1_i, false); });
+        b.With(loop->Initializer(), [&] { b.NextIteration(loop, 1_i, false); });
 
         auto* loop_param = b.BlockParam(ty.i32());
-        l->Body()->SetParams({loop_param});
+        loop->Body()->SetParams({loop_param});
 
-        b.With(l->Body(), [&] {
+        b.With(loop->Body(), [&] {
             auto* inc = b.Add(ty.i32(), loop_param, 1_i);
-            b.Continue(l, inc);
+            b.Continue(loop, inc);
         });
 
         auto* cont_param = b.BlockParam(ty.i32());
-        l->Continuing()->SetParams({cont_param});
-        b.With(l->Continuing(), [&] {
+        loop->Continuing()->SetParams({cont_param});
+        b.With(loop->Continuing(), [&] {
             auto* cmp = b.GreaterThan(ty.bool_(), cont_param, 5_i);
-            b.BreakIf(cmp, l, cont_param);
+            b.BreakIf(loop, cmp, cont_param);
         });
 
         b.Return(func);
@@ -409,26 +409,26 @@
     auto* func = b.Function("foo", ty.void_());
 
     b.With(func->Block(), [&] {
-        auto* l = b.Loop();
+        auto* loop = b.Loop();
 
-        b.With(l->Initializer(), [&] { b.NextIteration(l, 1_i, false); });
+        b.With(loop->Initializer(), [&] { b.NextIteration(loop, 1_i, false); });
 
         auto* loop_param_a = b.BlockParam(ty.i32());
         auto* loop_param_b = b.BlockParam(ty.bool_());
-        l->Body()->SetParams({loop_param_a, loop_param_b});
+        loop->Body()->SetParams({loop_param_a, loop_param_b});
 
-        b.With(l->Body(), [&] {
+        b.With(loop->Body(), [&] {
             auto* inc = b.Add(ty.i32(), loop_param_a, 1_i);
-            b.Continue(l, inc, loop_param_b);
+            b.Continue(loop, inc, loop_param_b);
         });
 
         auto* cont_param_a = b.BlockParam(ty.i32());
         auto* cont_param_b = b.BlockParam(ty.bool_());
-        l->Continuing()->SetParams({cont_param_a, cont_param_b});
-        b.With(l->Continuing(), [&] {
+        loop->Continuing()->SetParams({cont_param_a, cont_param_b});
+        b.With(loop->Continuing(), [&] {
             auto* cmp = b.GreaterThan(ty.bool_(), cont_param_a, 5_i);
             auto* not_b = b.Not(ty.bool_(), cont_param_b);
-            b.BreakIf(cmp, l, cont_param_a, not_b);
+            b.BreakIf(loop, cmp, cont_param_a, not_b);
         });
 
         b.Return(func);