xref: /aosp_15_r20/external/llvm/test/MC/AArch64/jump-table.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc < %s -triple=aarch64-none-linux-gnu -filetype=obj | llvm-readobj -r | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker	.file	"<stdin>"
4*9880d681SAndroid Build Coastguard Worker	.text
5*9880d681SAndroid Build Coastguard Worker	.globl	test_jumptable
6*9880d681SAndroid Build Coastguard Worker	.type	test_jumptable,@function
7*9880d681SAndroid Build Coastguard Workertest_jumptable:                         // @test_jumptable
8*9880d681SAndroid Build Coastguard Worker	.cfi_startproc
9*9880d681SAndroid Build Coastguard Worker// BB#0:
10*9880d681SAndroid Build Coastguard Worker	ubfx	w1, w0, #0, #32
11*9880d681SAndroid Build Coastguard Worker	cmp w0, #4
12*9880d681SAndroid Build Coastguard Worker	b.hi .LBB0_3
13*9880d681SAndroid Build Coastguard Worker// BB#1:
14*9880d681SAndroid Build Coastguard Worker	adrp	x0, .LJTI0_0
15*9880d681SAndroid Build Coastguard Worker	add	x0, x0, #:lo12:.LJTI0_0
16*9880d681SAndroid Build Coastguard Worker	ldr	x0, [x0, x1, lsl #3]
17*9880d681SAndroid Build Coastguard Worker	br	x0
18*9880d681SAndroid Build Coastguard Worker.LBB0_2:                                // %lbl1
19*9880d681SAndroid Build Coastguard Worker	movz	x0, #1
20*9880d681SAndroid Build Coastguard Worker	ret
21*9880d681SAndroid Build Coastguard Worker.LBB0_3:                                // %def
22*9880d681SAndroid Build Coastguard Worker	mov	 x0, xzr
23*9880d681SAndroid Build Coastguard Worker	ret
24*9880d681SAndroid Build Coastguard Worker.LBB0_4:                                // %lbl2
25*9880d681SAndroid Build Coastguard Worker	movz	x0, #2
26*9880d681SAndroid Build Coastguard Worker	ret
27*9880d681SAndroid Build Coastguard Worker.LBB0_5:                                // %lbl3
28*9880d681SAndroid Build Coastguard Worker	movz	x0, #4
29*9880d681SAndroid Build Coastguard Worker	ret
30*9880d681SAndroid Build Coastguard Worker.LBB0_6:                                // %lbl4
31*9880d681SAndroid Build Coastguard Worker	movz	x0, #8
32*9880d681SAndroid Build Coastguard Worker	ret
33*9880d681SAndroid Build Coastguard Worker.Ltmp0:
34*9880d681SAndroid Build Coastguard Worker	.size	test_jumptable, .Ltmp0-test_jumptable
35*9880d681SAndroid Build Coastguard Worker	.cfi_endproc
36*9880d681SAndroid Build Coastguard Worker	.section	.rodata,"a",@progbits
37*9880d681SAndroid Build Coastguard Worker	.align	3
38*9880d681SAndroid Build Coastguard Worker.LJTI0_0:
39*9880d681SAndroid Build Coastguard Worker	.xword	.LBB0_2
40*9880d681SAndroid Build Coastguard Worker	.xword	.LBB0_4
41*9880d681SAndroid Build Coastguard Worker	.xword	.LBB0_5
42*9880d681SAndroid Build Coastguard Worker	.xword	.LBB0_3
43*9880d681SAndroid Build Coastguard Worker	.xword	.LBB0_6
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker// First make sure we get a page/lo12 pair in .text to pick up the jump-table
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker// CHECK:      Relocations [
50*9880d681SAndroid Build Coastguard Worker// CHECK:        Section ({{[0-9]+}}) .rela.text {
51*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 .rodata
52*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ADD_ABS_LO12_NC .rodata
53*9880d681SAndroid Build Coastguard Worker// CHECK:        }
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker// Also check the targets in .rodata are relocated
56*9880d681SAndroid Build Coastguard Worker// CHECK:        Section ({{[0-9]+}}) .rela.rodata {
57*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ABS64 .text
58*9880d681SAndroid Build Coastguard Worker// CHECK:        }
59*9880d681SAndroid Build Coastguard Worker// CHECK:      ]
60