Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrControl.td @@ -13,9 +13,9 @@ //===----------------------------------------------------------------------===// let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in { -def BR_IF : I<(outs), (ins bb_op:$dst, I32:$a), +def BR_IF : I<(outs), (ins I32:$a, bb_op:$dst), [(brcond I32:$a, bb:$dst)], - "br_if\t$dst, $a">; + "br_if\t$a, $dst">; let isBarrier = 1 in { def BR : I<(outs), (ins bb_op:$dst), [(br bb:$dst)], Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp @@ -54,8 +54,8 @@ case WebAssembly::BR_IF: if (HaveCond) return true; - Cond.push_back(MI.getOperand(1)); - TBB = MI.getOperand(0).getMBB(); + Cond.push_back(MI.getOperand(0)); + TBB = MI.getOperand(1).getMBB(); HaveCond = true; break; case WebAssembly::BR: @@ -105,8 +105,8 @@ } BuildMI(&MBB, DL, get(WebAssembly::BR_IF)) - .addMBB(TBB) - .addOperand(Cond[0]); + .addOperand(Cond[0]) + .addMBB(TBB); if (!FBB) return 1; Index: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll +++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll @@ -67,9 +67,9 @@ ; CHECK-LABEL: test2: ; CHECK: block BB2_2{{$}} -; CHECK: br_if BB2_2, {{.*}} +; CHECK: br_if {{.*}}, BB2_2{{$}} ; CHECK: BB2_1: -; CHECK: br_if BB2_1, (get_local 10){{$}} +; CHECK: br_if (get_local 10), BB2_1{{$}} ; CHECK: BB2_2: ; CHECK: return{{$}} define void @test2(double* nocapture %p, i32 %n) { @@ -101,10 +101,10 @@ ; CHECK: block BB3_5{{$}} ; CHECK: block BB3_4{{$}} ; CHECK: block BB3_2{{$}} -; CHECK: br_if BB3_2, (get_local 4){{$}} +; CHECK: br_if (get_local 4), BB3_2{{$}} ; CHECK: br BB3_5{{$}} ; CHECK: BB3_2: -; CHECK: br_if BB3_4, (get_local 6){{$}} +; CHECK: br_if (get_local 6), BB3_4{{$}} ; CHECK: br BB3_5{{$}} ; CHECK: BB3_4: ; CHECK: BB3_5: @@ -134,7 +134,7 @@ ; CHECK-LABEL: triangle: ; CHECK: block BB4_2{{$}} -; CHECK: br_if BB4_2, (get_local 3){{$}} +; CHECK: br_if (get_local 3), BB4_2{{$}} ; CHECK: BB4_2: ; CHECK: return (get_local 2){{$}} define i32 @triangle(i32* %p, i32 %a) { @@ -153,7 +153,7 @@ ; CHECK-LABEL: diamond: ; CHECK: block BB5_3{{$}} ; CHECK: block BB5_2{{$}} -; CHECK: br_if BB5_2, (get_local 3){{$}} +; CHECK: br_if (get_local 3), BB5_2{{$}} ; CHECK: br BB5_3{{$}} ; CHECK: BB5_2: ; CHECK: BB5_3: @@ -201,7 +201,7 @@ ; CHECK-NOT: br ; CHECK: BB8_1: ; CHECK: loop BB8_2{{$}} -; CHECK: br_if BB8_1, (get_local 3){{$}} +; CHECK: br_if (get_local 3), BB8_1{{$}} ; CHECK: return (get_local 2){{$}} define i32 @simple_loop(i32* %p, i32 %a) { entry: @@ -219,8 +219,8 @@ ; CHECK-LABEL: doubletriangle: ; CHECK: block BB9_4{{$}} ; CHECK: block BB9_3{{$}} -; CHECK: br_if BB9_4, (get_local 4){{$}} -; CHECK: br_if BB9_3, (get_local 6){{$}} +; CHECK: br_if (get_local 4), BB9_4{{$}} +; CHECK: br_if (get_local 6), BB9_3{{$}} ; CHECK: BB9_3: ; CHECK: BB9_4: ; CHECK: return (get_local 3){{$}} @@ -247,10 +247,10 @@ ; CHECK-LABEL: ifelse_earlyexits: ; CHECK: block BB10_4{{$}} ; CHECK: block BB10_2{{$}} -; CHECK: br_if BB10_2, (get_local 4){{$}} +; CHECK: br_if (get_local 4), BB10_2{{$}} ; CHECK: br BB10_4{{$}} ; CHECK: BB10_2: -; CHECK: br_if BB10_4, (get_local 6){{$}} +; CHECK: br_if (get_local 6), BB10_4{{$}} ; CHECK: BB10_4: ; CHECK: return (get_local 3){{$}} define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {