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