1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
; RUN: not llc < %s -march=xcore -code-model=medium 2>&1 | FileCheck %s -check-prefix=BAD_CM
; RUN: not llc < %s -march=xcore -code-model=kernel 2>&1 | FileCheck %s -check-prefix=BAD_CM
; RUN: not llc < %s -march=xcore -code-model=tiny 2>&1 | FileCheck %s -check-prefix=BAD_CM
; BAD_CM: Target only supports CodeModel Small or Large
; RUN: llc < %s -march=xcore | FileCheck %s
; RUN: llc < %s -march=xcore -code-model=small | FileCheck %s
; RUN: llc < %s -march=xcore -code-model=large | FileCheck %s -check-prefix=LARGE
; CHECK-LABEL: test:
; CHECK: zext r0, 1
; CHECK: bt r0, [[JUMP:.LBB[0-9_]*]]
; CHECK: ldaw r0, dp[A2]
; CHECK: retsp 0
; CHECK: [[JUMP]]
; CHECK: ldaw r0, dp[A1]
; CHECK: retsp 0
; LARGE-LABEL: test:
; LARGE: zext r0, 1
; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
; LARGE: mov r1, r11
; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
; LARGE: bt r0, [[JUMP:.LBB[0-9_]*]]
; LARGE: mov r11, r1
; LARGE: [[JUMP]]
; LARGE: ldw r0, r11[0]
; LARGE: retsp 0
@A1 = external global [50000 x i32]
@A2 = external global [50000 x i32]
define [50000 x i32]* @test(i1 %bool) nounwind {
entry:
%Addr = select i1 %bool, [50000 x i32]* @A1, [50000 x i32]* @A2
ret [50000 x i32]* %Addr
}
; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
; CHECK: .long 65536
; CHECK: .text
; CHECK-LABEL: f:
; CHECK: ldc r1, 65532
; CHECK: add r1, r0, r1
; CHECK: ldw r1, r1[0]
; CHECK: ldw r2, cp[.LCPI{{[0-9_]*}}]
; CHECK: add r0, r0, r2
; CHECK: ldw r0, r0[0]
; CHECK: add r0, r1, r0
; CHECK: ldw r1, dp[l]
; CHECK: add r0, r0, r1
; CHECK: ldw r1, dp[l+4]
; CHECK: add r0, r0, r1
; CHECK: ldw r1, dp[l+392]
; CHECK: add r0, r0, r1
; CHECK: ldw r1, dp[l+396]
; CHECK: add r0, r0, r1
; CHECK: ldw r1, dp[s]
; CHECK: add r0, r0, r1
; CHECK: ldw r1, dp[s+36]
; CHECK: add r0, r0, r1
; CHECK: retsp 0
;
; LARGE: .section .cp.rodata.cst4,"aMc",@progbits,4
; LARGE: .long 65536
; LARGE: .section .cp.rodata,"ac",@progbits
; LARGE: .long l
; LARGE: .long l+4
; LARGE: .long l+392
; LARGE: .long l+396
; LARGE: .text
; LARGE-LABEL: f:
; LARGE: ldc r1, 65532
; LARGE: add r1, r0, r1
; LARGE: ldw r1, r1[0]
; LARGE: ldw r2, cp[.LCPI{{[0-9_]*}}]
; LARGE: add r0, r0, r2
; LARGE: ldw r0, r0[0]
; LARGE: add r0, r1, r0
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
; LARGE: ldw r1, r1[0]
; LARGE: add r0, r0, r1
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
; LARGE: ldw r1, r1[0]
; LARGE: add r0, r0, r1
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
; LARGE: ldw r1, r1[0]
; LARGE: add r0, r0, r1
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
; LARGE: ldw r1, r1[0]
; LARGE: add r0, r0, r1
; LARGE: ldw r1, dp[s]
; LARGE: add r0, r0, r1
; LARGE: ldw r1, dp[s+36]
; LARGE: add r0, r0, r1
; LARGE: retsp 0
define i32 @f(i32* %i) {
entry:
%0 = getelementptr inbounds i32, i32* %i, i32 16383
%1 = load i32, i32* %0
%2 = getelementptr inbounds i32, i32* %i, i32 16384
%3 = load i32, i32* %2
%4 = add nsw i32 %1, %3
%5 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 0)
%6 = add nsw i32 %4, %5
%7 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 1)
%8 = add nsw i32 %6, %7
%9 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 98)
%10 = add nsw i32 %8, %9
%11 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 99)
%12 = add nsw i32 %10, %11
%13 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 0)
%14 = add nsw i32 %12, %13
%15 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 9)
%16 = add nsw i32 %14, %15
ret i32 %16
}
; CHECK-LABEL: UnknownSize:
; CHECK: ldw r0, dp[NoSize+40]
; CHECK-NEXT: retsp 0
;
; LARGE: .section .cp.rodata,"ac",@progbits
; LARGE: .LCPI{{[0-9_]*}}
; LARGE-NEXT: .long NoSize
; LARGE-NEXT: .text
; LARGE-LABEL: UnknownSize:
; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
; LARGE-NEXT: ldw r0, r0[0]
; LARGE-NEXT: retsp 0
@NoSize = external global [0 x i32]
define i32 @UnknownSize() nounwind {
entry:
%0 = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @NoSize, i32 0, i32 10)
ret i32 %0
}
; CHECK-LABEL: UnknownStruct:
; CHECK: ldaw r0, dp[Unknown]
; CHECK-NEXT: retsp 0
;
; LARGE: .section .cp.rodata,"ac",@progbits
; LARGE: .LCPI{{[0-9_]*}}
; LARGE-NEXT: .long Unknown
; LARGE-NEXT: .text
; LARGE-LABEL: UnknownStruct:
; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
; LARGE-NEXT: retsp 0
%Struct = type opaque
@Unknown = external global %Struct
define %Struct* @UnknownStruct() nounwind {
entry:
ret %Struct* @Unknown
}
; CHECK: .section .dp.bss,"awd",@nobits
; CHECK-LABEL: l:
; CHECK: .space 400
; LARGE: .section .dp.bss.large,"awd",@nobits
; LARGE-LABEL: l:
; LARGE: .space 400
@l = global [100 x i32] zeroinitializer
; CHECK-LABEL: s:
; CHECK: .space 40
; LARGE: .section .dp.bss,"awd",@nobits
; LARGE-LABEL: s:
; LARGE: .space 40
@s = global [10 x i32] zeroinitializer
; CHECK: .section .dp.rodata,"awd",@progbits
; CHECK-LABEL: cl:
; CHECK: .space 400
; LARGE: .section .dp.rodata.large,"awd",@progbits
; LARGE-LABEL: cl:
; LARGE: .space 400
@cl = constant [100 x i32] zeroinitializer
; CHECK-LABEL: cs:
; CHECK: .space 40
; LARGE: .section .dp.rodata,"awd",@progbits
; LARGE-LABEL: cs:
; LARGE: .space 40
@cs = constant [10 x i32] zeroinitializer
; CHECK: .section .cp.rodata,"ac",@progbits
; CHECK-LABEL: icl:
; CHECK: .space 400
; LARGE: .section .cp.rodata.large,"ac",@progbits
; LARGE-LABEL: icl:
; LARGE: .space 400
@icl = internal constant [100 x i32] zeroinitializer
; CHECK-LABEL: cs:
; CHECK: .space 40
; LARGE: .section .cp.rodata,"ac",@progbits
; LARGE-LABEL: cs:
; LARGE: .space 40
@ics = internal constant [10 x i32] zeroinitializer
; CHECK: .section .cp.namedsection,"ac",@progbits
; CHECK-LABEL: cpsec:
; CHECK: .long 0
@cpsec = constant i32 0, section ".cp.namedsection"
; CHECK: .section .dp.namedsection,"awd",@progbits
; CHECK-LABEL: dpsec:
; CHECK: .long 0
@dpsec = global i32 0, section ".dp.namedsection"
|