ARM64: initial backend import
[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
78 ; Shift immediates range checking.
79   sqrshrn b4, h9, #10
80   rshrn v9.8b, v11.8h, #17
81   sqrshrn v7.4h, v8.4s, #39
82   uqshrn2 v4.4s, v5.2d, #67
83
84 ; CHECK-ERRORS: error: immediate must be an integer in range [1,8].
85 ; CHECK-ERRORS:   sqrshrn b4, h9, #10
86 ; CHECK-ERRORS:                   ^
87 ; CHECK-ERRORS: error: immediate must be an integer in range [1,8].
88 ; CHECK-ERRORS:   rshrn v9.8b, v11.8h, #17
89 ; CHECK-ERRORS:                        ^
90 ; CHECK-ERRORS: error: immediate must be an integer in range [1,16].
91 ; CHECK-ERRORS:   sqrshrn v7.4h, v8.4s, #39
92 ; CHECK-ERRORS:                         ^
93 ; CHECK-ERRORS: error: immediate must be an integer in range [1,32].
94 ; CHECK-ERRORS:   uqshrn2 v4.4s, v5.2d, #67
95 ; CHECK-ERRORS:                         ^
96
97
98   st1.s4 {v14, v15}, [x2], #32
99 ; CHECK-ERRORS: error: invalid type suffix for instruction
100 ; CHECK-ERRORS: st1.s4 {v14, v15}, [x2], #32
101 ; CHECK-ERRORS:     ^
102
103
104
105 ; Load pair instructions where Rt==Rt2 and writeback load/store instructions
106 ; where Rt==Rn or Rt2==Rn are unpredicatable.
107   ldp x1, x2, [x2], #16
108   ldp x2, x2, [x2], #16
109   ldp w1, w2, [x2], #16
110   ldp w2, w2, [x2], #16
111   ldp x1, x1, [x2]
112
113   ldr x2, [x2], #8
114   ldr x2, [x2, #8]!
115   ldr w2, [x2], #8
116   ldr w2, [x2, #8]!
117
118   str x2, [x2], #8
119   str x2, [x2, #8]!
120   str w2, [x2], #8
121   str w2, [x2, #8]!
122
123 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
124 ; CHECK-ERRORS:   ldp x1, x2, [x2], #16
125 ; CHECK-ERRORS:           ^
126 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
127 ; CHECK-ERRORS:   ldp x2, x2, [x2], #16
128 ; CHECK-ERRORS:       ^
129 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
130 ; CHECK-ERRORS:   ldp w1, w2, [x2], #16
131 ; CHECK-ERRORS:           ^
132 ; CHECK-ERRORS: error: unpredictable LDP instruction, writeback base is also a destination
133 ; CHECK-ERRORS:   ldp w2, w2, [x2], #16
134 ; CHECK-ERRORS:       ^
135 ; CHECK-ERRORS: error: unpredictable LDP instruction, Rt2==Rt
136 ; CHECK-ERRORS:   ldp x1, x1, [x2]
137 ; CHECK-ERRORS:           ^
138 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
139 ; CHECK-ERRORS:   ldr x2, [x2], #8
140 ; CHECK-ERRORS:       ^
141 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
142 ; CHECK-ERRORS:   ldr x2, [x2, #8]!
143 ; CHECK-ERRORS:       ^
144 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
145 ; CHECK-ERRORS:   ldr w2, [x2], #8
146 ; CHECK-ERRORS:       ^
147 ; CHECK-ERRORS: error: unpredictable LDR instruction, writeback base is also a source
148 ; CHECK-ERRORS:   ldr w2, [x2, #8]!
149 ; CHECK-ERRORS:       ^
150 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
151 ; CHECK-ERRORS:   str x2, [x2], #8
152 ; CHECK-ERRORS:       ^
153 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
154 ; CHECK-ERRORS:   str x2, [x2, #8]!
155 ; CHECK-ERRORS:       ^
156 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
157 ; CHECK-ERRORS:   str w2, [x2], #8
158 ; CHECK-ERRORS:       ^
159 ; CHECK-ERRORS: error: unpredictable STR instruction, writeback base is also a source
160 ; CHECK-ERRORS:   str w2, [x2, #8]!
161 ; CHECK-ERRORS:       ^
162
163 ; The validity checking for shifted-immediate operands.  rdar://13174476
164 ; Where the immediate is out of range.
165   add w1, w2, w3, lsr #75
166
167 ; CHECK-ERRORS: error: immediate value too large for shifter operand
168 ; CHECK-ERRORS: add w1, w2, w3, lsr #75
169 ; CHECK-ERRORS:                      ^
170
171 ; logical instructions on 32-bit regs with shift > 31 is not legal
172 orr w0, w0, w0, lsl #32
173 ; CHECK-ERRORS: error: shift value out of range
174 ; CHECK-ERRORS:        orr w0, w0, w0, lsl #32
175 ; CHECK-ERRORS:                        ^
176 eor w0, w0, w0, lsl #32
177 ; CHECK-ERRORS: error: shift value out of range
178 ; CHECK-ERRORS:        eor w0, w0, w0, lsl #32
179 ; CHECK-ERRORS:                        ^
180 and w0, w0, w0, lsl #32
181 ; CHECK-ERRORS: error: shift value out of range
182 ; CHECK-ERRORS:        and w0, w0, w0, lsl #32
183 ; CHECK-ERRORS:                        ^
184 ands w0, w0, w0, lsl #32
185 ; CHECK-ERRORS: error: shift value out of range
186 ; CHECK-ERRORS:        ands w0, w0, w0, lsl #32
187 ; CHECK-ERRORS:                        ^
188
189 ; Relocated expressions should not be accepted for 32-bit adds or sub (imm)
190 add w3, w5, sym@PAGEOFF
191 ; CHECK-ERRORS: error: invalid immediate expression
192 ; CHECK-ERRORS: add w3, w5, sym@PAGEOFF
193 ; CHECK-ERRORS:             ^
194
195 adds w3, w5, sym@PAGEOFF
196 adds x9, x12, sym@PAGEOFF
197 ; CHECK-ERRORS: error: invalid immediate expression
198 ; CHECK-ERRORS: adds w3, w5, sym@PAGEOFF
199 ; CHECK-ERRORS:              ^
200 ; CHECK-ERRORS: error: invalid immediate expression
201 ; CHECK-ERRORS: adds x9, x12, sym@PAGEOFF
202 ; CHECK-ERRORS:               ^
203
204 sub x3, x5, sym@PAGEOFF
205 sub w20, w30, sym@PAGEOFF
206 ; CHECK-ERRORS: error: invalid immediate expression
207 ; CHECK-ERRORS: sub x3, x5, sym@PAGEOFF
208 ; CHECK-ERRORS:             ^
209 ; CHECK-ERRORS: error: invalid immediate expression
210 ; CHECK-ERRORS: sub w20, w30, sym@PAGEOFF
211 ; CHECK-ERRORS:               ^
212
213 subs w9, w10, sym@PAGEOFF
214 subs x20, x30, sym@PAGEOFF
215 ; CHECK-ERRORS: error: invalid immediate expression
216 ; CHECK-ERRORS: subs w9, w10, sym@PAGEOFF
217 ; CHECK-ERRORS:               ^
218 ; CHECK-ERRORS: error: invalid immediate expression
219 ; CHECK-ERRORS: subs x20, x30, sym@PAGEOFF
220 ; CHECK-ERRORS:                ^
221
222 tbl v0.8b, { v1 }, v0.8b
223 tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
224 tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
225 tbx v2.8b, { v0 }, v6.8b
226 ; CHECK-ERRORS: error: invalid operand for instruction
227 ; CHECK-ERRORS: tbl v0.8b, { v1 }, v0.8b
228 ; CHECK-ERRORS:            ^
229 ; CHECK-ERRORS: error: invalid operand for instruction
230 ; CHECK-ERRORS: tbl v0.16b, { v1.8b, v2.8b, v3.8b }, v0.16b
231 ; CHECK-ERRORS:             ^
232 ; CHECK-ERRORS: error: invalid operand for instruction
233 ; CHECK-ERRORS: tbx v3.16b, { v12.8b, v13.8b, v14.8b }, v6.8b
234 ; CHECK-ERRORS:             ^
235 ; CHECK-ERRORS: error: invalid operand for instruction
236 ; CHECK-ERRORS: tbx v2.8b, { v0 }, v6.8b
237 ; CHECK-ERRORS:            ^
238
239 b.c #0x4
240 ; CHECK-ERRORS: error: invalid condition code
241 ; CHECK-ERRORS: b.c #0x4
242 ; CHECK-ERRORS:   ^