summaryrefslogtreecommitdiff
path: root/test/MC/AArch64/arm64-diags.s
blob: cf00e9826e167004c900345086402789a2b62e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
; RUN: not llvm-mc -triple arm64-apple-darwin -show-encoding < %s 2> %t | FileCheck %s
; RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s

foo:

; The first should encode as an expression. The second should error expecting
; a register.
  ldr x3, (foo + 4)
  ldr x3, [foo + 4]
; CHECK:  ldr x3, foo+4               ; encoding: [0bAAA00011,A,A,0x58]
; CHECK:                              ;   fixup A - offset: 0, value: foo+4, kind: fixup_aarch64_ldr_pcrel_imm19
; CHECK-ERRORS: error: invalid operand for instruction

; The last argument should be flagged as an error.  rdar://9576009
  ld4.8b	{v0, v1, v2, v3}, [x0], #33
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS: ld4.8b	{v0, v1, v2, v3}, [x0], #33


        ldr x0, [x0, #804]
        ldr w0, [x0, #802]
        ldr x0, [x0, #804]!
        ldr w0, [w0, #301]!
        ldr x0, [x0], #804
        ldr w0, [w0], #301

        ldp w3, w4, [x5, #11]!
        ldp x3, x4, [x5, #12]!
        ldp q3, q4, [x5, #12]!
        ldp w3, w4, [x5], #11
        ldp x3, x4, [x5], #12
        ldp q3, q4, [x5], #12

        ldur x0, [x1, #-257]

; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:         ldr x0, [x0, #804]
; CHECK-ERRORS:                 ^
; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:         ldr w0, [x0, #802]
; CHECK-ERRORS:                 ^
; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:         ldr x0, [x0, #804]!
; CHECK-ERRORS:                 ^
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS:         ldr w0, [w0, #301]!
; CHECK-ERRORS:                  ^
; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:         ldr x0, [x0], #804
; CHECK-ERRORS:                       ^
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS:         ldr w0, [w0], #301
; CHECK-ERRORS:                  ^
; CHECK-ERRORS: error: index must be a multiple of 4 in range [-256, 252].
; CHECK-ERRORS:         ldp w3, w4, [x5, #11]!
; CHECK-ERRORS:                     ^
; CHECK-ERRORS: error: index must be a multiple of 8 in range [-512, 504].
; CHECK-ERRORS:         ldp x3, x4, [x5, #12]!
; CHECK-ERRORS:                     ^
; CHECK-ERRORS: error: index must be a multiple of 16 in range [-1024, 1008].
; CHECK-ERRORS:         ldp q3, q4, [x5, #12]!
; CHECK-ERRORS:                     ^
; CHECK-ERRORS: error: index must be a multiple of 4 in range [-256, 252].
; CHECK-ERRORS:         ldp w3, w4, [x5], #11
; CHECK-ERRORS:                           ^
; CHECK-ERRORS: error: index must be a multiple of 8 in range [-512, 504].
; CHECK-ERRORS:         ldp x3, x4, [x5], #12
; CHECK-ERRORS:                           ^
; CHECK-ERRORS: error: index must be a multiple of 16 in range [-1024, 1008].
; CHECK-ERRORS:         ldp q3, q4, [x5], #12
; CHECK-ERRORS:                           ^
; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:         ldur x0, [x1, #-257]
; CHECK-ERRORS:                   ^


ldrb   w1, [x3, w3, sxtw #4]
ldrh   w1, [x3, w3, sxtw #4]
ldr    w1, [x3, w3, sxtw #4]
ldr    x1, [x3, w3, sxtw #4]
ldr    b1, [x3, w3, sxtw #4]
ldr    h1, [x3, w3, sxtw #4]
ldr    s1, [x3, w3, sxtw #4]
ldr    d1, [x3, w3, sxtw #4]
ldr    q1, [x3, w3, sxtw #1]

; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0
; CHECK-ERRORS:ldrb   w1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #1
; CHECK-ERRORS:ldrh   w1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #2
; CHECK-ERRORS:ldr    w1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #3
; CHECK-ERRORS:ldr    x1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0
; CHECK-ERRORS:ldr    b1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #1
; CHECK-ERRORS:ldr    h1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #2
; CHECK-ERRORS:ldr    s1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #3
; CHECK-ERRORS:ldr    d1, [x3, w3, sxtw #4]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #4
; CHECK-ERRORS:ldr    q1, [x3, w3, sxtw #1]
; CHECK-ERRORS:           ^

; Check that register offset addressing modes only accept 32-bit offset
; registers when using uxtw/sxtw extends. Everything else requires a 64-bit
; register.
  str    d1, [x3, w3, sxtx #3]
  ldr    s1, [x3, d3, sxtx #2]

; CHECK-ERRORS: error: expected 'uxtw' or 'sxtw' with optional shift of #0 or #3
; CHECK-ERRORS:   str    d1, [x3, w3, sxtx #3]
; CHECK-ERRORS:                       ^
; CHECK-ERRORS: error: index must be an integer in range [-256, 255].
; CHECK-ERRORS:   ldr    s1, [x3, d3, sxtx #2]
; CHECK-ERRORS:                   ^

; Shift immediates range checking.
  sqrshrn b4, h9, #10
  rshrn v9.8b, v11.8h, #17
  sqrshrn v7.4h, v8.4s, #39
  uqshrn2 v4.4s, v5.2d, #67

; CHECK-ERRORS: error: immediate must be an integer in range [1, 8].
; CHECK-ERRORS:   sqrshrn b4, h9, #10
; CHECK-ERRORS:                   ^
; CHECK-ERRORS: error: immediate must be an integer in range [1, 8].
; CHECK-ERRORS:   rshrn v9.8b, v11.8h, #17
; CHECK-ERRORS:                        ^
; CHECK-ERRORS: error: immediate must be an integer in range [1, 16].
; CHECK-ERRORS:   sqrshrn v7.4h, v8.4s, #39
; CHECK-ERRORS:                         ^
; CHECK-ERRORS: error: immediate must be an integer in range [1, 32].
; CHECK-ERRORS:   uqshrn2 v4.4s, v5.2d, #67
; CHECK-ERRORS:                         ^


  st1.s4 {v14, v15}, [x2], #32
; CHECK-ERRORS: error: invalid type suffix for instruction
; CHECK-ERRORS: st1.s4 {v14, v15}, [x2], #32
; CHECK-ERRORS:     ^



; Load pair instructions where Rt==Rt2 and writeback load/store instructions
; where Rt==Rn or Rt2==Rn are unpredicatable.
  ldp x1, x2, [x2], #16
  ldp x2, x2, [x2], #16
  ldp w1, w2, [x2], #16
  ldp w2, w2, [x2], #16
  ldp x1, x1, [x2]

  ldr x2, [x2], #8
  ldr x2, [x2, #8]!
  ldr w2, [x2], #8
  ldr w2, [x2, #8]!

  str x2, [x2], #8
  str x2, [x2, #8]!
  str w2, [x2], #8
  str w2, [x2, #8]!

; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
; CHECK-ERRORS:   ldp x1, x2, [x2], #16
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
; CHECK-ERRORS:   ldp x2, x2, [x2], #16
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
; CHECK-ERRORS:   ldp w1, w2, [x2], #16
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
; CHECK-ERRORS:   ldp w2, w2, [x2], #16
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable LDP instruction, Rt2==Rt
; CHECK-ERRORS:   ldp x1, x1, [x2]
; CHECK-ERRORS:           ^
; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
; CHECK-ERRORS:   ldr x2, [x2], #8
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
; CHECK-ERRORS:   ldr x2, [x2, #8]!
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
; CHECK-ERRORS:   ldr w2, [x2], #8
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
; CHECK-ERRORS:   ldr w2, [x2, #8]!
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
; CHECK-ERRORS:   str x2, [x2], #8
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
; CHECK-ERRORS:   str x2, [x2, #8]!
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
; CHECK-ERRORS:   str w2, [x2], #8
; CHECK-ERRORS:       ^
; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
; CHECK-ERRORS:   str w2, [x2, #8]!
; CHECK-ERRORS:       ^

; The validity checking for shifted-immediate operands.  rdar://13174476
; Where the immediate is out of range.
  add w1, w2, w3, lsr #75

; CHECK-ERRORS: error: expected 'sxtx' 'uxtx' or 'lsl' with optional integer in range [0, 4]
; CHECK-ERRORS: add w1, w2, w3, lsr #75
; CHECK-ERRORS:                      ^

; logical instructions on 32-bit regs with shift > 31 is not legal
orr w0, w0, w0, lsl #32
; CHECK-ERRORS: error: expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31]
; CHECK-ERRORS:        orr w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
eor w0, w0, w0, lsl #32
; CHECK-ERRORS: error: expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31]
; CHECK-ERRORS:        eor w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
and w0, w0, w0, lsl #32
; CHECK-ERRORS: error: expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31]
; CHECK-ERRORS:        and w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
ands w0, w0, w0, lsl #32
; CHECK-ERRORS: error: expected 'lsl', 'lsr' or 'asr' with optional integer in range [0, 31]
; CHECK-ERRORS:        ands w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^

; Relocated expressions should not be accepted for 32-bit adds or sub (imm)
add w3, w5, sym@PAGEOFF
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: add w3, w5, sym@PAGEOFF
; CHECK-ERRORS:             ^

adds w3, w5, sym@PAGEOFF
adds x9, x12, sym@PAGEOFF
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: adds w3, w5, sym@PAGEOFF
; CHECK-ERRORS:              ^
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: adds x9, x12, sym@PAGEOFF
; CHECK-ERRORS:               ^

sub x3, x5, sym@PAGEOFF
sub w20, w30, sym@PAGEOFF
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: sub x3, x5, sym@PAGEOFF
; CHECK-ERRORS:             ^
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: sub w20, w30, sym@PAGEOFF
; CHECK-ERRORS:               ^

subs w9, w10, sym@PAGEOFF
subs x20, x30, sym@PAGEOFF
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: subs w9, w10, sym@PAGEOFF
; CHECK-ERRORS:               ^
; CHECK-ERRORS: error: invalid immediate expression
; CHECK-ERRORS: subs x20, x30, sym@PAGEOFF
; CHECK-ERRORS:                ^

tbl v0.8b, { v1 }, v0.8b
tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
tbx v2.8b, { v0 }, v6.8b
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS: tbl v0.8b, { v1 }, v0.8b
; CHECK-ERRORS:            ^
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS: tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
; CHECK-ERRORS:             ^
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS: tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
; CHECK-ERRORS:             ^
; CHECK-ERRORS: error: invalid operand for instruction
; CHECK-ERRORS: tbx v2.8b, { v0 }, v6.8b
; CHECK-ERRORS:            ^

b.c #0x4
; CHECK-ERRORS: error: invalid condition code
; CHECK-ERRORS: b.c #0x4
; CHECK-ERRORS:   ^

ic ialluis, x0
; CHECK-ERRORS: error: specified ic op does not use a register
ic iallu, x0
; CHECK-ERRORS: error: specified ic op does not use a register
ic ivau
; CHECK-ERRORS: error: specified ic op requires a register

dc zva
; CHECK-ERRORS: error: specified dc op requires a register
dc ivac
; CHECK-ERRORS: error: specified dc op requires a register
dc isw
; CHECK-ERRORS: error: specified dc op requires a register
dc cvac
; CHECK-ERRORS: error: specified dc op requires a register
dc csw
; CHECK-ERRORS: error: specified dc op requires a register
dc cvau
; CHECK-ERRORS: error: specified dc op requires a register
dc civac
; CHECK-ERRORS: error: specified dc op requires a register
dc cisw
; CHECK-ERRORS: error: specified dc op requires a register

at s1e1r
; CHECK-ERRORS: error: specified at op requires a register
at s1e2r
; CHECK-ERRORS: error: specified at op requires a register
at s1e3r
; CHECK-ERRORS: error: specified at op requires a register
at s1e1w
; CHECK-ERRORS: error: specified at op requires a register
at s1e2w
; CHECK-ERRORS: error: specified at op requires a register
at s1e3w
; CHECK-ERRORS: error: specified at op requires a register
at s1e0r
; CHECK-ERRORS: error: specified at op requires a register
at s1e0w
; CHECK-ERRORS: error: specified at op requires a register
at s12e1r
; CHECK-ERRORS: error: specified at op requires a register
at s12e1w
; CHECK-ERRORS: error: specified at op requires a register
at s12e0r
; CHECK-ERRORS: error: specified at op requires a register
at s12e0w
; CHECK-ERRORS: error: specified at op requires a register

tlbi vmalle1is, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi vmalle1, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle1is, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle2is, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle3is, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle1, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle2, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi alle3, x0
; CHECK-ERRORS: error: specified tlbi op does not use a register
tlbi vae1is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vae2is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vae3is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi aside1is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vaae1is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale1is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vaale1is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale2is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale3is
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vae1
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vae2
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vae3
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi aside1
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vaae1
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale1
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale2
; CHECK-ERRORS: error: specified tlbi op requires a register
tlbi vale3
; CHECK-ERRORS: error: specified tlbi op requires a register