2015-12-10 00:23:59 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false -disable-block-placement -verify-machineinstrs | FileCheck %s
|
2015-09-17 00:51:30 +08:00
|
|
|
|
2015-12-05 11:03:35 +08:00
|
|
|
; Test switch instructions. Block placement is disabled because it reorders
|
|
|
|
; the blocks in a way that isn't interesting here.
|
2015-09-17 00:51:30 +08:00
|
|
|
|
2016-01-07 11:19:23 +08:00
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
2015-09-17 00:51:30 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
|
|
|
declare void @foo0()
|
|
|
|
declare void @foo1()
|
|
|
|
declare void @foo2()
|
|
|
|
declare void @foo3()
|
|
|
|
declare void @foo4()
|
|
|
|
declare void @foo5()
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: bar32:
|
[WebAssembly] Make CFG stackification independent of basic-block labels.
This patch changes the way labels are referenced. Instead of referencing the
basic-block label name (eg. .LBB0_0), instructions now just have an immediate
which indicates the depth in the control-flow stack to find a label to jump to.
This makes them much closer to what we expect to have in the binary encoding,
and avoids the problem of basic-block label names not being explicit in the
binary encoding.
Also, it terminates blocks and loops with end_block and end_loop instructions,
rather than basic-block label names, for similar reasons.
This will also fix problems where two constructs appear to have the same label,
because we no longer explicitly use labels, so consumers that need labels will
presumably create their own labels, and presumably they won't reuse labels
when they do.
This patch does make the code a little more awkward to read; as a partial
mitigation, this patch also introduces comments showing where the labels are,
and comments on each branch showing where it's branching to.
llvm-svn: 257505
2016-01-13 03:14:46 +08:00
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
2016-03-08 11:18:12 +08:00
|
|
|
; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_2:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo0@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_3:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo1@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_4:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo2@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_5:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo3@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_6:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo4@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_7:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo5@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB0_8:
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK: return{{$}}
|
2015-09-17 00:51:30 +08:00
|
|
|
define void @bar32(i32 %n) {
|
|
|
|
entry:
|
|
|
|
switch i32 %n, label %sw.epilog [
|
|
|
|
i32 0, label %sw.bb
|
|
|
|
i32 1, label %sw.bb
|
|
|
|
i32 2, label %sw.bb
|
|
|
|
i32 3, label %sw.bb
|
|
|
|
i32 4, label %sw.bb
|
|
|
|
i32 5, label %sw.bb
|
|
|
|
i32 6, label %sw.bb
|
|
|
|
i32 7, label %sw.bb.1
|
|
|
|
i32 8, label %sw.bb.1
|
|
|
|
i32 9, label %sw.bb.1
|
|
|
|
i32 10, label %sw.bb.1
|
|
|
|
i32 11, label %sw.bb.1
|
|
|
|
i32 12, label %sw.bb.1
|
|
|
|
i32 13, label %sw.bb.1
|
|
|
|
i32 14, label %sw.bb.1
|
|
|
|
i32 15, label %sw.bb.2
|
|
|
|
i32 16, label %sw.bb.2
|
|
|
|
i32 17, label %sw.bb.2
|
|
|
|
i32 18, label %sw.bb.2
|
|
|
|
i32 19, label %sw.bb.2
|
|
|
|
i32 20, label %sw.bb.2
|
|
|
|
i32 21, label %sw.bb.3
|
|
|
|
i32 22, label %sw.bb.4
|
|
|
|
i32 23, label %sw.bb.5
|
|
|
|
]
|
|
|
|
|
|
|
|
sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo0()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo1()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo2()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.3: ; preds = %entry
|
|
|
|
tail call void @foo3()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.4: ; preds = %entry
|
|
|
|
tail call void @foo4()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.5: ; preds = %entry
|
|
|
|
tail call void @foo5()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: bar64:
|
[WebAssembly] Make CFG stackification independent of basic-block labels.
This patch changes the way labels are referenced. Instead of referencing the
basic-block label name (eg. .LBB0_0), instructions now just have an immediate
which indicates the depth in the control-flow stack to find a label to jump to.
This makes them much closer to what we expect to have in the binary encoding,
and avoids the problem of basic-block label names not being explicit in the
binary encoding.
Also, it terminates blocks and loops with end_block and end_loop instructions,
rather than basic-block label names, for similar reasons.
This will also fix problems where two constructs appear to have the same label,
because we no longer explicitly use labels, so consumers that need labels will
presumably create their own labels, and presumably they won't reuse labels
when they do.
This patch does make the code a little more awkward to read; as a partial
mitigation, this patch also introduces comments showing where the labels are,
and comments on each branch showing where it's branching to.
llvm-svn: 257505
2016-01-13 03:14:46 +08:00
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
|
|
|
; CHECK: block{{$}}
|
2016-03-08 11:18:12 +08:00
|
|
|
; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_2:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo0@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_3:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo1@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_4:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo2@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_5:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo3@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_6:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo4@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_7:
|
2016-01-12 07:38:05 +08:00
|
|
|
; CHECK: call foo5@FUNCTION{{$}}
|
2016-01-08 02:49:53 +08:00
|
|
|
; CHECK: .LBB1_8:
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK: return{{$}}
|
2015-09-17 00:51:30 +08:00
|
|
|
define void @bar64(i64 %n) {
|
|
|
|
entry:
|
|
|
|
switch i64 %n, label %sw.epilog [
|
|
|
|
i64 0, label %sw.bb
|
|
|
|
i64 1, label %sw.bb
|
|
|
|
i64 2, label %sw.bb
|
|
|
|
i64 3, label %sw.bb
|
|
|
|
i64 4, label %sw.bb
|
|
|
|
i64 5, label %sw.bb
|
|
|
|
i64 6, label %sw.bb
|
|
|
|
i64 7, label %sw.bb.1
|
|
|
|
i64 8, label %sw.bb.1
|
|
|
|
i64 9, label %sw.bb.1
|
|
|
|
i64 10, label %sw.bb.1
|
|
|
|
i64 11, label %sw.bb.1
|
|
|
|
i64 12, label %sw.bb.1
|
|
|
|
i64 13, label %sw.bb.1
|
|
|
|
i64 14, label %sw.bb.1
|
|
|
|
i64 15, label %sw.bb.2
|
|
|
|
i64 16, label %sw.bb.2
|
|
|
|
i64 17, label %sw.bb.2
|
|
|
|
i64 18, label %sw.bb.2
|
|
|
|
i64 19, label %sw.bb.2
|
|
|
|
i64 20, label %sw.bb.2
|
|
|
|
i64 21, label %sw.bb.3
|
|
|
|
i64 22, label %sw.bb.4
|
|
|
|
i64 23, label %sw.bb.5
|
|
|
|
]
|
|
|
|
|
|
|
|
sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo0()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo1()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
|
|
|
|
tail call void @foo2()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.3: ; preds = %entry
|
|
|
|
tail call void @foo3()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.4: ; preds = %entry
|
|
|
|
tail call void @foo4()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.bb.5: ; preds = %entry
|
|
|
|
tail call void @foo5()
|
|
|
|
br label %sw.epilog
|
|
|
|
|
|
|
|
sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
|
|
|
|
ret void
|
|
|
|
}
|