1 ; RUN: llc -no-integrated-as -verify-machineinstrs -o - %s -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 | FileCheck %s
2 ; RUN: llc -no-integrated-as -code-model=large -verify-machineinstrs -o - %s -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 | FileCheck --check-prefix=CHECK-LARGE %s
3 ; RUN: llc -no-integrated-as -mtriple=aarch64-none-linux-gnu -verify-machineinstrs -relocation-model=pic -aarch64-enable-atomic-cfg-tidy=0 -o - %s | FileCheck --check-prefix=CHECK-PIC %s
4 ; RUN: llc -no-integrated-as -code-model=tiny -verify-machineinstrs -o - %s -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 | FileCheck --check-prefix=CHECK-TINY %s
6 define i32 @test_jumptable(i32 %in) {
7 ; CHECK: test_jumptable
9 switch i32 %in, label %def [
15 ; CHECK-LABEL: test_jumptable:
16 ; CHECK: adrp [[JTPAGE:x[0-9]+]], .LJTI0_0
17 ; CHECK: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI0_0
18 ; CHECK: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
19 ; CHECK: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
20 ; CHECK: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
23 ; CHECK-LARGE: movz x[[JTADDR:[0-9]+]], #:abs_g0_nc:.LJTI0_0
24 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g1_nc:.LJTI0_0
25 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g2_nc:.LJTI0_0
26 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g3:.LJTI0_0
27 ; CHECK-LARGE: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
28 ; CHECK-LARGE: ldrb w[[OFFSET:[0-9]+]], [x[[JTADDR]], {{x[0-9]+}}]
29 ; CHECK-LARGE: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
30 ; CHECK-LARGE: br [[DEST]]
32 ; CHECK-PIC-LABEL: test_jumptable:
33 ; CHECK-PIC: adrp [[JTPAGE:x[0-9]+]], .LJTI0_0
34 ; CHECK-PIC: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI0_0
35 ; CHECK-PIC: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
36 ; CHECK-PIC: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
37 ; CHECK-PIC: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
38 ; CHECK-PIC: br [[DEST]]
40 ; CHECK-IOS: adrp [[JTPAGE:x[0-9]+]], LJTI0_0@PAGE
41 ; CHECK-IOS: add x[[JT:[0-9]+]], [[JTPAGE]], LJTI0_0@PAGEOFF
42 ; CHECK-IOS: adr [[PCBASE:x[0-9]+]], [[JTBASE:LBB[0-9]+_[0-9]+]]
43 ; CHECK-IOS: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
44 ; CHECK-IOS: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
45 ; CHECK-IOS: br [[DEST]]
47 ; CHECK-TINY-LABEL: test_jumptable:
48 ; CHECK-TINY: adr x[[JT:[0-9]+]], .LJTI0_0
49 ; CHECK-TINY: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
50 ; CHECK-TINY: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
51 ; CHECK-TINY: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
52 ; CHECK-TINY: br [[DEST]]
75 ; CHECK-NEXT: .byte ([[JTBASE]]-[[JTBASE]])>>2
76 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
77 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
78 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
79 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
81 define i32 @test_jumptable16(i32 %in) {
83 switch i32 %in, label %def [
89 ; CHECK-LABEL: test_jumptable16:
90 ; CHECK: adrp [[JTPAGE:x[0-9]+]], .LJTI1_0
91 ; CHECK: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI1_0
92 ; CHECK: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
93 ; CHECK: ldrh w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}, lsl #1]
94 ; CHECK: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
104 call i64 @llvm.aarch64.space(i32 1024, i64 undef)
118 ; CHECK-NEXT: .hword ([[JTBASE]]-[[JTBASE]])>>2
119 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
120 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
121 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
122 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
124 ; CHECK-PIC-NOT: .data_region
125 ; CHECK-PIC-NOT: .LJTI0_0
126 ; CHECK-PIC: .LJTI0_0:
127 ; CHECK-PIC-NEXT: .byte ([[JTBASE]]-[[JTBASE]])>>2
128 ; CHECK-PIC-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
129 ; CHECK-PIC-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
130 ; CHECK-PIC-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
131 ; CHECK-PIC-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
132 ; CHECK-PIC-NOT: .end_data_region
134 ; CHECK-IOS: .section __TEXT,__const
135 ; CHECK-IOS-NOT: .data_region
136 ; CHECK-IOS: LJTI0_0:
137 ; CHECK-IOS-NEXT: .byte ([[JTBASE]]-[[JTBASE]])>>2
138 ; CHECK-IOS-NEXT: .byte (LBB{{.*}}-[[JTBASE]])>>2
139 ; CHECK-IOS-NEXT: .byte (LBB{{.*}}-[[JTBASE]])>>2
140 ; CHECK-IOS-NEXT: .byte (LBB{{.*}}-[[JTBASE]])>>2
141 ; CHECK-IOS-NEXT: .byte (LBB{{.*}}-[[JTBASE]])>>2
142 ; CHECK-IOS-NOT: .end_data_region
144 ; Compressing just the first table has the opportunity to truncate the vector of
145 ; sizes. Make sure it doesn't.
146 define i32 @test_twotables(i32 %in1, i32 %in2) {
147 ; CHECK-LABEL: test_twotables:
151 switch i32 %in1, label %def [
171 switch i32 %in1, label %def [
179 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
183 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
187 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
190 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
195 declare i64 @llvm.aarch64.space(i32, i64)