[ARM] Better OR's for MVE compares
[llvm-core.git] / test / MC / AArch64 / ldr-pseudo.s
blob1d99d14018017beb74103081f2c75a14f70295d0
1 //RUN: llvm-mc -triple=aarch64-linux-gnu -print-imm-hex %s | FileCheck %s
3 //
4 // Check that large constants are converted to ldr from constant pool
5 //
6 // simple test
7 .section a, "ax", @progbits
8 // CHECK-LABEL: f1:
9 f1:
10 ldr x0, =0x1234
11 // CHECK: mov x0, #0x1234
12 ldr w1, =0x4567
13 // CHECK: mov w1, #0x4567
14 ldr x0, =0x12340000
15 // CHECK: mov x0, #0x12340000
16 ldr w1, =0x45670000
17 // CHECK: mov w1, #0x45670000
18 ldr x0, =0xabc00000000
19 // CHECK: mov x0, #0xabc00000000
20 ldr x0, =0xbeef000000000000
21 // CHECK: mov x0, #-0x4111000000000000
23 .section b,"ax",@progbits
24 // CHECK-LABEL: f3:
25 f3:
26 ldr w0, =0x10001
27 // CHECK: ldr w0, .Ltmp[[TMP0:[0-9]+]]
29 // loading multiple constants
30 .section c,"ax",@progbits
31 // CHECK-LABEL: f4:
32 f4:
33 ldr w0, =0x10002
34 // CHECK: ldr w0, .Ltmp[[TMP1:[0-9]+]]
35 adds x0, x0, #1
36 adds x0, x0, #1
37 adds x0, x0, #1
38 adds x0, x0, #1
39 ldr w0, =0x10003
40 // CHECK: ldr w0, .Ltmp[[TMP2:[0-9]+]]
41 adds x0, x0, #1
42 adds x0, x0, #1
44 // TODO: the same constants should have the same constant pool location
45 .section d,"ax",@progbits
46 // CHECK-LABEL: f5:
47 f5:
48 ldr w0, =0x10004
49 // CHECK: ldr w0, .Ltmp[[TMP3:[0-9]+]]
50 adds x0, x0, #1
51 adds x0, x0, #1
52 adds x0, x0, #1
53 adds x0, x0, #1
54 adds x0, x0, #1
55 adds x0, x0, #1
56 adds x0, x0, #1
57 ldr w0, =0x10004
58 // CHECK: ldr w0, .Ltmp[[TMP3:[0-9]+]]
59 adds x0, x0, #1
60 adds x0, x0, #1
61 adds x0, x0, #1
62 adds x0, x0, #1
63 adds x0, x0, #1
64 adds x0, x0, #1
66 // a section defined in multiple pieces should be merged and use a single constant pool
67 .section e,"ax",@progbits
68 // CHECK-LABEL: f6:
69 f6:
70 ldr w0, =0x10006
71 // CHECK: ldr w0, .Ltmp[[TMP5:[0-9]+]]
72 adds x0, x0, #1
73 adds x0, x0, #1
74 adds x0, x0, #1
76 .section f, "ax", @progbits
77 // CHECK-LABEL: f7:
78 f7:
79 adds x0, x0, #1
80 adds x0, x0, #1
81 adds x0, x0, #1
83 .section e, "ax", @progbits
84 // CHECK-LABEL: f8:
85 f8:
86 adds x0, x0, #1
87 ldr w0, =0x10007
88 // CHECK: ldr w0, .Ltmp[[TMP6:[0-9]+]]
89 adds x0, x0, #1
90 adds x0, x0, #1
93 // Check that symbols can be loaded using ldr pseudo
96 // load an undefined symbol
97 .section g,"ax",@progbits
98 // CHECK-LABEL: f9:
99 f9:
100 ldr w0, =foo
101 // CHECK: ldr w0, .Ltmp[[TMP7:[0-9]+]]
103 // load a symbol from another section
104 .section h,"ax",@progbits
105 // CHECK-LABEL: f10:
106 f10:
107 ldr w0, =f5
108 // CHECK: ldr w0, .Ltmp[[TMP8:[0-9]+]]
110 // load a symbol from the same section
111 .section i,"ax",@progbits
112 // CHECK-LABEL: f11:
113 f11:
114 ldr w0, =f12
115 // CHECK: ldr w0, .Ltmp[[TMP9:[0-9]+]]
116 ldr w0,=0x3C000
117 // CHECK: ldr w0, .Ltmp[[TMP10:[0-9]+]]
119 // CHECK-LABEL: f12:
120 f12:
121 adds x0, x0, #1
122 adds x0, x0, #1
124 .section j,"ax",@progbits
125 // mix of symbols and constants
126 // CHECK-LABEL: f13:
127 f13:
128 adds x0, x0, #1
129 adds x0, x0, #1
130 ldr w0, =0x101
131 // CHECK: mov w0, #0x101
132 adds x0, x0, #1
133 adds x0, x0, #1
134 ldr w0, =bar
135 // CHECK: ldr w0, .Ltmp[[TMP11:[0-9]+]]
136 adds x0, x0, #1
137 adds x0, x0, #1
139 // Check for correct usage in other contexts
142 // usage in macro
143 .macro useit_in_a_macro
144 ldr w0, =0x10008
145 ldr w0, =baz
146 .endm
147 .section k,"ax",@progbits
148 // CHECK-LABEL: f14:
149 f14:
150 useit_in_a_macro
151 // CHECK: ldr w0, .Ltmp[[TMP12:[0-9]+]]
152 // CHECK: ldr w0, .Ltmp[[TMP13:[0-9]+]]
154 // usage with expressions
155 .section l, "ax", @progbits
156 // CHECK-LABEL: f15:
157 f15:
158 ldr w0, =0x10001+8
159 // CHECK: ldr w0, .Ltmp[[TMP14:[0-9]+]]
160 adds x0, x0, #1
161 ldr w0, =bar+4
162 // CHECK: ldr w0, .Ltmp[[TMP15:[0-9]+]]
163 adds x0, x0, #1
165 // usage with 64-bit regs
166 .section m, "ax", @progbits
167 // CHECK-LABEL: f16:
168 f16:
169 ldr x0, =0x0102030405060708
170 // CHECK: ldr x0, .Ltmp[[TMP16:[0-9]+]]
171 add x0, x0, #1
172 ldr w0, =bar
173 // CHECK: ldr w0, .Ltmp[[TMP17:[0-9]+]]
174 ldr x0, =bar+16
175 // CHECK: ldr x0, .Ltmp[[TMP18:[0-9]+]]
176 add x0, x0, #1
177 ldr x0, =0x100000001
178 // CHECK: ldr x0, .Ltmp[[TMP19:[0-9]+]]
179 ldr x1, =-0x80000001
180 // CHECK: ldr x1, .Ltmp[[TMP20:[0-9]+]]
181 ldr x2, =0x10001
182 // CHECK: ldr x2, .Ltmp[[TMP21:[0-9]+]]
184 // check range for 32-bit regs
185 .section n, "ax", @progbits
186 // CHECK-LABEL: f17:
187 f17:
188 ldr w0, =0xFFFFFFFF
189 // CHECK: ldr w0, .Ltmp[[TMP22:[0-9]+]]
190 add w0, w0, #1
191 ldr w1, =-0x7FFFFFFF
192 // CHECK: ldr w1, .Ltmp[[TMP23:[0-9]+]]
193 add w0, w0, #1
194 ldr w0, =-1
195 // CHECK: ldr w0, .Ltmp[[TMP24:[0-9]+]]
196 add w0, w0, #1
198 // make sure the same contant uses different pools for 32- and 64-bit registers
199 .section o, "ax", @progbits
200 // CHECK-LABEL: f18:
201 f18:
202 ldr w0, =0x320064
203 // CHECK: ldr w0, .Ltmp[[TMP25:[0-9]+]]
204 add w0, w0, #1
205 ldr x1, =0x320064
206 // CHECK: ldr x1, .Ltmp[[TMP26:[0-9]+]]
208 // We previously used a DenseMap with constant values as keys, check that
209 // sentinel values can be used.
210 ldr x0, =0x7ffffffffffffffe
211 // CHECK: ldr x0, .Ltmp[[TMP27:[0-9]+]]
212 ldr x1, =0x7fffffffffffffff
213 // CHECK: ldr x1, .Ltmp[[TMP28:[0-9]+]]
216 // Constant Pools
218 // CHECK: .section b,"ax",@progbits
219 // CHECK: .p2align 2
220 // CHECK: .Ltmp[[TMP0]]
221 // CHECK: .word 65537
223 // CHECK: .section c,"ax",@progbits
224 // CHECK: .p2align 2
225 // CHECK: .Ltmp[[TMP1]]
226 // CHECK: .word 65538
227 // CHECK: .p2align 2
228 // CHECK: .Ltmp[[TMP2]]
229 // CHECK: .word 65539
231 // CHECK: .section d,"ax",@progbits
232 // CHECK: .p2align 2
233 // CHECK: .Ltmp[[TMP3]]
234 // CHECK: .word 65540
236 // CHECK: .section e,"ax",@progbits
237 // CHECK: .p2align 2
238 // CHECK: .Ltmp[[TMP5]]
239 // CHECK: .word 65542
240 // CHECK: .p2align 2
241 // CHECK: .Ltmp[[TMP6]]
242 // CHECK: .word 65543
244 // Should not switch to section because it has no constant pool
245 // CHECK-NOT: .section f,"ax",@progbits
247 // CHECK: .section g,"ax",@progbits
248 // CHECK: .p2align 2
249 // CHECK: .Ltmp[[TMP7]]
250 // CHECK: .word foo
252 // CHECK: .section h,"ax",@progbits
253 // CHECK: .p2align 2
254 // CHECK: .Ltmp[[TMP8]]
255 // CHECK: .word f5
257 // CHECK: .section i,"ax",@progbits
258 // CHECK: .p2align 2
259 // CHECK: .Ltmp[[TMP9]]
260 // CHECK: .word f12
261 // CHECK: .p2align 2
262 // CHECK: .Ltmp[[TMP10]]
263 // CHECK: .word 245760
265 // CHECK: .section j,"ax",@progbits
266 // CHECK: .p2align 2
267 // CHECK: .Ltmp[[TMP11]]
268 // CHECK: .word bar
270 // CHECK: .section k,"ax",@progbits
271 // CHECK: .p2align 2
272 // CHECK: .Ltmp[[TMP12]]
273 // CHECK: .word 65544
274 // CHECK: .p2align 2
275 // CHECK: .Ltmp[[TMP13]]
276 // CHECK: .word baz
278 // CHECK: .section l,"ax",@progbits
279 // CHECK: .p2align 2
280 // CHECK: .Ltmp[[TMP14]]
281 // CHECK: .word 65545
282 // CHECK: .p2align 2
283 // CHECK: .Ltmp[[TMP15]]
284 // CHECK: .word bar+4
286 // CHECK: .section m,"ax",@progbits
287 // CHECK: .p2align 3
288 // CHECK: .Ltmp[[TMP16]]
289 // CHECK: .xword 72623859790382856
290 // CHECK: .p2align 2
291 // CHECK: .Ltmp[[TMP17]]
292 // CHECK: .word bar
293 // CHECK: .p2align 3
294 // CHECK: .Ltmp[[TMP18]]
295 // CHECK: .xword bar+16
296 // CHECK: .p2align 3
297 // CHECK: .Ltmp[[TMP19]]
298 // CHECK: .xword 4294967297
299 // CHECK: .p2align 3
300 // CHECK: .Ltmp[[TMP20]]
301 // CHECK: .xword -2147483649
302 // CHECK: .p2align 3
303 // CHECK: .Ltmp[[TMP21]]
304 // CHECK: .xword 65537
306 // CHECK: .section n,"ax",@progbits
307 // CHECK: .p2align 2
308 // CHECK: .Ltmp[[TMP22]]
309 // CHECK: .word 4294967295
310 // CHECK: .p2align 2
311 // CHECK: .Ltmp[[TMP23]]
312 // CHECK: .word -2147483647
313 // CHECK: .p2align 2
314 // CHECK: .Ltmp[[TMP24]]
315 // CHECK: .word -1
317 // CHECK: .section o,"ax",@progbits
318 // CHECK: .p2align 2
319 // CHECK: .Ltmp[[TMP25]]
320 // CHECK: .word 3276900
322 // CHECK: .Ltmp[[TMP27]]
323 // CHECK: .xword 9223372036854775806
324 // CHECK: .Ltmp[[TMP28]]
325 // CHECK: .xword 9223372036854775807