1 ; Test for generation of jump table for ropi/rwpi
3 ; RUN: llc -relocation-model=static -mtriple=armv7a--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM --check-prefix=ARM_ABS
4 ; RUN: llc -relocation-model=ropi -mtriple=armv7a--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM --check-prefix=ARM_PC
5 ; RUN: llc -relocation-model=ropi-rwpi -mtriple=armv7a--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM --check-prefix=ARM_PC
7 ; RUN: llc -relocation-model=static -mtriple=thumbv7m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB2
8 ; RUN: llc -relocation-model=ropi -mtriple=thumbv7m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB2
9 ; RUN: llc -relocation-model=ropi-rwpi -mtriple=thumbv7m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB2
11 ; RUN: llc -relocation-model=static -mtriple=thumbv6m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB1
12 ; RUN: llc -relocation-model=ropi -mtriple=thumbv6m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB1
13 ; RUN: llc -relocation-model=ropi-rwpi -mtriple=thumbv6m--none-eabi -disable-block-placement < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB1
21 define void @jump_table(i32 %val) {
23 switch i32 %val, label %default [ i32 1, label %lab1
29 tail call void @exit0()
33 tail call void @exit1()
37 tail call void @exit2()
41 tail call void @exit3()
45 tail call void @exit4()
48 ; CHECK-LABEL: jump_table:
50 ; ARM: adr r[[R_TAB_BASE:[0-9]+]], [[LJTI:\.LJTI[0-9]+_[0-9]+]]
51 ; ARM_ABS: ldr pc, [r[[R_TAB_BASE]], r{{[0-9]+}}, lsl #2]
52 ; ARM_PC: ldr r[[R_OFFSET:[0-9]+]], [r[[R_TAB_BASE]], r{{[0-9]+}}, lsl #2]
53 ; ARM_PC: add pc, r[[R_TAB_BASE]], r[[R_OFFSET]]
55 ; ARM_ABS: .long [[LBB1:\.LBB[0-9]+_[0-9]+]]
56 ; ARM_ABS: .long [[LBB2:\.LBB[0-9]+_[0-9]+]]
57 ; ARM_ABS: .long [[LBB3:\.LBB[0-9]+_[0-9]+]]
58 ; ARM_ABS: .long [[LBB4:\.LBB[0-9]+_[0-9]+]]
59 ; ARM_PC: .long [[LBB1:\.LBB[0-9]+_[0-9]+]]-[[LJTI]]
60 ; ARM_PC: .long [[LBB2:\.LBB[0-9]+_[0-9]+]]-[[LJTI]]
61 ; ARM_PC: .long [[LBB3:\.LBB[0-9]+_[0-9]+]]-[[LJTI]]
62 ; ARM_PC: .long [[LBB4:\.LBB[0-9]+_[0-9]+]]-[[LJTI]]
72 ; THUMB2: [[LCPI:\.LCPI[0-9]+_[0-9]+]]:
73 ; THUMB2: tbb [pc, r{{[0-9]+}}]
74 ; THUMB2: .byte ([[LBB1:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
75 ; THUMB2: .byte ([[LBB2:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
76 ; THUMB2: .byte ([[LBB3:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
77 ; THUMB2: .byte ([[LBB4:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
79 ; THUMB2-NEXT: b exit1
81 ; THUMB2-NEXT: b exit2
83 ; THUMB2-NEXT: b exit3
85 ; THUMB2-NEXT: b exit4
88 ; THUMB1: add r[[x:[0-9]+]], pc
89 ; THUMB1: ldrb r[[x]], [r[[x]], #4]
90 ; THUMB1: lsls r[[x]], r[[x]], #1
91 ; THUMB1: [[LCPI:\.LCPI[0-9]+_[0-9]+]]:
92 ; THUMB1: add pc, r[[x]]
94 ; THUMB1: .byte ([[LBB1:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
95 ; THUMB1: .byte ([[LBB2:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
96 ; THUMB1: .byte ([[LBB3:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
97 ; THUMB1: .byte ([[LBB4:\.LBB[0-9]+_[0-9]+]]-([[LCPI]]+4))/2
99 ; THUMB1-NEXT: bl exit1
101 ; THUMB1-NEXT: bl exit2
103 ; THUMB1-NEXT: bl exit3
105 ; THUMB1-NEXT: bl exit4