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 -verify-machineinstrs -o - %s -mtriple=arm64-apple-ios -aarch64-enable-atomic-cfg-tidy=0 | FileCheck --check-prefix=CHECK-IOS %s
5 ; 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
7 define i32 @test_jumptable(i32 %in) {
8 ; CHECK: test_jumptable
10 switch i32 %in, label %def [
16 ; CHECK-LABEL: test_jumptable:
17 ; CHECK: adrp [[JTPAGE:x[0-9]+]], .LJTI0_0
18 ; CHECK: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI0_0
19 ; CHECK: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
20 ; CHECK: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
21 ; CHECK: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
24 ; CHECK-LARGE: movz x[[JTADDR:[0-9]+]], #:abs_g0_nc:.LJTI0_0
25 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g1_nc:.LJTI0_0
26 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g2_nc:.LJTI0_0
27 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g3:.LJTI0_0
28 ; CHECK-LARGE: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
29 ; CHECK-LARGE: ldrb w[[OFFSET:[0-9]+]], [x[[JTADDR]], {{x[0-9]+}}]
30 ; CHECK-LARGE: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
31 ; CHECK-LARGE: br [[DEST]]
33 ; CHECK-PIC-LABEL: test_jumptable:
34 ; CHECK-PIC: adrp [[JTPAGE:x[0-9]+]], .LJTI0_0
35 ; CHECK-PIC: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI0_0
36 ; CHECK-PIC: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
37 ; CHECK-PIC: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
38 ; CHECK-PIC: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
39 ; CHECK-PIC: br [[DEST]]
41 ; CHECK-IOS: adrp [[JTPAGE:x[0-9]+]], LJTI0_0@PAGE
42 ; CHECK-IOS: add x[[JT:[0-9]+]], [[JTPAGE]], LJTI0_0@PAGEOFF
43 ; CHECK-IOS: adr [[PCBASE:x[0-9]+]], [[JTBASE:LBB[0-9]+_[0-9]+]]
44 ; CHECK-IOS: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
45 ; CHECK-IOS: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
46 ; CHECK-IOS: br [[DEST]]
48 ; CHECK-TINY-LABEL: test_jumptable:
49 ; CHECK-TINY: adr x[[JT:[0-9]+]], .LJTI0_0
50 ; CHECK-TINY: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
51 ; CHECK-TINY: ldrb w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}]
52 ; CHECK-TINY: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
53 ; CHECK-TINY: br [[DEST]]
76 ; CHECK-NEXT: .byte ([[JTBASE]]-[[JTBASE]])>>2
77 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
78 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
79 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
80 ; CHECK-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
82 define i32 @test_jumptable16(i32 %in) {
84 switch i32 %in, label %def [
90 ; CHECK-LABEL: test_jumptable16:
91 ; CHECK: adrp [[JTPAGE:x[0-9]+]], .LJTI1_0
92 ; CHECK: add x[[JT:[0-9]+]], [[JTPAGE]], {{#?}}:lo12:.LJTI1_0
93 ; CHECK: adr [[PCBASE:x[0-9]+]], [[JTBASE:.LBB[0-9]+_[0-9]+]]
94 ; CHECK: ldrh w[[OFFSET:[0-9]+]], [x[[JT]], {{x[0-9]+}}, lsl #1]
95 ; CHECK: add [[DEST:x[0-9]+]], [[PCBASE]], x[[OFFSET]], lsl #2
105 call i64 @llvm.aarch64.space(i32 1024, i64 undef)
119 ; CHECK-NEXT: .hword ([[JTBASE]]-[[JTBASE]])>>2
120 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
121 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
122 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
123 ; CHECK-NEXT: .hword (.LBB{{.*}}-[[JTBASE]])>>2
125 ; CHECK-PIC-NOT: .data_region
126 ; CHECK-PIC-NOT: .LJTI0_0
127 ; CHECK-PIC: .LJTI0_0:
128 ; CHECK-PIC-NEXT: .byte ([[JTBASE]]-[[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-NEXT: .byte (.LBB{{.*}}-[[JTBASE]])>>2
133 ; CHECK-PIC-NOT: .end_data_region
135 ; CHECK-IOS: .section __TEXT,__const
136 ; CHECK-IOS-NOT: .data_region
137 ; CHECK-IOS: LJTI0_0:
138 ; CHECK-IOS-NEXT: .byte ([[JTBASE]]-[[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-NEXT: .byte (LBB{{.*}}-[[JTBASE]])>>2
143 ; CHECK-IOS-NOT: .end_data_region
145 ; Compressing just the first table has the opportunity to truncate the vector of
146 ; sizes. Make sure it doesn't.
147 define i32 @test_twotables(i32 %in1, i32 %in2) {
148 ; CHECK-LABEL: test_twotables:
152 switch i32 %in1, label %def [
172 switch i32 %in1, label %def [
180 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
184 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
188 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
191 call i64 @llvm.aarch64.space(i32 262144, i64 undef)
196 declare i64 @llvm.aarch64.space(i32, i64)