1 ; NOTE: This test case generates a jump table on PowerPC big and little endian
2 ; NOTE: then verifies that the command line option to enable absolute jump
3 ; NOTE: table works correctly.
4 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
5 ; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \
6 ; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-LE
7 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
8 ; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \
9 ; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-BE
10 ; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \
11 ; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \
12 ; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-AIX
13 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
14 ; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \
15 ; RUN: -check-prefix=CHECK-A-PIC-LE
16 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
17 ; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \
18 ; RUN: -check-prefix=CHECK-R-PIC-LE
19 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
20 ; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \
21 ; RUN: -check-prefix=CHECK-A-PIC-BE
22 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
23 ; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \
24 ; RUN: -check-prefix=CHECK-R-PIC-BE
25 ; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \
26 ; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \
27 ; RUN: -check-prefix=CHECK-A-PIC-AIX
28 ; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \
29 ; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \
30 ; RUN: -check-prefix=CHECK-R-PIC-AIX
31 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
32 ; RUN: -ppc-use-absolute-jumptables=true --relocation-model=static < %s | FileCheck %s \
33 ; RUN: -check-prefix=CHECK-A-STATIC-LE
34 ; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
35 ; RUN: -ppc-use-absolute-jumptables=false --relocation-model=static < %s | FileCheck %s \
36 ; RUN: -check-prefix=CHECK-R-STATIC-LE
37 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
38 ; RUN: -ppc-use-absolute-jumptables=true --relocation-model=static < %s | FileCheck %s \
39 ; RUN: -check-prefix=CHECK-A-STATIC-BE
40 ; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \
41 ; RUN: -ppc-use-absolute-jumptables=false --relocation-model=static < %s | FileCheck %s \
42 ; RUN: -check-prefix=CHECK-R-STATIC-BE
44 %struct.node = type { i8, ptr }
46 ; Function Attrs: norecurse nounwind readonly
47 define zeroext i32 @jumpTableTest(ptr readonly %list) {
48 ; CHECK-LE-LABEL: jumpTableTest:
49 ; CHECK-LE: # %bb.0: # %entry
50 ; CHECK-LE: rldic r[[REG:[0-9]+]], r[[REG]], 3, 29
51 ; CHECK-LE: ldx r[[REG]], r[[REG]], r[[REG1:[0-9]+]]
52 ; CHECK-LE: mtctr r[[REG]]
56 ; CHECK-BE-LABEL: jumpTableTest:
57 ; CHECK-BE: # %bb.0: # %entry
58 ; CHECK-BE: rldic r[[REG:[0-9]+]], r[[REG]], 2, 30
59 ; CHECK-BE: lwax r[[REG]], r[[REG]], r[[REG1:[0-9]+]]
60 ; CHECK-BE: mtctr r[[REG]]
64 ; CHECK-AIX-LABEL: jumpTableTest:
65 ; CHECK-AIX: # %bb.0: # %entry
66 ; CHECK-AIX: rldic r[[REG:[0-9]+]], r[[REG]], 2, 30
67 ; CHECK-AIX: lwax r[[REG]], r[[REG]], r[[REG1:[0-9]+]]
68 ; CHECK-AIX: mtctr r[[REG]]
72 ; CHECK-A-PIC-LE-LABEL: .LJTI0_0:
73 ; CHECK-A-PIC-LE: .long .LBB0_6-.LJTI0_0
75 ; CHECK-R-PIC-LE-LABEL: .LJTI0_0:
76 ; CHECK-R-PIC-LE: .long .LBB0_6-.LJTI0_0
78 ; CHECK-A-PIC-BE-LABEL: .LJTI0_0:
79 ; CHECK-A-PIC-BE: .long .LBB0_9-.LJTI0_0
81 ; CHECK-R-PIC-BE-LABEL: .LJTI0_0:
82 ; CHECK-R-PIC-BE: .long .LBB0_9-.LJTI0_0
84 ; CHECK-A-PIC-AIX-LABEL: L..JTI0_0:
85 ; CHECK-A-PIC-AIX: .vbyte 4, L..BB0_9-L..JTI0_0
87 ; CHECK-R-PIC-AIX-LABEL: L..JTI0_0:
88 ; CHECK-R-PIC-AIX: .vbyte 4, L..BB0_9-L..JTI0_0
90 ; CHECK-A-STATIC-LE-LABEL: .LJTI0_0:
91 ; CHECK-A-STATIC-LE: .quad .LBB0_6
93 ; CHECK-R-STATIC-LE-LABEL: .LJTI0_0:
94 ; CHECK-R-STATIC-LE: .long .LBB0_6-.LJTI0_0
96 ; CHECK-A-STATIC-BE-LABEL: .LJTI0_0:
97 ; CHECK-A-STATIC-BE: .quad .LBB0_9
99 ; CHECK-R-STATIC-BE-LABEL: .LJTI0_0:
100 ; CHECK-R-STATIC-BE: .long .LBB0_9-.LJTI0_0
102 %cmp36 = icmp eq ptr %list, null
103 br i1 %cmp36, label %while.end, label %while.body
105 while.body: ; preds = %entry, %sw.epilog
106 %result.038 = phi i32 [ %result.1, %sw.epilog ], [ 0, %entry ]
107 %current.037 = phi ptr [ %spec.store.select, %sw.epilog ], [ %list, %entry ]
108 %next1 = getelementptr inbounds %struct.node, ptr %current.037, i64 0, i32 1
109 %0 = load ptr, ptr %next1, align 8
110 %cmp2 = icmp eq ptr %0, %current.037
111 %spec.store.select = select i1 %cmp2, ptr null, ptr %0
112 %1 = load i8, ptr %current.037, align 8
113 switch i8 %1, label %sw.epilog [
125 sw.bb: ; preds = %while.body
126 %add = add nsw i32 %result.038, 13
129 sw.bb3: ; preds = %while.body
130 %add4 = add nsw i32 %result.038, 5
133 sw.bb5: ; preds = %while.body
134 %add6 = add nsw i32 %result.038, 2
137 sw.bb7: ; preds = %while.body
138 %add8 = add nsw i32 %result.038, 7
141 sw.bb9: ; preds = %while.body
142 %add10 = add nsw i32 %result.038, 11
145 sw.bb11: ; preds = %while.body
146 %add12 = add nsw i32 %result.038, 17
149 sw.bb13: ; preds = %while.body
150 %add14 = add nsw i32 %result.038, 16
153 sw.bb15: ; preds = %while.body
154 %add16 = add nsw i32 %result.038, 81
157 sw.bb17: ; preds = %while.body
158 %add18 = add nsw i32 %result.038, 72
161 sw.epilog: ; preds = %while.body, %sw.bb17, %sw.bb15, %sw.bb13, %sw.bb11, %sw.bb9, %sw.bb7, %sw.bb5, %sw.bb3, %sw.bb
162 %result.1 = phi i32 [ %result.038, %while.body ], [ %add18, %sw.bb17 ], [ %add16, %sw.bb15 ], [ %add14, %sw.bb13 ], [ %add12, %sw.bb11 ], [ %add10, %sw.bb9 ], [ %add8, %sw.bb7 ], [ %add6, %sw.bb5 ], [ %add4, %sw.bb3 ], [ %add, %sw.bb ]
163 %cmp = icmp eq ptr %spec.store.select, null
164 br i1 %cmp, label %while.end, label %while.body
166 while.end: ; preds = %sw.epilog, %entry
167 %result.0.lcssa = phi i32 [ 0, %entry ], [ %result.1, %sw.epilog ]
168 ret i32 %result.0.lcssa