ARM: fix more cases where predication may or may not be allowed
[oota-llvm.git] / test / MC / ARM / diagnostics.s
1 @ RUN: not llvm-mc -triple=armv7-apple-darwin < %s 2> %t
2 @ RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s
3
4 @ Check for various assembly diagnostic messages on invalid input.
5
6 @ 's' bit on an instruction that can't accept it.
7         mlss r1, r2, r3, r4
8 @ CHECK-ERRORS: error: instruction 'mls' can not set flags,
9 @ CHECK-ERRORS: but 's' suffix specified
10
11
12         @ Out of range shift immediate values.
13         adc r1, r2, r3, lsl #invalid
14         adc r4, r5, r6, lsl #-1
15         adc r4, r5, r6, lsl #32
16         adc r4, r5, r6, lsr #-1
17         adc r4, r5, r6, lsr #33
18         adc r4, r5, r6, asr #-1
19         adc r4, r5, r6, asr #33
20         adc r4, r5, r6, ror #-1
21         adc r4, r5, r6, ror #32
22
23 @ CHECK-ERRORS: error: invalid immediate shift value
24 @ CHECK-ERRORS:         adc r1, r2, r3, lsl #invalid
25 @ CHECK-ERRORS:                              ^
26 @ CHECK-ERRORS: error: immediate shift value out of range
27 @ CHECK-ERRORS:         adc r4, r5, r6, lsl #-1
28 @ CHECK-ERRORS:                              ^
29 @ CHECK-ERRORS: error: immediate shift value out of range
30 @ CHECK-ERRORS:         adc r4, r5, r6, lsl #32
31 @ CHECK-ERRORS:                              ^
32 @ CHECK-ERRORS: error: immediate shift value out of range
33 @ CHECK-ERRORS:         adc r4, r5, r6, lsr #-1
34 @ CHECK-ERRORS:                              ^
35 @ CHECK-ERRORS: error: immediate shift value out of range
36 @ CHECK-ERRORS:         adc r4, r5, r6, lsr #33
37 @ CHECK-ERRORS:                              ^
38 @ CHECK-ERRORS: error: immediate shift value out of range
39 @ CHECK-ERRORS:         adc r4, r5, r6, asr #-1
40 @ CHECK-ERRORS:                              ^
41 @ CHECK-ERRORS: error: immediate shift value out of range
42 @ CHECK-ERRORS:         adc r4, r5, r6, asr #33
43 @ CHECK-ERRORS:                              ^
44 @ CHECK-ERRORS: error: immediate shift value out of range
45 @ CHECK-ERRORS:         adc r4, r5, r6, ror #-1
46 @ CHECK-ERRORS:                              ^
47 @ CHECK-ERRORS: error: immediate shift value out of range
48 @ CHECK-ERRORS:         adc r4, r5, r6, ror #32
49
50         @ Out of range shift immediate values for load/store.
51         str r1, [r2, r3, lsl #invalid]
52         ldr r4, [r5], r6, lsl #-1
53         pld r4, [r5, r6, lsl #32]
54         str r4, [r5], r6, lsr #-1
55         ldr r4, [r5, r6, lsr #33]
56         pld r4, [r5, r6, asr #-1]
57         str r4, [r5, r6, asr #33]
58         ldr r4, [r5, r6, ror #-1]
59         pld r4, [r5, r6, ror #32]
60         pld r4, [r5, r6, rrx #0]
61
62 @ CHECK-ERRORS: error: shift amount must be an immediate
63 @ CHECK-ERRORS:         str r1, [r2, r3, lsl #invalid]
64 @ CHECK-ERRORS:                              ^
65 @ CHECK-ERRORS: error: immediate shift value out of range
66 @ CHECK-ERRORS:         ldr r4, [r5], r6, lsl #-1
67 @ CHECK-ERRORS:                              ^
68 @ CHECK-ERRORS: error: immediate shift value out of range
69 @ CHECK-ERRORS:         pld r4, [r5, r6, lsl #32]
70 @ CHECK-ERRORS:                              ^
71 @ CHECK-ERRORS: error: immediate shift value out of range
72 @ CHECK-ERRORS:         str r4, [r5], r6, lsr #-1
73 @ CHECK-ERRORS:                              ^
74 @ CHECK-ERRORS: error: immediate shift value out of range
75 @ CHECK-ERRORS:         ldr r4, [r5, r6, lsr #33]
76 @ CHECK-ERRORS:                              ^
77 @ CHECK-ERRORS: error: immediate shift value out of range
78 @ CHECK-ERRORS:         pld r4, [r5, r6, asr #-1]
79 @ CHECK-ERRORS:                              ^
80 @ CHECK-ERRORS: error: immediate shift value out of range
81 @ CHECK-ERRORS:         str r4, [r5, r6, asr #33]
82 @ CHECK-ERRORS:                              ^
83 @ CHECK-ERRORS: error: immediate shift value out of range
84 @ CHECK-ERRORS:         ldr r4, [r5, r6, ror #-1]
85 @ CHECK-ERRORS:                              ^
86 @ CHECK-ERRORS: error: immediate shift value out of range
87 @ CHECK-ERRORS:         pld r4, [r5, r6, ror #32]
88 @ CHECK-ERRORS: error: ']' expected
89 @ CHECK-ERRORS:         pld r4, [r5, r6, rrx #0]
90         
91         @ Out of range 16-bit immediate on BKPT
92         bkpt #65536
93
94 @ CHECK-ERRORS: error: invalid operand for instruction
95
96         @ Out of range 4 and 3 bit immediates on CDP[2]
97
98         @ Out of range immediates for CDP/CDP2
99         cdp  p7, #2, c1, c1, c1, #8
100         cdp  p7, #1, c1, c1, c1, #8
101         cdp2  p7, #2, c1, c1, c1, #8
102         cdp2  p7, #1, c1, c1, c1, #8
103
104 @ CHECK-ERRORS: error: invalid operand for instruction
105 @ CHECK-ERRORS: error: invalid operand for instruction
106 @ CHECK-ERRORS: error: invalid operand for instruction
107 @ CHECK-ERRORS: error: invalid operand for instruction
108
109         @ Out of range immediates for DBG
110         dbg #-1
111         dbg #16
112
113 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
114 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
115 @  Double-check that we're synced up with the right diagnostics.
116 @ CHECK-ERRORS: dbg #16
117
118         @ Out of range immediate for MCR/MCR2/MCRR/MCRR2
119         mcr  p7, #8, r5, c1, c1, #4
120         mcr  p7, #2, r5, c1, c1, #8
121         mcr2  p7, #8, r5, c1, c1, #4
122         mcr2  p7, #1, r5, c1, c1, #8
123         mcrr  p7, #16, r5, r4, c1
124         mcrr2  p7, #16, r5, r4, c1
125 @ CHECK-ERRORS: error: invalid operand for instruction
126 @ CHECK-ERRORS: error: invalid operand for instruction
127 @ CHECK-ERRORS: error: invalid operand for instruction
128 @ CHECK-ERRORS: error: invalid operand for instruction
129 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
130 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
131
132
133         @ Out of range immediate for MOV
134         movw r9, 0x10000
135 @ CHECK-ERRORS: error: invalid operand for instruction
136
137         @ Invalid 's' bit usage for MOVW
138         movs r6, #0xffff
139         movwseq r9, #0xffff
140 @ CHECK-ERRORS: error: invalid operand for instruction
141 @ CHECK-ERRORS: error: instruction 'movw' can not set flags, but 's' suffix specified
142
143         @ Out of range immediate for MOVT
144         movt r9, 0x10000
145 @ CHECK-ERRORS: error: invalid operand for instruction
146
147         @ Out of range immediates for MRC/MRC2/MRRC/MRRC2
148         mrc  p14, #8, r1, c1, c2, #4
149         mrc  p14, #1, r1, c1, c2, #8
150         mrc2  p14, #8, r1, c1, c2, #4
151         mrc2  p14, #0, r1, c1, c2, #9
152         mrrc  p7, #16, r5, r4, c1
153         mrrc2  p7, #17, r5, r4, c1
154 @ CHECK-ERRORS: error: invalid operand for instruction
155 @ CHECK-ERRORS: error: invalid operand for instruction
156 @ CHECK-ERRORS: error: invalid operand for instruction
157 @ CHECK-ERRORS: error: invalid operand for instruction
158 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
159 @ CHECK-ERRORS: error: immediate operand must be in the range [0,15]
160
161         @ Shifter operand validation for PKH instructions.
162         pkhbt r2, r2, r3, lsl #-1
163         pkhbt r2, r2, r3, lsl #32
164         pkhtb r2, r2, r3, asr #0
165         pkhtb r2, r2, r3, asr #33
166         pkhbt r2, r2, r3, asr #3
167         pkhtb r2, r2, r3, lsl #3
168
169 @ CHECK-ERRORS: error: immediate value out of range
170 @ CHECK-ERRORS:         pkhbt r2, r2, r3, lsl #-1
171 @ CHECK-ERRORS:                                ^
172 @ CHECK-ERRORS: error: immediate value out of range
173 @ CHECK-ERRORS:         pkhbt r2, r2, r3, lsl #32
174 @ CHECK-ERRORS:                                ^
175 @ CHECK-ERRORS: error: immediate value out of range
176 @ CHECK-ERRORS:         pkhtb r2, r2, r3, asr #0
177 @ CHECK-ERRORS:                                ^
178 @ CHECK-ERRORS: error: immediate value out of range
179 @ CHECK-ERRORS:         pkhtb r2, r2, r3, asr #33
180 @ CHECK-ERRORS:                                ^
181 @ CHECK-ERRORS: error: lsl operand expected.
182 @ CHECK-ERRORS:         pkhbt r2, r2, r3, asr #3
183 @ CHECK-ERRORS:                           ^
184 @ CHECK-ERRORS: error: asr operand expected.
185 @ CHECK-ERRORS:         pkhtb r2, r2, r3, lsl #3
186 @ CHECK-ERRORS:                           ^
187
188
189         @ bad values for SETEND
190         setendne be
191         setend me
192         setend 1
193
194 @ CHECK-ERRORS: error: instruction 'setend' is not predicable, but condition code specified
195 @ CHECK-ERRORS:         setendne be
196 @ CHECK-ERRORS:         ^
197 @ CHECK-ERRORS: error: 'be' or 'le' operand expected
198 @ CHECK-ERRORS:         setend me
199 @ CHECK-ERRORS:                  ^
200 @ CHECK-ERRORS: error: 'be' or 'le' operand expected
201 @ CHECK-ERRORS:         setend 1
202 @ CHECK-ERRORS:                ^
203
204
205         @ Out of range immediates and bad shift types for SSAT
206         ssat    r8, #0, r10, lsl #8
207         ssat    r8, #33, r10, lsl #8
208         ssat    r8, #1, r10, lsl #-1
209         ssat    r8, #1, r10, lsl #32
210         ssat    r8, #1, r10, asr #0
211         ssat    r8, #1, r10, asr #33
212         ssat    r8, #1, r10, lsr #5
213         ssat    r8, #1, r10, lsl fred
214         ssat    r8, #1, r10, lsl #fred
215
216 @ CHECK-ERRORS: error: invalid operand for instruction
217 @ CHECK-ERRORS:         ssat    r8, #0, r10, lsl #8
218 @ CHECK-ERRORS:                     ^
219 @ CHECK-ERRORS: error: invalid operand for instruction
220 @ CHECK-ERRORS:         ssat    r8, #33, r10, lsl #8
221 @ CHECK-ERRORS:                     ^
222 @ CHECK-ERRORS: error: 'lsr' shift amount must be in range [0,31]
223 @ CHECK-ERRORS:         ssat    r8, #1, r10, lsl #-1
224 @ CHECK-ERRORS:                                   ^
225 @ CHECK-ERRORS: error: 'lsr' shift amount must be in range [0,31]
226 @ CHECK-ERRORS:         ssat    r8, #1, r10, lsl #32
227 @ CHECK-ERRORS:                                   ^
228 @ CHECK-ERRORS: error: 'asr' shift amount must be in range [1,32]
229 @ CHECK-ERRORS:         ssat    r8, #1, r10, asr #0
230 @ CHECK-ERRORS:                                   ^
231 @ CHECK-ERRORS: error: 'asr' shift amount must be in range [1,32]
232 @ CHECK-ERRORS:         ssat    r8, #1, r10, asr #33
233 @ CHECK-ERRORS:                                   ^
234 @ CHECK-ERRORS: error: shift operator 'asr' or 'lsl' expected
235 @ CHECK-ERRORS:         ssat    r8, #1, r10, lsr #5
236 @ CHECK-ERRORS:                              ^
237 @ CHECK-ERRORS: error: '#' expected
238 @ CHECK-ERRORS:         ssat    r8, #1, r10, lsl fred
239 @ CHECK-ERRORS:                                  ^
240 @ CHECK-ERRORS: error: shift amount must be an immediate
241 @ CHECK-ERRORS:         ssat    r8, #1, r10, lsl #fred
242 @ CHECK-ERRORS:                                   ^
243
244         @ Out of range immediates for SSAT16
245         ssat16  r2, #0, r7
246         ssat16  r3, #17, r5
247
248 @ CHECK-ERRORS: error: invalid operand for instruction
249 @ CHECK-ERRORS:         ssat16  r2, #0, r7
250 @ CHECK-ERRORS:                     ^
251 @ CHECK-ERRORS: error: invalid operand for instruction
252 @ CHECK-ERRORS:         ssat16  r3, #17, r5
253 @ CHECK-ERRORS:                     ^
254
255
256         @ Out of order STM registers
257         stmda sp!, {r5, r2}
258
259 @ CHECK-ERRORS: warning: register list not in ascending order
260 @ CHECK-ERRORS:         stmda     sp!, {r5, r2}
261 @ CHECK-ERRORS:                            ^
262
263
264         @ Out of range immediate on SVC
265         svc #0x1000000
266 @ CHECK-ERRORS: error: invalid operand for instruction
267 @ CHECK-ERRORS:   svc #0x1000000
268 @ CHECK-ERRORS:       ^
269
270
271         @ Out of order Rt/Rt2 operands for ldrexd/strexd
272         ldrexd  r4, r3, [r8]
273         strexd  r6, r5, r3, [r8]
274
275 @ CHECK-ERRORS: error: destination operands must be sequential
276 @ CHECK-ERRORS:         ldrexd  r4, r3, [r8]
277 @ CHECK-ERRORS:                     ^
278 @ CHECK-ERRORS: error: source operands must be sequential
279 @ CHECK-ERRORS:         strexd  r6, r5, r3, [r8]
280 @ CHECK-ERRORS:                         ^
281
282         @ Illegal rotate operators for extend instructions
283         sxtb r8, r3, #8
284         sxtb r8, r3, ror 24
285         sxtb r8, r3, ror #8 -
286         sxtab r3, r8, r3, ror #(fred - wilma)
287         sxtab r7, r8, r3, ror #25
288         sxtah r9, r3, r3, ror #-8
289         sxtb16ge r2, r3, lsr #24
290
291 @ CHECK-ERRORS: error: invalid operand for instruction
292 @ CHECK-ERRORS:         sxtb r8, r3, #8
293 @ CHECK-ERRORS:                      ^
294 @ CHECK-ERRORS: error: '#' expected
295 @ CHECK-ERRORS:         sxtb r8, r3, ror 24
296 @ CHECK-ERRORS:                          ^
297 @ CHECK-ERRORS: error: unknown token in expression
298 @ CHECK-ERRORS:         sxtb r8, r3, ror #8 -
299 @ CHECK-ERRORS:                              ^
300 @ CHECK-ERRORS: error: malformed rotate expression
301 @ CHECK-ERRORS:         sxtb r8, r3, ror #8 -
302 @ CHECK-ERRORS:                           ^
303 @ CHECK-ERRORS: error: rotate amount must be an immediate
304 @ CHECK-ERRORS:         sxtab r3, r8, r3, ror #(fred - wilma)
305 @ CHECK-ERRORS:                                ^
306 @ CHECK-ERRORS: error: 'ror' rotate amount must be 8, 16, or 24
307 @ CHECK-ERRORS:         sxtab r7, r8, r3, ror #25
308 @ CHECK-ERRORS:                                ^
309 @ CHECK-ERRORS: error: 'ror' rotate amount must be 8, 16, or 24
310 @ CHECK-ERRORS:         sxtah r9, r3, r3, ror #-8
311 @ CHECK-ERRORS:                                ^
312 @ CHECK-ERRORS: error: invalid operand for instruction
313 @ CHECK-ERRORS:         sxtb16ge r2, r3, lsr #24
314 @ CHECK-ERRORS:                          ^
315
316         @ Out of range width for SBFX/UBFX
317         sbfx r4, r5, #31, #2
318         ubfxgt r4, r5, #16, #17
319
320 @ CHECK-ERRORS: error: bitfield width must be in range [1,32-lsb]
321 @ CHECK-ERRORS:         sbfx r4, r5, #31, #2
322 @ CHECK-ERRORS:                           ^
323 @ CHECK-ERRORS: error: bitfield width must be in range [1,32-lsb]
324 @ CHECK-ERRORS:         ubfxgt r4, r5, #16, #17
325 @ CHECK-ERRORS:                             ^
326
327         @ Out of order Rt/Rt2 operands for ldrd
328         ldrd  r4, r3, [r8]
329         ldrd  r4, r3, [r8, #8]!
330         ldrd  r4, r3, [r8], #8
331 @ CHECK-ERRORS: error: destination operands must be sequential
332 @ CHECK-ERRORS:         ldrd  r4, r3, [r8]
333 @ CHECK-ERRORS:                   ^
334 @ CHECK-ERRORS: error: destination operands must be sequential
335 @ CHECK-ERRORS:         ldrd  r4, r3, [r8, #8]!
336 @ CHECK-ERRORS:                   ^
337 @ CHECK-ERRORS: error: destination operands must be sequential
338 @ CHECK-ERRORS:         ldrd  r4, r3, [r8], #8
339 @ CHECK-ERRORS:                   ^
340
341
342         @ Bad register lists for VFP.
343         vpush {s0, s3}
344 @ CHECK-ERRORS: error: non-contiguous register range
345 @ CHECK-ERRORS:         vpush {s0, s3}
346 @ CHECK-ERRORS:                    ^
347
348         @ Out of range coprocessor option immediate.
349         ldc2 p2, c8, [r1], { 256 }
350         ldc2 p2, c8, [r1], { -1 }
351
352 @ CHECK-ERRORS: error: coprocessor option must be an immediate in range [0, 255]
353 @ CHECK-ERRORS:         ldc2 p2, c8, [r1], { 256 }
354 @ CHECK-ERRORS:                              ^
355 @ CHECK-ERRORS: error: coprocessor option must be an immediate in range [0, 255]
356 @ CHECK-ERRORS:         ldc2 p2, c8, [r1], { -1 }
357 @ CHECK-ERRORS:                              ^
358
359         @ Bad CPS instruction format.
360         cps f,#1
361 @ CHECK-ERRORS: error: invalid operand for instruction
362 @ CHECK-ERRORS:         cps f,#1
363 @ CHECK-ERRORS:               ^
364
365         @ Bad operands for msr
366         msr #0, #0
367         msr foo, #0
368 @ CHECK-ERRORS: error: invalid operand for instruction
369 @ CHECK-ERRORS:         msr #0, #0
370 @ CHECK-ERRORS:             ^
371 @ CHECK-ERRORS: error: invalid operand for instruction
372 @ CHECK-ERRORS:         msr foo, #0
373 @ CHECK-ERRORS:             ^
374
375         isb #-1
376         isb #16
377 @ CHECK-ERRORS: error: immediate value out of range
378 @ CHECK-ERRORS: error: immediate value out of range
379
380         nop.n
381 @ CHECK-ERRORS: error: instruction with .n (narrow) qualifier not allowed in arm mode
382
383         dmbeq #5
384         dsble #15
385         isblo #7
386 @ CHECK-ERRORS: error: instruction 'dmb' is not predicable, but condition code specified
387 @ CHECK-ERRORS: error: instruction 'dsb' is not predicable, but condition code specified
388 @ CHECK-ERRORS: error: instruction 'isb' is not predicable, but condition code specified
389
390         dmblt
391         dsbne
392         isbeq
393 @ CHECK-ERRORS: error: instruction 'dmb' is not predicable, but condition code specified
394 @ CHECK-ERRORS: error: instruction 'dsb' is not predicable, but condition code specified
395 @ CHECK-ERRORS: error: instruction 'isb' is not predicable, but condition code specified
396
397         mcr2le  p7, #1, r5, c1, c1, #4
398         mcrr2ne p7, #15, r5, r4, c1
399         mrc2lo  p14, #0, r1, c1, c2, #4
400         mrrc2lo  p7, #1, r5, r4, c1
401         cdp2hi   p10, #0, c6, c12, c0, #7
402 @ CHECK-ERRORS: error: instruction 'mcr2' is not predicable, but condition code specified
403 @ CHECK-ERRORS: error: instruction 'mcrr2' is not predicable, but condition code specified
404 @ CHECK-ERRORS: error: instruction 'mrc2' is not predicable, but condition code specified
405 @ CHECK-ERRORS: error: instruction 'mrrc2' is not predicable, but condition code specified
406 @ CHECK-ERRORS: error: instruction 'cdp2' is not predicable, but condition code specified
407
408         bkpteq #7
409 @ CHECK-ERRORS: error: instruction 'bkpt' is not predicable, but condition code specified