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