ARM64: Improve diagnostics for malformed reg+reg addressing mode.
[oota-llvm.git] / test / MC / ARM64 / diags.s
1 ; RUN: not llvm-mc -triple arm64-apple-darwin -show-encoding < %s 2> %t | FileCheck %s
2 ; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s
3
4 foo:
5
6 ; The first should encode as an expression. The second should error expecting
7 ; a register.
8   ldr x3, (foo + 4)
9   ldr x3, [foo + 4]
10 ; CHECK:  ldr x3, foo+4               ; encoding: [0bAAA00011,A,A,0x58]
11 ; CHECK:                              ;   fixup A - offset: 0, value: foo+4, kind: fixup_arm64_pcrel_imm19
12 ; CHECK-ERRORS: error: register expected
13
14 ; The last argument should be flagged as an error.  rdar://9576009
15   ld4.8b        {v0, v1, v2, v3}, [x0], #33
16 ; CHECK-ERRORS: error: invalid operand for instruction
17 ; CHECK-ERRORS: ld4.8b  {v0, v1, v2, v3}, [x0], #33
18
19
20         ldr x0, [x0, #804]
21         ldr w0, [x0, #802]
22         ldr x0, [x0, #804]!
23         ldr w0, [w0, #301]!
24         ldr x0, [x0], #804
25         ldr w0, [w0], #301
26
27         ldp w3, w4, [x5, #11]!
28         ldp x3, x4, [x5, #12]!
29         ldp q3, q4, [x5, #12]!
30         ldp w3, w4, [x5], #11
31         ldp x3, x4, [x5], #12
32         ldp q3, q4, [x5], #12
33
34         ldur x0, [x1, #-257]
35
36 ; CHECK-ERRORS: error: index must be a multiple of 8 in range [0,32760].
37 ; CHECK-ERRORS:         ldr x0, [x0, #804]
38 ; CHECK-ERRORS:                 ^
39 ; CHECK-ERRORS: error: index must be a multiple of 4 in range [0,16380].
40 ; CHECK-ERRORS:         ldr w0, [x0, #802]
41 ; CHECK-ERRORS:                 ^
42 ; CHECK-ERRORS: error: index must be an integer in range [-256,255].
43 ; CHECK-ERRORS:         ldr x0, [x0, #804]!
44 ; CHECK-ERRORS:                 ^
45 ; CHECK-ERRORS: error: index must be an integer in range [-256,255].
46 ; CHECK-ERRORS:         ldr w0, [w0, #301]!
47 ; CHECK-ERRORS:                 ^
48 ; CHECK-ERRORS: error: index must be an integer in range [-256,255].
49 ; CHECK-ERRORS:         ldr x0, [x0], #804
50 ; CHECK-ERRORS:                       ^
51 ; CHECK-ERRORS: error: index must be an integer in range [-256,255].
52 ; CHECK-ERRORS:         ldr w0, [w0], #301
53 ; CHECK-ERRORS:                       ^
54 ; CHECK-ERRORS: error: index must be a multiple of 4 in range [-256,252].
55 ; CHECK-ERRORS:         ldp w3, w4, [x5, #11]!
56 ; CHECK-ERRORS:                     ^
57 ; CHECK-ERRORS: error: index must be a multiple of 8 in range [-512,504].
58 ; CHECK-ERRORS:         ldp x3, x4, [x5, #12]!
59 ; CHECK-ERRORS:                     ^
60 ; CHECK-ERRORS: error: index must be a multiple of 16 in range [-1024,1008].
61 ; CHECK-ERRORS:         ldp q3, q4, [x5, #12]!
62 ; CHECK-ERRORS:                     ^
63 ; CHECK-ERRORS: error: index must be a multiple of 4 in range [-256,252].
64 ; CHECK-ERRORS:         ldp w3, w4, [x5], #11
65 ; CHECK-ERRORS:                           ^
66 ; CHECK-ERRORS: error: index must be a multiple of 8 in range [-512,504].
67 ; CHECK-ERRORS:         ldp x3, x4, [x5], #12
68 ; CHECK-ERRORS:                           ^
69 ; CHECK-ERRORS: error: index must be a multiple of 8 in range [-512,504].
70 ; CHECK-ERRORS:         ldp q3, q4, [x5], #12
71 ; CHECK-ERRORS:                           ^
72 ; CHECK-ERRORS: error: index must be an integer in range [-256,255].
73 ; CHECK-ERRORS:         ldur x0, [x1, #-257]
74 ; CHECK-ERRORS:                   ^
75
76
77 ; Check that register offset addressing modes only accept 32-bit offset
78 ; registers when using uxtw/sxtw extends. Everything else requires a 64-bit
79 ; register.
80   str    d1, [x3, w3, sxtx #3]
81   ldr    s1, [x3, d3, sxtx #2]
82
83 ; CHECK-ERRORS: 32-bit general purpose offset register requires sxtw or uxtw extend
84 ; CHECK-ERRORS:   str    d1, [x3, w3, sxtx #3]
85 ; CHECK-ERRORS:                       ^
86 ; CHECK-ERRORS: error: 64-bit general purpose offset register expected
87 ; CHECK-ERRORS:   ldr    s1, [x3, d3, sxtx #2]
88 ; CHECK-ERRORS:                   ^
89
90 ; Shift immediates range checking.
91   sqrshrn b4, h9, #10
92   rshrn v9.8b, v11.8h, #17
93   sqrshrn v7.4h, v8.4s, #39
94   uqshrn2 v4.4s, v5.2d, #67
95
96 ; CHECK-ERRORS: error: immediate must be an integer in range [1,8].
97 ; CHECK-ERRORS:   sqrshrn b4, h9, #10
98 ; CHECK-ERRORS:                   ^
99 ; CHECK-ERRORS: error: immediate must be an integer in range [1,8].
100 ; CHECK-ERRORS:   rshrn v9.8b, v11.8h, #17
101 ; CHECK-ERRORS:                        ^
102 ; CHECK-ERRORS: error: immediate must be an integer in range [1,16].
103 ; CHECK-ERRORS:   sqrshrn v7.4h, v8.4s, #39
104 ; CHECK-ERRORS:                         ^
105 ; CHECK-ERRORS: error: immediate must be an integer in range [1,32].
106 ; CHECK-ERRORS:   uqshrn2 v4.4s, v5.2d, #67
107 ; CHECK-ERRORS:                         ^
108
109
110   st1.s4 {v14, v15}, [x2], #32
111 ; CHECK-ERRORS: error: invalid type suffix for instruction
112 ; CHECK-ERRORS: st1.s4 {v14, v15}, [x2], #32
113 ; CHECK-ERRORS:     ^
114
115
116
117 ; Load pair instructions where Rt==Rt2 and writeback load/store instructions
118 ; where Rt==Rn or Rt2==Rn are unpredicatable.
119   ldp x1, x2, [x2], #16
120   ldp x2, x2, [x2], #16
121   ldp w1, w2, [x2], #16
122   ldp w2, w2, [x2], #16
123   ldp x1, x1, [x2]
124
125   ldr x2, [x2], #8
126   ldr x2, [x2, #8]!
127   ldr w2, [x2], #8
128   ldr w2, [x2, #8]!
129
130   str x2, [x2], #8
131   str x2, [x2, #8]!
132   str w2, [x2], #8
133   str w2, [x2, #8]!
134
135 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
136 ; CHECK-ERRORS:   ldp x1, x2, [x2], #16
137 ; CHECK-ERRORS:           ^
138 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
139 ; CHECK-ERRORS:   ldp x2, x2, [x2], #16
140 ; CHECK-ERRORS:       ^
141 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
142 ; CHECK-ERRORS:   ldp w1, w2, [x2], #16
143 ; CHECK-ERRORS:           ^
144 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
145 ; CHECK-ERRORS:   ldp w2, w2, [x2], #16
146 ; CHECK-ERRORS:       ^
147 ; CHECK-ERRORS: error: unpredictable LDP instruction, Rt2==Rt
148 ; CHECK-ERRORS:   ldp x1, x1, [x2]
149 ; CHECK-ERRORS:           ^
150 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
151 ; CHECK-ERRORS:   ldr x2, [x2], #8
152 ; CHECK-ERRORS:       ^
153 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
154 ; CHECK-ERRORS:   ldr x2, [x2, #8]!
155 ; CHECK-ERRORS:       ^
156 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
157 ; CHECK-ERRORS:   ldr w2, [x2], #8
158 ; CHECK-ERRORS:       ^
159 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
160 ; CHECK-ERRORS:   ldr w2, [x2, #8]!
161 ; CHECK-ERRORS:       ^
162 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
163 ; CHECK-ERRORS:   str x2, [x2], #8
164 ; CHECK-ERRORS:       ^
165 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
166 ; CHECK-ERRORS:   str x2, [x2, #8]!
167 ; CHECK-ERRORS:       ^
168 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
169 ; CHECK-ERRORS:   str w2, [x2], #8
170 ; CHECK-ERRORS:       ^
171 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
172 ; CHECK-ERRORS:   str w2, [x2, #8]!
173 ; CHECK-ERRORS:       ^
174
175 ; The validity checking for shifted-immediate operands.  rdar://13174476
176 ; Where the immediate is out of range.
177   add w1, w2, w3, lsr #75
178
179 ; CHECK-ERRORS: error: immediate value too large for shifter operand
180 ; CHECK-ERRORS: add w1, w2, w3, lsr #75
181 ; CHECK-ERRORS:                      ^
182
183 ; logical instructions on 32-bit regs with shift > 31 is not legal
184 orr w0, w0, w0, lsl #32
185 ; CHECK-ERRORS: error: shift value out of range
186 ; CHECK-ERRORS:        orr w0, w0, w0, lsl #32
187 ; CHECK-ERRORS:                        ^
188 eor w0, w0, w0, lsl #32
189 ; CHECK-ERRORS: error: shift value out of range
190 ; CHECK-ERRORS:        eor w0, w0, w0, lsl #32
191 ; CHECK-ERRORS:                        ^
192 and w0, w0, w0, lsl #32
193 ; CHECK-ERRORS: error: shift value out of range
194 ; CHECK-ERRORS:        and w0, w0, w0, lsl #32
195 ; CHECK-ERRORS:                        ^
196 ands w0, w0, w0, lsl #32
197 ; CHECK-ERRORS: error: shift value out of range
198 ; CHECK-ERRORS:        ands w0, w0, w0, lsl #32
199 ; CHECK-ERRORS:                        ^
200
201 ; Relocated expressions should not be accepted for 32-bit adds or sub (imm)
202 add w3, w5, sym@PAGEOFF
203 ; CHECK-ERRORS: error: invalid immediate expression
204 ; CHECK-ERRORS: add w3, w5, sym@PAGEOFF
205 ; CHECK-ERRORS:             ^
206
207 adds w3, w5, sym@PAGEOFF
208 adds x9, x12, sym@PAGEOFF
209 ; CHECK-ERRORS: error: invalid immediate expression
210 ; CHECK-ERRORS: adds w3, w5, sym@PAGEOFF
211 ; CHECK-ERRORS:              ^
212 ; CHECK-ERRORS: error: invalid immediate expression
213 ; CHECK-ERRORS: adds x9, x12, sym@PAGEOFF
214 ; CHECK-ERRORS:               ^
215
216 sub x3, x5, sym@PAGEOFF
217 sub w20, w30, sym@PAGEOFF
218 ; CHECK-ERRORS: error: invalid immediate expression
219 ; CHECK-ERRORS: sub x3, x5, sym@PAGEOFF
220 ; CHECK-ERRORS:             ^
221 ; CHECK-ERRORS: error: invalid immediate expression
222 ; CHECK-ERRORS: sub w20, w30, sym@PAGEOFF
223 ; CHECK-ERRORS:               ^
224
225 subs w9, w10, sym@PAGEOFF
226 subs x20, x30, sym@PAGEOFF
227 ; CHECK-ERRORS: error: invalid immediate expression
228 ; CHECK-ERRORS: subs w9, w10, sym@PAGEOFF
229 ; CHECK-ERRORS:               ^
230 ; CHECK-ERRORS: error: invalid immediate expression
231 ; CHECK-ERRORS: subs x20, x30, sym@PAGEOFF
232 ; CHECK-ERRORS:                ^
233
234 tbl v0.8b, { v1 }, v0.8b
235 tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
236 tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
237 tbx v2.8b, { v0 }, v6.8b
238 ; CHECK-ERRORS: error: invalid operand for instruction
239 ; CHECK-ERRORS: tbl v0.8b, { v1 }, v0.8b
240 ; CHECK-ERRORS:            ^
241 ; CHECK-ERRORS: error: invalid operand for instruction
242 ; CHECK-ERRORS: tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
243 ; CHECK-ERRORS:             ^
244 ; CHECK-ERRORS: error: invalid operand for instruction
245 ; CHECK-ERRORS: tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
246 ; CHECK-ERRORS:             ^
247 ; CHECK-ERRORS: error: invalid operand for instruction
248 ; CHECK-ERRORS: tbx v2.8b, { v0 }, v6.8b
249 ; CHECK-ERRORS:            ^
250
251 b.c #0x4
252 ; CHECK-ERRORS: error: invalid condition code
253 ; CHECK-ERRORS: b.c #0x4
254 ; CHECK-ERRORS:   ^
255
256 ic ialluis, x0
257 ; CHECK-ERRORS: error: specified ic op does not use a register
258 ic iallu, x0
259 ; CHECK-ERRORS: error: specified ic op does not use a register
260 ic ivau
261 ; CHECK-ERRORS: error: specified ic op requires a register
262
263 dc zva
264 ; CHECK-ERRORS: error: specified dc op requires a register
265 dc ivac
266 ; CHECK-ERRORS: error: specified dc op requires a register
267 dc isw
268 ; CHECK-ERRORS: error: specified dc op requires a register
269 dc cvac
270 ; CHECK-ERRORS: error: specified dc op requires a register
271 dc csw
272 ; CHECK-ERRORS: error: specified dc op requires a register
273 dc cvau
274 ; CHECK-ERRORS: error: specified dc op requires a register
275 dc civac
276 ; CHECK-ERRORS: error: specified dc op requires a register
277 dc cisw
278 ; CHECK-ERRORS: error: specified dc op requires a register
279
280 at s1e1r
281 ; CHECK-ERRORS: error: specified at op requires a register
282 at s1e2r
283 ; CHECK-ERRORS: error: specified at op requires a register
284 at s1e3r
285 ; CHECK-ERRORS: error: specified at op requires a register
286 at s1e1w
287 ; CHECK-ERRORS: error: specified at op requires a register
288 at s1e2w
289 ; CHECK-ERRORS: error: specified at op requires a register
290 at s1e3w
291 ; CHECK-ERRORS: error: specified at op requires a register
292 at s1e0r
293 ; CHECK-ERRORS: error: specified at op requires a register
294 at s1e0w
295 ; CHECK-ERRORS: error: specified at op requires a register
296 at s12e1r
297 ; CHECK-ERRORS: error: specified at op requires a register
298 at s12e1w
299 ; CHECK-ERRORS: error: specified at op requires a register
300 at s12e0r
301 ; CHECK-ERRORS: error: specified at op requires a register
302 at s12e0w
303 ; CHECK-ERRORS: error: specified at op requires a register
304
305 tlbi vmalle1is, x0
306 ; CHECK-ERRORS: error: specified tlbi op does not use a register
307 tlbi vmalle1, x0
308 ; CHECK-ERRORS: error: specified tlbi op does not use a register
309 tlbi alle1is, x0
310 ; CHECK-ERRORS: error: specified tlbi op does not use a register
311 tlbi alle2is, x0
312 ; CHECK-ERRORS: error: specified tlbi op does not use a register
313 tlbi alle3is, x0
314 ; CHECK-ERRORS: error: specified tlbi op does not use a register
315 tlbi alle1, x0
316 ; CHECK-ERRORS: error: specified tlbi op does not use a register
317 tlbi alle2, x0
318 ; CHECK-ERRORS: error: specified tlbi op does not use a register
319 tlbi alle3, x0
320 ; CHECK-ERRORS: error: specified tlbi op does not use a register
321 tlbi vae1is
322 ; CHECK-ERRORS: error: specified tlbi op requires a register
323 tlbi vae2is
324 ; CHECK-ERRORS: error: specified tlbi op requires a register
325 tlbi vae3is
326 ; CHECK-ERRORS: error: specified tlbi op requires a register
327 tlbi aside1is
328 ; CHECK-ERRORS: error: specified tlbi op requires a register
329 tlbi vaae1is
330 ; CHECK-ERRORS: error: specified tlbi op requires a register
331 tlbi vale1is
332 ; CHECK-ERRORS: error: specified tlbi op requires a register
333 tlbi vaale1is
334 ; CHECK-ERRORS: error: specified tlbi op requires a register
335 tlbi vale2is
336 ; CHECK-ERRORS: error: specified tlbi op requires a register
337 tlbi vale3is
338 ; CHECK-ERRORS: error: specified tlbi op requires a register
339 tlbi vae1
340 ; CHECK-ERRORS: error: specified tlbi op requires a register
341 tlbi vae2
342 ; CHECK-ERRORS: error: specified tlbi op requires a register
343 tlbi vae3
344 ; CHECK-ERRORS: error: specified tlbi op requires a register
345 tlbi aside1
346 ; CHECK-ERRORS: error: specified tlbi op requires a register
347 tlbi vaae1
348 ; CHECK-ERRORS: error: specified tlbi op requires a register
349 tlbi vale1
350 ; CHECK-ERRORS: error: specified tlbi op requires a register
351 tlbi vale2
352 ; CHECK-ERRORS: error: specified tlbi op requires a register
353 tlbi vale3
354 ; CHECK-ERRORS: error: specified tlbi op requires a register