1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -mattr=+2e3 | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -relocation-model=pic -code-model=small -mattr=+2e3 | FileCheck %s --check-prefix=CHECK-PIC-SMALL
4 ; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -relocation-model=pic -code-model=large -mattr=+2e3 | FileCheck %s --check-prefix=CHECK-PIC-LARGE
6 @f.a = private unnamed_addr constant [2 x ptr] [ptr blockaddress(@f, %return), ptr blockaddress(@f, %l2)], align 16
8 define i32 @f(i32 %x) #0 {
10 ; CHECK: # %bb.0: # %entry
11 ; CHECK-NEXT: lrw32 a1, [.LCPI0_0]
12 ; CHECK-NEXT: ldr32.w a0, (a1, a0 << 2)
13 ; CHECK-NEXT: jmp32 a0
14 ; CHECK-NEXT: .Ltmp0: # Block address taken
15 ; CHECK-NEXT: .LBB0_1: # %return
16 ; CHECK-NEXT: movi16 a0, 1
18 ; CHECK-NEXT: .Ltmp1: # Block address taken
19 ; CHECK-NEXT: .LBB0_2: # %l2
20 ; CHECK-NEXT: movi16 a0, 2
22 ; CHECK-NEXT: .p2align 1
23 ; CHECK-NEXT: # %bb.3:
24 ; CHECK-NEXT: .p2align 2
25 ; CHECK-NEXT: .LCPI0_0:
26 ; CHECK-NEXT: .long .Lf.a
28 ; CHECK-PIC-SMALL-LABEL: f:
29 ; CHECK-PIC-SMALL: # %bb.0: # %entry
30 ; CHECK-PIC-SMALL-NEXT: subi16 sp, sp, 4
31 ; CHECK-PIC-SMALL-NEXT: .cfi_def_cfa_offset 4
32 ; CHECK-PIC-SMALL-NEXT: st32.w rgb, (sp, 0) # 4-byte Folded Spill
33 ; CHECK-PIC-SMALL-NEXT: .cfi_offset rgb, -4
34 ; CHECK-PIC-SMALL-NEXT: .cfi_def_cfa_offset 4
35 ; CHECK-PIC-SMALL-NEXT: lrw32 rgb, [.LCPI0_0]
36 ; CHECK-PIC-SMALL-NEXT: lrw32 a1, [.LCPI0_1]
37 ; CHECK-PIC-SMALL-NEXT: addu32 a1, rgb, a1
38 ; CHECK-PIC-SMALL-NEXT: ldr32.w a0, (a1, a0 << 2)
39 ; CHECK-PIC-SMALL-NEXT: jmp32 a0
40 ; CHECK-PIC-SMALL-NEXT: .Ltmp0: # Block address taken
41 ; CHECK-PIC-SMALL-NEXT: .LBB0_1: # %return
42 ; CHECK-PIC-SMALL-NEXT: movi16 a0, 1
43 ; CHECK-PIC-SMALL-NEXT: br32 .LBB0_3
44 ; CHECK-PIC-SMALL-NEXT: .Ltmp1: # Block address taken
45 ; CHECK-PIC-SMALL-NEXT: .LBB0_2: # %l2
46 ; CHECK-PIC-SMALL-NEXT: movi16 a0, 2
47 ; CHECK-PIC-SMALL-NEXT: .LBB0_3: # %.split
48 ; CHECK-PIC-SMALL-NEXT: ld32.w rgb, (sp, 0) # 4-byte Folded Reload
49 ; CHECK-PIC-SMALL-NEXT: addi16 sp, sp, 4
50 ; CHECK-PIC-SMALL-NEXT: rts16
51 ; CHECK-PIC-SMALL-NEXT: .p2align 1
52 ; CHECK-PIC-SMALL-NEXT: # %bb.4:
53 ; CHECK-PIC-SMALL-NEXT: .p2align 2
54 ; CHECK-PIC-SMALL-NEXT: .LCPI0_0:
55 ; CHECK-PIC-SMALL-NEXT: .long _GLOBAL_OFFSET_TABLE_
56 ; CHECK-PIC-SMALL-NEXT: .LCPI0_1:
57 ; CHECK-PIC-SMALL-NEXT: .long .Lf.a@GOTOFF
59 ; CHECK-PIC-LARGE-LABEL: f:
60 ; CHECK-PIC-LARGE: # %bb.0: # %entry
61 ; CHECK-PIC-LARGE-NEXT: subi16 sp, sp, 4
62 ; CHECK-PIC-LARGE-NEXT: .cfi_def_cfa_offset 4
63 ; CHECK-PIC-LARGE-NEXT: st32.w rgb, (sp, 0) # 4-byte Folded Spill
64 ; CHECK-PIC-LARGE-NEXT: .cfi_offset rgb, -4
65 ; CHECK-PIC-LARGE-NEXT: .cfi_def_cfa_offset 4
66 ; CHECK-PIC-LARGE-NEXT: lrw32 rgb, [.LCPI0_0]
67 ; CHECK-PIC-LARGE-NEXT: lrw32 a1, [.LCPI0_1]
68 ; CHECK-PIC-LARGE-NEXT: addu32 a1, rgb, a1
69 ; CHECK-PIC-LARGE-NEXT: ldr32.w a0, (a1, a0 << 2)
70 ; CHECK-PIC-LARGE-NEXT: jmp32 a0
71 ; CHECK-PIC-LARGE-NEXT: .Ltmp0: # Block address taken
72 ; CHECK-PIC-LARGE-NEXT: .LBB0_1: # %return
73 ; CHECK-PIC-LARGE-NEXT: movi16 a0, 1
74 ; CHECK-PIC-LARGE-NEXT: br32 .LBB0_3
75 ; CHECK-PIC-LARGE-NEXT: .Ltmp1: # Block address taken
76 ; CHECK-PIC-LARGE-NEXT: .LBB0_2: # %l2
77 ; CHECK-PIC-LARGE-NEXT: movi16 a0, 2
78 ; CHECK-PIC-LARGE-NEXT: .LBB0_3: # %.split
79 ; CHECK-PIC-LARGE-NEXT: ld32.w rgb, (sp, 0) # 4-byte Folded Reload
80 ; CHECK-PIC-LARGE-NEXT: addi16 sp, sp, 4
81 ; CHECK-PIC-LARGE-NEXT: rts16
82 ; CHECK-PIC-LARGE-NEXT: .p2align 1
83 ; CHECK-PIC-LARGE-NEXT: # %bb.4:
84 ; CHECK-PIC-LARGE-NEXT: .p2align 2
85 ; CHECK-PIC-LARGE-NEXT: .LCPI0_0:
86 ; CHECK-PIC-LARGE-NEXT: .long _GLOBAL_OFFSET_TABLE_
87 ; CHECK-PIC-LARGE-NEXT: .LCPI0_1:
88 ; CHECK-PIC-LARGE-NEXT: .long .Lf.a@GOTOFF
90 %idxprom = sext i32 %x to i64
91 %arrayidx = getelementptr inbounds [2 x ptr], ptr @f.a, i64 0, i64 %idxprom
92 %0 = load ptr, ptr %arrayidx, align 8
93 indirectbr ptr %0, [label %return, label %l2]
98 return: ; preds = %entry, %l2
99 %retval.0 = phi i32 [ 2, %l2 ], [ 1, %entry ]