2 ; RUN: not --crash llc < %s -mtriple=xcore -code-model=medium 2>&1 | FileCheck %s -check-prefix=BAD_CM
3 ; RUN: not --crash llc < %s -mtriple=xcore -code-model=kernel 2>&1 | FileCheck %s -check-prefix=BAD_CM
4 ; RUN: not --crash llc < %s -mtriple=xcore -code-model=tiny 2>&1 | FileCheck %s -check-prefix=BAD_CM
5 ; BAD_CM: Target only supports CodeModel Small or Large
8 ; RUN: llc < %s -mtriple=xcore | FileCheck %s
9 ; RUN: llc < %s -mtriple=xcore -code-model=small | FileCheck %s
10 ; RUN: llc < %s -mtriple=xcore -code-model=large | FileCheck %s -check-prefix=LARGE
15 ; CHECK: bt r0, [[JUMP:.LBB[0-9_]*]]
16 ; CHECK: ldaw r0, dp[A2]
19 ; CHECK: ldaw r0, dp[A1]
23 ; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
25 ; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
26 ; LARGE: bt r0, [[JUMP:.LBB[0-9_]*]]
29 ; LARGE: ldw r0, r11[0]
31 @A1 = external dso_local global [50000 x i32]
32 @A2 = external dso_local global [50000 x i32]
33 define ptr @test(i1 %bool) nounwind {
35 %Addr = select i1 %bool, ptr @A1, ptr @A2
40 ; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
44 ; CHECK: ldc r1, 65532
45 ; CHECK: add r1, r0, r1
46 ; CHECK: ldw r1, r1[0]
47 ; CHECK: ldw r2, cp[.LCPI{{[0-9_]*}}]
48 ; CHECK: add r0, r0, r2
49 ; CHECK: ldw r0, r0[0]
50 ; CHECK: add r0, r1, r0
51 ; CHECK: ldw r1, dp[l]
52 ; CHECK: add r0, r0, r1
53 ; CHECK: ldw r1, dp[l+4]
54 ; CHECK: add r0, r0, r1
55 ; CHECK: ldw r1, dp[l+392]
56 ; CHECK: add r0, r0, r1
57 ; CHECK: ldw r1, dp[l+396]
58 ; CHECK: add r0, r0, r1
59 ; CHECK: ldw r1, dp[s]
60 ; CHECK: add r0, r0, r1
61 ; CHECK: ldw r1, dp[s+36]
62 ; CHECK: add r0, r0, r1
65 ; LARGE: .section .cp.rodata.cst4,"aMc",@progbits,4
67 ; LARGE: .section .cp.rodata,"ac",@progbits
74 ; LARGE: ldc r1, 65532
75 ; LARGE: add r1, r0, r1
76 ; LARGE: ldw r1, r1[0]
77 ; LARGE: ldw r2, cp[.LCPI{{[0-9_]*}}]
78 ; LARGE: add r0, r0, r2
79 ; LARGE: ldw r0, r0[0]
80 ; LARGE: add r0, r1, r0
81 ; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
82 ; LARGE: ldw r1, r1[0]
83 ; LARGE: add r0, r0, r1
84 ; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
85 ; LARGE: ldw r1, r1[0]
86 ; LARGE: add r0, r0, r1
87 ; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
88 ; LARGE: ldw r1, r1[0]
89 ; LARGE: add r0, r0, r1
90 ; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
91 ; LARGE: ldw r1, r1[0]
92 ; LARGE: add r0, r0, r1
93 ; LARGE: ldw r1, dp[s]
94 ; LARGE: add r0, r0, r1
95 ; LARGE: ldw r1, dp[s+36]
96 ; LARGE: add r0, r0, r1
98 define dso_local i32 @f(ptr %i) {
100 %0 = getelementptr inbounds i32, ptr %i, i32 16383
101 %1 = load i32, ptr %0
102 %2 = getelementptr inbounds i32, ptr %i, i32 16384
103 %3 = load i32, ptr %2
104 %4 = add nsw i32 %1, %3
105 %5 = load i32, ptr @l
106 %6 = add nsw i32 %4, %5
107 %7 = load i32, ptr getelementptr inbounds ([100 x i32], ptr @l, i32 0, i32 1)
108 %8 = add nsw i32 %6, %7
109 %9 = load i32, ptr getelementptr inbounds ([100 x i32], ptr @l, i32 0, i32 98)
110 %10 = add nsw i32 %8, %9
111 %11 = load i32, ptr getelementptr inbounds ([100 x i32], ptr @l, i32 0, i32 99)
112 %12 = add nsw i32 %10, %11
113 %13 = load i32, ptr @s
114 %14 = add nsw i32 %12, %13
115 %15 = load i32, ptr getelementptr inbounds ([10 x i32], ptr @s, i32 0, i32 9)
116 %16 = add nsw i32 %14, %15
121 ; CHECK-LABEL: UnknownSize:
122 ; CHECK: ldw r0, dp[NoSize+40]
123 ; CHECK-NEXT: retsp 0
125 ; LARGE: .section .cp.rodata,"ac",@progbits
126 ; LARGE: .LCPI{{[0-9_]*}}
127 ; LARGE-NEXT: .long NoSize
129 ; LARGE-LABEL: UnknownSize:
130 ; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
131 ; LARGE-NEXT: ldw r0, r0[0]
132 ; LARGE-NEXT: retsp 0
133 @NoSize = external dso_local global [0 x i32]
134 define dso_local i32 @UnknownSize() nounwind {
136 %0 = load i32, ptr getelementptr inbounds ([0 x i32], ptr @NoSize, i32 0, i32 10)
141 ; CHECK-LABEL: UnknownStruct:
142 ; CHECK: ldaw r0, dp[Unknown]
143 ; CHECK-NEXT: retsp 0
145 ; LARGE: .section .cp.rodata,"ac",@progbits
146 ; LARGE: .LCPI{{[0-9_]*}}
147 ; LARGE-NEXT: .long Unknown
149 ; LARGE-LABEL: UnknownStruct:
150 ; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
151 ; LARGE-NEXT: retsp 0
152 %Struct = type opaque
153 @Unknown = external dso_local global %Struct
154 define ptr @UnknownStruct() nounwind {
160 ; CHECK: .section .dp.bss,"awd",@nobits
163 ; LARGE: .section .dp.bss.large,"awd",@nobits
166 @l = dso_local global [100 x i32] zeroinitializer
170 ; LARGE: .section .dp.bss,"awd",@nobits
173 @s = dso_local global [10 x i32] zeroinitializer
175 ; CHECK: .section .dp.rodata,"awd",@progbits
178 ; LARGE: .section .dp.rodata.large,"awd",@progbits
181 @cl = dso_local constant [100 x i32] zeroinitializer
185 ; LARGE: .section .dp.rodata,"awd",@progbits
188 @cs = dso_local constant [10 x i32] zeroinitializer
190 ; CHECK: .section .cp.rodata,"ac",@progbits
193 ; LARGE: .section .cp.rodata.large,"ac",@progbits
196 @icl = internal constant [100 x i32] zeroinitializer
200 ; LARGE: .section .cp.rodata,"ac",@progbits
203 @ics = internal constant [10 x i32] zeroinitializer
205 ; CHECK: .section .cp.namedsection,"ac",@progbits
206 ; CHECK-LABEL: cpsec:
208 @cpsec = dso_local constant i32 0, section ".cp.namedsection"
210 ; CHECK: .section .dp.namedsection,"awd",@progbits
211 ; CHECK-LABEL: dpsec:
213 @dpsec = dso_local global i32 0, section ".dp.namedsection"