aboutsummaryrefslogtreecommitdiffstats
path: root/test/MC/ARM64/diags.s
blob: d857fe124c61442c1bac6547ac71a682abd17d96 (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
; 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_arm64_pcrel_imm19
; CHECK-ERRORS: error: register expected

; 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 a multiple of 8 in range [0,32760].
; CHECK-ERRORS:         ldr x0, [x0, #804]
; CHECK-ERRORS:                 ^
; CHECK-ERRORS: error: index must be a multiple of 4 in range [0,16380].
; 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: index must be an integer in range [-256,255].
; 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: index must be an integer in range [-256,255].
; 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 8 in range [-512,504].
; 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:                   ^



; 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: immediate value too large for shifter operand
; 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: shift value out of range
; CHECK-ERRORS:        orr w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
eor w0, w0, w0, lsl #32
; CHECK-ERRORS: error: shift value out of range
; CHECK-ERRORS:        eor w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
and w0, w0, w0, lsl #32
; CHECK-ERRORS: error: shift value out of range
; CHECK-ERRORS:        and w0, w0, w0, lsl #32
; CHECK-ERRORS:                        ^
ands w0, w0, w0, lsl #32
; CHECK-ERRORS: error: shift value out of range
; 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:   ^