[Thumb/Thumb2] Added restrictions on PC, LR, SP in the register list for PUSH/POP...
[oota-llvm.git] / test / MC / ARM / thumb-diagnostics.s
1 @ RUN: not llvm-mc -triple=thumbv6-apple-darwin < %s 2> %t
2 @ RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s
3 @ RUN: not llvm-mc -triple=thumbv5-apple-darwin < %s 2> %t
4 @ RUN: FileCheck --check-prefix=CHECK-ERRORS-V5 < %t %s
5 @ RUN: not llvm-mc -triple=thumbv7m < %s 2> %t
6 @ RUN: FileCheck --check-prefix=CHECK-ERRORS-V7M < %t %s
7 @ RUN: not llvm-mc -triple=thumbv8 < %s 2> %t
8 @ RUN: FileCheck --check-prefix=CHECK-ERRORS-V8 < %t %s
9
10 @ Check for various assembly diagnostic messages on invalid input.
11
12 @ ADD instruction w/o 'S' suffix.
13         add r1, r2, r3
14 @ CHECK-ERRORS: error: invalid instruction
15 @ CHECK-ERRORS:         add r1, r2, r3
16 @ CHECK-ERRORS:         ^
17
18 @ Instructions which require v6+ for both registers to be low regs.
19         add r2, r3
20         mov r2, r3
21 @ CHECK-ERRORS: error: instruction variant requires Thumb2
22 @ CHECK-ERRORS:         add r2, r3
23 @ CHECK-ERRORS:         ^
24 @ CHECK-ERRORS-V5: error: instruction variant requires ARMv6 or later
25 @ CHECK-ERRORS-V5:         mov r2, r3
26 @ CHECK-ERRORS-V5:         ^
27
28
29 @ Out of range immediates for ASR instruction.
30         asrs r2, r3, #33
31 @ CHECK-ERRORS: error: invalid operand for instruction
32 @ CHECK-ERRORS:         asrs r2, r3, #33
33 @ CHECK-ERRORS:                      ^
34
35 @ Out of range immediates for BKPT instruction.
36         bkpt #256
37         bkpt #-1
38 error: invalid operand for instruction
39         bkpt #256
40              ^
41 error: invalid operand for instruction
42         bkpt #-1
43              ^
44
45 @ Out of range immediates for v8 HLT instruction.
46         hlt #64
47         hlt #-1
48 @CHECK-ERRORS: error: instruction requires: armv8 arm-mode
49 @CHECK-ERRORS:        hlt #64
50 @CHECK-ERRORS:        ^
51 @CHECK-ERRORS-V8: error: instruction requires: arm-mode
52 @CHECK-ERRORS-V8:         hlt #64
53 @CHECK-ERRORS-V8:              ^
54 @CHECK-ERRORS: error: invalid operand for instruction
55 @CHECK-ERRORS:         hlt #-1
56 @CHECK-ERRORS:              ^
57
58 @ Invalid writeback and register lists for LDM
59         ldm r2!, {r5, r8}
60         ldm r2, {r5, r7}
61         ldm r2!, {r2, r3, r4}
62         ldm r2!, {r2, r3, r4, r10}
63         ldmdb r2!, {r2, r3, r4}
64         ldm r0, {r2, sp}
65         ldmia r0, {r2-r3, sp}
66         ldmia r0!, {r2-r3, sp}
67         ldmfd r2, {r1, r3-r6, sp}
68         ldmfd r2!, {r1, r3-r6, sp}
69         ldmdb r1, {r2, r3, sp}
70         ldmdb r1!, {r2, r3, sp} 
71         ldm r2, {r5, lr, pc}
72 @ CHECK-ERRORS: error: registers must be in range r0-r7
73 @ CHECK-ERRORS:         ldm r2!, {r5, r8}
74 @ CHECK-ERRORS:                  ^
75 @ CHECK-ERRORS: error: writeback operator '!' expected
76 @ CHECK-ERRORS:         ldm r2, {r5, r7}
77 @ CHECK-ERRORS:             ^
78 @ CHECK-ERRORS: error: writeback operator '!' not allowed when base register in register list
79 @ CHECK-ERRORS:         ldm r2!, {r2, r3, r4}
80 @ CHECK-ERRORS:               ^
81 @ CHECK-ERRORS-V8: error: writeback operator '!' not allowed when base register in register list
82 @ CHECK-ERRORS-V8:         ldm r2!, {r2, r3, r4, r10}
83 @ CHECK-ERRORS-V8:               ^
84 @ CHECK-ERRORS-V8: error: writeback register not allowed in register list
85 @ CHECK-ERRORS-V8:         ldmdb r2!, {r2, r3, r4}
86 @ CHECK-ERRORS-V8:                 ^
87 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
88 @ CHECK-ERRORS-V7M:         ldm r0, {r2, sp}
89 @ CHECK-ERRORS-V7M:                 ^
90 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
91 @ CHECK-ERRORS-V7M:         ldmia r0, {r2-r3, sp}
92 @ CHECK-ERRORS-V7M:                   ^
93 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
94 @ CHECK-ERRORS-V7M:         ldmia r0!, {r2-r3, sp}
95 @ CHECK-ERRORS-V7M:                    ^
96 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
97 @ CHECK-ERRORS-V7M:         ldmfd r2, {r1, r3-r6, sp}
98 @ CHECK-ERRORS-V7M:                   ^
99 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
100 @ CHECK-ERRORS-V7M:         ldmfd r2!, {r1, r3-r6, sp}
101 @ CHECK-ERRORS-V7M:                    ^
102 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
103 @ CHECK-ERRORS-V7M:         ldmdb r1, {r2, r3, sp}
104 @ CHECK-ERRORS-V7M:                   ^
105 @ CHECK-ERRORS-V7M: error: SP not allowed in register list
106 @ CHECK-ERRORS-V7M:         ldmdb r1!, {r2, r3, sp}
107 @ CHECK-ERRORS-V7M:                    ^
108 @ CHECK-ERRORS-V7M: error: LR not allowed in the list, when PC is in the register list
109 @ CHECK-ERRORS-V7M:         ldm r2, {r5, lr, pc}
110 @ CHECK-ERRORS-V7M:                 ^
111
112 @ Invalid writeback and register lists for PUSH/POP
113         pop {r1, r2, r10}
114         pop {r1, r2, lr, pc}
115         push {r8, r9}
116         push {r8, r9, sp}
117         push {r8, r9, pc}
118 @ CHECK-ERRORS: error: registers must be in range r0-r7 or pc
119 @ CHECK-ERRORS:         pop {r1, r2, r10}
120 @ CHECK-ERRORS:             ^
121 @ CHECK-ERRORS-V7M: error: LR not allowed in the list, when PC is in the register list
122 @ CHECK-ERRORS-V7M:         pop {r1, r2, lr, pc}
123 @ CHECK-ERRORS-V7M:             ^
124 @ CHECK-ERRORS: error: registers must be in range r0-r7 or lr
125 @ CHECK-ERRORS:         push {r8, r9}
126 @ CHECK-ERRORS:              ^
127 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
128 @ CHECK-ERRORS-V7M:          push {r8, r9, sp}
129 @ CHECK-ERRORS-V7M:               ^
130 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
131 @ CHECK-ERRORS-V7M:          push {r8, r9, pc}
132 @ CHECK-ERRORS-V7M:               ^
133
134
135 @ Invalid writeback and register lists for STM
136         stm r1, {r2, r6}
137         stm r1!, {r2, r9}
138         stm r2!, {r2, r9}
139         stmdb r2!, {r0, r2}
140         stm r1!, {r2, sp}
141         stmia r4!, {r0-r3, sp}
142         stmdb r1, {r2, r3, sp}
143         stmdb r1!, {r2, r3, sp}
144         stmia r4, {r2, sp, pc}
145         stmdb r1!, {r2, r3, pc} 
146 @ CHECK-ERRORS: error: instruction requires: thumb2
147 @ CHECK-ERRORS:         stm r1, {r2, r6}
148 @ CHECK-ERRORS:         ^
149 @ CHECK-ERRORS: error: registers must be in range r0-r7
150 @ CHECK-ERRORS:         stm r1!, {r2, r9}
151 @ CHECK-ERRORS:                  ^
152 @ CHECK-ERRORS-V8: error: writeback operator '!' not allowed when base register in register list
153 @ CHECK-ERRORS-V8:         stm r2!, {r2, r9}
154 @ CHECK-ERRORS-V8:                  ^
155 @ CHECK-ERRORS-V8: error: writeback register not allowed in register list
156 @ CHECK-ERRORS-V8:         stmdb r2!, {r0, r2}
157 @ CHECK-ERRORS-V8:                  ^
158 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
159 @ CHECK-ERRORS-V7M:         stm r1!, {r2, sp}
160 @ CHECK-ERRORS-V7M:                  ^
161 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
162 @ CHECK-ERRORS-V7M:         stmia r4!, {r0-r3, sp}
163 @ CHECK-ERRORS-V7M:                    ^
164 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
165 @ CHECK-ERRORS-V7M:         stmdb r1, {r2, r3, sp}
166 @ CHECK-ERRORS-V7M:                   ^
167 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
168 @ CHECK-ERRORS-V7M:         stmdb r1!, {r2, r3, sp}
169 @ CHECK-ERRORS-V7M:                    ^
170 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
171 @ CHECK-ERRORS-V7M:         stmia r4, {r2, sp, pc}
172 @ CHECK-ERRORS-V7M:                   ^
173 @ CHECK-ERRORS-V7M: error: SP, PC not allowed in register list
174 @ CHECK-ERRORS-V7M:         stmdb r1!, {r2, r3, pc}
175 @ CHECK-ERRORS-V7M:                    ^
176
177 @ Out of range immediates for LSL instruction.
178         lsls r4, r5, #-1
179         lsls r4, r5, #32
180 @ CHECK-ERRORS: error: invalid operand for instruction
181 @ CHECK-ERRORS:         lsls r4, r5, #-1
182 @ CHECK-ERRORS:                      ^
183 @ CHECK-ERRORS: error: invalid operand for instruction
184 @ CHECK-ERRORS:         lsls r4, r5, #32
185 @ CHECK-ERRORS:                      ^
186
187 @ Mismatched source/destination operands for MUL instruction.
188         muls r1, r2, r3
189 @ CHECK-ERRORS: error: destination register must match source register
190 @ CHECK-ERRORS:         muls r1, r2, r3
191 @ CHECK-ERRORS:              ^
192
193
194 @ Out of range immediates for STR instruction.
195         str r2, [r7, #-1]
196         str r5, [r1, #3]
197         str r3, [r7, #128]
198 @ CHECK-ERRORS: error: instruction requires: thumb2
199 @ CHECK-ERRORS:         str r2, [r7, #-1]
200 @ CHECK-ERRORS:         ^
201 @ CHECK-ERRORS: error: instruction requires: thumb2
202 @ CHECK-ERRORS:         str r5, [r1, #3]
203 @ CHECK-ERRORS:         ^
204 @ CHECK-ERRORS: error: instruction requires: thumb2
205 @ CHECK-ERRORS:         str r3, [r7, #128]
206 @ CHECK-ERRORS:         ^
207
208 @ Out of range immediate for SVC instruction.
209         svc #-1
210         svc #256
211 @ CHECK-ERRORS: error: invalid operand for instruction
212 @ CHECK-ERRORS:         svc #-1
213 @ CHECK-ERRORS:             ^
214 @ CHECK-ERRORS: error: instruction requires: arm-mode
215 @ CHECK-ERRORS:         svc #256
216 @ CHECK-ERRORS:         ^
217
218
219 @ Out of range immediate for ADD SP instructions
220         add sp, #-1
221         add sp, #3
222         add sp, sp, #512
223         add r2, sp, #1024
224 @ CHECK-ERRORS: error: instruction requires: thumb2
225 @ CHECK-ERRORS:         add sp, #-1
226 @ CHECK-ERRORS:                 ^
227 @ CHECK-ERRORS: error: instruction requires: thumb2
228 @ CHECK-ERRORS:         add sp, #3
229 @ CHECK-ERRORS:                 ^
230 @ CHECK-ERRORS: error: instruction requires: thumb2
231 @ CHECK-ERRORS:         add sp, sp, #512
232 @ CHECK-ERRORS:                     ^
233 @ CHECK-ERRORS: error: instruction requires: thumb2
234 @ CHECK-ERRORS:         add r2, sp, #1024
235 @ CHECK-ERRORS:         ^
236
237         add r2, sp, ip
238 @ CHECK-ERRORS: error: source register must be the same as destination
239 @ CHECK-ERRORS:         add r2, sp, ip
240 @ CHECK-ERRORS:                     ^
241
242
243 @------------------------------------------------------------------------------
244 @ B/Bcc - out of range immediates for Thumb1 branches
245 @------------------------------------------------------------------------------
246
247         beq    #-258
248         bne    #256
249         bgt    #13
250         b      #-1048578
251         b      #1048576
252         b      #10323
253
254 @ CHECK-ERRORS: error: branch target out of range
255 @ CHECK-ERRORS: error: branch target out of range
256 @ CHECK-ERRORS: error: branch target out of range
257 @ CHECK-ERRORS: error: branch target out of range
258 @ CHECK-ERRORS: error: branch target out of range
259 @ CHECK-ERRORS: error: branch target out of range
260
261 @------------------------------------------------------------------------------
262 @ WFE/WFI/YIELD - are not supported pre v6T2
263 @------------------------------------------------------------------------------
264         wfe
265         wfi
266         yield
267
268 @ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2
269 @ CHECK-ERRORS: wfe
270 @ CHECK-ERRORS: ^
271 @ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2
272 @ CHECK-ERRORS: wfi
273 @ CHECK-ERRORS: ^
274 @ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2
275 @ CHECK-ERRORS: yield
276 @ CHECK-ERRORS: ^
277
278 @------------------------------------------------------------------------------
279 @ PLDW required mp-extensions
280 @------------------------------------------------------------------------------
281         pldw [r0, #4]
282 @ CHECK-ERRORS: error: instruction requires: mp-extensions
283
284 @------------------------------------------------------------------------------
285 @ LDR(lit) - invalid offsets
286 @------------------------------------------------------------------------------
287
288         ldr r4, [pc, #-12]
289 @ CHECK-ERRORS: error: instruction requires: thumb2
290
291 @------------------------------------------------------------------------------
292 @ STC2{L}/LDC2{L} - requires thumb2
293 @------------------------------------------------------------------------------
294         stc2 p0, c8, [r1, #4]
295         stc2l p6, c2, [r7, #4]
296         ldc2 p0, c8, [r1, #4]
297         ldc2l p6, c2, [r7, #4]
298 @ CHECK-ERRORS: error: invalid operand for instruction
299 @ CHECK-ERRORS: error: invalid operand for instruction
300 @ CHECK-ERRORS: error: invalid operand for instruction
301 @ CHECK-ERRORS: error: invalid operand for instruction