/src/binutils-gdb/opcodes/aarch64-opc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* aarch64-opc.c -- AArch64 opcode support. |
2 | | Copyright (C) 2009-2025 Free Software Foundation, Inc. |
3 | | Contributed by ARM Ltd. |
4 | | |
5 | | This file is part of the GNU opcodes library. |
6 | | |
7 | | This library is free software; you can redistribute it and/or modify |
8 | | it under the terms of the GNU General Public License as published by |
9 | | the Free Software Foundation; either version 3, or (at your option) |
10 | | any later version. |
11 | | |
12 | | It is distributed in the hope that it will be useful, but WITHOUT |
13 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
15 | | License for more details. |
16 | | |
17 | | You should have received a copy of the GNU General Public License |
18 | | along with this program; see the file COPYING3. If not, |
19 | | see <http://www.gnu.org/licenses/>. */ |
20 | | |
21 | | #include "sysdep.h" |
22 | | #include <assert.h> |
23 | | #include <stdlib.h> |
24 | | #include <stdio.h> |
25 | | #include <stdint.h> |
26 | | #include <stdarg.h> |
27 | | #include <inttypes.h> |
28 | | |
29 | | #include "opintl.h" |
30 | | #include "libiberty.h" |
31 | | |
32 | | #include "aarch64-opc.h" |
33 | | |
34 | | #ifdef DEBUG_AARCH64 |
35 | | int debug_dump = false; |
36 | | #endif /* DEBUG_AARCH64 */ |
37 | | |
38 | | /* The enumeration strings associated with each value of a 5-bit SVE |
39 | | pattern operand. A null entry indicates a reserved meaning. */ |
40 | | const char *const aarch64_sve_pattern_array[32] = { |
41 | | /* 0-7. */ |
42 | | "pow2", |
43 | | "vl1", |
44 | | "vl2", |
45 | | "vl3", |
46 | | "vl4", |
47 | | "vl5", |
48 | | "vl6", |
49 | | "vl7", |
50 | | /* 8-15. */ |
51 | | "vl8", |
52 | | "vl16", |
53 | | "vl32", |
54 | | "vl64", |
55 | | "vl128", |
56 | | "vl256", |
57 | | 0, |
58 | | 0, |
59 | | /* 16-23. */ |
60 | | 0, |
61 | | 0, |
62 | | 0, |
63 | | 0, |
64 | | 0, |
65 | | 0, |
66 | | 0, |
67 | | 0, |
68 | | /* 24-31. */ |
69 | | 0, |
70 | | 0, |
71 | | 0, |
72 | | 0, |
73 | | 0, |
74 | | "mul4", |
75 | | "mul3", |
76 | | "all" |
77 | | }; |
78 | | |
79 | | /* The enumeration strings associated with each value of a 4-bit SVE |
80 | | prefetch operand. A null entry indicates a reserved meaning. */ |
81 | | const char *const aarch64_sve_prfop_array[16] = { |
82 | | /* 0-7. */ |
83 | | "pldl1keep", |
84 | | "pldl1strm", |
85 | | "pldl2keep", |
86 | | "pldl2strm", |
87 | | "pldl3keep", |
88 | | "pldl3strm", |
89 | | 0, |
90 | | 0, |
91 | | /* 8-15. */ |
92 | | "pstl1keep", |
93 | | "pstl1strm", |
94 | | "pstl2keep", |
95 | | "pstl2strm", |
96 | | "pstl3keep", |
97 | | "pstl3strm", |
98 | | 0, |
99 | | 0 |
100 | | }; |
101 | | |
102 | | /* The enumeration strings associated with each value of a 6-bit RPRFM |
103 | | operation. */ |
104 | | const char *const aarch64_rprfmop_array[64] = { |
105 | | "pldkeep", |
106 | | "pstkeep", |
107 | | 0, |
108 | | 0, |
109 | | "pldstrm", |
110 | | "pststrm" |
111 | | }; |
112 | | |
113 | | /* Vector length multiples for a predicate-as-counter operand. Used in things |
114 | | like AARCH64_OPND_SME_VLxN_10. */ |
115 | | const char *const aarch64_sme_vlxn_array[2] = { |
116 | | "vlx2", |
117 | | "vlx4" |
118 | | }; |
119 | | |
120 | | /* Values accepted by the brb alias. */ |
121 | | const char *const aarch64_brbop_array[] = { |
122 | | "iall", |
123 | | "inj", |
124 | | }; |
125 | | |
126 | | /* Helper functions to determine which operand to be used to encode/decode |
127 | | the size:Q fields for AdvSIMD instructions. */ |
128 | | |
129 | | static inline bool |
130 | | vector_qualifier_p (enum aarch64_opnd_qualifier qualifier) |
131 | 3.28M | { |
132 | 3.28M | return (qualifier >= AARCH64_OPND_QLF_V_8B |
133 | 3.28M | && qualifier <= AARCH64_OPND_QLF_V_1Q); |
134 | 3.28M | } |
135 | | |
136 | | static inline bool |
137 | | fp_qualifier_p (enum aarch64_opnd_qualifier qualifier) |
138 | 1.03k | { |
139 | 1.03k | return (qualifier >= AARCH64_OPND_QLF_S_B |
140 | 1.03k | && qualifier <= AARCH64_OPND_QLF_S_Q); |
141 | 1.03k | } |
142 | | |
143 | | enum data_pattern |
144 | | { |
145 | | DP_UNKNOWN, |
146 | | DP_VECTOR_3SAME, |
147 | | DP_VECTOR_LONG, |
148 | | DP_VECTOR_WIDE, |
149 | | DP_VECTOR_ACROSS_LANES, |
150 | | }; |
151 | | |
152 | | static const char significant_operand_index [] = |
153 | | { |
154 | | 0, /* DP_UNKNOWN, by default using operand 0. */ |
155 | | 0, /* DP_VECTOR_3SAME */ |
156 | | 1, /* DP_VECTOR_LONG */ |
157 | | 2, /* DP_VECTOR_WIDE */ |
158 | | 1, /* DP_VECTOR_ACROSS_LANES */ |
159 | | }; |
160 | | |
161 | | /* Given a sequence of qualifiers in QUALIFIERS, determine and return |
162 | | the data pattern. |
163 | | N.B. QUALIFIERS is a possible sequence of qualifiers each of which |
164 | | corresponds to one of a sequence of operands. */ |
165 | | |
166 | | static enum data_pattern |
167 | | get_data_pattern (const aarch64_opnd_qualifier_seq_t qualifiers) |
168 | 1.48M | { |
169 | 1.48M | if (vector_qualifier_p (qualifiers[0])) |
170 | 1.48M | { |
171 | | /* e.g. v.4s, v.4s, v.4s |
172 | | or v.4h, v.4h, v.h[3]. */ |
173 | 1.48M | if (qualifiers[0] == qualifiers[1] |
174 | 1.48M | && vector_qualifier_p (qualifiers[2]) |
175 | 1.48M | && (aarch64_get_qualifier_esize (qualifiers[0]) |
176 | 374k | == aarch64_get_qualifier_esize (qualifiers[1])) |
177 | 1.48M | && (aarch64_get_qualifier_esize (qualifiers[0]) |
178 | 374k | == aarch64_get_qualifier_esize (qualifiers[2]))) |
179 | 365k | return DP_VECTOR_3SAME; |
180 | | /* e.g. v.8h, v.8b, v.8b. |
181 | | or v.4s, v.4h, v.h[2]. |
182 | | or v.8h, v.16b. */ |
183 | 1.12M | if (vector_qualifier_p (qualifiers[1]) |
184 | 1.12M | && aarch64_get_qualifier_esize (qualifiers[0]) != 0 |
185 | 1.12M | && (aarch64_get_qualifier_esize (qualifiers[0]) |
186 | 582k | == aarch64_get_qualifier_esize (qualifiers[1]) << 1)) |
187 | 270k | return DP_VECTOR_LONG; |
188 | | /* e.g. v.8h, v.8h, v.8b. */ |
189 | 849k | if (qualifiers[0] == qualifiers[1] |
190 | 849k | && vector_qualifier_p (qualifiers[2]) |
191 | 849k | && aarch64_get_qualifier_esize (qualifiers[0]) != 0 |
192 | 849k | && (aarch64_get_qualifier_esize (qualifiers[0]) |
193 | 9.03k | == aarch64_get_qualifier_esize (qualifiers[2]) << 1) |
194 | 849k | && (aarch64_get_qualifier_esize (qualifiers[0]) |
195 | 9.03k | == aarch64_get_qualifier_esize (qualifiers[1]))) |
196 | 9.03k | return DP_VECTOR_WIDE; |
197 | 849k | } |
198 | 1.03k | else if (fp_qualifier_p (qualifiers[0])) |
199 | 1.03k | { |
200 | | /* e.g. SADDLV <V><d>, <Vn>.<T>. */ |
201 | 1.03k | if (vector_qualifier_p (qualifiers[1]) |
202 | 1.03k | && qualifiers[2] == AARCH64_OPND_QLF_NIL) |
203 | 940 | return DP_VECTOR_ACROSS_LANES; |
204 | 1.03k | } |
205 | | |
206 | 840k | return DP_UNKNOWN; |
207 | 1.48M | } |
208 | | |
209 | | /* Select the operand to do the encoding/decoding of the 'size:Q' fields in |
210 | | the AdvSIMD instructions. */ |
211 | | /* N.B. it is possible to do some optimization that doesn't call |
212 | | get_data_pattern each time when we need to select an operand. We can |
213 | | either buffer the caculated the result or statically generate the data, |
214 | | however, it is not obvious that the optimization will bring significant |
215 | | benefit. */ |
216 | | |
217 | | int |
218 | | aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *opcode) |
219 | 1.48M | { |
220 | 1.48M | return |
221 | 1.48M | significant_operand_index [get_data_pattern (opcode->qualifiers_list[0])]; |
222 | 1.48M | } |
223 | | |
224 | | /* Instruction bit-fields. |
225 | | + Keep synced with 'enum aarch64_field_kind'. */ |
226 | | const aarch64_field fields[] = |
227 | | { |
228 | | { 0, 0 }, /* NIL. */ |
229 | | { 8, 4 }, /* CRm: in the system instructions. */ |
230 | | { 10, 2 }, /* CRm_dsb_nxs: 2-bit imm. encoded in CRm<3:2>. */ |
231 | | { 12, 4 }, /* CRn: in the system instructions. */ |
232 | | { 10, 8 }, /* CSSC_imm8. */ |
233 | | { 11, 1 }, /* H: in advsimd scalar x indexed element instructions. */ |
234 | | { 21, 1 }, /* L: in advsimd scalar x indexed element instructions. */ |
235 | | { 0, 5 }, /* LSE128_Rt: Shared input+output operand register. */ |
236 | | { 16, 5 }, /* LSE128_Rt2: Shared input+output operand register 2. */ |
237 | | { 20, 1 }, /* M: in advsimd scalar x indexed element instructions. */ |
238 | | { 22, 1 }, /* N: in logical (immediate) instructions. */ |
239 | | { 30, 1 }, /* Q: in most AdvSIMD instructions. */ |
240 | | { 10, 5 }, /* Ra: in fp instructions. */ |
241 | | { 0, 5 }, /* Rd: in many integer instructions. */ |
242 | | { 16, 5 }, /* Rm: in ld/st reg offset and some integer inst. */ |
243 | | { 5, 5 }, /* Rn: in many integer instructions. */ |
244 | | { 16, 5 }, /* Rs: in load/store exclusive instructions. */ |
245 | | { 0, 5 }, /* Rt: in load/store instructions. */ |
246 | | { 10, 5 }, /* Rt2: in load/store pair instructions. */ |
247 | | { 12, 1 }, /* S: in load/store reg offset instructions. */ |
248 | | { 12, 2 }, /* SM3_imm2: Indexed element SM3 2 bits index immediate. */ |
249 | | { 1, 3 }, /* SME_Pdx2: predicate register, multiple of 2, [3:1]. */ |
250 | | { 13, 3 }, /* SME_Pm: second source scalable predicate register P0-P7. */ |
251 | | { 0, 3 }, /* SME_PNd3: PN0-PN7, bits [2:0]. */ |
252 | | { 5, 3 }, /* SME_PNn3: PN0-PN7, bits [7:5]. */ |
253 | | { 16, 1 }, /* SME_Q: Q class bit, bit 16. */ |
254 | | { 16, 2 }, /* SME_Rm: index base register W12-W15 [17:16]. */ |
255 | | { 13, 2 }, /* SME_Rv: vector select register W12-W15, bits [14:13]. */ |
256 | | { 15, 1 }, /* SME_V: (horizontal / vertical tiles), bit 15. */ |
257 | | { 10, 1 }, /* SME_VL_10: VLx2 or VLx4, bit [10]. */ |
258 | | { 13, 1 }, /* SME_VL_13: VLx2 or VLx4, bit [13]. */ |
259 | | { 0, 1 }, /* SME_ZAda_1b: tile ZA0-ZA1. */ |
260 | | { 0, 2 }, /* SME_ZAda_2b: tile ZA0-ZA3. */ |
261 | | { 0, 3 }, /* SME_ZAda_3b: tile ZA0-ZA7. */ |
262 | | { 1, 4 }, /* SME_Zdn2: Z0-Z31, multiple of 2, bits [4:1]. */ |
263 | | { 2, 3 }, /* SME_Zdn4: Z0-Z31, multiple of 4, bits [4:2]. */ |
264 | | { 16, 4 }, /* SME_Zm: Z0-Z15, bits [19:16]. */ |
265 | | { 17, 4 }, /* SME_Zm2: Z0-Z31, multiple of 2, bits [20:17]. */ |
266 | | { 18, 3 }, /* SME_Zm4: Z0-Z31, multiple of 4, bits [20:18]. */ |
267 | | { 6, 4 }, /* SME_Zn2: Z0-Z31, multiple of 2, bits [9:6]. */ |
268 | | { 7, 3 }, /* SME_Zn4: Z0-Z31, multiple of 4, bits [9:7]. */ |
269 | | { 4, 1 }, /* SME_ZtT: upper bit of Zt, bit [4]. */ |
270 | | { 0, 3 }, /* SME_Zt3: lower 3 bits of Zt, bits [2:0]. */ |
271 | | { 0, 2 }, /* SME_Zt2: lower 2 bits of Zt, bits [1:0]. */ |
272 | | { 23, 1 }, /* SME_i1: immediate field, bit 23. */ |
273 | | { 12, 2 }, /* SME_size_12: bits [13:12]. */ |
274 | | { 22, 2 }, /* SME_size_22: size<1>, size<0> class field, [23:22]. */ |
275 | | { 23, 1 }, /* SME_sz_23: bit [23]. */ |
276 | | { 22, 1 }, /* SME_tszh: immediate and qualifier field, bit 22. */ |
277 | | { 18, 3 }, /* SME_tszl: immediate and qualifier field, bits [20:18]. */ |
278 | | { 0, 8 }, /* SME_zero_mask: list of up to 8 tile names separated by commas [7:0]. */ |
279 | | { 4, 1 }, /* SVE_M_4: Merge/zero select, bit 4. */ |
280 | | { 14, 1 }, /* SVE_M_14: Merge/zero select, bit 14. */ |
281 | | { 16, 1 }, /* SVE_M_16: Merge/zero select, bit 16. */ |
282 | | { 17, 1 }, /* SVE_N: SVE equivalent of N. */ |
283 | | { 0, 4 }, /* SVE_Pd: p0-p15, bits [3,0]. */ |
284 | | { 10, 3 }, /* SVE_Pg3: p0-p7, bits [12,10]. */ |
285 | | { 5, 4 }, /* SVE_Pg4_5: p0-p15, bits [8,5]. */ |
286 | | { 10, 4 }, /* SVE_Pg4_10: p0-p15, bits [13,10]. */ |
287 | | { 16, 4 }, /* SVE_Pg4_16: p0-p15, bits [19,16]. */ |
288 | | { 16, 4 }, /* SVE_Pm: p0-p15, bits [19,16]. */ |
289 | | { 5, 4 }, /* SVE_Pn: p0-p15, bits [8,5]. */ |
290 | | { 0, 4 }, /* SVE_Pt: p0-p15, bits [3,0]. */ |
291 | | { 5, 5 }, /* SVE_Rm: SVE alternative position for Rm. */ |
292 | | { 16, 5 }, /* SVE_Rn: SVE alternative position for Rn. */ |
293 | | { 0, 5 }, /* SVE_Vd: Scalar SIMD&FP register, bits [4,0]. */ |
294 | | { 5, 5 }, /* SVE_Vm: Scalar SIMD&FP register, bits [9,5]. */ |
295 | | { 5, 5 }, /* SVE_Vn: Scalar SIMD&FP register, bits [9,5]. */ |
296 | | { 5, 5 }, /* SVE_Za_5: SVE vector register, bits [9,5]. */ |
297 | | { 16, 5 }, /* SVE_Za_16: SVE vector register, bits [20,16]. */ |
298 | | { 0, 5 }, /* SVE_Zd: SVE vector register. bits [4,0]. */ |
299 | | { 5, 5 }, /* SVE_Zm_5: SVE vector register, bits [9,5]. */ |
300 | | { 16, 5 }, /* SVE_Zm_16: SVE vector register, bits [20,16]. */ |
301 | | { 5, 5 }, /* SVE_Zn: SVE vector register, bits [9,5]. */ |
302 | | { 0, 5 }, /* SVE_Zt: SVE vector register, bits [4,0]. */ |
303 | | { 5, 1 }, /* SVE_i1: single-bit immediate. */ |
304 | | { 23, 1 }, /* SVE_i1_23: single-bit immediate. */ |
305 | | { 22, 2 }, /* SVE_i2: 2-bit index, bits [23,22]. */ |
306 | | { 20, 1 }, /* SVE_i2h: high bit of 2bit immediate, bits. */ |
307 | | { 22, 1 }, /* SVE_i3h: high bit of 3-bit immediate. */ |
308 | | { 19, 2 }, /* SVE_i3h2: two high bits of 3bit immediate, bits [20,19]. */ |
309 | | { 22, 2 }, /* SVE_i3h3: two high bits of 3bit immediate, bits [22,23]. */ |
310 | | { 11, 1 }, /* SVE_i3l: low bit of 3-bit immediate. */ |
311 | | { 12, 1 }, /* SVE_i3l2: low bit of 3-bit immediate, bit 12. */ |
312 | | { 10, 2 }, /* SVE_i4l2: two low bits of 4bit immediate, bits [11,10]. */ |
313 | | { 16, 3 }, /* SVE_imm3: 3-bit immediate field. */ |
314 | | { 16, 4 }, /* SVE_imm4: 4-bit immediate field. */ |
315 | | { 5, 5 }, /* SVE_imm5: 5-bit immediate field. */ |
316 | | { 16, 5 }, /* SVE_imm5b: secondary 5-bit immediate field. */ |
317 | | { 16, 6 }, /* SVE_imm6: 6-bit immediate field. */ |
318 | | { 14, 7 }, /* SVE_imm7: 7-bit immediate field. */ |
319 | | { 5, 8 }, /* SVE_imm8: 8-bit immediate field. */ |
320 | | { 5, 9 }, /* SVE_imm9: 9-bit immediate field. */ |
321 | | { 11, 6 }, /* SVE_immr: SVE equivalent of immr. */ |
322 | | { 5, 6 }, /* SVE_imms: SVE equivalent of imms. */ |
323 | | { 10, 2 }, /* SVE_msz: 2-bit shift amount for ADR. */ |
324 | | { 5, 5 }, /* SVE_pattern: vector pattern enumeration. */ |
325 | | { 0, 4 }, /* SVE_prfop: prefetch operation for SVE PRF[BHWD]. */ |
326 | | { 16, 1 }, /* SVE_rot1: 1-bit rotation amount. */ |
327 | | { 10, 2 }, /* SVE_rot2: 2-bit rotation amount. */ |
328 | | { 10, 1 }, /* SVE_rot3: 1-bit rotation amount at bit 10. */ |
329 | | { 17, 2 }, /* SVE_size: 2-bit element size, bits [18,17]. */ |
330 | | { 22, 1 }, /* SVE_sz: 1-bit element size select. */ |
331 | | { 30, 1 }, /* SVE_sz2: 1-bit element size select. */ |
332 | | { 16, 4 }, /* SVE_tsz: triangular size select. */ |
333 | | { 22, 2 }, /* SVE_tszh: triangular size select high, bits [23,22]. */ |
334 | | { 8, 2 }, /* SVE_tszl_8: triangular size select low, bits [9,8]. */ |
335 | | { 19, 2 }, /* SVE_tszl_19: triangular size select low, bits [20,19]. */ |
336 | | { 14, 1 }, /* SVE_xs_14: UXTW/SXTW select (bit 14). */ |
337 | | { 22, 1 }, /* SVE_xs_22: UXTW/SXTW select (bit 22). */ |
338 | | { 22, 1 }, /* S_imm10: in LDRAA and LDRAB instructions. */ |
339 | | { 16, 3 }, /* abc: a:b:c bits in AdvSIMD modified immediate. */ |
340 | | { 13, 3 }, /* asisdlso_opcode: opcode in advsimd ld/st single element. */ |
341 | | { 19, 5 }, /* b40: in the test bit and branch instructions. */ |
342 | | { 31, 1 }, /* b5: in the test bit and branch instructions. */ |
343 | | { 12, 4 }, /* cmode: in advsimd modified immediate instructions. */ |
344 | | { 12, 4 }, /* cond: condition flags as a source operand. */ |
345 | | { 0, 4 }, /* cond2: condition in truly conditional-executed inst. */ |
346 | | { 5, 5 }, /* defgh: d:e:f:g:h bits in AdvSIMD modified immediate. */ |
347 | | { 21, 2 }, /* hw: in move wide constant instructions. */ |
348 | | { 0, 1 }, /* imm1_0: general immediate in bits [0]. */ |
349 | | { 2, 1 }, /* imm1_2: general immediate in bits [2]. */ |
350 | | { 3, 1 }, /* imm1_3: general immediate in bits [3]. */ |
351 | | { 8, 1 }, /* imm1_8: general immediate in bits [8]. */ |
352 | | { 10, 1 }, /* imm1_10: general immediate in bits [10]. */ |
353 | | { 14, 1 }, /* imm1_14: general immediate in bits [14]. */ |
354 | | { 15, 1 }, /* imm1_15: general immediate in bits [15]. */ |
355 | | { 16, 1 }, /* imm1_16: general immediate in bits [16]. */ |
356 | | { 0, 2 }, /* imm2_0: general immediate in bits [1:0]. */ |
357 | | { 1, 2 }, /* imm2_1: general immediate in bits [2:1]. */ |
358 | | { 2, 2 }, /* imm2_2: general immediate in bits [3:2]. */ |
359 | | { 8, 2 }, /* imm2_8: general immediate in bits [9:8]. */ |
360 | | { 10, 2 }, /* imm2_10: 2-bit immediate, bits [11:10] */ |
361 | | { 12, 2 }, /* imm2_12: 2-bit immediate, bits [13:12] */ |
362 | | { 13, 2 }, /* imm2_13: 2-bit immediate, bits [14:13] */ |
363 | | { 15, 2 }, /* imm2_15: 2-bit immediate, bits [16:15] */ |
364 | | { 16, 2 }, /* imm2_16: 2-bit immediate, bits [17:16] */ |
365 | | { 19, 2 }, /* imm2_19: 2-bit immediate, bits [20:19] */ |
366 | | { 0, 3 }, /* imm3_0: general immediate in bits [2:0]. */ |
367 | | { 5, 3 }, /* imm3_5: general immediate in bits [7:5]. */ |
368 | | { 10, 3 }, /* imm3_10: in add/sub extended reg instructions. */ |
369 | | { 12, 3 }, /* imm3_12: general immediate in bits [14:12]. */ |
370 | | { 14, 3 }, /* imm3_14: general immediate in bits [16:14]. */ |
371 | | { 15, 3 }, /* imm3_15: general immediate in bits [17:15]. */ |
372 | | { 19, 3 }, /* imm3_19: general immediate in bits [21:19]. */ |
373 | | { 0, 4 }, /* imm4_0: in rmif instructions. */ |
374 | | { 5, 4 }, /* imm4_5: in SME instructions. */ |
375 | | { 10, 4 }, /* imm4_10: in adddg/subg instructions. */ |
376 | | { 11, 4 }, /* imm4_11: in advsimd ext and advsimd ins instructions. */ |
377 | | { 14, 4 }, /* imm4_14: general immediate in bits [17:14]. */ |
378 | | { 16, 5 }, /* imm5: in conditional compare (immediate) instructions. */ |
379 | | { 10, 6 }, /* imm6_10: in add/sub reg shifted instructions. */ |
380 | | { 15, 6 }, /* imm6_15: in rmif instructions. */ |
381 | | { 15, 7 }, /* imm7: in load/store pair pre/post index instructions. */ |
382 | | { 13, 8 }, /* imm8: in floating-point scalar move immediate inst. */ |
383 | | { 12, 9 }, /* imm9: in load/store pre/post index instructions. */ |
384 | | { 5, 9 }, /* imm9_5: in CB<cc> (immediate). */ |
385 | | { 10, 12 }, /* imm12: in ld/st unsigned imm or add/sub shifted inst. */ |
386 | | { 5, 14 }, /* imm14: in test bit and branch instructions. */ |
387 | | { 0, 16 }, /* imm16_0: in udf instruction. */ |
388 | | { 5, 16 }, /* imm16_5: in exception instructions. */ |
389 | | { 17, 1 }, /* imm17_1: in 1 bit element index. */ |
390 | | { 17, 2 }, /* imm17_2: in 2 bits element index. */ |
391 | | { 5, 19 }, /* imm19: e.g. in CBZ. */ |
392 | | { 0, 26 }, /* imm26: in unconditional branch instructions. */ |
393 | | { 16, 3 }, /* immb: in advsimd shift by immediate instructions. */ |
394 | | { 19, 4 }, /* immh: in advsimd shift by immediate instructions. */ |
395 | | { 5, 19 }, /* immhi: e.g. in ADRP. */ |
396 | | { 29, 2 }, /* immlo: e.g. in ADRP. */ |
397 | | { 16, 6 }, /* immr: in bitfield and logical immediate instructions. */ |
398 | | { 10, 6 }, /* imms: in bitfield and logical immediate instructions. */ |
399 | | { 11, 1 }, /* index: in ld/st inst deciding the pre/post-index. */ |
400 | | { 24, 1 }, /* index2: in ld/st pair inst deciding the pre/post-index. */ |
401 | | { 30, 2 }, /* ldst_size: size field in ld/st reg offset inst. */ |
402 | | { 13, 2 }, /* len: in advsimd tbl/tbx instructions. */ |
403 | | { 30, 1 }, /* lse_sz: in LSE extension atomic instructions. */ |
404 | | { 0, 4 }, /* nzcv: flag bit specifier, encoded in the "nzcv" field. */ |
405 | | { 29, 1 }, /* op: in AdvSIMD modified immediate instructions. */ |
406 | | { 19, 2 }, /* op0: in the system instructions. */ |
407 | | { 16, 3 }, /* op1: in the system instructions. */ |
408 | | { 5, 3 }, /* op2: in the system instructions. */ |
409 | | { 22, 2 }, /* opc: in load/store reg offset instructions. */ |
410 | | { 23, 1 }, /* opc1: in load/store reg offset instructions. */ |
411 | | { 12, 4 }, /* opcode: in advsimd load/store instructions. */ |
412 | | { 13, 3 }, /* option: in ld/st reg offset + add/sub extended reg inst. */ |
413 | | { 11, 2 }, /* rotate1: FCMLA immediate rotate. */ |
414 | | { 13, 2 }, /* rotate2: Indexed element FCMLA immediate rotate. */ |
415 | | { 12, 1 }, /* rotate3: FCADD immediate rotate. */ |
416 | | { 10, 6 }, /* scale: in the fixed-point scalar to fp converting inst. */ |
417 | | { 31, 1 }, /* sf: in integer data processing instructions. */ |
418 | | { 22, 2 }, /* shift: in add/sub reg/imm shifted instructions. */ |
419 | | { 22, 2 }, /* size: in most AdvSIMD and floating-point instructions. */ |
420 | | { 22, 1 }, /* sz: 1-bit element size select. */ |
421 | | { 22, 2 }, /* type: floating point type field in fp data inst. */ |
422 | | { 10, 2 }, /* vldst_size: size field in the AdvSIMD load/store inst. */ |
423 | | { 5, 3 }, /* off3: immediate offset used to calculate slice number in a |
424 | | ZA tile. */ |
425 | | { 5, 2 }, /* off2: immediate offset used to calculate slice number in |
426 | | a ZA tile. */ |
427 | | { 7, 1 }, /* ZAn_1: name of the 1bit encoded ZA tile. */ |
428 | | { 5, 1 }, /* ol: immediate offset used to calculate slice number in a ZA |
429 | | tile. */ |
430 | | { 6, 2 }, /* ZAn_2: name of the 2bit encoded ZA tile. */ |
431 | | { 5, 3 }, /* ZAn_3: name of the 3bit encoded ZA tile. */ |
432 | | { 6, 1 }, /* ZAn: name of the bit encoded ZA tile. */ |
433 | | { 12, 4 }, /* opc2: in rcpc3 ld/st inst deciding the pre/post-index. */ |
434 | | { 30, 2 }, /* rcpc3_size: in rcpc3 ld/st, field controls Rt/Rt2 width. */ |
435 | | { 5, 1 }, /* FLD_brbop: used in BRB to mean IALL or INJ. */ |
436 | | { 8, 1 }, /* ZA8_1: name of the 1 bit encoded ZA tile ZA0-ZA1. */ |
437 | | { 7, 2 }, /* ZA7_2: name of the 2 bits encoded ZA tile ZA0-ZA3. */ |
438 | | { 6, 3 }, /* ZA6_3: name of the 3 bits encoded ZA tile ZA0-ZA7. */ |
439 | | { 5, 4 }, /* ZA5_4: name of the 4 bits encoded ZA tile ZA0-ZA15. */ |
440 | | }; |
441 | | |
442 | | enum aarch64_operand_class |
443 | | aarch64_get_operand_class (enum aarch64_opnd type) |
444 | 10.1M | { |
445 | 10.1M | return aarch64_operands[type].op_class; |
446 | 10.1M | } |
447 | | |
448 | | const char * |
449 | | aarch64_get_operand_name (enum aarch64_opnd type) |
450 | 0 | { |
451 | 0 | return aarch64_operands[type].name; |
452 | 0 | } |
453 | | |
454 | | /* Get operand description string. |
455 | | This is usually for the diagnosis purpose. */ |
456 | | const char * |
457 | | aarch64_get_operand_desc (enum aarch64_opnd type) |
458 | 0 | { |
459 | 0 | return aarch64_operands[type].desc; |
460 | 0 | } |
461 | | |
462 | | /* Table of all conditional affixes. */ |
463 | | const aarch64_cond aarch64_conds[16] = |
464 | | { |
465 | | {{"eq", "none"}, 0x0}, |
466 | | {{"ne", "any"}, 0x1}, |
467 | | {{"cs", "hs", "nlast"}, 0x2}, |
468 | | {{"cc", "lo", "ul", "last"}, 0x3}, |
469 | | {{"mi", "first"}, 0x4}, |
470 | | {{"pl", "nfrst"}, 0x5}, |
471 | | {{"vs"}, 0x6}, |
472 | | {{"vc"}, 0x7}, |
473 | | {{"hi", "pmore"}, 0x8}, |
474 | | {{"ls", "plast"}, 0x9}, |
475 | | {{"ge", "tcont"}, 0xa}, |
476 | | {{"lt", "tstop"}, 0xb}, |
477 | | {{"gt"}, 0xc}, |
478 | | {{"le"}, 0xd}, |
479 | | {{"al"}, 0xe}, |
480 | | {{"nv"}, 0xf}, |
481 | | }; |
482 | | |
483 | | const aarch64_cond * |
484 | | get_cond_from_value (aarch64_insn value) |
485 | 215k | { |
486 | 215k | assert (value < 16); |
487 | 215k | return &aarch64_conds[(unsigned int) value]; |
488 | 215k | } |
489 | | |
490 | | const aarch64_cond * |
491 | | get_inverted_cond (const aarch64_cond *cond) |
492 | 2.55k | { |
493 | 2.55k | return &aarch64_conds[cond->value ^ 0x1]; |
494 | 2.55k | } |
495 | | |
496 | | /* Table describing the operand extension/shifting operators; indexed by |
497 | | enum aarch64_modifier_kind. |
498 | | |
499 | | The value column provides the most common values for encoding modifiers, |
500 | | which enables table-driven encoding/decoding for the modifiers. */ |
501 | | const struct aarch64_name_value_pair aarch64_operand_modifiers [] = |
502 | | { |
503 | | {"none", 0x0}, |
504 | | {"msl", 0x0}, |
505 | | {"ror", 0x3}, |
506 | | {"asr", 0x2}, |
507 | | {"lsr", 0x1}, |
508 | | {"lsl", 0x0}, |
509 | | {"uxtb", 0x0}, |
510 | | {"uxth", 0x1}, |
511 | | {"uxtw", 0x2}, |
512 | | {"uxtx", 0x3}, |
513 | | {"sxtb", 0x4}, |
514 | | {"sxth", 0x5}, |
515 | | {"sxtw", 0x6}, |
516 | | {"sxtx", 0x7}, |
517 | | {"mul", 0x0}, |
518 | | {"mul vl", 0x0}, |
519 | | {NULL, 0}, |
520 | | }; |
521 | | |
522 | | enum aarch64_modifier_kind |
523 | | aarch64_get_operand_modifier (const struct aarch64_name_value_pair *desc) |
524 | 0 | { |
525 | 0 | return desc - aarch64_operand_modifiers; |
526 | 0 | } |
527 | | |
528 | | aarch64_insn |
529 | | aarch64_get_operand_modifier_value (enum aarch64_modifier_kind kind) |
530 | 0 | { |
531 | 0 | return aarch64_operand_modifiers[kind].value; |
532 | 0 | } |
533 | | |
534 | | enum aarch64_modifier_kind |
535 | | aarch64_get_operand_modifier_from_value (aarch64_insn value, |
536 | | bool extend_p) |
537 | 3.03M | { |
538 | 3.03M | if (extend_p) |
539 | 268k | return AARCH64_MOD_UXTB + value; |
540 | 2.76M | else |
541 | 2.76M | return AARCH64_MOD_LSL - value; |
542 | 3.03M | } |
543 | | |
544 | | bool |
545 | | aarch64_extend_operator_p (enum aarch64_modifier_kind kind) |
546 | 138k | { |
547 | 138k | return kind > AARCH64_MOD_LSL && kind <= AARCH64_MOD_SXTX; |
548 | 138k | } |
549 | | |
550 | | static inline bool |
551 | | aarch64_shift_operator_p (enum aarch64_modifier_kind kind) |
552 | 2.69M | { |
553 | 2.69M | return kind >= AARCH64_MOD_ROR && kind <= AARCH64_MOD_LSL; |
554 | 2.69M | } |
555 | | |
556 | | const struct aarch64_name_value_pair aarch64_barrier_options[16] = |
557 | | { |
558 | | { "#0x00", 0x0 }, |
559 | | { "oshld", 0x1 }, |
560 | | { "oshst", 0x2 }, |
561 | | { "osh", 0x3 }, |
562 | | { "#0x04", 0x4 }, |
563 | | { "nshld", 0x5 }, |
564 | | { "nshst", 0x6 }, |
565 | | { "nsh", 0x7 }, |
566 | | { "#0x08", 0x8 }, |
567 | | { "ishld", 0x9 }, |
568 | | { "ishst", 0xa }, |
569 | | { "ish", 0xb }, |
570 | | { "#0x0c", 0xc }, |
571 | | { "ld", 0xd }, |
572 | | { "st", 0xe }, |
573 | | { "sy", 0xf }, |
574 | | }; |
575 | | |
576 | | const struct aarch64_name_value_pair aarch64_barrier_dsb_nxs_options[4] = |
577 | | { /* CRm<3:2> #imm */ |
578 | | { "oshnxs", 16 }, /* 00 16 */ |
579 | | { "nshnxs", 20 }, /* 01 20 */ |
580 | | { "ishnxs", 24 }, /* 10 24 */ |
581 | | { "synxs", 28 }, /* 11 28 */ |
582 | | }; |
583 | | |
584 | | /* Table describing the operands supported by the aliases of the HINT |
585 | | instruction. |
586 | | |
587 | | The name column is the operand that is accepted for the alias. The value |
588 | | column is the hint number of the alias. The list of operands is terminated |
589 | | by NULL in the name column. */ |
590 | | |
591 | | const struct aarch64_name_value_pair aarch64_hint_options[] = |
592 | | { |
593 | | /* BTI. This is also the F_DEFAULT entry for AARCH64_OPND_BTI_TARGET. */ |
594 | | { " ", HINT_ENCODE (HINT_OPD_F_NOPRINT, 0x20) }, |
595 | | { "csync", HINT_OPD_CSYNC }, /* PSB CSYNC. */ |
596 | | { "dsync", HINT_OPD_DSYNC }, /* GCSB DSYNC. */ |
597 | | { "c", HINT_OPD_C }, /* BTI C. */ |
598 | | { "j", HINT_OPD_J }, /* BTI J. */ |
599 | | { "jc", HINT_OPD_JC }, /* BTI JC. */ |
600 | | { NULL, HINT_OPD_NULL }, |
601 | | }; |
602 | | |
603 | | /* op -> op: load = 0 instruction = 1 store = 2 |
604 | | l -> level: 1-3 |
605 | | t -> temporal: temporal (retained) = 0 non-temporal (streaming) = 1 */ |
606 | | #define B(op,l,t) (((op) << 3) | (((l) - 1) << 1) | (t)) |
607 | | const struct aarch64_name_value_pair aarch64_prfops[32] = |
608 | | { |
609 | | { "pldl1keep", B(0, 1, 0) }, |
610 | | { "pldl1strm", B(0, 1, 1) }, |
611 | | { "pldl2keep", B(0, 2, 0) }, |
612 | | { "pldl2strm", B(0, 2, 1) }, |
613 | | { "pldl3keep", B(0, 3, 0) }, |
614 | | { "pldl3strm", B(0, 3, 1) }, |
615 | | { "pldslckeep", B(0, 4, 0) }, |
616 | | { "pldslcstrm", B(0, 4, 1) }, |
617 | | { "plil1keep", B(1, 1, 0) }, |
618 | | { "plil1strm", B(1, 1, 1) }, |
619 | | { "plil2keep", B(1, 2, 0) }, |
620 | | { "plil2strm", B(1, 2, 1) }, |
621 | | { "plil3keep", B(1, 3, 0) }, |
622 | | { "plil3strm", B(1, 3, 1) }, |
623 | | { "plislckeep", B(1, 4, 0) }, |
624 | | { "plislcstrm", B(1, 4, 1) }, |
625 | | { "pstl1keep", B(2, 1, 0) }, |
626 | | { "pstl1strm", B(2, 1, 1) }, |
627 | | { "pstl2keep", B(2, 2, 0) }, |
628 | | { "pstl2strm", B(2, 2, 1) }, |
629 | | { "pstl3keep", B(2, 3, 0) }, |
630 | | { "pstl3strm", B(2, 3, 1) }, |
631 | | { "pstslckeep", B(2, 4, 0) }, |
632 | | { "pstslcstrm", B(2, 4, 1) }, |
633 | | { NULL, 0x18 }, |
634 | | { NULL, 0x19 }, |
635 | | { NULL, 0x1a }, |
636 | | { NULL, 0x1b }, |
637 | | { NULL, 0x1c }, |
638 | | { NULL, 0x1d }, |
639 | | { NULL, 0x1e }, |
640 | | { NULL, 0x1f }, |
641 | | }; |
642 | | #undef B |
643 | | |
644 | | /* Utilities on value constraint. */ |
645 | | |
646 | | static inline bool |
647 | | value_in_range_p (int64_t value, int64_t low, int64_t high) |
648 | 10.3M | { |
649 | 10.3M | return (low <= value) && (value <= high); |
650 | 10.3M | } |
651 | | |
652 | | /* Return true if VALUE is a multiple of ALIGN. */ |
653 | | static inline bool |
654 | | value_aligned_p (int64_t value, int align) |
655 | 6.49M | { |
656 | 6.49M | return (value % align) == 0; |
657 | 6.49M | } |
658 | | |
659 | | /* A signed value fits in a field. */ |
660 | | static inline bool |
661 | | value_fit_signed_field_p (int64_t value, unsigned width) |
662 | 4.67M | { |
663 | 4.67M | assert (width < 32); |
664 | 4.67M | if (width < sizeof (value) * 8) |
665 | 4.67M | { |
666 | 4.67M | int64_t lim = (uint64_t) 1 << (width - 1); |
667 | 4.67M | if (value >= -lim && value < lim) |
668 | 4.67M | return true; |
669 | 4.67M | } |
670 | 0 | return false; |
671 | 4.67M | } |
672 | | |
673 | | /* An unsigned value fits in a field. */ |
674 | | static inline bool |
675 | | value_fit_unsigned_field_p (int64_t value, unsigned width) |
676 | 10.7M | { |
677 | 10.7M | assert (width < 32); |
678 | 10.7M | if (width < sizeof (value) * 8) |
679 | 10.7M | { |
680 | 10.7M | int64_t lim = (uint64_t) 1 << width; |
681 | 10.7M | if (value >= 0 && value < lim) |
682 | 10.7M | return true; |
683 | 10.7M | } |
684 | 0 | return false; |
685 | 10.7M | } |
686 | | |
687 | | /* Return true if OPERAND is SP or WSP. */ |
688 | | bool |
689 | | aarch64_stack_pointer_p (const aarch64_opnd_info *operand) |
690 | 442k | { |
691 | 442k | return ((aarch64_get_operand_class (operand->type) |
692 | 442k | == AARCH64_OPND_CLASS_INT_REG) |
693 | 442k | && operand_maybe_stack_pointer (aarch64_operands + operand->type) |
694 | 442k | && operand->reg.regno == 31); |
695 | 442k | } |
696 | | |
697 | | /* Return 1 if OPERAND is XZR or WZP. */ |
698 | | int |
699 | | aarch64_zero_register_p (const aarch64_opnd_info *operand) |
700 | 0 | { |
701 | 0 | return ((aarch64_get_operand_class (operand->type) |
702 | 0 | == AARCH64_OPND_CLASS_INT_REG) |
703 | 0 | && !operand_maybe_stack_pointer (aarch64_operands + operand->type) |
704 | 0 | && operand->reg.regno == 31); |
705 | 0 | } |
706 | | |
707 | | /* Return true if the operand *OPERAND that has the operand code |
708 | | OPERAND->TYPE and been qualified by OPERAND->QUALIFIER can be also |
709 | | qualified by the qualifier TARGET. */ |
710 | | |
711 | | static inline bool |
712 | | operand_also_qualified_p (const struct aarch64_opnd_info *operand, |
713 | | aarch64_opnd_qualifier_t target) |
714 | 18.1M | { |
715 | 18.1M | switch (operand->qualifier) |
716 | 18.1M | { |
717 | 13.1k | case AARCH64_OPND_QLF_W: |
718 | 13.1k | if (target == AARCH64_OPND_QLF_WSP && aarch64_stack_pointer_p (operand)) |
719 | 579 | return true; |
720 | 12.5k | break; |
721 | 4.60M | case AARCH64_OPND_QLF_X: |
722 | 4.60M | if (target == AARCH64_OPND_QLF_SP && aarch64_stack_pointer_p (operand)) |
723 | 342 | return true; |
724 | 4.60M | break; |
725 | 4.60M | case AARCH64_OPND_QLF_WSP: |
726 | 0 | if (target == AARCH64_OPND_QLF_W |
727 | 0 | && operand_maybe_stack_pointer (aarch64_operands + operand->type)) |
728 | 0 | return true; |
729 | 0 | break; |
730 | 0 | case AARCH64_OPND_QLF_SP: |
731 | 0 | if (target == AARCH64_OPND_QLF_X |
732 | 0 | && operand_maybe_stack_pointer (aarch64_operands + operand->type)) |
733 | 0 | return true; |
734 | 0 | break; |
735 | 13.5M | default: |
736 | 13.5M | break; |
737 | 18.1M | } |
738 | | |
739 | 18.1M | return false; |
740 | 18.1M | } |
741 | | |
742 | | /* Given qualifier sequence list QSEQ_LIST and the known qualifier KNOWN_QLF |
743 | | for operand KNOWN_IDX, return the expected qualifier for operand IDX. |
744 | | |
745 | | Return NIL if more than one expected qualifiers are found. */ |
746 | | |
747 | | aarch64_opnd_qualifier_t |
748 | | aarch64_get_expected_qualifier (const aarch64_opnd_qualifier_seq_t *qseq_list, |
749 | | int idx, |
750 | | const aarch64_opnd_qualifier_t known_qlf, |
751 | | int known_idx) |
752 | 0 | { |
753 | 0 | int i, saved_i; |
754 | | |
755 | | /* Special case. |
756 | | |
757 | | When the known qualifier is NIL, we have to assume that there is only |
758 | | one qualifier sequence in the *QSEQ_LIST and return the corresponding |
759 | | qualifier directly. One scenario is that for instruction |
760 | | PRFM <prfop>, [<Xn|SP>, #:lo12:<symbol>] |
761 | | which has only one possible valid qualifier sequence |
762 | | NIL, S_D |
763 | | the caller may pass NIL in KNOWN_QLF to obtain S_D so that it can |
764 | | determine the correct relocation type (i.e. LDST64_LO12) for PRFM. |
765 | | |
766 | | Because the qualifier NIL has dual roles in the qualifier sequence: |
767 | | it can mean no qualifier for the operand, or the qualifer sequence is |
768 | | not in use (when all qualifiers in the sequence are NILs), we have to |
769 | | handle this special case here. */ |
770 | 0 | if (((enum aarch64_opnd) known_qlf) == AARCH64_OPND_NIL) |
771 | 0 | { |
772 | 0 | assert (((enum aarch64_opnd) qseq_list[0][known_idx]) == AARCH64_OPND_NIL); |
773 | 0 | return qseq_list[0][idx]; |
774 | 0 | } |
775 | | |
776 | 0 | for (i = 0, saved_i = -1; i < AARCH64_MAX_QLF_SEQ_NUM; ++i) |
777 | 0 | { |
778 | 0 | if (qseq_list[i][known_idx] == known_qlf) |
779 | 0 | { |
780 | 0 | if (saved_i != -1) |
781 | | /* More than one sequences are found to have KNOWN_QLF at |
782 | | KNOWN_IDX. */ |
783 | 0 | return AARCH64_OPND_QLF_NIL; |
784 | 0 | saved_i = i; |
785 | 0 | } |
786 | 0 | } |
787 | | |
788 | 0 | return qseq_list[saved_i][idx]; |
789 | 0 | } |
790 | | |
791 | | enum operand_qualifier_kind |
792 | | { |
793 | | OQK_NIL, |
794 | | OQK_OPD_VARIANT, |
795 | | OQK_VALUE_IN_RANGE, |
796 | | OQK_MISC, |
797 | | }; |
798 | | |
799 | | /* Operand qualifier description. */ |
800 | | struct operand_qualifier_data |
801 | | { |
802 | | /* The usage of the three data fields depends on the qualifier kind. */ |
803 | | int data0; |
804 | | int data1; |
805 | | int data2; |
806 | | /* Description. */ |
807 | | const char *desc; |
808 | | /* Kind. */ |
809 | | enum operand_qualifier_kind kind; |
810 | | }; |
811 | | |
812 | | /* Indexed by the operand qualifier enumerators. */ |
813 | | struct operand_qualifier_data aarch64_opnd_qualifiers[] = |
814 | | { |
815 | | {0, 0, 0, "NIL", OQK_NIL}, |
816 | | |
817 | | /* Operand variant qualifiers. |
818 | | First 3 fields: |
819 | | element size, number of elements and common value for encoding. */ |
820 | | |
821 | | {4, 1, 0x0, "w", OQK_OPD_VARIANT}, |
822 | | {8, 1, 0x1, "x", OQK_OPD_VARIANT}, |
823 | | {4, 1, 0x0, "wsp", OQK_OPD_VARIANT}, |
824 | | {8, 1, 0x1, "sp", OQK_OPD_VARIANT}, |
825 | | |
826 | | {1, 1, 0x0, "b", OQK_OPD_VARIANT}, |
827 | | {2, 1, 0x1, "h", OQK_OPD_VARIANT}, |
828 | | {4, 1, 0x2, "s", OQK_OPD_VARIANT}, |
829 | | {8, 1, 0x3, "d", OQK_OPD_VARIANT}, |
830 | | {16, 1, 0x4, "q", OQK_OPD_VARIANT}, |
831 | | {2, 1, 0x0, "2b", OQK_OPD_VARIANT}, |
832 | | {4, 1, 0x0, "4b", OQK_OPD_VARIANT}, |
833 | | {4, 1, 0x0, "2h", OQK_OPD_VARIANT}, |
834 | | |
835 | | {1, 4, 0x0, "4b", OQK_OPD_VARIANT}, |
836 | | {1, 8, 0x0, "8b", OQK_OPD_VARIANT}, |
837 | | {1, 16, 0x1, "16b", OQK_OPD_VARIANT}, |
838 | | {2, 2, 0x0, "2h", OQK_OPD_VARIANT}, |
839 | | {2, 4, 0x2, "4h", OQK_OPD_VARIANT}, |
840 | | {2, 8, 0x3, "8h", OQK_OPD_VARIANT}, |
841 | | {4, 2, 0x4, "2s", OQK_OPD_VARIANT}, |
842 | | {4, 4, 0x5, "4s", OQK_OPD_VARIANT}, |
843 | | {8, 1, 0x6, "1d", OQK_OPD_VARIANT}, |
844 | | {8, 2, 0x7, "2d", OQK_OPD_VARIANT}, |
845 | | {16, 1, 0x8, "1q", OQK_OPD_VARIANT}, |
846 | | |
847 | | {0, 0, 0, "z", OQK_OPD_VARIANT}, |
848 | | {0, 0, 0, "m", OQK_OPD_VARIANT}, |
849 | | |
850 | | /* Qualifier for scaled immediate for Tag granule (stg,st2g,etc). */ |
851 | | {16, 0, 0, "tag", OQK_OPD_VARIANT}, |
852 | | |
853 | | /* Qualifiers constraining the value range. |
854 | | First 3 fields: |
855 | | Lower bound, higher bound, unused. */ |
856 | | |
857 | | {0, 15, 0, "CR", OQK_VALUE_IN_RANGE}, |
858 | | {0, 7, 0, "imm_0_7" , OQK_VALUE_IN_RANGE}, |
859 | | {0, 15, 0, "imm_0_15", OQK_VALUE_IN_RANGE}, |
860 | | {0, 31, 0, "imm_0_31", OQK_VALUE_IN_RANGE}, |
861 | | {0, 63, 0, "imm_0_63", OQK_VALUE_IN_RANGE}, |
862 | | {1, 32, 0, "imm_1_32", OQK_VALUE_IN_RANGE}, |
863 | | {1, 64, 0, "imm_1_64", OQK_VALUE_IN_RANGE}, |
864 | | |
865 | | /* Qualifiers for miscellaneous purpose. |
866 | | First 3 fields: |
867 | | unused, unused and unused. */ |
868 | | |
869 | | {0, 0, 0, "lsl", 0}, |
870 | | {0, 0, 0, "msl", 0}, |
871 | | |
872 | | {0, 0, 0, "retrieving", 0}, |
873 | | }; |
874 | | |
875 | | static inline bool |
876 | | operand_variant_qualifier_p (aarch64_opnd_qualifier_t qualifier) |
877 | 42.6M | { |
878 | 42.6M | return aarch64_opnd_qualifiers[qualifier].kind == OQK_OPD_VARIANT; |
879 | 42.6M | } |
880 | | |
881 | | static inline bool |
882 | | qualifier_value_in_range_constraint_p (aarch64_opnd_qualifier_t qualifier) |
883 | 17.4M | { |
884 | 17.4M | return aarch64_opnd_qualifiers[qualifier].kind == OQK_VALUE_IN_RANGE; |
885 | 17.4M | } |
886 | | |
887 | | const char* |
888 | | aarch64_get_qualifier_name (aarch64_opnd_qualifier_t qualifier) |
889 | 14.0M | { |
890 | 14.0M | return aarch64_opnd_qualifiers[qualifier].desc; |
891 | 14.0M | } |
892 | | |
893 | | /* Given an operand qualifier, return the expected data element size |
894 | | of a qualified operand. */ |
895 | | unsigned char |
896 | | aarch64_get_qualifier_esize (aarch64_opnd_qualifier_t qualifier) |
897 | 30.7M | { |
898 | 30.7M | assert (operand_variant_qualifier_p (qualifier)); |
899 | 30.7M | return aarch64_opnd_qualifiers[qualifier].data0; |
900 | 30.7M | } |
901 | | |
902 | | unsigned char |
903 | | aarch64_get_qualifier_nelem (aarch64_opnd_qualifier_t qualifier) |
904 | 322k | { |
905 | 322k | assert (operand_variant_qualifier_p (qualifier)); |
906 | 322k | return aarch64_opnd_qualifiers[qualifier].data1; |
907 | 322k | } |
908 | | |
909 | | aarch64_insn |
910 | | aarch64_get_qualifier_standard_value (aarch64_opnd_qualifier_t qualifier) |
911 | 11.5M | { |
912 | 11.5M | assert (operand_variant_qualifier_p (qualifier)); |
913 | 11.5M | return aarch64_opnd_qualifiers[qualifier].data2; |
914 | 11.5M | } |
915 | | |
916 | | static int |
917 | | get_lower_bound (aarch64_opnd_qualifier_t qualifier) |
918 | 1.61M | { |
919 | 1.61M | assert (qualifier_value_in_range_constraint_p (qualifier)); |
920 | 1.61M | return aarch64_opnd_qualifiers[qualifier].data0; |
921 | 1.61M | } |
922 | | |
923 | | static int |
924 | | get_upper_bound (aarch64_opnd_qualifier_t qualifier) |
925 | 1.72M | { |
926 | 1.72M | assert (qualifier_value_in_range_constraint_p (qualifier)); |
927 | 1.72M | return aarch64_opnd_qualifiers[qualifier].data1; |
928 | 1.72M | } |
929 | | |
930 | | #ifdef DEBUG_AARCH64 |
931 | | void |
932 | | aarch64_verbose (const char *str, ...) |
933 | | { |
934 | | va_list ap; |
935 | | va_start (ap, str); |
936 | | printf ("#### "); |
937 | | vprintf (str, ap); |
938 | | printf ("\n"); |
939 | | va_end (ap); |
940 | | } |
941 | | |
942 | | static inline void |
943 | | dump_qualifier_sequence (const aarch64_opnd_qualifier_t *qualifier) |
944 | | { |
945 | | int i; |
946 | | printf ("#### \t"); |
947 | | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i, ++qualifier) |
948 | | printf ("%s,", aarch64_get_qualifier_name (*qualifier)); |
949 | | printf ("\n"); |
950 | | } |
951 | | |
952 | | static void |
953 | | dump_match_qualifiers (const struct aarch64_opnd_info *opnd, |
954 | | const aarch64_opnd_qualifier_t *qualifier) |
955 | | { |
956 | | int i; |
957 | | aarch64_opnd_qualifier_t curr[AARCH64_MAX_OPND_NUM]; |
958 | | |
959 | | aarch64_verbose ("dump_match_qualifiers:"); |
960 | | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i) |
961 | | curr[i] = opnd[i].qualifier; |
962 | | dump_qualifier_sequence (curr); |
963 | | aarch64_verbose ("against"); |
964 | | dump_qualifier_sequence (qualifier); |
965 | | } |
966 | | #endif /* DEBUG_AARCH64 */ |
967 | | |
968 | | /* This function checks if the given instruction INSN is a destructive |
969 | | instruction based on the usage of the registers. It does not recognize |
970 | | unary destructive instructions. */ |
971 | | bool |
972 | | aarch64_is_destructive_by_operands (const aarch64_opcode *opcode) |
973 | 376 | { |
974 | 376 | int i = 0; |
975 | 376 | const enum aarch64_opnd *opnds = opcode->operands; |
976 | | |
977 | 376 | if (opnds[0] == AARCH64_OPND_NIL) |
978 | 0 | return false; |
979 | | |
980 | 1.15k | while (opnds[++i] != AARCH64_OPND_NIL) |
981 | 952 | if (opnds[i] == opnds[0]) |
982 | 175 | return true; |
983 | | |
984 | 201 | return false; |
985 | 376 | } |
986 | | |
987 | | /* TODO improve this, we can have an extra field at the runtime to |
988 | | store the number of operands rather than calculating it every time. */ |
989 | | |
990 | | int |
991 | | aarch64_num_of_operands (const aarch64_opcode *opcode) |
992 | 37.0M | { |
993 | 37.0M | int i = 0; |
994 | 37.0M | const enum aarch64_opnd *opnds = opcode->operands; |
995 | 122M | while (opnds[i++] != AARCH64_OPND_NIL) |
996 | 85.6M | ; |
997 | 37.0M | --i; |
998 | 37.0M | assert (i >= 0 && i <= AARCH64_MAX_OPND_NUM); |
999 | 37.0M | return i; |
1000 | 37.0M | } |
1001 | | |
1002 | | /* Find the best matched qualifier sequence in *QUALIFIERS_LIST for INST. |
1003 | | If succeeds, fill the found sequence in *RET, return 1; otherwise return 0. |
1004 | | |
1005 | | Store the smallest number of non-matching qualifiers in *INVALID_COUNT. |
1006 | | This is always 0 if the function succeeds. |
1007 | | |
1008 | | N.B. on the entry, it is very likely that only some operands in *INST |
1009 | | have had their qualifiers been established. |
1010 | | |
1011 | | If STOP_AT is not -1, the function will only try to match |
1012 | | the qualifier sequence for operands before and including the operand |
1013 | | of index STOP_AT; and on success *RET will only be filled with the first |
1014 | | (STOP_AT+1) qualifiers. |
1015 | | |
1016 | | A couple examples of the matching algorithm: |
1017 | | |
1018 | | X,W,NIL should match |
1019 | | X,W,NIL |
1020 | | |
1021 | | NIL,NIL should match |
1022 | | X ,NIL |
1023 | | |
1024 | | Apart from serving the main encoding routine, this can also be called |
1025 | | during or after the operand decoding. */ |
1026 | | |
1027 | | int |
1028 | | aarch64_find_best_match (const aarch64_inst *inst, |
1029 | | const aarch64_opnd_qualifier_seq_t *qualifiers_list, |
1030 | | int stop_at, aarch64_opnd_qualifier_t *ret, |
1031 | | int *invalid_count) |
1032 | 33.8M | { |
1033 | 33.8M | int i, num_opnds, invalid, min_invalid; |
1034 | 33.8M | const aarch64_opnd_qualifier_t *qualifiers; |
1035 | | |
1036 | 33.8M | num_opnds = aarch64_num_of_operands (inst->opcode); |
1037 | 33.8M | if (num_opnds == 0) |
1038 | 15 | { |
1039 | 15 | DEBUG_TRACE ("SUCCEED: no operand"); |
1040 | 15 | *invalid_count = 0; |
1041 | 15 | return 1; |
1042 | 15 | } |
1043 | | |
1044 | 33.8M | if (stop_at < 0 || stop_at >= num_opnds) |
1045 | 30.2M | stop_at = num_opnds - 1; |
1046 | | |
1047 | | /* For each pattern. */ |
1048 | 33.8M | min_invalid = num_opnds; |
1049 | 46.7M | for (i = 0; i < AARCH64_MAX_QLF_SEQ_NUM; ++i, ++qualifiers_list) |
1050 | 46.7M | { |
1051 | 46.7M | int j; |
1052 | 46.7M | qualifiers = *qualifiers_list; |
1053 | | |
1054 | | /* Start as positive. */ |
1055 | 46.7M | invalid = 0; |
1056 | | |
1057 | 46.7M | DEBUG_TRACE ("%d", i); |
1058 | | #ifdef DEBUG_AARCH64 |
1059 | | if (debug_dump) |
1060 | | dump_match_qualifiers (inst->operands, qualifiers); |
1061 | | #endif |
1062 | | |
1063 | | /* The first entry should be taken literally, even if it's an empty |
1064 | | qualifier sequence. (This matters for strict testing.) In other |
1065 | | positions an empty sequence acts as a terminator. */ |
1066 | 46.7M | if (i > 0 && empty_qualifier_sequence_p (qualifiers)) |
1067 | 220k | break; |
1068 | | |
1069 | 157M | for (j = 0; j < num_opnds && j <= stop_at; ++j, ++qualifiers) |
1070 | 111M | { |
1071 | 111M | if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL |
1072 | 111M | && !(inst->opcode->flags & F_STRICT)) |
1073 | 60.0M | { |
1074 | | /* Either the operand does not have qualifier, or the qualifier |
1075 | | for the operand needs to be deduced from the qualifier |
1076 | | sequence. |
1077 | | In the latter case, any constraint checking related with |
1078 | | the obtained qualifier should be done later in |
1079 | | operand_general_constraint_met_p. */ |
1080 | 60.0M | continue; |
1081 | 60.0M | } |
1082 | 51.0M | else if (*qualifiers != inst->operands[j].qualifier) |
1083 | 18.1M | { |
1084 | | /* Unless the target qualifier can also qualify the operand |
1085 | | (which has already had a non-nil qualifier), non-equal |
1086 | | qualifiers are generally un-matched. */ |
1087 | 18.1M | if (operand_also_qualified_p (inst->operands + j, *qualifiers)) |
1088 | 921 | continue; |
1089 | 18.1M | else |
1090 | 18.1M | invalid += 1; |
1091 | 18.1M | } |
1092 | 32.8M | else |
1093 | 32.8M | continue; /* Equal qualifiers are certainly matched. */ |
1094 | 111M | } |
1095 | | |
1096 | 46.5M | if (min_invalid > invalid) |
1097 | 41.7M | min_invalid = invalid; |
1098 | | |
1099 | | /* Qualifiers established. */ |
1100 | 46.5M | if (min_invalid == 0) |
1101 | 33.6M | break; |
1102 | 46.5M | } |
1103 | | |
1104 | 33.8M | *invalid_count = min_invalid; |
1105 | 33.8M | if (min_invalid == 0) |
1106 | 33.6M | { |
1107 | | /* Fill the result in *RET. */ |
1108 | 33.6M | int j; |
1109 | 33.6M | qualifiers = *qualifiers_list; |
1110 | | |
1111 | 33.6M | DEBUG_TRACE ("complete qualifiers using list %d", i); |
1112 | | #ifdef DEBUG_AARCH64 |
1113 | | if (debug_dump) |
1114 | | dump_qualifier_sequence (qualifiers); |
1115 | | #endif |
1116 | | |
1117 | 108M | for (j = 0; j <= stop_at; ++j, ++qualifiers) |
1118 | 74.9M | ret[j] = *qualifiers; |
1119 | 193M | for (; j < AARCH64_MAX_OPND_NUM; ++j) |
1120 | 160M | ret[j] = AARCH64_OPND_QLF_NIL; |
1121 | | |
1122 | 33.6M | DEBUG_TRACE ("SUCCESS"); |
1123 | 33.6M | return 1; |
1124 | 33.6M | } |
1125 | | |
1126 | 220k | DEBUG_TRACE ("FAIL"); |
1127 | 220k | return 0; |
1128 | 33.8M | } |
1129 | | |
1130 | | /* Operand qualifier matching and resolving. |
1131 | | |
1132 | | Return 1 if the operand qualifier(s) in *INST match one of the qualifier |
1133 | | sequences in INST->OPCODE->qualifiers_list; otherwise return 0. |
1134 | | |
1135 | | Store the smallest number of non-matching qualifiers in *INVALID_COUNT. |
1136 | | This is always 0 if the function succeeds. |
1137 | | |
1138 | | if UPDATE_P, update the qualifier(s) in *INST after the matching |
1139 | | succeeds. */ |
1140 | | |
1141 | | static int |
1142 | | match_operands_qualifier (aarch64_inst *inst, bool update_p, |
1143 | | int *invalid_count) |
1144 | 30.2M | { |
1145 | 30.2M | int i; |
1146 | 30.2M | aarch64_opnd_qualifier_seq_t qualifiers; |
1147 | | |
1148 | 30.2M | if (!aarch64_find_best_match (inst, inst->opcode->qualifiers_list, -1, |
1149 | 30.2M | qualifiers, invalid_count)) |
1150 | 106k | { |
1151 | 106k | DEBUG_TRACE ("matching FAIL"); |
1152 | 106k | return 0; |
1153 | 106k | } |
1154 | | |
1155 | | /* Update the qualifiers. */ |
1156 | 30.1M | if (update_p) |
1157 | 96.5M | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i) |
1158 | 96.5M | { |
1159 | 96.5M | if (inst->opcode->operands[i] == AARCH64_OPND_NIL) |
1160 | 30.1M | break; |
1161 | 66.3M | DEBUG_TRACE_IF (inst->operands[i].qualifier != qualifiers[i], |
1162 | 66.3M | "update %s with %s for operand %d", |
1163 | 66.3M | aarch64_get_qualifier_name (inst->operands[i].qualifier), |
1164 | 66.3M | aarch64_get_qualifier_name (qualifiers[i]), i); |
1165 | 66.3M | inst->operands[i].qualifier = qualifiers[i]; |
1166 | 66.3M | } |
1167 | | |
1168 | 30.1M | DEBUG_TRACE ("matching SUCCESS"); |
1169 | 30.1M | return 1; |
1170 | 30.2M | } |
1171 | | |
1172 | | /* Return TRUE if VALUE is a wide constant that can be moved into a general |
1173 | | register by MOVZ. |
1174 | | |
1175 | | IS32 indicates whether value is a 32-bit immediate or not. |
1176 | | If SHIFT_AMOUNT is not NULL, on the return of TRUE, the logical left shift |
1177 | | amount will be returned in *SHIFT_AMOUNT. */ |
1178 | | |
1179 | | bool |
1180 | | aarch64_wide_constant_p (uint64_t value, int is32, unsigned int *shift_amount) |
1181 | 265k | { |
1182 | 265k | int amount; |
1183 | | |
1184 | 265k | DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 ")", value, value); |
1185 | | |
1186 | 265k | if (is32) |
1187 | 94.2k | { |
1188 | | /* Allow all zeros or all ones in top 32-bits, so that |
1189 | | 32-bit constant expressions like ~0x80000000 are |
1190 | | permitted. */ |
1191 | 94.2k | if (value >> 32 != 0 && value >> 32 != 0xffffffff) |
1192 | | /* Immediate out of range. */ |
1193 | 0 | return false; |
1194 | 94.2k | value &= 0xffffffff; |
1195 | 94.2k | } |
1196 | | |
1197 | | /* first, try movz then movn */ |
1198 | 265k | amount = -1; |
1199 | 265k | if ((value & ((uint64_t) 0xffff << 0)) == value) |
1200 | 107k | amount = 0; |
1201 | 157k | else if ((value & ((uint64_t) 0xffff << 16)) == value) |
1202 | 37.6k | amount = 16; |
1203 | 120k | else if (!is32 && (value & ((uint64_t) 0xffff << 32)) == value) |
1204 | 24.2k | amount = 32; |
1205 | 96.0k | else if (!is32 && (value & ((uint64_t) 0xffff << 48)) == value) |
1206 | 14.9k | amount = 48; |
1207 | | |
1208 | 265k | if (amount == -1) |
1209 | 81.1k | { |
1210 | 81.1k | DEBUG_TRACE ("exit false with 0x%" PRIx64 "(%" PRIi64 ")", value, value); |
1211 | 81.1k | return false; |
1212 | 81.1k | } |
1213 | | |
1214 | 184k | if (shift_amount != NULL) |
1215 | 0 | *shift_amount = amount; |
1216 | | |
1217 | 184k | DEBUG_TRACE ("exit true with amount %d", amount); |
1218 | | |
1219 | 184k | return true; |
1220 | 265k | } |
1221 | | |
1222 | | /* Build the accepted values for immediate logical SIMD instructions. |
1223 | | |
1224 | | The standard encodings of the immediate value are: |
1225 | | N imms immr SIMD size R S |
1226 | | 1 ssssss rrrrrr 64 UInt(rrrrrr) UInt(ssssss) |
1227 | | 0 0sssss 0rrrrr 32 UInt(rrrrr) UInt(sssss) |
1228 | | 0 10ssss 00rrrr 16 UInt(rrrr) UInt(ssss) |
1229 | | 0 110sss 000rrr 8 UInt(rrr) UInt(sss) |
1230 | | 0 1110ss 0000rr 4 UInt(rr) UInt(ss) |
1231 | | 0 11110s 00000r 2 UInt(r) UInt(s) |
1232 | | where all-ones value of S is reserved. |
1233 | | |
1234 | | Let's call E the SIMD size. |
1235 | | |
1236 | | The immediate value is: S+1 bits '1' rotated to the right by R. |
1237 | | |
1238 | | The total of valid encodings is 64*63 + 32*31 + ... + 2*1 = 5334 |
1239 | | (remember S != E - 1). */ |
1240 | | |
1241 | 1.07M | #define TOTAL_IMM_NB 5334 |
1242 | | |
1243 | | typedef struct |
1244 | | { |
1245 | | uint64_t imm; |
1246 | | aarch64_insn encoding; |
1247 | | } simd_imm_encoding; |
1248 | | |
1249 | | static simd_imm_encoding simd_immediates[TOTAL_IMM_NB]; |
1250 | | |
1251 | | static int |
1252 | | simd_imm_encoding_cmp(const void *i1, const void *i2) |
1253 | 12.4M | { |
1254 | 12.4M | const simd_imm_encoding *imm1 = (const simd_imm_encoding *)i1; |
1255 | 12.4M | const simd_imm_encoding *imm2 = (const simd_imm_encoding *)i2; |
1256 | | |
1257 | 12.4M | if (imm1->imm < imm2->imm) |
1258 | 6.31M | return -1; |
1259 | 6.13M | if (imm1->imm > imm2->imm) |
1260 | 5.05M | return +1; |
1261 | 1.07M | return 0; |
1262 | 6.13M | } |
1263 | | |
1264 | | /* immediate bitfield standard encoding |
1265 | | imm13<12> imm13<5:0> imm13<11:6> SIMD size R S |
1266 | | 1 ssssss rrrrrr 64 rrrrrr ssssss |
1267 | | 0 0sssss 0rrrrr 32 rrrrr sssss |
1268 | | 0 10ssss 00rrrr 16 rrrr ssss |
1269 | | 0 110sss 000rrr 8 rrr sss |
1270 | | 0 1110ss 0000rr 4 rr ss |
1271 | | 0 11110s 00000r 2 r s */ |
1272 | | static inline int |
1273 | | encode_immediate_bitfield (int is64, uint32_t s, uint32_t r) |
1274 | 10.6k | { |
1275 | 10.6k | return (is64 << 12) | (r << 6) | s; |
1276 | 10.6k | } |
1277 | | |
1278 | | static void |
1279 | | build_immediate_table (void) |
1280 | 2 | { |
1281 | 2 | uint32_t log_e, e, s, r, s_mask; |
1282 | 2 | uint64_t mask, imm; |
1283 | 2 | int nb_imms; |
1284 | 2 | int is64; |
1285 | | |
1286 | 2 | nb_imms = 0; |
1287 | 14 | for (log_e = 1; log_e <= 6; log_e++) |
1288 | 12 | { |
1289 | | /* Get element size. */ |
1290 | 12 | e = 1u << log_e; |
1291 | 12 | if (log_e == 6) |
1292 | 2 | { |
1293 | 2 | is64 = 1; |
1294 | 2 | mask = 0xffffffffffffffffull; |
1295 | 2 | s_mask = 0; |
1296 | 2 | } |
1297 | 10 | else |
1298 | 10 | { |
1299 | 10 | is64 = 0; |
1300 | 10 | mask = (1ull << e) - 1; |
1301 | | /* log_e s_mask |
1302 | | 1 ((1 << 4) - 1) << 2 = 111100 |
1303 | | 2 ((1 << 3) - 1) << 3 = 111000 |
1304 | | 3 ((1 << 2) - 1) << 4 = 110000 |
1305 | | 4 ((1 << 1) - 1) << 5 = 100000 |
1306 | | 5 ((1 << 0) - 1) << 6 = 000000 */ |
1307 | 10 | s_mask = ((1u << (5 - log_e)) - 1) << (log_e + 1); |
1308 | 10 | } |
1309 | 252 | for (s = 0; s < e - 1; s++) |
1310 | 10.9k | for (r = 0; r < e; r++) |
1311 | 10.6k | { |
1312 | | /* s+1 consecutive bits to 1 (s < 63) */ |
1313 | 10.6k | imm = (1ull << (s + 1)) - 1; |
1314 | | /* rotate right by r */ |
1315 | 10.6k | if (r != 0) |
1316 | 10.4k | imm = (imm >> r) | ((imm << (e - r)) & mask); |
1317 | | /* replicate the constant depending on SIMD size */ |
1318 | 10.6k | switch (log_e) |
1319 | 10.6k | { |
1320 | 4 | case 1: imm = (imm << 2) | imm; |
1321 | | /* Fall through. */ |
1322 | 28 | case 2: imm = (imm << 4) | imm; |
1323 | | /* Fall through. */ |
1324 | 140 | case 3: imm = (imm << 8) | imm; |
1325 | | /* Fall through. */ |
1326 | 620 | case 4: imm = (imm << 16) | imm; |
1327 | | /* Fall through. */ |
1328 | 2.60k | case 5: imm = (imm << 32) | imm; |
1329 | | /* Fall through. */ |
1330 | 10.6k | case 6: break; |
1331 | 0 | default: abort (); |
1332 | 10.6k | } |
1333 | 10.6k | simd_immediates[nb_imms].imm = imm; |
1334 | 10.6k | simd_immediates[nb_imms].encoding = |
1335 | 10.6k | encode_immediate_bitfield(is64, s | s_mask, r); |
1336 | 10.6k | nb_imms++; |
1337 | 10.6k | } |
1338 | 12 | } |
1339 | 2 | assert (nb_imms == TOTAL_IMM_NB); |
1340 | 2 | qsort(simd_immediates, nb_imms, |
1341 | 2 | sizeof(simd_immediates[0]), simd_imm_encoding_cmp); |
1342 | 2 | } |
1343 | | |
1344 | | /* Return TRUE if VALUE is a valid logical immediate, i.e. bitmask, that can |
1345 | | be accepted by logical (immediate) instructions |
1346 | | e.g. ORR <Xd|SP>, <Xn>, #<imm>. |
1347 | | |
1348 | | ESIZE is the number of bytes in the decoded immediate value. |
1349 | | If ENCODING is not NULL, on the return of TRUE, the standard encoding for |
1350 | | VALUE will be returned in *ENCODING. */ |
1351 | | |
1352 | | bool |
1353 | | aarch64_logical_immediate_p (uint64_t value, int esize, aarch64_insn *encoding) |
1354 | 1.07M | { |
1355 | 1.07M | simd_imm_encoding imm_enc; |
1356 | 1.07M | const simd_imm_encoding *imm_encoding; |
1357 | 1.07M | static bool initialized = false; |
1358 | 1.07M | uint64_t upper; |
1359 | 1.07M | int i; |
1360 | | |
1361 | 1.07M | DEBUG_TRACE ("enter with 0x%" PRIx64 "(%" PRIi64 "), esize: %d", value, |
1362 | 1.07M | value, esize); |
1363 | | |
1364 | 1.07M | if (!initialized) |
1365 | 2 | { |
1366 | 2 | build_immediate_table (); |
1367 | 2 | initialized = true; |
1368 | 2 | } |
1369 | | |
1370 | | /* Allow all zeros or all ones in top bits, so that |
1371 | | constant expressions like ~1 are permitted. */ |
1372 | 1.07M | upper = (uint64_t) -1 << (esize * 4) << (esize * 4); |
1373 | 1.07M | if ((value & ~upper) != value && (value | upper) != value) |
1374 | 0 | return false; |
1375 | | |
1376 | | /* Replicate to a full 64-bit value. */ |
1377 | 1.07M | value &= ~upper; |
1378 | 1.87M | for (i = esize * 8; i < 64; i *= 2) |
1379 | 797k | value |= (value << i); |
1380 | | |
1381 | 1.07M | imm_enc.imm = value; |
1382 | 1.07M | imm_encoding = (const simd_imm_encoding *) |
1383 | 1.07M | bsearch(&imm_enc, simd_immediates, TOTAL_IMM_NB, |
1384 | 1.07M | sizeof(simd_immediates[0]), simd_imm_encoding_cmp); |
1385 | 1.07M | if (imm_encoding == NULL) |
1386 | 0 | { |
1387 | 0 | DEBUG_TRACE ("exit with false"); |
1388 | 0 | return false; |
1389 | 0 | } |
1390 | 1.07M | if (encoding != NULL) |
1391 | 0 | *encoding = imm_encoding->encoding; |
1392 | 1.07M | DEBUG_TRACE ("exit with true"); |
1393 | 1.07M | return true; |
1394 | 1.07M | } |
1395 | | |
1396 | | /* If 64-bit immediate IMM is in the format of |
1397 | | "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhh", |
1398 | | where a, b, c, d, e, f, g and h are independently 0 or 1, return an integer |
1399 | | of value "abcdefgh". Otherwise return -1. */ |
1400 | | int |
1401 | | aarch64_shrink_expanded_imm8 (uint64_t imm) |
1402 | 1.66k | { |
1403 | 1.66k | int i, ret; |
1404 | 1.66k | uint32_t byte; |
1405 | | |
1406 | 1.66k | ret = 0; |
1407 | 14.9k | for (i = 0; i < 8; i++) |
1408 | 13.3k | { |
1409 | 13.3k | byte = (imm >> (8 * i)) & 0xff; |
1410 | 13.3k | if (byte == 0xff) |
1411 | 9.04k | ret |= 1 << i; |
1412 | 4.27k | else if (byte != 0x00) |
1413 | 0 | return -1; |
1414 | 13.3k | } |
1415 | 1.66k | return ret; |
1416 | 1.66k | } |
1417 | | |
1418 | | /* Utility inline functions for operand_general_constraint_met_p. */ |
1419 | | |
1420 | | static inline void |
1421 | | set_error (aarch64_operand_error *mismatch_detail, |
1422 | | enum aarch64_operand_error_kind kind, int idx, |
1423 | | const char* error) |
1424 | 0 | { |
1425 | 0 | if (mismatch_detail == NULL) |
1426 | 0 | return; |
1427 | 0 | mismatch_detail->kind = kind; |
1428 | 0 | mismatch_detail->index = idx; |
1429 | 0 | mismatch_detail->error = error; |
1430 | 0 | } |
1431 | | |
1432 | | static inline void |
1433 | | set_syntax_error (aarch64_operand_error *mismatch_detail, int idx, |
1434 | | const char* error) |
1435 | 44.8k | { |
1436 | 44.8k | if (mismatch_detail == NULL) |
1437 | 44.8k | return; |
1438 | 0 | set_error (mismatch_detail, AARCH64_OPDE_SYNTAX_ERROR, idx, error); |
1439 | 0 | } |
1440 | | |
1441 | | static inline void |
1442 | | set_invalid_regno_error (aarch64_operand_error *mismatch_detail, int idx, |
1443 | | const char *prefix, int lower_bound, int upper_bound) |
1444 | 0 | { |
1445 | 0 | if (mismatch_detail == NULL) |
1446 | 0 | return; |
1447 | 0 | set_error (mismatch_detail, AARCH64_OPDE_INVALID_REGNO, idx, NULL); |
1448 | 0 | mismatch_detail->data[0].s = prefix; |
1449 | 0 | mismatch_detail->data[1].i = lower_bound; |
1450 | 0 | mismatch_detail->data[2].i = upper_bound; |
1451 | 0 | } |
1452 | | |
1453 | | static inline void |
1454 | | set_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1455 | | int idx, int lower_bound, int upper_bound, |
1456 | | const char* error) |
1457 | 0 | { |
1458 | 0 | if (mismatch_detail == NULL) |
1459 | 0 | return; |
1460 | 0 | set_error (mismatch_detail, AARCH64_OPDE_OUT_OF_RANGE, idx, error); |
1461 | 0 | mismatch_detail->data[0].i = lower_bound; |
1462 | 0 | mismatch_detail->data[1].i = upper_bound; |
1463 | 0 | } |
1464 | | |
1465 | | static inline void |
1466 | | set_imm_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1467 | | int idx, int lower_bound, int upper_bound) |
1468 | 144k | { |
1469 | 144k | if (mismatch_detail == NULL) |
1470 | 144k | return; |
1471 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1472 | 0 | _("immediate value")); |
1473 | 0 | } |
1474 | | |
1475 | | static inline void |
1476 | | set_offset_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1477 | | int idx, int lower_bound, int upper_bound) |
1478 | 0 | { |
1479 | 0 | if (mismatch_detail == NULL) |
1480 | 0 | return; |
1481 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1482 | 0 | _("immediate offset")); |
1483 | 0 | } |
1484 | | |
1485 | | static inline void |
1486 | | set_regno_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1487 | | int idx, int lower_bound, int upper_bound) |
1488 | 0 | { |
1489 | 0 | if (mismatch_detail == NULL) |
1490 | 0 | return; |
1491 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1492 | 0 | _("register number")); |
1493 | 0 | } |
1494 | | |
1495 | | static inline void |
1496 | | set_elem_idx_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1497 | | int idx, int lower_bound, int upper_bound) |
1498 | 1.32k | { |
1499 | 1.32k | if (mismatch_detail == NULL) |
1500 | 1.32k | return; |
1501 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1502 | 0 | _("register element index")); |
1503 | 0 | } |
1504 | | |
1505 | | static inline void |
1506 | | set_sft_amount_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1507 | | int idx, int lower_bound, int upper_bound) |
1508 | 309k | { |
1509 | 309k | if (mismatch_detail == NULL) |
1510 | 309k | return; |
1511 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1512 | 0 | _("shift amount")); |
1513 | 0 | } |
1514 | | |
1515 | | /* Report that the MUL modifier in operand IDX should be in the range |
1516 | | [LOWER_BOUND, UPPER_BOUND]. */ |
1517 | | static inline void |
1518 | | set_multiplier_out_of_range_error (aarch64_operand_error *mismatch_detail, |
1519 | | int idx, int lower_bound, int upper_bound) |
1520 | 0 | { |
1521 | 0 | if (mismatch_detail == NULL) |
1522 | 0 | return; |
1523 | 0 | set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound, |
1524 | 0 | _("multiplier")); |
1525 | 0 | } |
1526 | | |
1527 | | static inline void |
1528 | | set_unaligned_error (aarch64_operand_error *mismatch_detail, int idx, |
1529 | | int alignment) |
1530 | 0 | { |
1531 | 0 | if (mismatch_detail == NULL) |
1532 | 0 | return; |
1533 | 0 | set_error (mismatch_detail, AARCH64_OPDE_UNALIGNED, idx, NULL); |
1534 | 0 | mismatch_detail->data[0].i = alignment; |
1535 | 0 | } |
1536 | | |
1537 | | static inline void |
1538 | | set_reg_list_length_error (aarch64_operand_error *mismatch_detail, int idx, |
1539 | | int expected_num) |
1540 | 2.80k | { |
1541 | 2.80k | if (mismatch_detail == NULL) |
1542 | 2.80k | return; |
1543 | 0 | set_error (mismatch_detail, AARCH64_OPDE_REG_LIST_LENGTH, idx, NULL); |
1544 | 0 | mismatch_detail->data[0].i = 1 << expected_num; |
1545 | 0 | } |
1546 | | |
1547 | | static inline void |
1548 | | set_reg_list_stride_error (aarch64_operand_error *mismatch_detail, int idx, |
1549 | | int expected_num) |
1550 | 0 | { |
1551 | 0 | if (mismatch_detail == NULL) |
1552 | 0 | return; |
1553 | 0 | set_error (mismatch_detail, AARCH64_OPDE_REG_LIST_STRIDE, idx, NULL); |
1554 | 0 | mismatch_detail->data[0].i = 1 << expected_num; |
1555 | 0 | } |
1556 | | |
1557 | | static inline void |
1558 | | set_invalid_vg_size (aarch64_operand_error *mismatch_detail, |
1559 | | int idx, int expected) |
1560 | 0 | { |
1561 | 0 | if (mismatch_detail == NULL) |
1562 | 0 | return; |
1563 | 0 | set_error (mismatch_detail, AARCH64_OPDE_INVALID_VG_SIZE, idx, NULL); |
1564 | 0 | mismatch_detail->data[0].i = expected; |
1565 | 0 | } |
1566 | | |
1567 | | static inline void |
1568 | | set_other_error (aarch64_operand_error *mismatch_detail, int idx, |
1569 | | const char* error) |
1570 | 91.2k | { |
1571 | 91.2k | if (mismatch_detail == NULL) |
1572 | 91.2k | return; |
1573 | 0 | set_error (mismatch_detail, AARCH64_OPDE_OTHER_ERROR, idx, error); |
1574 | 0 | } |
1575 | | |
1576 | | /* Check that indexed register operand OPND has a register in the range |
1577 | | [MIN_REGNO, MAX_REGNO] and an index in the range [MIN_INDEX, MAX_INDEX]. |
1578 | | PREFIX is the register prefix, such as "z" for SVE vector registers. */ |
1579 | | |
1580 | | static bool |
1581 | | check_reglane (const aarch64_opnd_info *opnd, |
1582 | | aarch64_operand_error *mismatch_detail, int idx, |
1583 | | const char *prefix, int min_regno, int max_regno, |
1584 | | int min_index, int max_index) |
1585 | 232k | { |
1586 | 232k | if (!value_in_range_p (opnd->reglane.regno, min_regno, max_regno)) |
1587 | 0 | { |
1588 | 0 | set_invalid_regno_error (mismatch_detail, idx, prefix, min_regno, |
1589 | 0 | max_regno); |
1590 | 0 | return false; |
1591 | 0 | } |
1592 | 232k | if (!value_in_range_p (opnd->reglane.index, min_index, max_index)) |
1593 | 0 | { |
1594 | 0 | set_elem_idx_out_of_range_error (mismatch_detail, idx, min_index, |
1595 | 0 | max_index); |
1596 | 0 | return false; |
1597 | 0 | } |
1598 | 232k | return true; |
1599 | 232k | } |
1600 | | |
1601 | | /* Check that register list operand OPND has NUM_REGS registers and a |
1602 | | register stride of STRIDE. */ |
1603 | | |
1604 | | static bool |
1605 | | check_reglist (const aarch64_opnd_info *opnd, |
1606 | | aarch64_operand_error *mismatch_detail, int idx, |
1607 | | int num_regs, int stride) |
1608 | 1.34M | { |
1609 | 1.34M | if (opnd->reglist.num_regs != num_regs) |
1610 | 2.80k | { |
1611 | 2.80k | set_reg_list_length_error (mismatch_detail, idx, num_regs); |
1612 | 2.80k | return false; |
1613 | 2.80k | } |
1614 | 1.33M | if (opnd->reglist.stride != stride) |
1615 | 0 | { |
1616 | 0 | set_reg_list_stride_error (mismatch_detail, idx, stride); |
1617 | 0 | return false; |
1618 | 0 | } |
1619 | 1.33M | return true; |
1620 | 1.33M | } |
1621 | | |
1622 | | typedef struct |
1623 | | { |
1624 | | int64_t min; |
1625 | | int64_t max; |
1626 | | } imm_range_t; |
1627 | | |
1628 | | static imm_range_t |
1629 | | imm_range_min_max (unsigned size, bool signed_rng) |
1630 | 0 | { |
1631 | 0 | assert (size < 63); |
1632 | 0 | imm_range_t r; |
1633 | 0 | if (signed_rng) |
1634 | 0 | { |
1635 | 0 | r.max = (((int64_t) 0x1) << (size - 1)) - 1; |
1636 | 0 | r.min = - r.max - 1; |
1637 | 0 | } |
1638 | 0 | else |
1639 | 0 | { |
1640 | 0 | r.max = (((int64_t) 0x1) << size) - 1; |
1641 | 0 | r.min = 0; |
1642 | 0 | } |
1643 | 0 | return r; |
1644 | 0 | } |
1645 | | |
1646 | | /* Check that an immediate value is in the range provided by the |
1647 | | operand type. */ |
1648 | | static bool |
1649 | | check_immediate_out_of_range (int64_t imm, |
1650 | | enum aarch64_opnd type, |
1651 | | aarch64_operand_error *mismatch_detail, |
1652 | | int idx) |
1653 | 4.62M | { |
1654 | 4.62M | const aarch64_operand *operand = get_operand_from_code (type); |
1655 | 4.62M | uint8_t size = get_operand_fields_width (operand); |
1656 | 4.62M | bool unsigned_imm = operand_need_unsigned_offset (operand); |
1657 | 4.62M | bool (*value_fit_field) (int64_t, unsigned) |
1658 | 4.62M | = (unsigned_imm |
1659 | 4.62M | ? value_fit_unsigned_field_p |
1660 | 4.62M | : value_fit_signed_field_p); |
1661 | | |
1662 | 4.62M | if (!value_fit_field (imm, size)) |
1663 | 0 | { |
1664 | 0 | imm_range_t rng = imm_range_min_max (size, !unsigned_imm); |
1665 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, rng.min, rng.max); |
1666 | 0 | return false; |
1667 | 0 | } |
1668 | 4.62M | return true; |
1669 | 4.62M | } |
1670 | | |
1671 | | /* Check that indexed ZA operand OPND has: |
1672 | | |
1673 | | - a selection register in the range [MIN_WREG, MIN_WREG + 3] |
1674 | | |
1675 | | - RANGE_SIZE consecutive immediate offsets. |
1676 | | |
1677 | | - an initial immediate offset that is a multiple of RANGE_SIZE |
1678 | | in the range [0, MAX_VALUE * RANGE_SIZE] |
1679 | | |
1680 | | - a vector group size of GROUP_SIZE. |
1681 | | |
1682 | | - STATUS_VG for cases where VGx2 or VGx4 is mandatory. */ |
1683 | | static bool |
1684 | | check_za_access (const aarch64_opnd_info *opnd, |
1685 | | aarch64_operand_error *mismatch_detail, int idx, |
1686 | | int min_wreg, int max_value, unsigned int range_size, |
1687 | | int group_size, bool status_vg) |
1688 | 432k | { |
1689 | 432k | if (!value_in_range_p (opnd->indexed_za.index.regno, min_wreg, min_wreg + 3)) |
1690 | 0 | { |
1691 | 0 | if (min_wreg == 12) |
1692 | 0 | set_other_error (mismatch_detail, idx, |
1693 | 0 | _("expected a selection register in the" |
1694 | 0 | " range w12-w15")); |
1695 | 0 | else if (min_wreg == 8) |
1696 | 0 | set_other_error (mismatch_detail, idx, |
1697 | 0 | _("expected a selection register in the" |
1698 | 0 | " range w8-w11")); |
1699 | 0 | else |
1700 | 0 | abort (); |
1701 | 0 | return false; |
1702 | 0 | } |
1703 | | |
1704 | 432k | int max_index = max_value * range_size; |
1705 | 432k | if (!value_in_range_p (opnd->indexed_za.index.imm, 0, max_index)) |
1706 | 0 | { |
1707 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, 0, max_index); |
1708 | 0 | return false; |
1709 | 0 | } |
1710 | | |
1711 | 432k | if ((opnd->indexed_za.index.imm % range_size) != 0) |
1712 | 0 | { |
1713 | 0 | assert (range_size == 2 || range_size == 4); |
1714 | 0 | set_other_error (mismatch_detail, idx, |
1715 | 0 | range_size == 2 |
1716 | 0 | ? _("starting offset is not a multiple of 2") |
1717 | 0 | : _("starting offset is not a multiple of 4")); |
1718 | 0 | return false; |
1719 | 0 | } |
1720 | | |
1721 | 432k | if (opnd->indexed_za.index.countm1 != range_size - 1) |
1722 | 0 | { |
1723 | 0 | if (range_size == 1) |
1724 | 0 | set_other_error (mismatch_detail, idx, |
1725 | 0 | _("expected a single offset rather than" |
1726 | 0 | " a range")); |
1727 | 0 | else if (range_size == 2) |
1728 | 0 | set_other_error (mismatch_detail, idx, |
1729 | 0 | _("expected a range of two offsets")); |
1730 | 0 | else if (range_size == 4) |
1731 | 0 | set_other_error (mismatch_detail, idx, |
1732 | 0 | _("expected a range of four offsets")); |
1733 | 0 | else |
1734 | 0 | abort (); |
1735 | 0 | return false; |
1736 | 0 | } |
1737 | | |
1738 | | /* The vector group specifier is optional in assembly code. */ |
1739 | 432k | if (opnd->indexed_za.group_size != group_size |
1740 | 432k | && (status_vg || opnd->indexed_za.group_size != 0 )) |
1741 | 0 | { |
1742 | 0 | set_invalid_vg_size (mismatch_detail, idx, group_size); |
1743 | 0 | return false; |
1744 | 0 | } |
1745 | | |
1746 | 432k | return true; |
1747 | 432k | } |
1748 | | |
1749 | | /* Given a load/store operation, calculate the size of transferred data via a |
1750 | | cumulative sum of qualifier sizes preceding the address operand in the |
1751 | | OPNDS operand list argument. */ |
1752 | | int |
1753 | | calc_ldst_datasize (const aarch64_opnd_info *opnds) |
1754 | 19.8k | { |
1755 | 19.8k | unsigned num_bytes = 0; /* total number of bytes transferred. */ |
1756 | 19.8k | enum aarch64_operand_class opnd_class; |
1757 | 19.8k | enum aarch64_opnd type; |
1758 | | |
1759 | 58.5k | for (int i = 0; i < AARCH64_MAX_OPND_NUM; i++) |
1760 | 58.5k | { |
1761 | 58.5k | type = opnds[i].type; |
1762 | 58.5k | opnd_class = aarch64_operands[type].op_class; |
1763 | 58.5k | if (opnd_class == AARCH64_OPND_CLASS_ADDRESS) |
1764 | 19.8k | break; |
1765 | 38.7k | num_bytes += aarch64_get_qualifier_esize (opnds[i].qualifier); |
1766 | 38.7k | } |
1767 | 19.8k | return num_bytes; |
1768 | 19.8k | } |
1769 | | |
1770 | | |
1771 | | /* General constraint checking based on operand code. |
1772 | | |
1773 | | Return 1 if OPNDS[IDX] meets the general constraint of operand code TYPE |
1774 | | as the IDXth operand of opcode OPCODE. Otherwise return 0. |
1775 | | |
1776 | | This function has to be called after the qualifiers for all operands |
1777 | | have been resolved. |
1778 | | |
1779 | | Mismatching error message is returned in *MISMATCH_DETAIL upon request, |
1780 | | i.e. when MISMATCH_DETAIL is non-NULL. This avoids the generation |
1781 | | of error message during the disassembling where error message is not |
1782 | | wanted. We avoid the dynamic construction of strings of error messages |
1783 | | here (i.e. in libopcodes), as it is costly and complicated; instead, we |
1784 | | use a combination of error code, static string and some integer data to |
1785 | | represent an error. */ |
1786 | | |
1787 | | static bool |
1788 | | operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx, |
1789 | | enum aarch64_opnd type, |
1790 | | const aarch64_opcode *opcode, |
1791 | | aarch64_operand_error *mismatch_detail) |
1792 | 66.1M | { |
1793 | 66.1M | unsigned num, modifiers, shift; |
1794 | 66.1M | unsigned char size; |
1795 | 66.1M | int64_t imm, min_value, max_value; |
1796 | 66.1M | uint64_t uvalue, mask; |
1797 | 66.1M | const aarch64_opnd_info *opnd = opnds + idx; |
1798 | 66.1M | aarch64_opnd_qualifier_t qualifier = opnd->qualifier; |
1799 | 66.1M | int i; |
1800 | | |
1801 | 66.1M | assert (opcode->operands[idx] == opnd->type && opnd->type == type); |
1802 | | |
1803 | 66.1M | switch (aarch64_operands[type].op_class) |
1804 | 66.1M | { |
1805 | 21.4M | case AARCH64_OPND_CLASS_INT_REG: |
1806 | | /* Check for pair of xzr registers. */ |
1807 | 21.4M | if (type == AARCH64_OPND_PAIRREG_OR_XZR |
1808 | 21.4M | && opnds[idx - 1].reg.regno == 0x1f) |
1809 | 1.39k | { |
1810 | 1.39k | if (opnds[idx].reg.regno != 0x1f) |
1811 | 0 | { |
1812 | 0 | set_syntax_error (mismatch_detail, idx - 1, |
1813 | 0 | _("second reg in pair should be xzr if first is" |
1814 | 0 | " xzr")); |
1815 | 0 | return false; |
1816 | 0 | } |
1817 | 1.39k | } |
1818 | | /* Check pair reg constraints for instructions taking a pair of |
1819 | | consecutively-numbered general-purpose registers. */ |
1820 | 21.4M | else if (type == AARCH64_OPND_PAIRREG |
1821 | 21.4M | || type == AARCH64_OPND_PAIRREG_OR_XZR) |
1822 | 64.0k | { |
1823 | 64.0k | assert (idx == 1 || idx == 2 || idx == 3 || idx == 5); |
1824 | 64.0k | if (opnds[idx - 1].reg.regno % 2 != 0) |
1825 | 44.8k | { |
1826 | 44.8k | set_syntax_error (mismatch_detail, idx - 1, |
1827 | 44.8k | _("reg pair must start from even reg")); |
1828 | 44.8k | return false; |
1829 | 44.8k | } |
1830 | 19.1k | if (opnds[idx].reg.regno != opnds[idx - 1].reg.regno + 1) |
1831 | 0 | { |
1832 | 0 | set_syntax_error (mismatch_detail, idx, |
1833 | 0 | _("reg pair must be contiguous")); |
1834 | 0 | return false; |
1835 | 0 | } |
1836 | 19.1k | break; |
1837 | 19.1k | } |
1838 | | |
1839 | | /* <Xt> may be optional in some IC and TLBI instructions. */ |
1840 | 21.3M | if (type == AARCH64_OPND_Rt_SYS) |
1841 | 240 | { |
1842 | 240 | assert (idx == 1 && (aarch64_get_operand_class (opnds[0].type) |
1843 | 240 | == AARCH64_OPND_CLASS_SYSTEM)); |
1844 | 240 | if (opnds[1].present |
1845 | 240 | && !aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op)) |
1846 | 0 | { |
1847 | 0 | set_other_error (mismatch_detail, idx, _("extraneous register")); |
1848 | 0 | return false; |
1849 | 0 | } |
1850 | 240 | if (!opnds[1].present |
1851 | 240 | && aarch64_sys_ins_reg_has_xt (opnds[0].sysins_op)) |
1852 | 0 | { |
1853 | 0 | set_other_error (mismatch_detail, idx, _("missing register")); |
1854 | 0 | return false; |
1855 | 0 | } |
1856 | 240 | } |
1857 | 21.3M | switch (qualifier) |
1858 | 21.3M | { |
1859 | 6.45k | case AARCH64_OPND_QLF_WSP: |
1860 | 15.4k | case AARCH64_OPND_QLF_SP: |
1861 | 15.4k | if (!aarch64_stack_pointer_p (opnd)) |
1862 | 8.24k | { |
1863 | 8.24k | set_other_error (mismatch_detail, idx, |
1864 | 8.24k | _("stack pointer register expected")); |
1865 | 8.24k | return false; |
1866 | 8.24k | } |
1867 | 7.21k | break; |
1868 | 21.3M | default: |
1869 | 21.3M | break; |
1870 | 21.3M | } |
1871 | 21.3M | break; |
1872 | | |
1873 | 21.3M | case AARCH64_OPND_CLASS_SVE_REG: |
1874 | 5.51M | switch (type) |
1875 | 5.51M | { |
1876 | 10.8k | case AARCH64_OPND_SVE_Zm3_INDEX: |
1877 | 22.1k | case AARCH64_OPND_SVE_Zm3_22_INDEX: |
1878 | 22.5k | case AARCH64_OPND_SVE_Zm3_19_INDEX: |
1879 | 31.3k | case AARCH64_OPND_SVE_Zm3_11_INDEX: |
1880 | 38.1k | case AARCH64_OPND_SVE_Zm3_10_INDEX: |
1881 | 65.7k | case AARCH64_OPND_SVE_Zm4_11_INDEX: |
1882 | 79.5k | case AARCH64_OPND_SVE_Zm4_INDEX: |
1883 | 79.5k | size = get_operand_fields_width (get_operand_from_code (type)); |
1884 | 79.5k | shift = get_operand_specific_data (&aarch64_operands[type]); |
1885 | 79.5k | if (!check_reglane (opnd, mismatch_detail, idx, |
1886 | 79.5k | "z", 0, (1 << shift) - 1, |
1887 | 79.5k | 0, (1u << (size - shift)) - 1)) |
1888 | 0 | return false; |
1889 | 79.5k | break; |
1890 | | |
1891 | 79.5k | case AARCH64_OPND_SVE_Zm1_23_INDEX: |
1892 | 184 | size = get_operand_fields_width (get_operand_from_code (type)); |
1893 | 184 | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31, 0, 1)) |
1894 | 0 | return 0; |
1895 | 184 | break; |
1896 | | |
1897 | 2.30k | case AARCH64_OPND_SVE_Zm2_22_INDEX: |
1898 | 2.30k | size = get_operand_fields_width (get_operand_from_code (type)); |
1899 | 2.30k | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31, 0, 3)) |
1900 | 0 | return 0; |
1901 | 2.30k | break; |
1902 | | |
1903 | 2.63k | case AARCH64_OPND_SVE_Zn_INDEX: |
1904 | 2.63k | size = aarch64_get_qualifier_esize (opnd->qualifier); |
1905 | 2.63k | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31, |
1906 | 2.63k | 0, 64 / size - 1)) |
1907 | 0 | return false; |
1908 | 2.63k | break; |
1909 | | |
1910 | 2.63k | case AARCH64_OPND_SVE_Zn_5_INDEX: |
1911 | 155 | size = aarch64_get_qualifier_esize (opnd->qualifier); |
1912 | 155 | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31, |
1913 | 155 | 0, 16 / size - 1)) |
1914 | 0 | return false; |
1915 | 155 | break; |
1916 | | |
1917 | 155 | case AARCH64_OPND_SME_PNn3_INDEX1: |
1918 | 111 | case AARCH64_OPND_SME_PNn3_INDEX2: |
1919 | 111 | size = get_operand_field_width (get_operand_from_code (type), 1); |
1920 | 111 | if (!check_reglane (opnd, mismatch_detail, idx, "pn", 8, 15, |
1921 | 111 | 0, (1 << size) - 1)) |
1922 | 0 | return false; |
1923 | 111 | break; |
1924 | | |
1925 | 728 | case AARCH64_OPND_SVE_Zm3_12_INDEX: |
1926 | 750 | case AARCH64_OPND_SME_Zn_INDEX1_16: |
1927 | 2.50k | case AARCH64_OPND_SME_Zn_INDEX2_15: |
1928 | 3.09k | case AARCH64_OPND_SME_Zn_INDEX2_16: |
1929 | 3.13k | case AARCH64_OPND_SME_Zn_INDEX3_14: |
1930 | 3.81k | case AARCH64_OPND_SME_Zn_INDEX3_15: |
1931 | 4.04k | case AARCH64_OPND_SME_Zn_INDEX4_14: |
1932 | 4.06k | case AARCH64_OPND_SVE_Zn0_INDEX: |
1933 | 4.08k | case AARCH64_OPND_SVE_Zn1_17_INDEX: |
1934 | 4.12k | case AARCH64_OPND_SVE_Zn2_18_INDEX: |
1935 | 4.22k | case AARCH64_OPND_SVE_Zn3_22_INDEX: |
1936 | 4.27k | case AARCH64_OPND_SVE_Zd0_INDEX: |
1937 | 4.31k | case AARCH64_OPND_SVE_Zd1_17_INDEX: |
1938 | 4.36k | case AARCH64_OPND_SVE_Zd2_18_INDEX: |
1939 | 4.40k | case AARCH64_OPND_SVE_Zd3_22_INDEX: |
1940 | 4.40k | size = get_operand_fields_width (get_operand_from_code (type)) - 5; |
1941 | 4.40k | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 31, |
1942 | 4.40k | 0, (1 << size) - 1)) |
1943 | 0 | return false; |
1944 | 4.40k | break; |
1945 | | |
1946 | 4.40k | case AARCH64_OPND_SME_Zm_INDEX1: |
1947 | 4.02k | case AARCH64_OPND_SME_Zm_INDEX2: |
1948 | 4.13k | case AARCH64_OPND_SME_Zm_INDEX2_3: |
1949 | 6.27k | case AARCH64_OPND_SME_Zm_INDEX3_1: |
1950 | 8.95k | case AARCH64_OPND_SME_Zm_INDEX3_2: |
1951 | 11.5k | case AARCH64_OPND_SME_Zm_INDEX3_3: |
1952 | 75.2k | case AARCH64_OPND_SME_Zm_INDEX3_10: |
1953 | 79.0k | case AARCH64_OPND_SME_Zm_INDEX4_1: |
1954 | 80.0k | case AARCH64_OPND_SME_Zm_INDEX4_2: |
1955 | 105k | case AARCH64_OPND_SME_Zm_INDEX4_3: |
1956 | 138k | case AARCH64_OPND_SME_Zm_INDEX4_10: |
1957 | 138k | size = get_operand_fields_width (get_operand_from_code (type)) - 4; |
1958 | 138k | if (!check_reglane (opnd, mismatch_detail, idx, "z", 0, 15, |
1959 | 138k | 0, (1 << size) - 1)) |
1960 | 0 | return false; |
1961 | 138k | break; |
1962 | | |
1963 | 138k | case AARCH64_OPND_SME_Zm: |
1964 | 58.8k | case AARCH64_OPND_SME_Zm_17: |
1965 | 58.8k | if (opnd->reg.regno > 15) |
1966 | 0 | { |
1967 | 0 | set_invalid_regno_error (mismatch_detail, idx, "z", 0, 15); |
1968 | 0 | return false; |
1969 | 0 | } |
1970 | 58.8k | break; |
1971 | | |
1972 | 58.8k | case AARCH64_OPND_SME_PnT_Wm_imm: |
1973 | 4.99k | size = aarch64_get_qualifier_esize (opnd->qualifier); |
1974 | 4.99k | max_value = 16 / size - 1; |
1975 | 4.99k | if (!check_za_access (opnd, mismatch_detail, idx, |
1976 | 4.99k | 12, max_value, 1, 0, get_opcode_dependent_value (opcode))) |
1977 | 0 | return false; |
1978 | 4.99k | break; |
1979 | | |
1980 | 5.22M | default: |
1981 | 5.22M | break; |
1982 | 5.51M | } |
1983 | 5.51M | break; |
1984 | | |
1985 | 5.51M | case AARCH64_OPND_CLASS_SVE_REGLIST: |
1986 | 970k | switch (type) |
1987 | 970k | { |
1988 | 671 | case AARCH64_OPND_SME_Pdx2: |
1989 | 42.7k | case AARCH64_OPND_SME_Zdnx2: |
1990 | 52.9k | case AARCH64_OPND_SME_Zdnx4: |
1991 | 56.7k | case AARCH64_OPND_SME_Zmx2: |
1992 | 57.4k | case AARCH64_OPND_SME_Zmx4: |
1993 | 74.1k | case AARCH64_OPND_SME_Znx2: |
1994 | 74.1k | case AARCH64_OPND_SME_Znx2_BIT_INDEX: |
1995 | 82.8k | case AARCH64_OPND_SME_Znx4: |
1996 | 82.8k | num = get_operand_specific_data (&aarch64_operands[type]); |
1997 | 82.8k | if (!check_reglist (opnd, mismatch_detail, idx, num, 1)) |
1998 | 0 | return false; |
1999 | 82.8k | if ((opnd->reglist.first_regno % num) != 0) |
2000 | 0 | { |
2001 | 0 | set_other_error (mismatch_detail, idx, |
2002 | 0 | _("start register out of range")); |
2003 | 0 | return false; |
2004 | 0 | } |
2005 | 82.8k | break; |
2006 | | |
2007 | 82.8k | case AARCH64_OPND_SME_Ztx2_STRIDED: |
2008 | 25.4k | case AARCH64_OPND_SME_Ztx4_STRIDED: |
2009 | | /* 2-register lists have a stride of 8 and 4-register lists |
2010 | | have a stride of 4. */ |
2011 | 25.4k | num = get_operand_specific_data (&aarch64_operands[type]); |
2012 | 25.4k | if (!check_reglist (opnd, mismatch_detail, idx, num, 16 / num)) |
2013 | 0 | return false; |
2014 | 25.4k | num = 16 | (opnd->reglist.stride - 1); |
2015 | 25.4k | if ((opnd->reglist.first_regno & ~num) != 0) |
2016 | 0 | { |
2017 | 0 | set_other_error (mismatch_detail, idx, |
2018 | 0 | _("start register out of range")); |
2019 | 0 | return false; |
2020 | 0 | } |
2021 | 25.4k | break; |
2022 | | |
2023 | 25.4k | case AARCH64_OPND_SME_PdxN: |
2024 | 68.4k | case AARCH64_OPND_SVE_ZnxN: |
2025 | 861k | case AARCH64_OPND_SVE_ZtxN: |
2026 | 861k | num = get_opcode_dependent_value (opcode); |
2027 | 861k | if (!check_reglist (opnd, mismatch_detail, idx, num, 1)) |
2028 | 0 | return false; |
2029 | 861k | break; |
2030 | | |
2031 | 861k | default: |
2032 | 0 | abort (); |
2033 | 970k | } |
2034 | 970k | break; |
2035 | | |
2036 | 970k | case AARCH64_OPND_CLASS_ZA_ACCESS: |
2037 | 427k | switch (type) |
2038 | 427k | { |
2039 | 1.92k | case AARCH64_OPND_SME_ZA_HV_idx_src: |
2040 | 79.4k | case AARCH64_OPND_SME_ZA_HV_idx_dest: |
2041 | 220k | case AARCH64_OPND_SME_ZA_HV_idx_ldstr: |
2042 | 220k | size = aarch64_get_qualifier_esize (opnd->qualifier); |
2043 | 220k | max_value = 16 / size - 1; |
2044 | 220k | if (!check_za_access (opnd, mismatch_detail, idx, 12, max_value, 1, |
2045 | 220k | get_opcode_dependent_value (opcode), |
2046 | 220k | get_opcode_dependent_vg_status (opcode))) |
2047 | 0 | return false; |
2048 | 220k | break; |
2049 | | |
2050 | 220k | case AARCH64_OPND_SME_ZA_array_off4: |
2051 | 1.55k | if (!check_za_access (opnd, mismatch_detail, idx, 12, 15, 1, |
2052 | 1.55k | get_opcode_dependent_value (opcode), |
2053 | 1.55k | get_opcode_dependent_vg_status (opcode))) |
2054 | 0 | return false; |
2055 | 1.55k | break; |
2056 | | |
2057 | 14.5k | case AARCH64_OPND_SME_ZA_array_off3_0: |
2058 | 14.6k | case AARCH64_OPND_SME_ZA_array_off3_5: |
2059 | 14.6k | if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 1, |
2060 | 14.6k | get_opcode_dependent_value (opcode), |
2061 | 14.6k | get_opcode_dependent_vg_status (opcode))) |
2062 | 0 | return false; |
2063 | 14.6k | break; |
2064 | | |
2065 | 24.3k | case AARCH64_OPND_SME_ZA_array_off1x4: |
2066 | 24.3k | if (!check_za_access (opnd, mismatch_detail, idx, 8, 1, 4, |
2067 | 24.3k | get_opcode_dependent_value (opcode), |
2068 | 24.3k | get_opcode_dependent_vg_status (opcode))) |
2069 | 0 | return false; |
2070 | 24.3k | break; |
2071 | | |
2072 | 24.3k | case AARCH64_OPND_SME_ZA_array_off2x2: |
2073 | 5.45k | if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 2, |
2074 | 5.45k | get_opcode_dependent_value (opcode), |
2075 | 5.45k | get_opcode_dependent_vg_status (opcode))) |
2076 | 0 | return false; |
2077 | 5.45k | break; |
2078 | | |
2079 | 124k | case AARCH64_OPND_SME_ZA_array_off2x4: |
2080 | 124k | if (!check_za_access (opnd, mismatch_detail, idx, 8, 3, 4, |
2081 | 124k | get_opcode_dependent_value (opcode), |
2082 | 124k | get_opcode_dependent_vg_status (opcode))) |
2083 | 0 | return false; |
2084 | 124k | break; |
2085 | | |
2086 | 124k | case AARCH64_OPND_SME_ZA_array_off3x2: |
2087 | 32.4k | if (!check_za_access (opnd, mismatch_detail, idx, 8, 7, 2, |
2088 | 32.4k | get_opcode_dependent_value (opcode), |
2089 | 32.4k | get_opcode_dependent_vg_status (opcode))) |
2090 | 0 | return false; |
2091 | 32.4k | break; |
2092 | | |
2093 | 32.4k | case AARCH64_OPND_SME_ZA_array_vrsb_1: |
2094 | 31 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 7, 2, |
2095 | 31 | get_opcode_dependent_value (opcode), |
2096 | 31 | get_opcode_dependent_vg_status (opcode))) |
2097 | 0 | return false; |
2098 | 31 | break; |
2099 | | |
2100 | 60 | case AARCH64_OPND_SME_ZA_array_vrsh_1: |
2101 | 60 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 3, 2, |
2102 | 60 | get_opcode_dependent_value (opcode), |
2103 | 60 | get_opcode_dependent_vg_status (opcode))) |
2104 | 0 | return false; |
2105 | 60 | break; |
2106 | | |
2107 | 60 | case AARCH64_OPND_SME_ZA_array_vrss_1: |
2108 | 48 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 1, 2, |
2109 | 48 | get_opcode_dependent_value (opcode), |
2110 | 48 | get_opcode_dependent_vg_status (opcode))) |
2111 | 0 | return false; |
2112 | 48 | break; |
2113 | | |
2114 | 48 | case AARCH64_OPND_SME_ZA_array_vrsd_1: |
2115 | 10 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 0, 2, |
2116 | 10 | get_opcode_dependent_value (opcode), |
2117 | 10 | get_opcode_dependent_vg_status (opcode))) |
2118 | 0 | return false; |
2119 | 10 | break; |
2120 | | |
2121 | 291 | case AARCH64_OPND_SME_ZA_array_vrsb_2: |
2122 | 291 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 3, 4, |
2123 | 291 | get_opcode_dependent_value (opcode), |
2124 | 291 | get_opcode_dependent_vg_status (opcode))) |
2125 | 0 | return false; |
2126 | 291 | break; |
2127 | | |
2128 | 291 | case AARCH64_OPND_SME_ZA_array_vrsh_2: |
2129 | 10 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 1, 4, |
2130 | 10 | get_opcode_dependent_value (opcode), |
2131 | 10 | get_opcode_dependent_vg_status (opcode))) |
2132 | 0 | return false; |
2133 | 10 | break; |
2134 | | |
2135 | 791 | case AARCH64_OPND_SME_ZA_ARRAY4: |
2136 | 791 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 15, 1, |
2137 | 791 | get_opcode_dependent_value (opcode), |
2138 | 791 | get_opcode_dependent_vg_status (opcode))) |
2139 | 0 | return false; |
2140 | 791 | break; |
2141 | | |
2142 | 791 | case AARCH64_OPND_SME_ZA_array_vrss_2: |
2143 | 154 | case AARCH64_OPND_SME_ZA_array_vrsd_2: |
2144 | 154 | if (!check_za_access (opnd, mismatch_detail, idx, 12, 0, 4, |
2145 | 154 | get_opcode_dependent_value (opcode), |
2146 | 154 | get_opcode_dependent_vg_status (opcode))) |
2147 | 0 | return false; |
2148 | 154 | break; |
2149 | | |
2150 | 808 | case AARCH64_OPND_SME_ZA_HV_idx_srcxN: |
2151 | 2.75k | case AARCH64_OPND_SME_ZA_HV_idx_destxN: |
2152 | 2.75k | size = aarch64_get_qualifier_esize (opnd->qualifier); |
2153 | 2.75k | num = get_opcode_dependent_value (opcode); |
2154 | 2.75k | max_value = 16 / num / size; |
2155 | 2.75k | if (max_value > 0) |
2156 | 2.68k | max_value -= 1; |
2157 | 2.75k | if (!check_za_access (opnd, mismatch_detail, idx, 12, max_value, num, |
2158 | 2.75k | 0, get_opcode_dependent_value (opcode))) |
2159 | 0 | return false; |
2160 | 2.75k | break; |
2161 | | |
2162 | 2.75k | default: |
2163 | 0 | abort (); |
2164 | 427k | } |
2165 | 427k | break; |
2166 | | |
2167 | 3.18M | case AARCH64_OPND_CLASS_PRED_REG: |
2168 | 3.18M | switch (type) |
2169 | 3.18M | { |
2170 | 4.36k | case AARCH64_OPND_SME_PNd3: |
2171 | 73.1k | case AARCH64_OPND_SME_PNg3: |
2172 | 73.1k | if (opnd->reg.regno < 8) |
2173 | 0 | { |
2174 | 0 | set_invalid_regno_error (mismatch_detail, idx, "pn", 8, 15); |
2175 | 0 | return false; |
2176 | 0 | } |
2177 | 73.1k | break; |
2178 | | |
2179 | 3.11M | default: |
2180 | 3.11M | if (opnd->reg.regno >= 8 |
2181 | 3.11M | && get_operand_fields_width (get_operand_from_code (type)) == 3) |
2182 | 0 | { |
2183 | 0 | set_invalid_regno_error (mismatch_detail, idx, "p", 0, 7); |
2184 | 0 | return false; |
2185 | 0 | } |
2186 | 3.11M | break; |
2187 | 3.18M | } |
2188 | 3.18M | break; |
2189 | | |
2190 | 3.18M | case AARCH64_OPND_CLASS_COND: |
2191 | 60.1k | if (type == AARCH64_OPND_COND1 |
2192 | 60.1k | && (opnds[idx].cond->value & 0xe) == 0xe) |
2193 | 0 | { |
2194 | | /* Not allow AL or NV. */ |
2195 | 0 | set_syntax_error (mismatch_detail, idx, NULL); |
2196 | 0 | } |
2197 | 60.1k | break; |
2198 | | |
2199 | 11.4M | case AARCH64_OPND_CLASS_ADDRESS: |
2200 | | /* Check writeback. */ |
2201 | 11.4M | switch (opcode->iclass) |
2202 | 11.4M | { |
2203 | 909k | case ldst_pos: |
2204 | 1.32M | case ldst_unscaled: |
2205 | 1.78M | case ldstnapair_offs: |
2206 | 2.27M | case ldstpair_off: |
2207 | 2.35M | case ldst_unpriv: |
2208 | 2.35M | if (opnd->addr.writeback == 1) |
2209 | 0 | { |
2210 | 0 | set_syntax_error (mismatch_detail, idx, |
2211 | 0 | _("unexpected address writeback")); |
2212 | 0 | return false; |
2213 | 0 | } |
2214 | 2.35M | break; |
2215 | 2.35M | case ldst_imm10: |
2216 | 45.5k | if (opnd->addr.writeback == 1 && opnd->addr.preind != 1) |
2217 | 0 | { |
2218 | 0 | set_syntax_error (mismatch_detail, idx, |
2219 | 0 | _("unexpected address writeback")); |
2220 | 0 | return false; |
2221 | 0 | } |
2222 | 45.5k | break; |
2223 | 175k | case ldst_imm9: |
2224 | 649k | case ldstpair_indexed: |
2225 | 712k | case asisdlsep: |
2226 | 781k | case asisdlsop: |
2227 | 781k | if (opnd->addr.writeback == 0) |
2228 | 0 | { |
2229 | 0 | set_syntax_error (mismatch_detail, idx, |
2230 | 0 | _("address writeback expected")); |
2231 | 0 | return false; |
2232 | 0 | } |
2233 | 781k | break; |
2234 | 781k | case rcpc3: |
2235 | 39.9k | if (opnd->addr.writeback) |
2236 | 2.00k | if ((type == AARCH64_OPND_RCPC3_ADDR_PREIND_WB |
2237 | 2.00k | && !opnd->addr.preind) |
2238 | 2.00k | || (type == AARCH64_OPND_RCPC3_ADDR_POSTIND |
2239 | 2.00k | && !opnd->addr.postind)) |
2240 | 0 | { |
2241 | 0 | set_syntax_error (mismatch_detail, idx, |
2242 | 0 | _("unexpected address writeback")); |
2243 | 0 | return false; |
2244 | 0 | } |
2245 | | |
2246 | 39.9k | break; |
2247 | 8.22M | default: |
2248 | 8.22M | assert (opnd->addr.writeback == 0); |
2249 | 8.22M | break; |
2250 | 11.4M | } |
2251 | 11.4M | switch (type) |
2252 | 11.4M | { |
2253 | 1.36M | case AARCH64_OPND_ADDR_SIMM7: |
2254 | | /* Scaled signed 7 bits immediate offset. */ |
2255 | | /* Get the size of the data element that is accessed, which may be |
2256 | | different from that of the source register size, |
2257 | | e.g. in strb/ldrb. */ |
2258 | 1.36M | size = aarch64_get_qualifier_esize (opnd->qualifier); |
2259 | 1.36M | if (!value_in_range_p (opnd->addr.offset.imm, -64 * size, 63 * size)) |
2260 | 0 | { |
2261 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, |
2262 | 0 | -64 * size, 63 * size); |
2263 | 0 | return false; |
2264 | 0 | } |
2265 | 1.36M | if (!value_aligned_p (opnd->addr.offset.imm, size)) |
2266 | 0 | { |
2267 | 0 | set_unaligned_error (mismatch_detail, idx, size); |
2268 | 0 | return false; |
2269 | 0 | } |
2270 | 1.36M | break; |
2271 | 1.36M | case AARCH64_OPND_ADDR_OFFSET: |
2272 | 649k | case AARCH64_OPND_ADDR_SIMM9: |
2273 | | /* Unscaled signed 9 bits immediate offset. */ |
2274 | 649k | if (!value_in_range_p (opnd->addr.offset.imm, -256, 255)) |
2275 | 0 | { |
2276 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, -256, 255); |
2277 | 0 | return false; |
2278 | 0 | } |
2279 | 649k | break; |
2280 | | |
2281 | 649k | case AARCH64_OPND_ADDR_SIMM9_2: |
2282 | | /* Unscaled signed 9 bits immediate offset, which has to be negative |
2283 | | or unaligned. */ |
2284 | 0 | size = aarch64_get_qualifier_esize (qualifier); |
2285 | 0 | if ((value_in_range_p (opnd->addr.offset.imm, 0, 255) |
2286 | 0 | && !value_aligned_p (opnd->addr.offset.imm, size)) |
2287 | 0 | || value_in_range_p (opnd->addr.offset.imm, -256, -1)) |
2288 | 0 | return true; |
2289 | 0 | set_other_error (mismatch_detail, idx, |
2290 | 0 | _("negative or unaligned offset expected")); |
2291 | 0 | return false; |
2292 | | |
2293 | 45.5k | case AARCH64_OPND_ADDR_SIMM10: |
2294 | | /* Scaled signed 10 bits immediate offset. */ |
2295 | 45.5k | if (!value_in_range_p (opnd->addr.offset.imm, -4096, 4088)) |
2296 | 0 | { |
2297 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, -4096, 4088); |
2298 | 0 | return false; |
2299 | 0 | } |
2300 | 45.5k | if (!value_aligned_p (opnd->addr.offset.imm, 8)) |
2301 | 0 | { |
2302 | 0 | set_unaligned_error (mismatch_detail, idx, 8); |
2303 | 0 | return false; |
2304 | 0 | } |
2305 | 45.5k | break; |
2306 | | |
2307 | 62.3k | case AARCH64_OPND_ADDR_SIMM11: |
2308 | | /* Signed 11 bits immediate offset (multiple of 16). */ |
2309 | 62.3k | if (!value_in_range_p (opnd->addr.offset.imm, -1024, 1008)) |
2310 | 0 | { |
2311 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, -1024, 1008); |
2312 | 0 | return false; |
2313 | 0 | } |
2314 | | |
2315 | 62.3k | if (!value_aligned_p (opnd->addr.offset.imm, 16)) |
2316 | 0 | { |
2317 | 0 | set_unaligned_error (mismatch_detail, idx, 16); |
2318 | 0 | return false; |
2319 | 0 | } |
2320 | 62.3k | break; |
2321 | | |
2322 | 62.3k | case AARCH64_OPND_ADDR_SIMM13: |
2323 | | /* Signed 13 bits immediate offset (multiple of 16). */ |
2324 | 18.0k | if (!value_in_range_p (opnd->addr.offset.imm, -4096, 4080)) |
2325 | 0 | { |
2326 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, -4096, 4080); |
2327 | 0 | return false; |
2328 | 0 | } |
2329 | | |
2330 | 18.0k | if (!value_aligned_p (opnd->addr.offset.imm, 16)) |
2331 | 0 | { |
2332 | 0 | set_unaligned_error (mismatch_detail, idx, 16); |
2333 | 0 | return false; |
2334 | 0 | } |
2335 | 18.0k | break; |
2336 | | |
2337 | 131k | case AARCH64_OPND_SIMD_ADDR_POST: |
2338 | | /* AdvSIMD load/store multiple structures, post-index. */ |
2339 | 131k | assert (idx == 1); |
2340 | 131k | if (opnd->addr.offset.is_reg) |
2341 | 126k | { |
2342 | 126k | if (value_in_range_p (opnd->addr.offset.regno, 0, 30)) |
2343 | 126k | return true; |
2344 | 0 | else |
2345 | 0 | { |
2346 | 0 | set_other_error (mismatch_detail, idx, |
2347 | 0 | _("invalid register offset")); |
2348 | 0 | return false; |
2349 | 0 | } |
2350 | 126k | } |
2351 | 5.79k | else |
2352 | 5.79k | { |
2353 | 5.79k | const aarch64_opnd_info *prev = &opnds[idx-1]; |
2354 | 5.79k | unsigned num_bytes; /* total number of bytes transferred. */ |
2355 | | /* The opcode dependent area stores the number of elements in |
2356 | | each structure to be loaded/stored. */ |
2357 | 5.79k | int is_ld1r = get_opcode_dependent_value (opcode) == 1; |
2358 | 5.79k | if (opcode->operands[0] == AARCH64_OPND_LVt_AL) |
2359 | | /* Special handling of loading single structure to all lane. */ |
2360 | 910 | num_bytes = (is_ld1r ? 1 : prev->reglist.num_regs) |
2361 | 910 | * aarch64_get_qualifier_esize (prev->qualifier); |
2362 | 4.88k | else |
2363 | 4.88k | num_bytes = prev->reglist.num_regs |
2364 | 4.88k | * aarch64_get_qualifier_esize (prev->qualifier) |
2365 | 4.88k | * aarch64_get_qualifier_nelem (prev->qualifier); |
2366 | 5.79k | if ((int) num_bytes != opnd->addr.offset.imm) |
2367 | 0 | { |
2368 | 0 | set_other_error (mismatch_detail, idx, |
2369 | 0 | _("invalid post-increment amount")); |
2370 | 0 | return false; |
2371 | 0 | } |
2372 | 5.79k | } |
2373 | 5.79k | break; |
2374 | | |
2375 | 122k | case AARCH64_OPND_ADDR_REGOFF: |
2376 | | /* Get the size of the data element that is accessed, which may be |
2377 | | different from that of the source register size, |
2378 | | e.g. in strb/ldrb. */ |
2379 | 122k | size = aarch64_get_qualifier_esize (opnd->qualifier); |
2380 | | /* It is either no shift or shift by the binary logarithm of SIZE. */ |
2381 | 122k | if (opnd->shifter.amount != 0 |
2382 | 122k | && opnd->shifter.amount != (int)get_logsz (size)) |
2383 | 0 | { |
2384 | 0 | set_other_error (mismatch_detail, idx, |
2385 | 0 | _("invalid shift amount")); |
2386 | 0 | return false; |
2387 | 0 | } |
2388 | | /* Only UXTW, LSL, SXTW and SXTX are the accepted extending |
2389 | | operators. */ |
2390 | 122k | switch (opnd->shifter.kind) |
2391 | 122k | { |
2392 | 13.2k | case AARCH64_MOD_UXTW: |
2393 | 34.8k | case AARCH64_MOD_LSL: |
2394 | 42.8k | case AARCH64_MOD_SXTW: |
2395 | 51.7k | case AARCH64_MOD_SXTX: break; |
2396 | 70.4k | default: |
2397 | 70.4k | set_other_error (mismatch_detail, idx, |
2398 | 70.4k | _("invalid extend/shift operator")); |
2399 | 70.4k | return false; |
2400 | 122k | } |
2401 | 51.7k | break; |
2402 | | |
2403 | 909k | case AARCH64_OPND_ADDR_UIMM12: |
2404 | 909k | imm = opnd->addr.offset.imm; |
2405 | | /* Get the size of the data element that is accessed, which may be |
2406 | | different from that of the source register size, |
2407 | | e.g. in strb/ldrb. */ |
2408 | 909k | size = aarch64_get_qualifier_esize (qualifier); |
2409 | 909k | if (!value_in_range_p (opnd->addr.offset.imm, 0, 4095 * size)) |
2410 | 0 | { |
2411 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, |
2412 | 0 | 0, 4095 * size); |
2413 | 0 | return false; |
2414 | 0 | } |
2415 | 909k | if (!value_aligned_p (opnd->addr.offset.imm, size)) |
2416 | 0 | { |
2417 | 0 | set_unaligned_error (mismatch_detail, idx, size); |
2418 | 0 | return false; |
2419 | 0 | } |
2420 | 909k | break; |
2421 | | |
2422 | 909k | case AARCH64_OPND_ADDR_PCREL9: |
2423 | 977k | case AARCH64_OPND_ADDR_PCREL14: |
2424 | 2.44M | case AARCH64_OPND_ADDR_PCREL19: |
2425 | 3.77M | case AARCH64_OPND_ADDR_PCREL21: |
2426 | 4.62M | case AARCH64_OPND_ADDR_PCREL26: |
2427 | 4.62M | { |
2428 | 4.62M | imm = opnd->imm.value; |
2429 | 4.62M | if (operand_need_shift_by_two (get_operand_from_code (type))) |
2430 | 3.29M | { |
2431 | | /* The offset value in a PC-relative branch instruction is alway |
2432 | | 4-byte aligned and is encoded without the lowest 2 bits. */ |
2433 | 3.29M | if (!value_aligned_p (imm, 4)) |
2434 | 0 | { |
2435 | 0 | set_unaligned_error (mismatch_detail, idx, 4); |
2436 | 0 | return false; |
2437 | 0 | } |
2438 | | /* Right shift by 2 so that we can carry out the following check |
2439 | | canonically. */ |
2440 | 3.29M | imm >>= 2; |
2441 | 3.29M | } |
2442 | | |
2443 | 4.62M | if (!check_immediate_out_of_range (imm, type, mismatch_detail, idx)) |
2444 | 0 | return false; |
2445 | 4.62M | } |
2446 | 4.62M | break; |
2447 | | |
2448 | 4.62M | case AARCH64_OPND_SME_ADDR_RI_U4xVL: |
2449 | 1.55k | if (!value_in_range_p (opnd->addr.offset.imm, 0, 15)) |
2450 | 0 | { |
2451 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, 0, 15); |
2452 | 0 | return false; |
2453 | 0 | } |
2454 | 1.55k | break; |
2455 | | |
2456 | 77.0k | case AARCH64_OPND_SVE_ADDR_RI_S4xVL: |
2457 | 94.5k | case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL: |
2458 | 102k | case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL: |
2459 | 116k | case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL: |
2460 | 116k | min_value = -8; |
2461 | 116k | max_value = 7; |
2462 | 177k | sve_imm_offset_vl: |
2463 | 177k | assert (!opnd->addr.offset.is_reg); |
2464 | 177k | assert (opnd->addr.preind); |
2465 | 177k | num = 1 + get_operand_specific_data (&aarch64_operands[type]); |
2466 | 177k | min_value *= num; |
2467 | 177k | max_value *= num; |
2468 | 177k | if ((opnd->addr.offset.imm != 0 && !opnd->shifter.operator_present) |
2469 | 177k | || (opnd->shifter.operator_present |
2470 | 177k | && opnd->shifter.kind != AARCH64_MOD_MUL_VL)) |
2471 | 0 | { |
2472 | 0 | set_other_error (mismatch_detail, idx, |
2473 | 0 | _("invalid addressing mode")); |
2474 | 0 | return false; |
2475 | 0 | } |
2476 | 177k | if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value)) |
2477 | 0 | { |
2478 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, |
2479 | 0 | min_value, max_value); |
2480 | 0 | return false; |
2481 | 0 | } |
2482 | 177k | if (!value_aligned_p (opnd->addr.offset.imm, num)) |
2483 | 0 | { |
2484 | 0 | set_unaligned_error (mismatch_detail, idx, num); |
2485 | 0 | return false; |
2486 | 0 | } |
2487 | 177k | break; |
2488 | | |
2489 | 177k | case AARCH64_OPND_SVE_ADDR_RI_S6xVL: |
2490 | 8.17k | min_value = -32; |
2491 | 8.17k | max_value = 31; |
2492 | 8.17k | goto sve_imm_offset_vl; |
2493 | | |
2494 | 52.9k | case AARCH64_OPND_SVE_ADDR_RI_S9xVL: |
2495 | 52.9k | min_value = -256; |
2496 | 52.9k | max_value = 255; |
2497 | 52.9k | goto sve_imm_offset_vl; |
2498 | | |
2499 | 98.8k | case AARCH64_OPND_SVE_ADDR_RI_U6: |
2500 | 108k | case AARCH64_OPND_SVE_ADDR_RI_U6x2: |
2501 | 127k | case AARCH64_OPND_SVE_ADDR_RI_U6x4: |
2502 | 132k | case AARCH64_OPND_SVE_ADDR_RI_U6x8: |
2503 | 132k | min_value = 0; |
2504 | 132k | max_value = 63; |
2505 | 216k | sve_imm_offset: |
2506 | 216k | assert (!opnd->addr.offset.is_reg); |
2507 | 216k | assert (opnd->addr.preind); |
2508 | 216k | num = 1 << get_operand_specific_data (&aarch64_operands[type]); |
2509 | 216k | min_value *= num; |
2510 | 216k | max_value *= num; |
2511 | 216k | if (opnd->shifter.operator_present |
2512 | 216k | || opnd->shifter.amount_present) |
2513 | 0 | { |
2514 | 0 | set_other_error (mismatch_detail, idx, |
2515 | 0 | _("invalid addressing mode")); |
2516 | 0 | return false; |
2517 | 0 | } |
2518 | 216k | if (!value_in_range_p (opnd->addr.offset.imm, min_value, max_value)) |
2519 | 0 | { |
2520 | 0 | set_offset_out_of_range_error (mismatch_detail, idx, |
2521 | 0 | min_value, max_value); |
2522 | 0 | return false; |
2523 | 0 | } |
2524 | 216k | if (!value_aligned_p (opnd->addr.offset.imm, num)) |
2525 | 0 | { |
2526 | 0 | set_unaligned_error (mismatch_detail, idx, num); |
2527 | 0 | return false; |
2528 | 0 | } |
2529 | 216k | break; |
2530 | | |
2531 | 216k | case AARCH64_OPND_SVE_ADDR_RI_S4x16: |
2532 | 6.66k | case AARCH64_OPND_SVE_ADDR_RI_S4x32: |
2533 | 6.66k | min_value = -8; |
2534 | 6.66k | max_value = 7; |
2535 | 6.66k | goto sve_imm_offset; |
2536 | | |
2537 | 46.7k | case AARCH64_OPND_SVE_ADDR_ZX: |
2538 | | /* Everything is already ensured by parse_operands or |
2539 | | aarch64_ext_sve_addr_rr_lsl (because this is a very specific |
2540 | | argument type). */ |
2541 | 46.7k | assert (opnd->addr.offset.is_reg); |
2542 | 46.7k | assert (opnd->addr.preind); |
2543 | 46.7k | assert ((aarch64_operands[type].flags & OPD_F_NO_ZR) == 0); |
2544 | 46.7k | assert (opnd->shifter.kind == AARCH64_MOD_LSL); |
2545 | 46.7k | assert (opnd->shifter.operator_present == 0); |
2546 | 46.7k | break; |
2547 | | |
2548 | 46.7k | case AARCH64_OPND_SVE_ADDR_RR: |
2549 | 60.5k | case AARCH64_OPND_SVE_ADDR_RR_LSL1: |
2550 | 84.0k | case AARCH64_OPND_SVE_ADDR_RR_LSL2: |
2551 | 132k | case AARCH64_OPND_SVE_ADDR_RR_LSL3: |
2552 | 161k | case AARCH64_OPND_SVE_ADDR_RR_LSL4: |
2553 | 189k | case AARCH64_OPND_SVE_ADDR_RM: |
2554 | 196k | case AARCH64_OPND_SVE_ADDR_RM_LSL1: |
2555 | 204k | case AARCH64_OPND_SVE_ADDR_RM_LSL2: |
2556 | 213k | case AARCH64_OPND_SVE_ADDR_RM_LSL3: |
2557 | 213k | case AARCH64_OPND_SVE_ADDR_RM_LSL4: |
2558 | 251k | case AARCH64_OPND_SVE_ADDR_RX: |
2559 | 272k | case AARCH64_OPND_SVE_ADDR_RX_LSL1: |
2560 | 375k | case AARCH64_OPND_SVE_ADDR_RX_LSL2: |
2561 | 391k | case AARCH64_OPND_SVE_ADDR_RX_LSL3: |
2562 | 399k | case AARCH64_OPND_SVE_ADDR_RX_LSL4: |
2563 | 447k | case AARCH64_OPND_SVE_ADDR_RZ: |
2564 | 452k | case AARCH64_OPND_SVE_ADDR_RZ_LSL1: |
2565 | 457k | case AARCH64_OPND_SVE_ADDR_RZ_LSL2: |
2566 | 462k | case AARCH64_OPND_SVE_ADDR_RZ_LSL3: |
2567 | 462k | modifiers = 1 << AARCH64_MOD_LSL; |
2568 | 778k | sve_rr_operand: |
2569 | 778k | assert (opnd->addr.offset.is_reg); |
2570 | 778k | assert (opnd->addr.preind); |
2571 | 778k | if ((aarch64_operands[type].flags & OPD_F_NO_ZR) != 0 |
2572 | 778k | && opnd->addr.offset.regno == 31) |
2573 | 0 | { |
2574 | 0 | set_other_error (mismatch_detail, idx, |
2575 | 0 | _("index register xzr is not allowed")); |
2576 | 0 | return false; |
2577 | 0 | } |
2578 | 778k | if (((1 << opnd->shifter.kind) & modifiers) == 0 |
2579 | 778k | || (opnd->shifter.amount |
2580 | 778k | != get_operand_specific_data (&aarch64_operands[type]))) |
2581 | 0 | { |
2582 | 0 | set_other_error (mismatch_detail, idx, |
2583 | 0 | _("invalid addressing mode")); |
2584 | 0 | return false; |
2585 | 0 | } |
2586 | 778k | break; |
2587 | | |
2588 | 778k | case AARCH64_OPND_SVE_ADDR_RZ_XTW_14: |
2589 | 244k | case AARCH64_OPND_SVE_ADDR_RZ_XTW_22: |
2590 | 250k | case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14: |
2591 | 273k | case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22: |
2592 | 278k | case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14: |
2593 | 295k | case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22: |
2594 | 297k | case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14: |
2595 | 316k | case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22: |
2596 | 316k | modifiers = (1 << AARCH64_MOD_SXTW) | (1 << AARCH64_MOD_UXTW); |
2597 | 316k | goto sve_rr_operand; |
2598 | | |
2599 | 28.5k | case AARCH64_OPND_SVE_ADDR_ZI_U5: |
2600 | 46.6k | case AARCH64_OPND_SVE_ADDR_ZI_U5x2: |
2601 | 75.0k | case AARCH64_OPND_SVE_ADDR_ZI_U5x4: |
2602 | 77.2k | case AARCH64_OPND_SVE_ADDR_ZI_U5x8: |
2603 | 77.2k | min_value = 0; |
2604 | 77.2k | max_value = 31; |
2605 | 77.2k | goto sve_imm_offset; |
2606 | | |
2607 | 1.60k | case AARCH64_OPND_SVE_ADDR_ZZ_LSL: |
2608 | 1.60k | modifiers = 1 << AARCH64_MOD_LSL; |
2609 | 2.74k | sve_zz_operand: |
2610 | 2.74k | assert (opnd->addr.offset.is_reg); |
2611 | 2.74k | assert (opnd->addr.preind); |
2612 | 2.74k | if (((1 << opnd->shifter.kind) & modifiers) == 0 |
2613 | 2.74k | || opnd->shifter.amount < 0 |
2614 | 2.74k | || opnd->shifter.amount > 3) |
2615 | 0 | { |
2616 | 0 | set_other_error (mismatch_detail, idx, |
2617 | 0 | _("invalid addressing mode")); |
2618 | 0 | return false; |
2619 | 0 | } |
2620 | 2.74k | break; |
2621 | | |
2622 | 2.74k | case AARCH64_OPND_SVE_ADDR_ZZ_SXTW: |
2623 | 492 | modifiers = (1 << AARCH64_MOD_SXTW); |
2624 | 492 | goto sve_zz_operand; |
2625 | | |
2626 | 650 | case AARCH64_OPND_SVE_ADDR_ZZ_UXTW: |
2627 | 650 | modifiers = 1 << AARCH64_MOD_UXTW; |
2628 | 650 | goto sve_zz_operand; |
2629 | | |
2630 | 15.6k | case AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB: |
2631 | 17.3k | case AARCH64_OPND_RCPC3_ADDR_OPT_POSTIND: |
2632 | 17.5k | case AARCH64_OPND_RCPC3_ADDR_PREIND_WB: |
2633 | 17.8k | case AARCH64_OPND_RCPC3_ADDR_POSTIND: |
2634 | 17.8k | { |
2635 | 17.8k | int num_bytes = calc_ldst_datasize (opnds); |
2636 | 17.8k | int abs_offset = (type == AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB |
2637 | 17.8k | || type == AARCH64_OPND_RCPC3_ADDR_PREIND_WB) |
2638 | 17.8k | ? opnd->addr.offset.imm * -1 |
2639 | 17.8k | : opnd->addr.offset.imm; |
2640 | 17.8k | if ((int) num_bytes != abs_offset |
2641 | 17.8k | && opnd->addr.offset.imm != 0) |
2642 | 0 | { |
2643 | 0 | set_other_error (mismatch_detail, idx, |
2644 | 0 | _("invalid increment amount")); |
2645 | 0 | return false; |
2646 | 0 | } |
2647 | 17.8k | } |
2648 | 17.8k | break; |
2649 | | |
2650 | 22.0k | case AARCH64_OPND_RCPC3_ADDR_OFFSET: |
2651 | 22.0k | if (!value_in_range_p (opnd->addr.offset.imm, -256, 255)) |
2652 | 0 | { |
2653 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, -256, 255); |
2654 | 0 | return false; |
2655 | 0 | } |
2656 | | |
2657 | 2.27M | default: |
2658 | 2.27M | break; |
2659 | 11.4M | } |
2660 | 11.2M | break; |
2661 | | |
2662 | 11.2M | case AARCH64_OPND_CLASS_SIMD_REGLIST: |
2663 | 427k | if (type == AARCH64_OPND_LEt) |
2664 | 130k | { |
2665 | | /* Get the upper bound for the element index. */ |
2666 | 130k | num = 16 / aarch64_get_qualifier_esize (qualifier) - 1; |
2667 | 130k | if (!value_in_range_p (opnd->reglist.index, 0, num)) |
2668 | 0 | { |
2669 | 0 | set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num); |
2670 | 0 | return false; |
2671 | 0 | } |
2672 | 130k | } |
2673 | | /* The opcode dependent area stores the number of elements in |
2674 | | each structure to be loaded/stored. */ |
2675 | 427k | num = get_opcode_dependent_value (opcode); |
2676 | 427k | switch (type) |
2677 | 427k | { |
2678 | 4.74k | case AARCH64_OPND_LVn_LUT: |
2679 | 4.74k | if (!check_reglist (opnd, mismatch_detail, idx, num, 1)) |
2680 | 0 | return 0; |
2681 | 4.74k | break; |
2682 | 256k | case AARCH64_OPND_LVt: |
2683 | 256k | assert (num >= 1 && num <= 4); |
2684 | | /* Unless LD1/ST1, the number of registers should be equal to that |
2685 | | of the structure elements. */ |
2686 | 256k | if (num != 1 && !check_reglist (opnd, mismatch_detail, idx, num, 1)) |
2687 | 2.80k | return false; |
2688 | 253k | break; |
2689 | 253k | case AARCH64_OPND_LVt_AL: |
2690 | 135k | case AARCH64_OPND_LEt: |
2691 | 135k | assert (num >= 1 && num <= 4); |
2692 | | /* The number of registers should be equal to that of the structure |
2693 | | elements. */ |
2694 | 135k | if (!check_reglist (opnd, mismatch_detail, idx, num, 1)) |
2695 | 0 | return false; |
2696 | 135k | break; |
2697 | 135k | default: |
2698 | 30.7k | break; |
2699 | 427k | } |
2700 | 424k | if (opnd->reglist.stride != 1) |
2701 | 0 | { |
2702 | 0 | set_reg_list_stride_error (mismatch_detail, idx, 1); |
2703 | 0 | return false; |
2704 | 0 | } |
2705 | 424k | break; |
2706 | | |
2707 | 14.1M | case AARCH64_OPND_CLASS_IMMEDIATE: |
2708 | | /* Constraint check on immediate operand. */ |
2709 | 14.1M | imm = opnd->imm.value; |
2710 | | /* E.g. imm_0_31 constrains value to be 0..31. */ |
2711 | 14.1M | if (qualifier_value_in_range_constraint_p (qualifier) |
2712 | 14.1M | && !value_in_range_p (imm, get_lower_bound (qualifier), |
2713 | 1.46M | get_upper_bound (qualifier))) |
2714 | 144k | { |
2715 | 144k | set_imm_out_of_range_error (mismatch_detail, idx, |
2716 | 144k | get_lower_bound (qualifier), |
2717 | 144k | get_upper_bound (qualifier)); |
2718 | 144k | return false; |
2719 | 144k | } |
2720 | | |
2721 | 13.9M | switch (type) |
2722 | 13.9M | { |
2723 | 1.24M | case AARCH64_OPND_AIMM: |
2724 | 1.24M | if (opnd->shifter.kind != AARCH64_MOD_LSL) |
2725 | 0 | { |
2726 | 0 | set_other_error (mismatch_detail, idx, |
2727 | 0 | _("invalid shift operator")); |
2728 | 0 | return false; |
2729 | 0 | } |
2730 | 1.24M | if (opnd->shifter.amount != 0 && opnd->shifter.amount != 12) |
2731 | 0 | { |
2732 | 0 | set_other_error (mismatch_detail, idx, |
2733 | 0 | _("shift amount must be 0 or 12")); |
2734 | 0 | return false; |
2735 | 0 | } |
2736 | 1.24M | if (!value_fit_unsigned_field_p (opnd->imm.value, 12)) |
2737 | 0 | { |
2738 | 0 | set_other_error (mismatch_detail, idx, |
2739 | 0 | _("immediate out of range")); |
2740 | 0 | return false; |
2741 | 0 | } |
2742 | 1.24M | break; |
2743 | | |
2744 | 1.24M | case AARCH64_OPND_HALF: |
2745 | 373k | assert (idx == 1 && opnds[0].type == AARCH64_OPND_Rd); |
2746 | 373k | if (opnd->shifter.kind != AARCH64_MOD_LSL) |
2747 | 0 | { |
2748 | 0 | set_other_error (mismatch_detail, idx, |
2749 | 0 | _("invalid shift operator")); |
2750 | 0 | return false; |
2751 | 0 | } |
2752 | 373k | size = aarch64_get_qualifier_esize (opnds[0].qualifier); |
2753 | 373k | if (!value_aligned_p (opnd->shifter.amount, 16)) |
2754 | 0 | { |
2755 | 0 | set_other_error (mismatch_detail, idx, |
2756 | 0 | _("shift amount must be a multiple of 16")); |
2757 | 0 | return false; |
2758 | 0 | } |
2759 | 373k | if (!value_in_range_p (opnd->shifter.amount, 0, size * 8 - 16)) |
2760 | 52.3k | { |
2761 | 52.3k | set_sft_amount_out_of_range_error (mismatch_detail, idx, |
2762 | 52.3k | 0, size * 8 - 16); |
2763 | 52.3k | return false; |
2764 | 52.3k | } |
2765 | 321k | if (opnd->imm.value < 0) |
2766 | 0 | { |
2767 | 0 | set_other_error (mismatch_detail, idx, |
2768 | 0 | _("negative immediate value not allowed")); |
2769 | 0 | return false; |
2770 | 0 | } |
2771 | 321k | if (!value_fit_unsigned_field_p (opnd->imm.value, 16)) |
2772 | 0 | { |
2773 | 0 | set_other_error (mismatch_detail, idx, |
2774 | 0 | _("immediate out of range")); |
2775 | 0 | return false; |
2776 | 0 | } |
2777 | 321k | break; |
2778 | | |
2779 | 321k | case AARCH64_OPND_IMM_MOV: |
2780 | 184k | { |
2781 | 184k | int esize = aarch64_get_qualifier_esize (opnds[0].qualifier); |
2782 | 184k | imm = opnd->imm.value; |
2783 | 184k | assert (idx == 1); |
2784 | 184k | switch (opcode->op) |
2785 | 184k | { |
2786 | 76.7k | case OP_MOV_IMM_WIDEN: |
2787 | 76.7k | imm = ~imm; |
2788 | | /* Fall through. */ |
2789 | 182k | case OP_MOV_IMM_WIDE: |
2790 | 182k | if (!aarch64_wide_constant_p (imm, esize == 4, NULL)) |
2791 | 0 | { |
2792 | 0 | set_other_error (mismatch_detail, idx, |
2793 | 0 | _("immediate out of range")); |
2794 | 0 | return false; |
2795 | 0 | } |
2796 | 182k | break; |
2797 | 182k | case OP_MOV_IMM_LOG: |
2798 | 1.61k | if (!aarch64_logical_immediate_p (imm, esize, NULL)) |
2799 | 0 | { |
2800 | 0 | set_other_error (mismatch_detail, idx, |
2801 | 0 | _("immediate out of range")); |
2802 | 0 | return false; |
2803 | 0 | } |
2804 | 1.61k | break; |
2805 | 1.61k | default: |
2806 | 0 | assert (0); |
2807 | 0 | return false; |
2808 | 184k | } |
2809 | 184k | } |
2810 | 184k | break; |
2811 | | |
2812 | 184k | case AARCH64_OPND_NZCV: |
2813 | 25.2k | case AARCH64_OPND_CCMP_IMM: |
2814 | 27.9k | case AARCH64_OPND_EXCEPTION: |
2815 | 9.00M | case AARCH64_OPND_UNDEFINED: |
2816 | 9.00M | case AARCH64_OPND_TME_UIMM16: |
2817 | 9.00M | case AARCH64_OPND_UIMM4: |
2818 | 9.02M | case AARCH64_OPND_UIMM4_ADDG: |
2819 | 9.02M | case AARCH64_OPND_UIMM7: |
2820 | 9.03M | case AARCH64_OPND_UIMM3_OP1: |
2821 | 9.04M | case AARCH64_OPND_UIMM3_OP2: |
2822 | 9.04M | case AARCH64_OPND_SVE_UIMM3: |
2823 | 9.14M | case AARCH64_OPND_SVE_UIMM7: |
2824 | 9.14M | case AARCH64_OPND_SVE_UIMM8: |
2825 | 9.14M | case AARCH64_OPND_SVE_UIMM4: |
2826 | 9.22M | case AARCH64_OPND_SVE_UIMM8_53: |
2827 | 9.22M | case AARCH64_OPND_CSSC_UIMM8: |
2828 | 9.22M | size = get_operand_fields_width (get_operand_from_code (type)); |
2829 | 9.22M | assert (size < 32); |
2830 | 9.22M | if (!value_fit_unsigned_field_p (opnd->imm.value, size)) |
2831 | 0 | { |
2832 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 0, |
2833 | 0 | (1u << size) - 1); |
2834 | 0 | return false; |
2835 | 0 | } |
2836 | 9.22M | break; |
2837 | | |
2838 | 9.22M | case AARCH64_OPND_UIMM10: |
2839 | | /* Scaled unsigned 10 bits immediate offset. */ |
2840 | 18.6k | if (!value_in_range_p (opnd->imm.value, 0, 1008)) |
2841 | 0 | { |
2842 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 0, 1008); |
2843 | 0 | return false; |
2844 | 0 | } |
2845 | | |
2846 | 18.6k | if (!value_aligned_p (opnd->imm.value, 16)) |
2847 | 0 | { |
2848 | 0 | set_unaligned_error (mismatch_detail, idx, 16); |
2849 | 0 | return false; |
2850 | 0 | } |
2851 | 18.6k | break; |
2852 | | |
2853 | 35.0k | case AARCH64_OPND_SIMM5: |
2854 | 36.4k | case AARCH64_OPND_SVE_SIMM5: |
2855 | 37.3k | case AARCH64_OPND_SVE_SIMM5B: |
2856 | 39.9k | case AARCH64_OPND_SVE_SIMM6: |
2857 | 40.8k | case AARCH64_OPND_SVE_SIMM8: |
2858 | 44.8k | case AARCH64_OPND_CSSC_SIMM8: |
2859 | 44.8k | size = get_operand_fields_width (get_operand_from_code (type)); |
2860 | 44.8k | assert (size < 32); |
2861 | 44.8k | if (!value_fit_signed_field_p (opnd->imm.value, size)) |
2862 | 0 | { |
2863 | 0 | imm_range_t rng = imm_range_min_max (size, true); |
2864 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, rng.min, |
2865 | 0 | rng.max); |
2866 | 0 | return false; |
2867 | 0 | } |
2868 | 44.8k | break; |
2869 | | |
2870 | 112k | case AARCH64_OPND_WIDTH: |
2871 | 112k | assert (idx > 1 && opnds[idx-1].type == AARCH64_OPND_IMM |
2872 | 112k | && opnds[0].type == AARCH64_OPND_Rd); |
2873 | 112k | size = get_upper_bound (qualifier); |
2874 | 112k | if (opnd->imm.value + opnds[idx-1].imm.value > size) |
2875 | | /* lsb+width <= reg.size */ |
2876 | 0 | { |
2877 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 1, |
2878 | 0 | size - opnds[idx-1].imm.value); |
2879 | 0 | return false; |
2880 | 0 | } |
2881 | 112k | break; |
2882 | | |
2883 | 675k | case AARCH64_OPND_LIMM: |
2884 | 1.06M | case AARCH64_OPND_SVE_LIMM: |
2885 | 1.06M | { |
2886 | 1.06M | int esize = aarch64_get_qualifier_esize (opnds[0].qualifier); |
2887 | 1.06M | uint64_t uimm = opnd->imm.value; |
2888 | 1.06M | if (opcode->op == OP_BIC) |
2889 | 0 | uimm = ~uimm; |
2890 | 1.06M | if (!aarch64_logical_immediate_p (uimm, esize, NULL)) |
2891 | 0 | { |
2892 | 0 | set_other_error (mismatch_detail, idx, |
2893 | 0 | _("immediate out of range")); |
2894 | 0 | return false; |
2895 | 0 | } |
2896 | 1.06M | } |
2897 | 1.06M | break; |
2898 | | |
2899 | 1.06M | case AARCH64_OPND_IMM0: |
2900 | 1.09k | case AARCH64_OPND_FPIMM0: |
2901 | 1.09k | if (opnd->imm.value != 0) |
2902 | 0 | { |
2903 | 0 | set_other_error (mismatch_detail, idx, |
2904 | 0 | _("immediate zero expected")); |
2905 | 0 | return false; |
2906 | 0 | } |
2907 | 1.09k | break; |
2908 | | |
2909 | 1.66k | case AARCH64_OPND_IMM_ROT1: |
2910 | 40.5k | case AARCH64_OPND_IMM_ROT2: |
2911 | 59.7k | case AARCH64_OPND_SVE_IMM_ROT2: |
2912 | 59.7k | if (opnd->imm.value != 0 |
2913 | 59.7k | && opnd->imm.value != 90 |
2914 | 59.7k | && opnd->imm.value != 180 |
2915 | 59.7k | && opnd->imm.value != 270) |
2916 | 0 | { |
2917 | 0 | set_other_error (mismatch_detail, idx, |
2918 | 0 | _("rotate expected to be 0, 90, 180 or 270")); |
2919 | 0 | return false; |
2920 | 0 | } |
2921 | 59.7k | break; |
2922 | | |
2923 | 59.7k | case AARCH64_OPND_IMM_ROT3: |
2924 | 1.92k | case AARCH64_OPND_SVE_IMM_ROT1: |
2925 | 2.00k | case AARCH64_OPND_SVE_IMM_ROT3: |
2926 | 2.00k | if (opnd->imm.value != 90 && opnd->imm.value != 270) |
2927 | 0 | { |
2928 | 0 | set_other_error (mismatch_detail, idx, |
2929 | 0 | _("rotate expected to be 90 or 270")); |
2930 | 0 | return false; |
2931 | 0 | } |
2932 | 2.00k | break; |
2933 | | |
2934 | 2.00k | case AARCH64_OPND_SHLL_IMM: |
2935 | 124 | assert (idx == 2); |
2936 | 124 | size = 8 * aarch64_get_qualifier_esize (opnds[idx - 1].qualifier); |
2937 | 124 | if (opnd->imm.value != size) |
2938 | 0 | { |
2939 | 0 | set_other_error (mismatch_detail, idx, |
2940 | 0 | _("invalid shift amount")); |
2941 | 0 | return false; |
2942 | 0 | } |
2943 | 124 | break; |
2944 | | |
2945 | 33.3k | case AARCH64_OPND_IMM_VLSL: |
2946 | 33.3k | size = aarch64_get_qualifier_esize (qualifier); |
2947 | 33.3k | if (!value_in_range_p (opnd->imm.value, 0, size * 8 - 1)) |
2948 | 0 | { |
2949 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 0, |
2950 | 0 | size * 8 - 1); |
2951 | 0 | return false; |
2952 | 0 | } |
2953 | 33.3k | break; |
2954 | | |
2955 | 46.6k | case AARCH64_OPND_IMM_VLSR: |
2956 | 46.6k | size = aarch64_get_qualifier_esize (qualifier); |
2957 | 46.6k | if (!value_in_range_p (opnd->imm.value, 1, size * 8)) |
2958 | 0 | { |
2959 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 1, size * 8); |
2960 | 0 | return false; |
2961 | 0 | } |
2962 | 46.6k | break; |
2963 | | |
2964 | 46.6k | case AARCH64_OPND_SIMD_IMM: |
2965 | 10.5k | case AARCH64_OPND_SIMD_IMM_SFT: |
2966 | | /* Qualifier check. */ |
2967 | 10.5k | switch (qualifier) |
2968 | 10.5k | { |
2969 | 8.50k | case AARCH64_OPND_QLF_LSL: |
2970 | 8.50k | if (opnd->shifter.kind != AARCH64_MOD_LSL) |
2971 | 0 | { |
2972 | 0 | set_other_error (mismatch_detail, idx, |
2973 | 0 | _("invalid shift operator")); |
2974 | 0 | return false; |
2975 | 0 | } |
2976 | 8.50k | break; |
2977 | 8.50k | case AARCH64_OPND_QLF_MSL: |
2978 | 378 | if (opnd->shifter.kind != AARCH64_MOD_MSL) |
2979 | 0 | { |
2980 | 0 | set_other_error (mismatch_detail, idx, |
2981 | 0 | _("invalid shift operator")); |
2982 | 0 | return false; |
2983 | 0 | } |
2984 | 378 | break; |
2985 | 1.66k | case AARCH64_OPND_QLF_NIL: |
2986 | 1.66k | if (opnd->shifter.kind != AARCH64_MOD_NONE) |
2987 | 0 | { |
2988 | 0 | set_other_error (mismatch_detail, idx, |
2989 | 0 | _("shift is not permitted")); |
2990 | 0 | return false; |
2991 | 0 | } |
2992 | 1.66k | break; |
2993 | 1.66k | default: |
2994 | 0 | assert (0); |
2995 | 0 | return false; |
2996 | 10.5k | } |
2997 | | /* Is the immediate valid? */ |
2998 | 10.5k | assert (idx == 1); |
2999 | 10.5k | if (aarch64_get_qualifier_esize (opnds[0].qualifier) != 8) |
3000 | 8.88k | { |
3001 | | /* uimm8 or simm8 */ |
3002 | 8.88k | if (!value_in_range_p (opnd->imm.value, -128, 255)) |
3003 | 0 | { |
3004 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, -128, 255); |
3005 | 0 | return false; |
3006 | 0 | } |
3007 | 8.88k | } |
3008 | 1.66k | else if (aarch64_shrink_expanded_imm8 (opnd->imm.value) < 0) |
3009 | 0 | { |
3010 | | /* uimm64 is not |
3011 | | 'aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee |
3012 | | ffffffffgggggggghhhhhhhh'. */ |
3013 | 0 | set_other_error (mismatch_detail, idx, |
3014 | 0 | _("invalid value for immediate")); |
3015 | 0 | return false; |
3016 | 0 | } |
3017 | | /* Is the shift amount valid? */ |
3018 | 10.5k | switch (opnd->shifter.kind) |
3019 | 10.5k | { |
3020 | 8.50k | case AARCH64_MOD_LSL: |
3021 | 8.50k | size = aarch64_get_qualifier_esize (opnds[0].qualifier); |
3022 | 8.50k | if (!value_in_range_p (opnd->shifter.amount, 0, (size - 1) * 8)) |
3023 | 0 | { |
3024 | 0 | set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, |
3025 | 0 | (size - 1) * 8); |
3026 | 0 | return false; |
3027 | 0 | } |
3028 | 8.50k | if (!value_aligned_p (opnd->shifter.amount, 8)) |
3029 | 0 | { |
3030 | 0 | set_unaligned_error (mismatch_detail, idx, 8); |
3031 | 0 | return false; |
3032 | 0 | } |
3033 | 8.50k | break; |
3034 | 8.50k | case AARCH64_MOD_MSL: |
3035 | | /* Only 8 and 16 are valid shift amount. */ |
3036 | 378 | if (opnd->shifter.amount != 8 && opnd->shifter.amount != 16) |
3037 | 0 | { |
3038 | 0 | set_other_error (mismatch_detail, idx, |
3039 | 0 | _("shift amount must be 0 or 16")); |
3040 | 0 | return false; |
3041 | 0 | } |
3042 | 378 | break; |
3043 | 1.66k | default: |
3044 | 1.66k | if (opnd->shifter.kind != AARCH64_MOD_NONE) |
3045 | 0 | { |
3046 | 0 | set_other_error (mismatch_detail, idx, |
3047 | 0 | _("invalid shift operator")); |
3048 | 0 | return false; |
3049 | 0 | } |
3050 | 1.66k | break; |
3051 | 10.5k | } |
3052 | 10.5k | break; |
3053 | | |
3054 | 10.5k | case AARCH64_OPND_FPIMM: |
3055 | 8.57k | case AARCH64_OPND_SIMD_FPIMM: |
3056 | 13.2k | case AARCH64_OPND_SVE_FPIMM8: |
3057 | 13.2k | if (opnd->imm.is_fp == 0) |
3058 | 0 | { |
3059 | 0 | set_other_error (mismatch_detail, idx, |
3060 | 0 | _("floating-point immediate expected")); |
3061 | 0 | return false; |
3062 | 0 | } |
3063 | | /* The value is expected to be an 8-bit floating-point constant with |
3064 | | sign, 3-bit exponent and normalized 4 bits of precision, encoded |
3065 | | in "a:b:c:d:e:f:g:h" or FLD_imm8 (depending on the type of the |
3066 | | instruction). */ |
3067 | 13.2k | if (!value_in_range_p (opnd->imm.value, 0, 255)) |
3068 | 0 | { |
3069 | 0 | set_other_error (mismatch_detail, idx, |
3070 | 0 | _("immediate out of range")); |
3071 | 0 | return false; |
3072 | 0 | } |
3073 | 13.2k | if (opnd->shifter.kind != AARCH64_MOD_NONE) |
3074 | 0 | { |
3075 | 0 | set_other_error (mismatch_detail, idx, |
3076 | 0 | _("invalid shift operator")); |
3077 | 0 | return false; |
3078 | 0 | } |
3079 | 13.2k | break; |
3080 | | |
3081 | 13.2k | case AARCH64_OPND_SVE_AIMM: |
3082 | 2.47k | min_value = 0; |
3083 | 135k | sve_aimm: |
3084 | 135k | assert (opnd->shifter.kind == AARCH64_MOD_LSL); |
3085 | 135k | size = aarch64_get_qualifier_esize (opnds[0].qualifier); |
3086 | 135k | mask = ~((uint64_t) -1 << (size * 4) << (size * 4)); |
3087 | 135k | uvalue = opnd->imm.value; |
3088 | 135k | shift = opnd->shifter.amount; |
3089 | 135k | if (size == 1) |
3090 | 20.9k | { |
3091 | 20.9k | if (shift != 0) |
3092 | 69 | { |
3093 | 69 | set_other_error (mismatch_detail, idx, |
3094 | 69 | _("no shift amount allowed for" |
3095 | 69 | " 8-bit constants")); |
3096 | 69 | return false; |
3097 | 69 | } |
3098 | 20.9k | } |
3099 | 115k | else |
3100 | 115k | { |
3101 | 115k | if (shift != 0 && shift != 8) |
3102 | 0 | { |
3103 | 0 | set_other_error (mismatch_detail, idx, |
3104 | 0 | _("shift amount must be 0 or 8")); |
3105 | 0 | return false; |
3106 | 0 | } |
3107 | 115k | if (shift == 0 && (uvalue & 0xff) == 0) |
3108 | 34.2k | { |
3109 | 34.2k | shift = 8; |
3110 | 34.2k | uvalue = (int64_t) uvalue / 256; |
3111 | 34.2k | } |
3112 | 115k | } |
3113 | 135k | mask >>= shift; |
3114 | 135k | if ((uvalue & mask) != uvalue && (uvalue | ~mask) != uvalue) |
3115 | 5.05k | { |
3116 | 5.05k | set_other_error (mismatch_detail, idx, |
3117 | 5.05k | _("immediate too big for element size")); |
3118 | 5.05k | return false; |
3119 | 5.05k | } |
3120 | 130k | uvalue = (uvalue - min_value) & mask; |
3121 | 130k | if (uvalue > 0xff) |
3122 | 0 | { |
3123 | 0 | set_other_error (mismatch_detail, idx, |
3124 | 0 | _("invalid arithmetic immediate")); |
3125 | 0 | return false; |
3126 | 0 | } |
3127 | 130k | break; |
3128 | | |
3129 | 133k | case AARCH64_OPND_SVE_ASIMM: |
3130 | 133k | min_value = -128; |
3131 | 133k | goto sve_aimm; |
3132 | | |
3133 | 90 | case AARCH64_OPND_SVE_I1_HALF_ONE: |
3134 | 90 | assert (opnd->imm.is_fp); |
3135 | 90 | if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x3f800000) |
3136 | 0 | { |
3137 | 0 | set_other_error (mismatch_detail, idx, |
3138 | 0 | _("floating-point value must be 0.5 or 1.0")); |
3139 | 0 | return false; |
3140 | 0 | } |
3141 | 90 | break; |
3142 | | |
3143 | 121 | case AARCH64_OPND_SVE_I1_HALF_TWO: |
3144 | 121 | assert (opnd->imm.is_fp); |
3145 | 121 | if (opnd->imm.value != 0x3f000000 && opnd->imm.value != 0x40000000) |
3146 | 0 | { |
3147 | 0 | set_other_error (mismatch_detail, idx, |
3148 | 0 | _("floating-point value must be 0.5 or 2.0")); |
3149 | 0 | return false; |
3150 | 0 | } |
3151 | 121 | break; |
3152 | | |
3153 | 1.39k | case AARCH64_OPND_SVE_I1_ZERO_ONE: |
3154 | 1.39k | assert (opnd->imm.is_fp); |
3155 | 1.39k | if (opnd->imm.value != 0 && opnd->imm.value != 0x3f800000) |
3156 | 0 | { |
3157 | 0 | set_other_error (mismatch_detail, idx, |
3158 | 0 | _("floating-point value must be 0.0 or 1.0")); |
3159 | 0 | return false; |
3160 | 0 | } |
3161 | 1.39k | break; |
3162 | | |
3163 | 1.39k | case AARCH64_OPND_SVE_INV_LIMM: |
3164 | 0 | { |
3165 | 0 | int esize = aarch64_get_qualifier_esize (opnds[0].qualifier); |
3166 | 0 | uint64_t uimm = ~opnd->imm.value; |
3167 | 0 | if (!aarch64_logical_immediate_p (uimm, esize, NULL)) |
3168 | 0 | { |
3169 | 0 | set_other_error (mismatch_detail, idx, |
3170 | 0 | _("immediate out of range")); |
3171 | 0 | return false; |
3172 | 0 | } |
3173 | 0 | } |
3174 | 0 | break; |
3175 | | |
3176 | 3.94k | case AARCH64_OPND_SVE_LIMM_MOV: |
3177 | 3.94k | { |
3178 | 3.94k | int esize = aarch64_get_qualifier_esize (opnds[0].qualifier); |
3179 | 3.94k | uint64_t uimm = opnd->imm.value; |
3180 | 3.94k | if (!aarch64_logical_immediate_p (uimm, esize, NULL)) |
3181 | 0 | { |
3182 | 0 | set_other_error (mismatch_detail, idx, |
3183 | 0 | _("immediate out of range")); |
3184 | 0 | return false; |
3185 | 0 | } |
3186 | 3.94k | if (!aarch64_sve_dupm_mov_immediate_p (uimm, esize)) |
3187 | 0 | { |
3188 | 0 | set_other_error (mismatch_detail, idx, |
3189 | 0 | _("invalid replicated MOV immediate")); |
3190 | 0 | return false; |
3191 | 0 | } |
3192 | 3.94k | } |
3193 | 3.94k | break; |
3194 | | |
3195 | 12.6k | case AARCH64_OPND_SVE_PATTERN_SCALED: |
3196 | 12.6k | assert (opnd->shifter.kind == AARCH64_MOD_MUL); |
3197 | 12.6k | if (!value_in_range_p (opnd->shifter.amount, 1, 16)) |
3198 | 0 | { |
3199 | 0 | set_multiplier_out_of_range_error (mismatch_detail, idx, 1, 16); |
3200 | 0 | return false; |
3201 | 0 | } |
3202 | 12.6k | break; |
3203 | | |
3204 | 12.6k | case AARCH64_OPND_SVE_SHLIMM_PRED: |
3205 | 7.53k | case AARCH64_OPND_SVE_SHLIMM_UNPRED: |
3206 | 8.79k | case AARCH64_OPND_SVE_SHLIMM_UNPRED_22: |
3207 | 8.79k | size = aarch64_get_qualifier_esize (opnds[idx - 1].qualifier); |
3208 | 8.79k | if (!value_in_range_p (opnd->imm.value, 0, 8 * size - 1)) |
3209 | 0 | { |
3210 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, |
3211 | 0 | 0, 8 * size - 1); |
3212 | 0 | return false; |
3213 | 0 | } |
3214 | 8.79k | break; |
3215 | | |
3216 | 8.79k | case AARCH64_OPND_SME_SHRIMM4: |
3217 | 281 | size = 1 << get_operand_fields_width (get_operand_from_code (type)); |
3218 | 281 | if (!value_in_range_p (opnd->imm.value, 1, size)) |
3219 | 0 | { |
3220 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 1, size); |
3221 | 0 | return false; |
3222 | 0 | } |
3223 | 281 | break; |
3224 | | |
3225 | 1.70k | case AARCH64_OPND_SME_SHRIMM5: |
3226 | 8.35k | case AARCH64_OPND_SVE_SHRIMM_PRED: |
3227 | 12.1k | case AARCH64_OPND_SVE_SHRIMM_UNPRED: |
3228 | 23.2k | case AARCH64_OPND_SVE_SHRIMM_UNPRED_22: |
3229 | 23.2k | num = (type == AARCH64_OPND_SVE_SHRIMM_UNPRED_22) ? 2 : 1; |
3230 | 23.2k | size = aarch64_get_qualifier_esize (opnds[idx - num].qualifier); |
3231 | 23.2k | if (!value_in_range_p (opnd->imm.value, 1, 8 * size)) |
3232 | 0 | { |
3233 | 0 | set_imm_out_of_range_error (mismatch_detail, idx, 1, 8*size); |
3234 | 0 | return false; |
3235 | 0 | } |
3236 | 23.2k | break; |
3237 | | |
3238 | 23.2k | case AARCH64_OPND_SME_ZT0_INDEX: |
3239 | 22 | if (!value_in_range_p (opnd->imm.value, 0, 56)) |
3240 | 0 | { |
3241 | 0 | set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, 56); |
3242 | 0 | return false; |
3243 | 0 | } |
3244 | 22 | if (opnd->imm.value % 8 != 0) |
3245 | 0 | { |
3246 | 0 | set_other_error (mismatch_detail, idx, |
3247 | 0 | _("byte index must be a multiple of 8")); |
3248 | 0 | return false; |
3249 | 0 | } |
3250 | 22 | break; |
3251 | | |
3252 | 22 | case AARCH64_OPND_SME_ZT0_INDEX_MUL_VL: |
3253 | 20 | if (!value_in_range_p (opnd->imm.value, 0, 3)) |
3254 | 0 | { |
3255 | 0 | set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, 3); |
3256 | 0 | return 0; |
3257 | 0 | } |
3258 | 20 | break; |
3259 | | |
3260 | 1.35M | default: |
3261 | 1.35M | break; |
3262 | 13.9M | } |
3263 | 13.9M | break; |
3264 | | |
3265 | 13.9M | case AARCH64_OPND_CLASS_SYSTEM: |
3266 | 249k | switch (type) |
3267 | 249k | { |
3268 | 121 | case AARCH64_OPND_PSTATEFIELD: |
3269 | 304 | for (i = 0; aarch64_pstatefields[i].name; ++i) |
3270 | 304 | if (aarch64_pstatefields[i].value == opnd->pstatefield) |
3271 | 121 | break; |
3272 | 121 | assert (aarch64_pstatefields[i].name); |
3273 | 121 | assert (idx == 0 && opnds[1].type == AARCH64_OPND_UIMM4); |
3274 | 121 | max_value = F_GET_REG_MAX_VALUE (aarch64_pstatefields[i].flags); |
3275 | 121 | if (opnds[1].imm.value < 0 || opnds[1].imm.value > max_value) |
3276 | 55 | { |
3277 | 55 | set_imm_out_of_range_error (mismatch_detail, 1, 0, max_value); |
3278 | 55 | return false; |
3279 | 55 | } |
3280 | 66 | break; |
3281 | 214k | case AARCH64_OPND_PRFOP: |
3282 | 214k | if (opcode->iclass == ldst_regoff && opnd->prfop->value >= 24) |
3283 | 7.50k | { |
3284 | 7.50k | set_other_error (mismatch_detail, idx, |
3285 | 7.50k | _("the register-index form of PRFM does" |
3286 | 7.50k | " not accept opcodes in the range 24-31")); |
3287 | 7.50k | return false; |
3288 | 7.50k | } |
3289 | 206k | break; |
3290 | 206k | default: |
3291 | 35.1k | break; |
3292 | 249k | } |
3293 | 241k | break; |
3294 | | |
3295 | 299k | case AARCH64_OPND_CLASS_SIMD_ELEMENT: |
3296 | | /* Get the upper bound for the element index. */ |
3297 | 299k | if (opcode->op == OP_FCMLA_ELEM) |
3298 | | /* FCMLA index range depends on the vector size of other operands |
3299 | | and is halfed because complex numbers take two elements. */ |
3300 | 17.7k | num = aarch64_get_qualifier_nelem (opnds[0].qualifier) |
3301 | 17.7k | * aarch64_get_qualifier_esize (opnds[0].qualifier) / 2; |
3302 | 282k | else if (opcode->iclass == lut) |
3303 | 4.74k | { |
3304 | 4.74k | size = get_operand_fields_width (get_operand_from_code (type)) - 5; |
3305 | 4.74k | if (!check_reglane (opnd, mismatch_detail, idx, "v", 0, 31, |
3306 | 4.74k | 0, (1 << size) - 1)) |
3307 | 0 | return 0; |
3308 | 4.74k | break; |
3309 | 4.74k | } |
3310 | 277k | else |
3311 | 277k | num = 16; |
3312 | 295k | num = num / aarch64_get_qualifier_esize (qualifier) - 1; |
3313 | 295k | assert (aarch64_get_qualifier_nelem (qualifier) == 1); |
3314 | | |
3315 | | /* Index out-of-range. */ |
3316 | 295k | if (!value_in_range_p (opnd->reglane.index, 0, num)) |
3317 | 1.32k | { |
3318 | 1.32k | set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, num); |
3319 | 1.32k | return false; |
3320 | 1.32k | } |
3321 | | /* SMLAL<Q> <Vd>.<Ta>, <Vn>.<Tb>, <Vm>.<Ts>[<index>]. |
3322 | | <Vm> Is the vector register (V0-V31) or (V0-V15), whose |
3323 | | number is encoded in "size:M:Rm": |
3324 | | size <Vm> |
3325 | | 00 RESERVED |
3326 | | 01 0:Rm |
3327 | | 10 M:Rm |
3328 | | 11 RESERVED */ |
3329 | 293k | if (type == AARCH64_OPND_Em16 |
3330 | 293k | && (qualifier == AARCH64_OPND_QLF_S_H |
3331 | 168k | || qualifier == AARCH64_OPND_QLF_S_2B) |
3332 | 293k | && !value_in_range_p (opnd->reglane.regno, 0, 15)) |
3333 | 0 | { |
3334 | 0 | set_regno_out_of_range_error (mismatch_detail, idx, 0, 15); |
3335 | 0 | return false; |
3336 | 0 | } |
3337 | 293k | if (type == AARCH64_OPND_Em8 |
3338 | 293k | && !value_in_range_p (opnd->reglane.regno, 0, 7)) |
3339 | 0 | { |
3340 | 0 | set_regno_out_of_range_error (mismatch_detail, idx, 0, 7); |
3341 | 0 | return 0; |
3342 | 0 | } |
3343 | 293k | break; |
3344 | | |
3345 | 2.83M | case AARCH64_OPND_CLASS_MODIFIED_REG: |
3346 | 2.83M | assert (idx == 1 || idx == 2); |
3347 | 2.83M | switch (type) |
3348 | 2.83M | { |
3349 | 138k | case AARCH64_OPND_Rm_EXT: |
3350 | 138k | if (!aarch64_extend_operator_p (opnd->shifter.kind) |
3351 | 138k | && opnd->shifter.kind != AARCH64_MOD_LSL) |
3352 | 0 | { |
3353 | 0 | set_other_error (mismatch_detail, idx, |
3354 | 0 | _("extend operator expected")); |
3355 | 0 | return false; |
3356 | 0 | } |
3357 | | /* It is not optional unless at least one of "Rd" or "Rn" is '11111' |
3358 | | (i.e. SP), in which case it defaults to LSL. The LSL alias is |
3359 | | only valid when "Rd" or "Rn" is '11111', and is preferred in that |
3360 | | case. */ |
3361 | 138k | if (!aarch64_stack_pointer_p (opnds + 0) |
3362 | 138k | && (idx != 2 || !aarch64_stack_pointer_p (opnds + 1))) |
3363 | 132k | { |
3364 | 132k | if (!opnd->shifter.operator_present) |
3365 | 0 | { |
3366 | 0 | set_other_error (mismatch_detail, idx, |
3367 | 0 | _("missing extend operator")); |
3368 | 0 | return false; |
3369 | 0 | } |
3370 | 132k | else if (opnd->shifter.kind == AARCH64_MOD_LSL) |
3371 | 0 | { |
3372 | 0 | set_other_error (mismatch_detail, idx, |
3373 | 0 | _("'LSL' operator not allowed")); |
3374 | 0 | return false; |
3375 | 0 | } |
3376 | 132k | } |
3377 | 138k | assert (opnd->shifter.operator_present /* Default to LSL. */ |
3378 | 138k | || opnd->shifter.kind == AARCH64_MOD_LSL); |
3379 | 138k | if (!value_in_range_p (opnd->shifter.amount, 0, 4)) |
3380 | 29.9k | { |
3381 | 29.9k | set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, 4); |
3382 | 29.9k | return false; |
3383 | 29.9k | } |
3384 | | /* In the 64-bit form, the final register operand is written as Wm |
3385 | | for all but the (possibly omitted) UXTX/LSL and SXTX |
3386 | | operators. |
3387 | | N.B. GAS allows X register to be used with any operator as a |
3388 | | programming convenience. */ |
3389 | 108k | if (qualifier == AARCH64_OPND_QLF_X |
3390 | 108k | && opnd->shifter.kind != AARCH64_MOD_LSL |
3391 | 108k | && opnd->shifter.kind != AARCH64_MOD_UXTX |
3392 | 108k | && opnd->shifter.kind != AARCH64_MOD_SXTX) |
3393 | 0 | { |
3394 | 0 | set_other_error (mismatch_detail, idx, _("W register expected")); |
3395 | 0 | return false; |
3396 | 0 | } |
3397 | 108k | break; |
3398 | | |
3399 | 2.69M | case AARCH64_OPND_Rm_SFT: |
3400 | | /* ROR is not available to the shifted register operand in |
3401 | | arithmetic instructions. */ |
3402 | 2.69M | if (!aarch64_shift_operator_p (opnd->shifter.kind)) |
3403 | 0 | { |
3404 | 0 | set_other_error (mismatch_detail, idx, |
3405 | 0 | _("shift operator expected")); |
3406 | 0 | return false; |
3407 | 0 | } |
3408 | 2.69M | if (opnd->shifter.kind == AARCH64_MOD_ROR |
3409 | 2.69M | && opcode->iclass != log_shift) |
3410 | 0 | { |
3411 | 0 | set_other_error (mismatch_detail, idx, |
3412 | 0 | _("'ROR' operator not allowed")); |
3413 | 0 | return false; |
3414 | 0 | } |
3415 | 2.69M | num = qualifier == AARCH64_OPND_QLF_W ? 31 : 63; |
3416 | 2.69M | if (!value_in_range_p (opnd->shifter.amount, 0, num)) |
3417 | 227k | { |
3418 | 227k | set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, num); |
3419 | 227k | return false; |
3420 | 227k | } |
3421 | 2.46M | break; |
3422 | | |
3423 | 2.46M | case AARCH64_OPND_Rm_LSL: |
3424 | | /* We expect here that opnd->shifter.kind != AARCH64_MOD_LSL |
3425 | | because the parser already restricts the type of shift to LSL only, |
3426 | | so another check of shift kind would be redundant. */ |
3427 | 2.12k | if (!value_in_range_p (opnd->shifter.amount, 0, 7)) |
3428 | 0 | { |
3429 | 0 | set_sft_amount_out_of_range_error (mismatch_detail, idx, 0, 7); |
3430 | 0 | return false; |
3431 | 0 | } |
3432 | 2.12k | break; |
3433 | | |
3434 | 2.12k | default: |
3435 | 0 | break; |
3436 | 2.83M | } |
3437 | 2.57M | break; |
3438 | | |
3439 | 5.12M | default: |
3440 | 5.12M | break; |
3441 | 66.1M | } |
3442 | | |
3443 | 65.4M | return true; |
3444 | 66.1M | } |
3445 | | |
3446 | | /* Main entrypoint for the operand constraint checking. |
3447 | | |
3448 | | Return 1 if operands of *INST meet the constraint applied by the operand |
3449 | | codes and operand qualifiers; otherwise return 0 and if MISMATCH_DETAIL is |
3450 | | not NULL, return the detail of the error in *MISMATCH_DETAIL. N.B. when |
3451 | | adding more constraint checking, make sure MISMATCH_DETAIL->KIND is set |
3452 | | with a proper error kind rather than AARCH64_OPDE_NIL (GAS asserts non-NIL |
3453 | | error kind when it is notified that an instruction does not pass the check). |
3454 | | |
3455 | | Un-determined operand qualifiers may get established during the process. */ |
3456 | | |
3457 | | bool |
3458 | | aarch64_match_operands_constraint (aarch64_inst *inst, |
3459 | | aarch64_operand_error *mismatch_detail) |
3460 | 30.2M | { |
3461 | 30.2M | int i; |
3462 | | |
3463 | 30.2M | DEBUG_TRACE ("enter"); |
3464 | | |
3465 | 30.2M | i = inst->opcode->tied_operand; |
3466 | | |
3467 | 30.2M | if (i > 0) |
3468 | 541k | { |
3469 | | /* Check for tied_operands with specific opcode iclass. */ |
3470 | 541k | switch (inst->opcode->iclass) |
3471 | 541k | { |
3472 | | /* For SME LDR and STR instructions #imm must have the same numerical |
3473 | | value for both operands. |
3474 | | */ |
3475 | 1.51k | case sme_ldr: |
3476 | 1.55k | case sme_str: |
3477 | 1.55k | assert (inst->operands[0].type == AARCH64_OPND_SME_ZA_array_off4); |
3478 | 1.55k | assert (inst->operands[1].type == AARCH64_OPND_SME_ADDR_RI_U4xVL); |
3479 | 1.55k | if (inst->operands[0].indexed_za.index.imm |
3480 | 1.55k | != inst->operands[1].addr.offset.imm) |
3481 | 0 | { |
3482 | 0 | if (mismatch_detail) |
3483 | 0 | { |
3484 | 0 | mismatch_detail->kind = AARCH64_OPDE_UNTIED_IMMS; |
3485 | 0 | mismatch_detail->index = i; |
3486 | 0 | } |
3487 | 0 | return false; |
3488 | 0 | } |
3489 | 1.55k | break; |
3490 | | |
3491 | 540k | default: |
3492 | 540k | { |
3493 | | /* Check for cases where a source register needs to be the |
3494 | | same as the destination register. Do this before |
3495 | | matching qualifiers since if an instruction has both |
3496 | | invalid tying and invalid qualifiers, the error about |
3497 | | qualifiers would suggest several alternative instructions |
3498 | | that also have invalid tying. */ |
3499 | 540k | enum aarch64_operand_class op_class |
3500 | 540k | = aarch64_get_operand_class (inst->operands[0].type); |
3501 | 540k | assert (aarch64_get_operand_class (inst->operands[i].type) |
3502 | 540k | == op_class); |
3503 | 540k | if (op_class == AARCH64_OPND_CLASS_SVE_REGLIST |
3504 | 540k | ? ((inst->operands[0].reglist.first_regno |
3505 | 288 | != inst->operands[i].reglist.first_regno) |
3506 | 288 | || (inst->operands[0].reglist.num_regs |
3507 | 288 | != inst->operands[i].reglist.num_regs) |
3508 | 288 | || (inst->operands[0].reglist.stride |
3509 | 288 | != inst->operands[i].reglist.stride)) |
3510 | 540k | : (inst->operands[0].reg.regno |
3511 | 539k | != inst->operands[i].reg.regno)) |
3512 | 0 | { |
3513 | 0 | if (mismatch_detail) |
3514 | 0 | { |
3515 | 0 | mismatch_detail->kind = AARCH64_OPDE_UNTIED_OPERAND; |
3516 | 0 | mismatch_detail->index = i; |
3517 | 0 | mismatch_detail->error = NULL; |
3518 | 0 | } |
3519 | 0 | return false; |
3520 | 0 | } |
3521 | 540k | break; |
3522 | 540k | } |
3523 | 541k | } |
3524 | 541k | } |
3525 | | |
3526 | | /* Match operands' qualifier. |
3527 | | *INST has already had qualifier establish for some, if not all, of |
3528 | | its operands; we need to find out whether these established |
3529 | | qualifiers match one of the qualifier sequence in |
3530 | | INST->OPCODE->QUALIFIERS_LIST. If yes, we will assign each operand |
3531 | | with the corresponding qualifier in such a sequence. |
3532 | | Only basic operand constraint checking is done here; the more thorough |
3533 | | constraint checking will carried out by operand_general_constraint_met_p, |
3534 | | which has be to called after this in order to get all of the operands' |
3535 | | qualifiers established. */ |
3536 | 30.2M | int invalid_count; |
3537 | 30.2M | if (match_operands_qualifier (inst, true /* update_p */, |
3538 | 30.2M | &invalid_count) == 0) |
3539 | 106k | { |
3540 | 106k | DEBUG_TRACE ("FAIL on operand qualifier matching"); |
3541 | 106k | if (mismatch_detail) |
3542 | 0 | { |
3543 | | /* Return an error type to indicate that it is the qualifier |
3544 | | matching failure; we don't care about which operand as there |
3545 | | are enough information in the opcode table to reproduce it. */ |
3546 | 0 | mismatch_detail->kind = AARCH64_OPDE_INVALID_VARIANT; |
3547 | 0 | mismatch_detail->index = -1; |
3548 | 0 | mismatch_detail->error = NULL; |
3549 | 0 | mismatch_detail->data[0].i = invalid_count; |
3550 | 0 | } |
3551 | 106k | return false; |
3552 | 106k | } |
3553 | | |
3554 | | /* Match operands' constraint. */ |
3555 | 95.7M | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i) |
3556 | 95.7M | { |
3557 | 95.7M | enum aarch64_opnd type = inst->opcode->operands[i]; |
3558 | 95.7M | if (type == AARCH64_OPND_NIL) |
3559 | 29.5M | break; |
3560 | 66.1M | if (inst->operands[i].skip) |
3561 | 0 | { |
3562 | 0 | DEBUG_TRACE ("skip the incomplete operand %d", i); |
3563 | 0 | continue; |
3564 | 0 | } |
3565 | 66.1M | if (!operand_general_constraint_met_p (inst->operands, i, type, |
3566 | 66.1M | inst->opcode, mismatch_detail)) |
3567 | 594k | { |
3568 | 594k | DEBUG_TRACE ("FAIL on operand %d", i); |
3569 | 594k | return false; |
3570 | 594k | } |
3571 | 66.1M | } |
3572 | | |
3573 | 29.5M | DEBUG_TRACE ("PASS"); |
3574 | | |
3575 | 29.5M | return true; |
3576 | 30.1M | } |
3577 | | |
3578 | | /* Replace INST->OPCODE with OPCODE and return the replaced OPCODE. |
3579 | | Also updates the TYPE of each INST->OPERANDS with the corresponding |
3580 | | value of OPCODE->OPERANDS. |
3581 | | |
3582 | | Note that some operand qualifiers may need to be manually cleared by |
3583 | | the caller before it further calls the aarch64_opcode_encode; by |
3584 | | doing this, it helps the qualifier matching facilities work |
3585 | | properly. */ |
3586 | | |
3587 | | const aarch64_opcode* |
3588 | | aarch64_replace_opcode (aarch64_inst *inst, const aarch64_opcode *opcode) |
3589 | 304k | { |
3590 | 304k | int i; |
3591 | 304k | const aarch64_opcode *old = inst->opcode; |
3592 | | |
3593 | 304k | inst->opcode = opcode; |
3594 | | |
3595 | | /* Update the operand types. */ |
3596 | 1.14M | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i) |
3597 | 1.14M | { |
3598 | 1.14M | inst->operands[i].type = opcode->operands[i]; |
3599 | 1.14M | if (opcode->operands[i] == AARCH64_OPND_NIL) |
3600 | 304k | break; |
3601 | 1.14M | } |
3602 | | |
3603 | 304k | DEBUG_TRACE ("replace %s with %s", old->name, opcode->name); |
3604 | | |
3605 | 304k | return old; |
3606 | 304k | } |
3607 | | |
3608 | | int |
3609 | | aarch64_operand_index (const enum aarch64_opnd *operands, enum aarch64_opnd operand) |
3610 | 963k | { |
3611 | 963k | int i; |
3612 | 1.04M | for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i) |
3613 | 1.04M | if (operands[i] == operand) |
3614 | 955k | return i; |
3615 | 85.7k | else if (operands[i] == AARCH64_OPND_NIL) |
3616 | 8.03k | break; |
3617 | 8.03k | return -1; |
3618 | 963k | } |
3619 | | |
3620 | | /* R0...R30, followed by FOR31. */ |
3621 | | #define BANK(R, FOR31) \ |
3622 | | { R (0), R (1), R (2), R (3), R (4), R (5), R (6), R (7), \ |
3623 | | R (8), R (9), R (10), R (11), R (12), R (13), R (14), R (15), \ |
3624 | | R (16), R (17), R (18), R (19), R (20), R (21), R (22), R (23), \ |
3625 | | R (24), R (25), R (26), R (27), R (28), R (29), R (30), FOR31 } |
3626 | | /* [0][0] 32-bit integer regs with sp Wn |
3627 | | [0][1] 64-bit integer regs with sp Xn sf=1 |
3628 | | [1][0] 32-bit integer regs with #0 Wn |
3629 | | [1][1] 64-bit integer regs with #0 Xn sf=1 */ |
3630 | | static const char *int_reg[2][2][32] = { |
3631 | | #define R32(X) "w" #X |
3632 | | #define R64(X) "x" #X |
3633 | | { BANK (R32, "wsp"), BANK (R64, "sp") }, |
3634 | | { BANK (R32, "wzr"), BANK (R64, "xzr") } |
3635 | | #undef R64 |
3636 | | #undef R32 |
3637 | | }; |
3638 | | |
3639 | | /* Names of the SVE vector registers, first with .S suffixes, |
3640 | | then with .D suffixes. */ |
3641 | | |
3642 | | static const char *sve_reg[2][32] = { |
3643 | | #define ZS(X) "z" #X ".s" |
3644 | | #define ZD(X) "z" #X ".d" |
3645 | | BANK (ZS, ZS (31)), BANK (ZD, ZD (31)) |
3646 | | #undef ZD |
3647 | | #undef ZS |
3648 | | }; |
3649 | | #undef BANK |
3650 | | |
3651 | | /* Return the integer register name. |
3652 | | if SP_REG_P is not 0, R31 is an SP reg, other R31 is the zero reg. */ |
3653 | | |
3654 | | static inline const char * |
3655 | | get_int_reg_name (int regno, aarch64_opnd_qualifier_t qualifier, int sp_reg_p) |
3656 | 18.3M | { |
3657 | 18.3M | const int has_zr = sp_reg_p ? 0 : 1; |
3658 | 18.3M | const int is_64 = aarch64_get_qualifier_esize (qualifier) == 4 ? 0 : 1; |
3659 | 18.3M | return int_reg[has_zr][is_64][regno]; |
3660 | 18.3M | } |
3661 | | |
3662 | | /* Like get_int_reg_name, but IS_64 is always 1. */ |
3663 | | |
3664 | | static inline const char * |
3665 | | get_64bit_int_reg_name (int regno, int sp_reg_p) |
3666 | 6.15M | { |
3667 | 6.15M | const int has_zr = sp_reg_p ? 0 : 1; |
3668 | 6.15M | return int_reg[has_zr][1][regno]; |
3669 | 6.15M | } |
3670 | | |
3671 | | /* Get the name of the integer offset register in OPND, using the shift type |
3672 | | to decide whether it's a word or doubleword. */ |
3673 | | |
3674 | | static inline const char * |
3675 | | get_offset_int_reg_name (const aarch64_opnd_info *opnd) |
3676 | 451k | { |
3677 | 451k | switch (opnd->shifter.kind) |
3678 | 451k | { |
3679 | 13.2k | case AARCH64_MOD_UXTW: |
3680 | 21.2k | case AARCH64_MOD_SXTW: |
3681 | 21.2k | return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_W, 0); |
3682 | | |
3683 | 421k | case AARCH64_MOD_LSL: |
3684 | 430k | case AARCH64_MOD_SXTX: |
3685 | 430k | return get_int_reg_name (opnd->addr.offset.regno, AARCH64_OPND_QLF_X, 0); |
3686 | | |
3687 | 0 | default: |
3688 | 0 | abort (); |
3689 | 451k | } |
3690 | 451k | } |
3691 | | |
3692 | | /* Get the name of the SVE vector offset register in OPND, using the operand |
3693 | | qualifier to decide whether the suffix should be .S or .D. */ |
3694 | | |
3695 | | static inline const char * |
3696 | | get_addr_sve_reg_name (int regno, aarch64_opnd_qualifier_t qualifier) |
3697 | 508k | { |
3698 | 508k | assert (qualifier == AARCH64_OPND_QLF_S_S |
3699 | 508k | || qualifier == AARCH64_OPND_QLF_S_D); |
3700 | 508k | return sve_reg[qualifier == AARCH64_OPND_QLF_S_D][regno]; |
3701 | 508k | } |
3702 | | |
3703 | | /* Types for expanding an encoded 8-bit value to a floating-point value. */ |
3704 | | |
3705 | | typedef union |
3706 | | { |
3707 | | uint64_t i; |
3708 | | double d; |
3709 | | } double_conv_t; |
3710 | | |
3711 | | typedef union |
3712 | | { |
3713 | | uint32_t i; |
3714 | | float f; |
3715 | | } single_conv_t; |
3716 | | |
3717 | | typedef union |
3718 | | { |
3719 | | uint32_t i; |
3720 | | float f; |
3721 | | } half_conv_t; |
3722 | | |
3723 | | /* IMM8 is an 8-bit floating-point constant with sign, 3-bit exponent and |
3724 | | normalized 4 bits of precision, encoded in "a:b:c:d:e:f:g:h" or FLD_imm8 |
3725 | | (depending on the type of the instruction). IMM8 will be expanded to a |
3726 | | single-precision floating-point value (SIZE == 4) or a double-precision |
3727 | | floating-point value (SIZE == 8). A half-precision floating-point value |
3728 | | (SIZE == 2) is expanded to a single-precision floating-point value. The |
3729 | | expanded value is returned. */ |
3730 | | |
3731 | | static uint64_t |
3732 | | expand_fp_imm (int size, uint32_t imm8) |
3733 | 10.9k | { |
3734 | 10.9k | uint64_t imm = 0; |
3735 | 10.9k | uint32_t imm8_7, imm8_6_0, imm8_6, imm8_6_repl4; |
3736 | | |
3737 | 10.9k | imm8_7 = (imm8 >> 7) & 0x01; /* imm8<7> */ |
3738 | 10.9k | imm8_6_0 = imm8 & 0x7f; /* imm8<6:0> */ |
3739 | 10.9k | imm8_6 = imm8_6_0 >> 6; /* imm8<6> */ |
3740 | 10.9k | imm8_6_repl4 = (imm8_6 << 3) | (imm8_6 << 2) |
3741 | 10.9k | | (imm8_6 << 1) | imm8_6; /* Replicate(imm8<6>,4) */ |
3742 | 10.9k | if (size == 8) |
3743 | 1.83k | { |
3744 | 1.83k | imm = (imm8_7 << (63-32)) /* imm8<7> */ |
3745 | 1.83k | | ((imm8_6 ^ 1) << (62-32)) /* NOT(imm8<6) */ |
3746 | 1.83k | | (imm8_6_repl4 << (58-32)) | (imm8_6 << (57-32)) |
3747 | 1.83k | | (imm8_6 << (56-32)) | (imm8_6 << (55-32)) /* Replicate(imm8<6>,7) */ |
3748 | 1.83k | | (imm8_6_0 << (48-32)); /* imm8<6>:imm8<5:0> */ |
3749 | 1.83k | imm <<= 32; |
3750 | 1.83k | } |
3751 | 9.09k | else if (size == 4 || size == 2) |
3752 | 9.09k | { |
3753 | 9.09k | imm = (imm8_7 << 31) /* imm8<7> */ |
3754 | 9.09k | | ((imm8_6 ^ 1) << 30) /* NOT(imm8<6>) */ |
3755 | 9.09k | | (imm8_6_repl4 << 26) /* Replicate(imm8<6>,4) */ |
3756 | 9.09k | | (imm8_6_0 << 19); /* imm8<6>:imm8<5:0> */ |
3757 | 9.09k | } |
3758 | 0 | else |
3759 | 0 | { |
3760 | | /* An unsupported size. */ |
3761 | 0 | assert (0); |
3762 | 0 | } |
3763 | | |
3764 | 10.9k | return imm; |
3765 | 10.9k | } |
3766 | | |
3767 | | /* Return a string based on FMT with the register style applied. */ |
3768 | | |
3769 | | static const char * |
3770 | | style_reg (struct aarch64_styler *styler, const char *fmt, ...) |
3771 | 40.8M | { |
3772 | 40.8M | const char *txt; |
3773 | 40.8M | va_list ap; |
3774 | | |
3775 | 40.8M | va_start (ap, fmt); |
3776 | 40.8M | txt = styler->apply_style (styler, dis_style_register, fmt, ap); |
3777 | 40.8M | va_end (ap); |
3778 | | |
3779 | 40.8M | return txt; |
3780 | 40.8M | } |
3781 | | |
3782 | | /* Return a string based on FMT with the immediate style applied. */ |
3783 | | |
3784 | | static const char * |
3785 | | style_imm (struct aarch64_styler *styler, const char *fmt, ...) |
3786 | 18.7M | { |
3787 | 18.7M | const char *txt; |
3788 | 18.7M | va_list ap; |
3789 | | |
3790 | 18.7M | va_start (ap, fmt); |
3791 | 18.7M | txt = styler->apply_style (styler, dis_style_immediate, fmt, ap); |
3792 | 18.7M | va_end (ap); |
3793 | | |
3794 | 18.7M | return txt; |
3795 | 18.7M | } |
3796 | | |
3797 | | /* Return a string based on FMT with the sub-mnemonic style applied. */ |
3798 | | |
3799 | | static const char * |
3800 | | style_sub_mnem (struct aarch64_styler *styler, const char *fmt, ...) |
3801 | 3.01M | { |
3802 | 3.01M | const char *txt; |
3803 | 3.01M | va_list ap; |
3804 | | |
3805 | 3.01M | va_start (ap, fmt); |
3806 | 3.01M | txt = styler->apply_style (styler, dis_style_sub_mnemonic, fmt, ap); |
3807 | 3.01M | va_end (ap); |
3808 | | |
3809 | 3.01M | return txt; |
3810 | 3.01M | } |
3811 | | |
3812 | | /* Return a string based on FMT with the address style applied. */ |
3813 | | |
3814 | | static const char * |
3815 | | style_addr (struct aarch64_styler *styler, const char *fmt, ...) |
3816 | 4.90M | { |
3817 | 4.90M | const char *txt; |
3818 | 4.90M | va_list ap; |
3819 | | |
3820 | 4.90M | va_start (ap, fmt); |
3821 | 4.90M | txt = styler->apply_style (styler, dis_style_address, fmt, ap); |
3822 | 4.90M | va_end (ap); |
3823 | | |
3824 | 4.90M | return txt; |
3825 | 4.90M | } |
3826 | | |
3827 | | /* Produce the string representation of the register list operand *OPND |
3828 | | in the buffer pointed by BUF of size SIZE. PREFIX is the part of |
3829 | | the register name that comes before the register number, such as "v". */ |
3830 | | static void |
3831 | | print_register_list (char *buf, size_t size, const aarch64_opnd_info *opnd, |
3832 | | const char *prefix, struct aarch64_styler *styler) |
3833 | 1.39M | { |
3834 | 1.39M | const int mask = (prefix[0] == 'p' ? 15 : 31); |
3835 | 1.39M | const int num_regs = opnd->reglist.num_regs; |
3836 | 1.39M | const int stride = opnd->reglist.stride; |
3837 | 1.39M | const int first_reg = opnd->reglist.first_regno; |
3838 | 1.39M | const int last_reg = (first_reg + (num_regs - 1) * stride) & mask; |
3839 | 1.39M | const char *qlf_name = aarch64_get_qualifier_name (opnd->qualifier); |
3840 | 1.39M | char tb[16]; /* Temporary buffer. */ |
3841 | | |
3842 | 1.39M | assert (opnd->type != AARCH64_OPND_LEt || opnd->reglist.has_index); |
3843 | 1.39M | assert (num_regs >= 1 && num_regs <= 4); |
3844 | | |
3845 | | /* Prepare the index if any. */ |
3846 | 1.39M | if (opnd->reglist.has_index) |
3847 | | /* PR 21096: The %100 is to silence a warning about possible truncation. */ |
3848 | 130k | snprintf (tb, sizeof (tb), "[%s]", |
3849 | 130k | style_imm (styler, "%" PRIi64, (opnd->reglist.index % 100))); |
3850 | 1.26M | else |
3851 | 1.26M | tb[0] = '\0'; |
3852 | | |
3853 | | /* The hyphenated form is preferred for disassembly if there is |
3854 | | more than one register in the list, and the register numbers |
3855 | | are monotonically increasing in increments of one. */ |
3856 | 1.39M | if (stride == 1 && num_regs > 1) |
3857 | 487k | if (opnd->qualifier == AARCH64_OPND_QLF_NIL) |
3858 | 26 | snprintf (buf, size, "{%s-%s}%s", |
3859 | 26 | style_reg (styler, "%s%d", prefix, first_reg), |
3860 | 26 | style_reg (styler, "%s%d", prefix, last_reg), tb); |
3861 | 487k | else |
3862 | 487k | snprintf (buf, size, "{%s-%s}%s", |
3863 | 487k | style_reg (styler, "%s%d.%s", prefix, first_reg, qlf_name), |
3864 | 487k | style_reg (styler, "%s%d.%s", prefix, last_reg, qlf_name), tb); |
3865 | 905k | else |
3866 | 905k | { |
3867 | 905k | const int reg0 = first_reg; |
3868 | 905k | const int reg1 = (first_reg + stride) & mask; |
3869 | 905k | const int reg2 = (first_reg + stride * 2) & mask; |
3870 | 905k | const int reg3 = (first_reg + stride * 3) & mask; |
3871 | | |
3872 | 905k | switch (num_regs) |
3873 | 905k | { |
3874 | 880k | case 1: |
3875 | 880k | snprintf (buf, size, "{%s}%s", |
3876 | 880k | style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name), |
3877 | 880k | tb); |
3878 | 880k | break; |
3879 | 19.1k | case 2: |
3880 | 19.1k | snprintf (buf, size, "{%s, %s}%s", |
3881 | 19.1k | style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name), |
3882 | 19.1k | style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name), |
3883 | 19.1k | tb); |
3884 | 19.1k | break; |
3885 | 0 | case 3: |
3886 | 0 | snprintf (buf, size, "{%s, %s, %s}%s", |
3887 | 0 | style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name), |
3888 | 0 | style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name), |
3889 | 0 | style_reg (styler, "%s%d.%s", prefix, reg2, qlf_name), |
3890 | 0 | tb); |
3891 | 0 | break; |
3892 | 6.36k | case 4: |
3893 | 6.36k | snprintf (buf, size, "{%s, %s, %s, %s}%s", |
3894 | 6.36k | style_reg (styler, "%s%d.%s", prefix, reg0, qlf_name), |
3895 | 6.36k | style_reg (styler, "%s%d.%s", prefix, reg1, qlf_name), |
3896 | 6.36k | style_reg (styler, "%s%d.%s", prefix, reg2, qlf_name), |
3897 | 6.36k | style_reg (styler, "%s%d.%s", prefix, reg3, qlf_name), |
3898 | 6.36k | tb); |
3899 | 6.36k | break; |
3900 | 905k | } |
3901 | 905k | } |
3902 | 1.39M | } |
3903 | | |
3904 | | /* Print the register+immediate address in OPND to BUF, which has SIZE |
3905 | | characters. BASE is the name of the base register. */ |
3906 | | |
3907 | | static void |
3908 | | print_immediate_offset_address (char *buf, size_t size, |
3909 | | const aarch64_opnd_info *opnd, |
3910 | | const char *base, |
3911 | | struct aarch64_styler *styler) |
3912 | 2.56M | { |
3913 | 2.56M | if (opnd->addr.writeback) |
3914 | 680k | { |
3915 | 680k | if (opnd->addr.preind) |
3916 | 336k | { |
3917 | 336k | if (opnd->type == AARCH64_OPND_ADDR_SIMM10 && !opnd->addr.offset.imm) |
3918 | 59 | snprintf (buf, size, "[%s]!", style_reg (styler, base)); |
3919 | 335k | else |
3920 | 335k | snprintf (buf, size, "[%s, %s]!", |
3921 | 335k | style_reg (styler, base), |
3922 | 335k | style_imm (styler, "#%d", opnd->addr.offset.imm)); |
3923 | 336k | } |
3924 | 344k | else |
3925 | 344k | snprintf (buf, size, "[%s], %s", |
3926 | 344k | style_reg (styler, base), |
3927 | 344k | style_imm (styler, "#%d", opnd->addr.offset.imm)); |
3928 | 680k | } |
3929 | 1.88M | else |
3930 | 1.88M | { |
3931 | 1.88M | if (opnd->shifter.operator_present) |
3932 | 159k | { |
3933 | 159k | assert (opnd->shifter.kind == AARCH64_MOD_MUL_VL); |
3934 | 159k | snprintf (buf, size, "[%s, %s, %s]", |
3935 | 159k | style_reg (styler, base), |
3936 | 159k | style_imm (styler, "#%d", opnd->addr.offset.imm), |
3937 | 159k | style_sub_mnem (styler, "mul vl")); |
3938 | 159k | } |
3939 | 1.72M | else if (opnd->addr.offset.imm) |
3940 | 1.42M | snprintf (buf, size, "[%s, %s]", |
3941 | 1.42M | style_reg (styler, base), |
3942 | 1.42M | style_imm (styler, "#%d", opnd->addr.offset.imm)); |
3943 | 307k | else |
3944 | 307k | snprintf (buf, size, "[%s]", style_reg (styler, base)); |
3945 | 1.88M | } |
3946 | 2.56M | } |
3947 | | |
3948 | | /* Produce the string representation of the register offset address operand |
3949 | | *OPND in the buffer pointed by BUF of size SIZE. BASE and OFFSET are |
3950 | | the names of the base and offset registers. */ |
3951 | | static void |
3952 | | print_register_offset_address (char *buf, size_t size, |
3953 | | const aarch64_opnd_info *opnd, |
3954 | | const char *base, const char *offset, |
3955 | | struct aarch64_styler *styler) |
3956 | 879k | { |
3957 | 879k | char tb[32]; /* Temporary buffer. */ |
3958 | 879k | bool print_extend_p = true; |
3959 | 879k | bool print_amount_p = true; |
3960 | 879k | const char *shift_name = aarch64_operand_modifiers[opnd->shifter.kind].name; |
3961 | | |
3962 | | /* This is the case where offset is the optional argument and the optional |
3963 | | argument is ignored in the disassembly. */ |
3964 | 879k | if (opnd->type == AARCH64_OPND_SVE_ADDR_ZX && offset != NULL |
3965 | 879k | && strcmp (offset,"xzr") == 0) |
3966 | 3.29k | { |
3967 | | /* Example: [<Zn>.S{, <Xm>}]. |
3968 | | When the assembly is [Z0.S, XZR] or [Z0.S], Xm is XZR in both the cases |
3969 | | and the preferred disassembly is [Z0.S], ignoring the optional Xm. */ |
3970 | 3.29k | snprintf (buf, size, "[%s]", style_reg (styler, base)); |
3971 | 3.29k | } |
3972 | 876k | else |
3973 | 876k | { |
3974 | 876k | if (!opnd->shifter.amount && (opnd->qualifier != AARCH64_OPND_QLF_S_B |
3975 | 477k | || !opnd->shifter.amount_present)) |
3976 | 474k | { |
3977 | | /* Not print the shift/extend amount when the amount is zero and |
3978 | | when it is not the special case of 8-bit load/store |
3979 | | instruction. */ |
3980 | 474k | print_amount_p = false; |
3981 | | /* Likewise, no need to print the shift operator LSL in such a |
3982 | | situation. */ |
3983 | 474k | if (opnd->shifter.kind == AARCH64_MOD_LSL) |
3984 | 211k | print_extend_p = false; |
3985 | 474k | } |
3986 | | |
3987 | | /* Prepare for the extend/shift. */ |
3988 | 876k | if (print_extend_p) |
3989 | 664k | { |
3990 | 664k | if (print_amount_p) |
3991 | 402k | snprintf (tb, sizeof (tb), ", %s %s", |
3992 | 402k | style_sub_mnem (styler, shift_name), |
3993 | 402k | style_imm (styler, "#%" PRIi64, |
3994 | | /* PR 21096: The %100 is to silence a warning about possible |
3995 | | truncation. */ |
3996 | 402k | (opnd->shifter.amount % 100))); |
3997 | 262k | else |
3998 | 262k | snprintf (tb, sizeof (tb), ", %s", |
3999 | 262k | style_sub_mnem (styler, shift_name)); |
4000 | 664k | } |
4001 | 211k | else |
4002 | 211k | tb[0] = '\0'; |
4003 | | |
4004 | 876k | snprintf (buf, size, "[%s, %s%s]", style_reg (styler, base), |
4005 | 876k | style_reg (styler, offset), tb); |
4006 | 876k | } |
4007 | 879k | } |
4008 | | |
4009 | | /* Print ZA tiles from imm8 in ZERO instruction. |
4010 | | |
4011 | | The preferred disassembly of this instruction uses the shortest list of tile |
4012 | | names that represent the encoded immediate mask. |
4013 | | |
4014 | | For example: |
4015 | | * An all-ones immediate is disassembled as {ZA}. |
4016 | | * An all-zeros immediate is disassembled as an empty list { }. |
4017 | | */ |
4018 | | static void |
4019 | | print_sme_za_list (char *buf, size_t size, int mask, |
4020 | | struct aarch64_styler *styler) |
4021 | 370 | { |
4022 | 370 | const char* zan[] = { "za", "za0.h", "za1.h", "za0.s", |
4023 | 370 | "za1.s", "za2.s", "za3.s", "za0.d", |
4024 | 370 | "za1.d", "za2.d", "za3.d", "za4.d", |
4025 | 370 | "za5.d", "za6.d", "za7.d", " " }; |
4026 | 370 | const int zan_v[] = { 0xff, 0x55, 0xaa, 0x11, |
4027 | 370 | 0x22, 0x44, 0x88, 0x01, |
4028 | 370 | 0x02, 0x04, 0x08, 0x10, |
4029 | 370 | 0x20, 0x40, 0x80, 0x00 }; |
4030 | 370 | int i, k; |
4031 | 370 | const int ZAN_SIZE = sizeof(zan) / sizeof(zan[0]); |
4032 | | |
4033 | 370 | k = snprintf (buf, size, "{"); |
4034 | 3.82k | for (i = 0; i < ZAN_SIZE; i++) |
4035 | 3.82k | { |
4036 | 3.82k | if ((mask & zan_v[i]) == zan_v[i]) |
4037 | 1.22k | { |
4038 | 1.22k | mask &= ~zan_v[i]; |
4039 | 1.22k | if (k > 1) |
4040 | 865 | k += snprintf (buf + k, size - k, ", "); |
4041 | | |
4042 | 1.22k | k += snprintf (buf + k, size - k, "%s", style_reg (styler, zan[i])); |
4043 | 1.22k | } |
4044 | 3.82k | if (mask == 0) |
4045 | 370 | break; |
4046 | 3.82k | } |
4047 | 370 | snprintf (buf + k, size - k, "}"); |
4048 | 370 | } |
4049 | | |
4050 | | /* Generate the string representation of the operand OPNDS[IDX] for OPCODE |
4051 | | in *BUF. The caller should pass in the maximum size of *BUF in SIZE. |
4052 | | PC, PCREL_P and ADDRESS are used to pass in and return information about |
4053 | | the PC-relative address calculation, where the PC value is passed in |
4054 | | PC. If the operand is pc-relative related, *PCREL_P (if PCREL_P non-NULL) |
4055 | | will return 1 and *ADDRESS (if ADDRESS non-NULL) will return the |
4056 | | calculated address; otherwise, *PCREL_P (if PCREL_P non-NULL) returns 0. |
4057 | | |
4058 | | The function serves both the disassembler and the assembler diagnostics |
4059 | | issuer, which is the reason why it lives in this file. */ |
4060 | | |
4061 | | void |
4062 | | aarch64_print_operand (char *buf, size_t size, bfd_vma pc, |
4063 | | const aarch64_opcode *opcode, |
4064 | | const aarch64_opnd_info *opnds, int idx, int *pcrel_p, |
4065 | | bfd_vma *address, char** notes, |
4066 | | char *comment, size_t comment_size, |
4067 | | aarch64_feature_set features, |
4068 | | struct aarch64_styler *styler) |
4069 | 56.1M | { |
4070 | 56.1M | unsigned int i, num_conds; |
4071 | 56.1M | const char *name = NULL; |
4072 | 56.1M | const aarch64_opnd_info *opnd = opnds + idx; |
4073 | 56.1M | enum aarch64_modifier_kind kind; |
4074 | 56.1M | uint64_t addr, enum_value; |
4075 | | |
4076 | 56.1M | if (comment != NULL) |
4077 | 56.1M | { |
4078 | 56.1M | assert (comment_size > 0); |
4079 | 56.1M | comment[0] = '\0'; |
4080 | 56.1M | } |
4081 | 0 | else |
4082 | 0 | assert (comment_size == 0); |
4083 | | |
4084 | 56.1M | buf[0] = '\0'; |
4085 | 56.1M | if (pcrel_p) |
4086 | 56.1M | *pcrel_p = 0; |
4087 | | |
4088 | 56.1M | switch (opnd->type) |
4089 | 56.1M | { |
4090 | 4.69M | case AARCH64_OPND_Rd: |
4091 | 7.16M | case AARCH64_OPND_Rn: |
4092 | 7.55M | case AARCH64_OPND_Rm: |
4093 | 12.6M | case AARCH64_OPND_Rt: |
4094 | 13.3M | case AARCH64_OPND_Rt2: |
4095 | 14.4M | case AARCH64_OPND_Rs: |
4096 | 14.5M | case AARCH64_OPND_Ra: |
4097 | 14.5M | case AARCH64_OPND_Rt_IN_SYS_ALIASES: |
4098 | 14.5M | case AARCH64_OPND_Rt_LS64: |
4099 | 14.5M | case AARCH64_OPND_Rt_SYS: |
4100 | 14.5M | case AARCH64_OPND_PAIRREG: |
4101 | 14.5M | case AARCH64_OPND_PAIRREG_OR_XZR: |
4102 | 14.5M | case AARCH64_OPND_SVE_Rm: |
4103 | 14.5M | case AARCH64_OPND_LSE128_Rt: |
4104 | 14.5M | case AARCH64_OPND_LSE128_Rt2: |
4105 | | /* The optional-ness of <Xt> in e.g. IC <ic_op>{, <Xt>} is determined by |
4106 | | the <ic_op>, therefore we use opnd->present to override the |
4107 | | generic optional-ness information. */ |
4108 | 14.5M | if (opnd->type == AARCH64_OPND_Rt_SYS) |
4109 | 240 | { |
4110 | 240 | if (!opnd->present) |
4111 | 45 | break; |
4112 | 240 | } |
4113 | 14.5M | else if ((opnd->type == AARCH64_OPND_Rt_IN_SYS_ALIASES) |
4114 | 14.5M | && (opnd->reg.regno |
4115 | 0 | != get_optional_operand_default_value (opcode))) |
4116 | 0 | { |
4117 | | /* Avoid printing an invalid additional value for Rt in SYS aliases such as |
4118 | | BRB, provide a helpful comment instead */ |
4119 | 0 | snprintf (comment, comment_size, "unpredictable encoding (Rt!=31): #%u", opnd->reg.regno); |
4120 | 0 | break; |
4121 | 0 | } |
4122 | | /* Omit the operand, e.g. RET. */ |
4123 | 14.5M | else if (optional_operand_p (opcode, idx) |
4124 | 14.5M | && (opnd->reg.regno |
4125 | 16.8k | == get_optional_operand_default_value (opcode))) |
4126 | 12.4k | break; |
4127 | 14.5M | assert (opnd->qualifier == AARCH64_OPND_QLF_W |
4128 | 14.5M | || opnd->qualifier == AARCH64_OPND_QLF_X); |
4129 | 14.5M | snprintf (buf, size, "%s", |
4130 | 14.5M | style_reg (styler, get_int_reg_name (opnd->reg.regno, |
4131 | 14.5M | opnd->qualifier, 0))); |
4132 | 14.5M | break; |
4133 | | |
4134 | 634k | case AARCH64_OPND_Rd_SP: |
4135 | 1.39M | case AARCH64_OPND_Rn_SP: |
4136 | 1.41M | case AARCH64_OPND_Rt_SP: |
4137 | 1.41M | case AARCH64_OPND_SVE_Rn_SP: |
4138 | 1.41M | case AARCH64_OPND_Rm_SP: |
4139 | 1.41M | assert (opnd->qualifier == AARCH64_OPND_QLF_W |
4140 | 1.41M | || opnd->qualifier == AARCH64_OPND_QLF_WSP |
4141 | 1.41M | || opnd->qualifier == AARCH64_OPND_QLF_X |
4142 | 1.41M | || opnd->qualifier == AARCH64_OPND_QLF_SP); |
4143 | 1.41M | snprintf (buf, size, "%s", |
4144 | 1.41M | style_reg (styler, get_int_reg_name (opnd->reg.regno, |
4145 | 1.41M | opnd->qualifier, 1))); |
4146 | 1.41M | break; |
4147 | | |
4148 | 68.8k | case AARCH64_OPND_Rm_EXT: |
4149 | 68.8k | kind = opnd->shifter.kind; |
4150 | 68.8k | assert (idx == 1 || idx == 2); |
4151 | 68.8k | if ((aarch64_stack_pointer_p (opnds) |
4152 | 68.8k | || (idx == 2 && aarch64_stack_pointer_p (opnds + 1))) |
4153 | 68.8k | && ((opnd->qualifier == AARCH64_OPND_QLF_W |
4154 | 2.64k | && opnds[0].qualifier == AARCH64_OPND_QLF_W |
4155 | 2.64k | && kind == AARCH64_MOD_UXTW) |
4156 | 2.64k | || (opnd->qualifier == AARCH64_OPND_QLF_X |
4157 | 2.53k | && kind == AARCH64_MOD_UXTX))) |
4158 | 926 | { |
4159 | | /* 'LSL' is the preferred form in this case. */ |
4160 | 926 | kind = AARCH64_MOD_LSL; |
4161 | 926 | if (opnd->shifter.amount == 0) |
4162 | 532 | { |
4163 | | /* Shifter omitted. */ |
4164 | 532 | snprintf (buf, size, "%s", |
4165 | 532 | style_reg (styler, |
4166 | 532 | get_int_reg_name (opnd->reg.regno, |
4167 | 532 | opnd->qualifier, 0))); |
4168 | 532 | break; |
4169 | 532 | } |
4170 | 926 | } |
4171 | 68.3k | if (opnd->shifter.amount) |
4172 | 54.4k | snprintf (buf, size, "%s, %s %s", |
4173 | 54.4k | style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)), |
4174 | 54.4k | style_sub_mnem (styler, aarch64_operand_modifiers[kind].name), |
4175 | 54.4k | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4176 | 13.8k | else |
4177 | 13.8k | snprintf (buf, size, "%s, %s", |
4178 | 13.8k | style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)), |
4179 | 13.8k | style_sub_mnem (styler, aarch64_operand_modifiers[kind].name)); |
4180 | 68.3k | break; |
4181 | | |
4182 | 1.81M | case AARCH64_OPND_Rm_SFT: |
4183 | 1.81M | assert (opnd->qualifier == AARCH64_OPND_QLF_W |
4184 | 1.81M | || opnd->qualifier == AARCH64_OPND_QLF_X); |
4185 | 1.81M | if (opnd->shifter.amount == 0 && opnd->shifter.kind == AARCH64_MOD_LSL) |
4186 | 272k | snprintf (buf, size, "%s", |
4187 | 272k | style_reg (styler, get_int_reg_name (opnd->reg.regno, |
4188 | 272k | opnd->qualifier, 0))); |
4189 | 1.54M | else |
4190 | 1.54M | snprintf (buf, size, "%s, %s %s", |
4191 | 1.54M | style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)), |
4192 | 1.54M | style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name), |
4193 | 1.54M | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4194 | 1.81M | break; |
4195 | | |
4196 | 2.12k | case AARCH64_OPND_Rm_LSL: |
4197 | 2.12k | assert (opnd->qualifier == AARCH64_OPND_QLF_X); |
4198 | 2.12k | assert (opnd->shifter.kind == AARCH64_MOD_LSL); |
4199 | 2.12k | if (opnd->shifter.amount == 0) |
4200 | 196 | snprintf (buf, size, "%s", |
4201 | 196 | style_reg (styler, get_int_reg_name (opnd->reg.regno, |
4202 | 196 | opnd->qualifier, 0))); |
4203 | 1.93k | else |
4204 | 1.93k | snprintf (buf, size, "%s, %s %s", |
4205 | 1.93k | style_reg (styler, get_int_reg_name (opnd->reg.regno, opnd->qualifier, 0)), |
4206 | 1.93k | style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name), |
4207 | 1.93k | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4208 | 2.12k | break; |
4209 | | |
4210 | 171k | case AARCH64_OPND_Fd: |
4211 | 323k | case AARCH64_OPND_Fn: |
4212 | 493k | case AARCH64_OPND_Fm: |
4213 | 622k | case AARCH64_OPND_Fa: |
4214 | 2.03M | case AARCH64_OPND_Ft: |
4215 | 2.80M | case AARCH64_OPND_Ft2: |
4216 | 2.85M | case AARCH64_OPND_Sd: |
4217 | 2.90M | case AARCH64_OPND_Sn: |
4218 | 2.92M | case AARCH64_OPND_Sm: |
4219 | 2.92M | case AARCH64_OPND_SVE_VZn: |
4220 | 2.93M | case AARCH64_OPND_SVE_Vd: |
4221 | 2.93M | case AARCH64_OPND_SVE_Vm: |
4222 | 2.93M | case AARCH64_OPND_SVE_Vn: |
4223 | 2.93M | snprintf (buf, size, "%s", |
4224 | 2.93M | style_reg (styler, "%s%d", |
4225 | 2.93M | aarch64_get_qualifier_name (opnd->qualifier), |
4226 | 2.93M | opnd->reg.regno)); |
4227 | 2.93M | break; |
4228 | | |
4229 | 25.4k | case AARCH64_OPND_Va: |
4230 | 875k | case AARCH64_OPND_Vd: |
4231 | 1.65M | case AARCH64_OPND_Vn: |
4232 | 2.15M | case AARCH64_OPND_Vm: |
4233 | 2.15M | snprintf (buf, size, "%s", |
4234 | 2.15M | style_reg (styler, "v%d.%s", opnd->reg.regno, |
4235 | 2.15M | aarch64_get_qualifier_name (opnd->qualifier))); |
4236 | 2.15M | break; |
4237 | | |
4238 | 3.25k | case AARCH64_OPND_Ed: |
4239 | 12.9k | case AARCH64_OPND_En: |
4240 | 104k | case AARCH64_OPND_Em: |
4241 | 273k | case AARCH64_OPND_Em16: |
4242 | 284k | case AARCH64_OPND_Em8: |
4243 | 284k | case AARCH64_OPND_SM3_IMM2: |
4244 | 284k | snprintf (buf, size, "%s[%s]", |
4245 | 284k | style_reg (styler, "v%d.%s", opnd->reglane.regno, |
4246 | 284k | aarch64_get_qualifier_name (opnd->qualifier)), |
4247 | 284k | style_imm (styler, "%" PRIi64, opnd->reglane.index)); |
4248 | 284k | break; |
4249 | | |
4250 | 1.85k | case AARCH64_OPND_Em_INDEX1_14: |
4251 | 4.13k | case AARCH64_OPND_Em_INDEX2_13: |
4252 | 4.74k | case AARCH64_OPND_Em_INDEX3_12: |
4253 | 4.74k | snprintf (buf, size, "%s[%s]", |
4254 | 4.74k | style_reg (styler, "v%d", opnd->reglane.regno), |
4255 | 4.74k | style_imm (styler, "%" PRIi64, opnd->reglane.index)); |
4256 | 4.74k | break; |
4257 | | |
4258 | 78 | case AARCH64_OPND_VdD1: |
4259 | 719 | case AARCH64_OPND_VnD1: |
4260 | 719 | snprintf (buf, size, "%s[%s]", |
4261 | 719 | style_reg (styler, "v%d.d", opnd->reg.regno), |
4262 | 719 | style_imm (styler, "1")); |
4263 | 719 | break; |
4264 | | |
4265 | 30.7k | case AARCH64_OPND_LVn: |
4266 | 35.4k | case AARCH64_OPND_LVn_LUT: |
4267 | 288k | case AARCH64_OPND_LVt: |
4268 | 294k | case AARCH64_OPND_LVt_AL: |
4269 | 424k | case AARCH64_OPND_LEt: |
4270 | 424k | print_register_list (buf, size, opnd, "v", styler); |
4271 | 424k | break; |
4272 | | |
4273 | 323k | case AARCH64_OPND_SVE_Pd: |
4274 | 2.34M | case AARCH64_OPND_SVE_Pg3: |
4275 | 2.34M | case AARCH64_OPND_SVE_Pg4_5: |
4276 | 2.39M | case AARCH64_OPND_SVE_Pg4_10: |
4277 | 2.46M | case AARCH64_OPND_SVE_Pg4_16: |
4278 | 2.47M | case AARCH64_OPND_SVE_Pm: |
4279 | 2.48M | case AARCH64_OPND_SVE_Pn: |
4280 | 2.49M | case AARCH64_OPND_SVE_Pt: |
4281 | 2.70M | case AARCH64_OPND_SME_Pm: |
4282 | 2.70M | if (opnd->qualifier == AARCH64_OPND_QLF_NIL) |
4283 | 456k | snprintf (buf, size, "%s", |
4284 | 456k | style_reg (styler, "p%d", opnd->reg.regno)); |
4285 | 2.25M | else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z |
4286 | 2.25M | || opnd->qualifier == AARCH64_OPND_QLF_P_M) |
4287 | 1.90M | snprintf (buf, size, "%s", |
4288 | 1.90M | style_reg (styler, "p%d/%s", opnd->reg.regno, |
4289 | 1.90M | aarch64_get_qualifier_name (opnd->qualifier))); |
4290 | 345k | else |
4291 | 345k | snprintf (buf, size, "%s", |
4292 | 345k | style_reg (styler, "p%d.%s", opnd->reg.regno, |
4293 | 345k | aarch64_get_qualifier_name (opnd->qualifier))); |
4294 | 2.70M | break; |
4295 | | |
4296 | 0 | case AARCH64_OPND_SVE_PNd: |
4297 | 0 | case AARCH64_OPND_SVE_PNg4_10: |
4298 | 0 | case AARCH64_OPND_SVE_PNn: |
4299 | 0 | case AARCH64_OPND_SVE_PNt: |
4300 | 4.36k | case AARCH64_OPND_SME_PNd3: |
4301 | 73.1k | case AARCH64_OPND_SME_PNg3: |
4302 | 73.2k | case AARCH64_OPND_SME_PNn: |
4303 | 73.2k | if (opnd->qualifier == AARCH64_OPND_QLF_NIL) |
4304 | 27.9k | snprintf (buf, size, "%s", |
4305 | 27.9k | style_reg (styler, "pn%d", opnd->reg.regno)); |
4306 | 45.2k | else if (opnd->qualifier == AARCH64_OPND_QLF_P_Z |
4307 | 45.2k | || opnd->qualifier == AARCH64_OPND_QLF_P_M) |
4308 | 40.8k | snprintf (buf, size, "%s", |
4309 | 40.8k | style_reg (styler, "pn%d/%s", opnd->reg.regno, |
4310 | 40.8k | aarch64_get_qualifier_name (opnd->qualifier))); |
4311 | 4.44k | else |
4312 | 4.44k | snprintf (buf, size, "%s", |
4313 | 4.44k | style_reg (styler, "pn%d.%s", opnd->reg.regno, |
4314 | 4.44k | aarch64_get_qualifier_name (opnd->qualifier))); |
4315 | 73.2k | break; |
4316 | | |
4317 | 671 | case AARCH64_OPND_SME_Pdx2: |
4318 | 733 | case AARCH64_OPND_SME_PdxN: |
4319 | 733 | print_register_list (buf, size, opnd, "p", styler); |
4320 | 733 | break; |
4321 | | |
4322 | 62 | case AARCH64_OPND_SME_PNn3_INDEX1: |
4323 | 111 | case AARCH64_OPND_SME_PNn3_INDEX2: |
4324 | 111 | snprintf (buf, size, "%s[%s]", |
4325 | 111 | style_reg (styler, "pn%d", opnd->reglane.regno), |
4326 | 111 | style_imm (styler, "%" PRIi64, opnd->reglane.index)); |
4327 | 111 | break; |
4328 | | |
4329 | 22.6k | case AARCH64_OPND_SVE_Za_5: |
4330 | 38.5k | case AARCH64_OPND_SVE_Za_16: |
4331 | 1.59M | case AARCH64_OPND_SVE_Zd: |
4332 | 1.73M | case AARCH64_OPND_SVE_Zm_5: |
4333 | 2.72M | case AARCH64_OPND_SVE_Zm_16: |
4334 | 4.14M | case AARCH64_OPND_SVE_Zn: |
4335 | 4.17M | case AARCH64_OPND_SVE_Zt: |
4336 | 4.23M | case AARCH64_OPND_SME_Zm: |
4337 | 4.23M | case AARCH64_OPND_SME_Zm_17: |
4338 | 4.23M | if (opnd->qualifier == AARCH64_OPND_QLF_NIL) |
4339 | 32.0k | snprintf (buf, size, "%s", style_reg (styler, "z%d", opnd->reg.regno)); |
4340 | 4.20M | else |
4341 | 4.20M | snprintf (buf, size, "%s", |
4342 | 4.20M | style_reg (styler, "z%d.%s", opnd->reg.regno, |
4343 | 4.20M | aarch64_get_qualifier_name (opnd->qualifier))); |
4344 | 4.23M | break; |
4345 | | |
4346 | 68.3k | case AARCH64_OPND_SVE_ZnxN: |
4347 | 861k | case AARCH64_OPND_SVE_ZtxN: |
4348 | 903k | case AARCH64_OPND_SME_Zdnx2: |
4349 | 913k | case AARCH64_OPND_SME_Zdnx4: |
4350 | 917k | case AARCH64_OPND_SME_Zmx2: |
4351 | 918k | case AARCH64_OPND_SME_Zmx4: |
4352 | 933k | case AARCH64_OPND_SME_Znx2: |
4353 | 933k | case AARCH64_OPND_SME_Znx2_BIT_INDEX: |
4354 | 942k | case AARCH64_OPND_SME_Znx4: |
4355 | 961k | case AARCH64_OPND_SME_Ztx2_STRIDED: |
4356 | 967k | case AARCH64_OPND_SME_Ztx4_STRIDED: |
4357 | 967k | print_register_list (buf, size, opnd, "z", styler); |
4358 | 967k | break; |
4359 | | |
4360 | 184 | case AARCH64_OPND_SVE_Zm1_23_INDEX: |
4361 | 2.48k | case AARCH64_OPND_SVE_Zm2_22_INDEX: |
4362 | 13.3k | case AARCH64_OPND_SVE_Zm3_INDEX: |
4363 | 24.6k | case AARCH64_OPND_SVE_Zm3_22_INDEX: |
4364 | 25.0k | case AARCH64_OPND_SVE_Zm3_19_INDEX: |
4365 | 25.7k | case AARCH64_OPND_SVE_Zm3_12_INDEX: |
4366 | 34.5k | case AARCH64_OPND_SVE_Zm3_11_INDEX: |
4367 | 41.3k | case AARCH64_OPND_SVE_Zm3_10_INDEX: |
4368 | 68.9k | case AARCH64_OPND_SVE_Zm4_11_INDEX: |
4369 | 82.7k | case AARCH64_OPND_SVE_Zm4_INDEX: |
4370 | 84.0k | case AARCH64_OPND_SVE_Zn_INDEX: |
4371 | 84.8k | case AARCH64_OPND_SME_Zm_INDEX1: |
4372 | 88.0k | case AARCH64_OPND_SME_Zm_INDEX2: |
4373 | 88.2k | case AARCH64_OPND_SME_Zm_INDEX2_3: |
4374 | 90.3k | case AARCH64_OPND_SME_Zm_INDEX3_1: |
4375 | 93.0k | case AARCH64_OPND_SME_Zm_INDEX3_2: |
4376 | 95.6k | case AARCH64_OPND_SME_Zm_INDEX3_3: |
4377 | 159k | case AARCH64_OPND_SME_Zm_INDEX3_10: |
4378 | 159k | case AARCH64_OPND_SVE_Zn_5_INDEX: |
4379 | 163k | case AARCH64_OPND_SME_Zm_INDEX4_1: |
4380 | 164k | case AARCH64_OPND_SME_Zm_INDEX4_2: |
4381 | 190k | case AARCH64_OPND_SME_Zm_INDEX4_3: |
4382 | 222k | case AARCH64_OPND_SME_Zm_INDEX4_10: |
4383 | 222k | case AARCH64_OPND_SME_Zn_INDEX1_16: |
4384 | 224k | case AARCH64_OPND_SME_Zn_INDEX2_15: |
4385 | 225k | case AARCH64_OPND_SME_Zn_INDEX2_16: |
4386 | 225k | case AARCH64_OPND_SME_Zn_INDEX3_14: |
4387 | 225k | case AARCH64_OPND_SME_Zn_INDEX3_15: |
4388 | 226k | case AARCH64_OPND_SME_Zn_INDEX4_14: |
4389 | 226k | snprintf (buf, size, "%s[%s]", |
4390 | 226k | (opnd->qualifier == AARCH64_OPND_QLF_NIL |
4391 | 226k | ? style_reg (styler, "z%d", opnd->reglane.regno) |
4392 | 226k | : style_reg (styler, "z%d.%s", opnd->reglane.regno, |
4393 | 219k | aarch64_get_qualifier_name (opnd->qualifier))), |
4394 | 226k | style_imm (styler, "%" PRIi64, opnd->reglane.index)); |
4395 | 226k | break; |
4396 | | |
4397 | 20 | case AARCH64_OPND_SVE_Zn0_INDEX: |
4398 | 43 | case AARCH64_OPND_SVE_Zn1_17_INDEX: |
4399 | 82 | case AARCH64_OPND_SVE_Zn2_18_INDEX: |
4400 | 180 | case AARCH64_OPND_SVE_Zn3_22_INDEX: |
4401 | 232 | case AARCH64_OPND_SVE_Zd0_INDEX: |
4402 | 266 | case AARCH64_OPND_SVE_Zd1_17_INDEX: |
4403 | 319 | case AARCH64_OPND_SVE_Zd2_18_INDEX: |
4404 | 361 | case AARCH64_OPND_SVE_Zd3_22_INDEX: |
4405 | 361 | if (opnd->reglane.index == 0) |
4406 | 80 | snprintf (buf, size, "%s", style_reg (styler, "z%d", opnd->reg.regno)); |
4407 | 281 | else |
4408 | 281 | snprintf (buf, size, "%s[%s]", |
4409 | 281 | style_reg (styler, "z%d", opnd->reglane.regno), |
4410 | 281 | style_imm (styler, "%" PRIi64, opnd->reglane.index)); |
4411 | 361 | break; |
4412 | | |
4413 | 5.18k | case AARCH64_OPND_SME_ZAda_1b: |
4414 | 145k | case AARCH64_OPND_SME_ZAda_2b: |
4415 | 210k | case AARCH64_OPND_SME_ZAda_3b: |
4416 | 210k | snprintf (buf, size, "%s", |
4417 | 210k | style_reg (styler, "za%d.%s", opnd->reg.regno, |
4418 | 210k | aarch64_get_qualifier_name (opnd->qualifier))); |
4419 | 210k | break; |
4420 | | |
4421 | 964 | case AARCH64_OPND_SME_ZA_HV_idx_src: |
4422 | 1.36k | case AARCH64_OPND_SME_ZA_HV_idx_srcxN: |
4423 | 40.1k | case AARCH64_OPND_SME_ZA_HV_idx_dest: |
4424 | 41.1k | case AARCH64_OPND_SME_ZA_HV_idx_destxN: |
4425 | 182k | case AARCH64_OPND_SME_ZA_HV_idx_ldstr: |
4426 | 182k | snprintf (buf, size, "%s%s[%s, %s%s%s%s%s]%s", |
4427 | 182k | opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "{" : "", |
4428 | 182k | style_reg (styler, "za%d%c.%s", |
4429 | 182k | opnd->indexed_za.regno, |
4430 | 182k | opnd->indexed_za.v == 1 ? 'v' : 'h', |
4431 | 182k | aarch64_get_qualifier_name (opnd->qualifier)), |
4432 | 182k | style_reg (styler, "w%d", opnd->indexed_za.index.regno), |
4433 | 182k | style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm), |
4434 | 182k | opnd->indexed_za.index.countm1 ? ":" : "", |
4435 | 182k | (opnd->indexed_za.index.countm1 |
4436 | 182k | ? style_imm (styler, "%d", |
4437 | 1.37k | opnd->indexed_za.index.imm |
4438 | 1.37k | + opnd->indexed_za.index.countm1) |
4439 | 182k | : ""), |
4440 | 182k | opnd->indexed_za.group_size ? ", " : "", |
4441 | 182k | opnd->indexed_za.group_size == 2 |
4442 | 182k | ? style_sub_mnem (styler, "vgx2") |
4443 | 182k | : opnd->indexed_za.group_size == 4 |
4444 | 182k | ? style_sub_mnem (styler, "vgx4") : "", |
4445 | 182k | opnd->type == AARCH64_OPND_SME_ZA_HV_idx_ldstr ? "}" : ""); |
4446 | 182k | break; |
4447 | | |
4448 | 370 | case AARCH64_OPND_SME_list_of_64bit_tiles: |
4449 | 370 | print_sme_za_list (buf, size, opnd->imm.value, styler); |
4450 | 370 | break; |
4451 | | |
4452 | 24.3k | case AARCH64_OPND_SME_ZA_array_off1x4: |
4453 | 29.7k | case AARCH64_OPND_SME_ZA_array_off2x2: |
4454 | 154k | case AARCH64_OPND_SME_ZA_array_off2x4: |
4455 | 168k | case AARCH64_OPND_SME_ZA_array_off3_0: |
4456 | 168k | case AARCH64_OPND_SME_ZA_array_off3_5: |
4457 | 201k | case AARCH64_OPND_SME_ZA_array_off3x2: |
4458 | 202k | case AARCH64_OPND_SME_ZA_array_off4: |
4459 | 202k | snprintf (buf, size, "%s[%s, %s%s%s%s%s]", |
4460 | 202k | style_reg (styler, "za%s%s", |
4461 | 202k | opnd->qualifier == AARCH64_OPND_QLF_NIL ? "" : ".", |
4462 | 202k | (opnd->qualifier == AARCH64_OPND_QLF_NIL |
4463 | 202k | ? "" |
4464 | 202k | : aarch64_get_qualifier_name (opnd->qualifier))), |
4465 | 202k | style_reg (styler, "w%d", opnd->indexed_za.index.regno), |
4466 | 202k | style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm), |
4467 | 202k | opnd->indexed_za.index.countm1 ? ":" : "", |
4468 | 202k | (opnd->indexed_za.index.countm1 |
4469 | 202k | ? style_imm (styler, "%d", |
4470 | 186k | opnd->indexed_za.index.imm |
4471 | 186k | + opnd->indexed_za.index.countm1) |
4472 | 202k | : ""), |
4473 | 202k | opnd->indexed_za.group_size ? ", " : "", |
4474 | 202k | opnd->indexed_za.group_size == 2 |
4475 | 202k | ? style_sub_mnem (styler, "vgx2") |
4476 | 202k | : opnd->indexed_za.group_size == 4 |
4477 | 184k | ? style_sub_mnem (styler, "vgx4") : ""); |
4478 | 202k | break; |
4479 | | |
4480 | 31 | case AARCH64_OPND_SME_ZA_array_vrsb_1: |
4481 | 91 | case AARCH64_OPND_SME_ZA_array_vrsh_1: |
4482 | 139 | case AARCH64_OPND_SME_ZA_array_vrss_1: |
4483 | 149 | case AARCH64_OPND_SME_ZA_array_vrsd_1: |
4484 | 440 | case AARCH64_OPND_SME_ZA_array_vrsb_2: |
4485 | 450 | case AARCH64_OPND_SME_ZA_array_vrsh_2: |
4486 | 593 | case AARCH64_OPND_SME_ZA_array_vrss_2: |
4487 | 604 | case AARCH64_OPND_SME_ZA_array_vrsd_2: |
4488 | 1.39k | case AARCH64_OPND_SME_ZA_ARRAY4: |
4489 | 1.39k | snprintf (buf, size, "%s [%s, %s%s%s]", |
4490 | 1.39k | style_reg (styler, "za%d%c%s%s", |
4491 | 1.39k | opnd->indexed_za.regno, |
4492 | 1.39k | opnd->indexed_za.v ? 'v': 'h', |
4493 | 1.39k | opnd->qualifier == AARCH64_OPND_QLF_NIL ? "" : ".", |
4494 | 1.39k | (opnd->qualifier == AARCH64_OPND_QLF_NIL |
4495 | 1.39k | ? "" |
4496 | 1.39k | : aarch64_get_qualifier_name (opnd->qualifier))), |
4497 | 1.39k | style_reg (styler, "w%d", opnd->indexed_za.index.regno), |
4498 | 1.39k | style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm), |
4499 | 1.39k | opnd->indexed_za.index.countm1 ? ":" : "", |
4500 | 1.39k | opnd->indexed_za.index.countm1 ? style_imm (styler, "%d", |
4501 | 604 | opnd->indexed_za.index.imm |
4502 | 791 | + opnd->indexed_za.index.countm1):""); |
4503 | 1.39k | break; |
4504 | | |
4505 | 1 | case AARCH64_OPND_SME_SM_ZA: |
4506 | 1 | snprintf (buf, size, "%s", |
4507 | 1 | style_reg (styler, opnd->reg.regno == 's' ? "sm" : "za")); |
4508 | 1 | break; |
4509 | | |
4510 | 2.49k | case AARCH64_OPND_SME_PnT_Wm_imm: |
4511 | 2.49k | snprintf (buf, size, "%s[%s, %s]", |
4512 | 2.49k | style_reg (styler, "p%d.%s", opnd->indexed_za.regno, |
4513 | 2.49k | aarch64_get_qualifier_name (opnd->qualifier)), |
4514 | 2.49k | style_reg (styler, "w%d", opnd->indexed_za.index.regno), |
4515 | 2.49k | style_imm (styler, "%" PRIi64, opnd->indexed_za.index.imm)); |
4516 | 2.49k | break; |
4517 | | |
4518 | 86 | case AARCH64_OPND_SME_VLxN_10: |
4519 | 4.44k | case AARCH64_OPND_SME_VLxN_13: |
4520 | 4.44k | enum_value = opnd->imm.value; |
4521 | 4.44k | assert (enum_value < ARRAY_SIZE (aarch64_sme_vlxn_array)); |
4522 | 4.44k | snprintf (buf, size, "%s", |
4523 | 4.44k | style_sub_mnem (styler, aarch64_sme_vlxn_array[enum_value])); |
4524 | 4.44k | break; |
4525 | | |
4526 | 0 | case AARCH64_OPND_BRBOP: |
4527 | 0 | enum_value = opnd->imm.value; |
4528 | 0 | assert (enum_value < ARRAY_SIZE (aarch64_brbop_array)); |
4529 | 0 | snprintf (buf, size, "%s", |
4530 | 0 | style_sub_mnem (styler, aarch64_brbop_array[enum_value])); |
4531 | 0 | break; |
4532 | | |
4533 | 6.42k | case AARCH64_OPND_CRn: |
4534 | 12.8k | case AARCH64_OPND_CRm: |
4535 | 12.8k | snprintf (buf, size, "%s", |
4536 | 12.8k | style_reg (styler, "C%" PRIi64, opnd->imm.value)); |
4537 | 12.8k | break; |
4538 | | |
4539 | 68.6k | case AARCH64_OPND_IDX: |
4540 | 70.6k | case AARCH64_OPND_MASK: |
4541 | 201k | case AARCH64_OPND_IMM: |
4542 | 316k | case AARCH64_OPND_IMM_2: |
4543 | 428k | case AARCH64_OPND_WIDTH: |
4544 | 435k | case AARCH64_OPND_UIMM3_OP1: |
4545 | 441k | case AARCH64_OPND_UIMM3_OP2: |
4546 | 929k | case AARCH64_OPND_BIT_NUM: |
4547 | 960k | case AARCH64_OPND_IMM_VLSL: |
4548 | 1.00M | case AARCH64_OPND_IMM_VLSR: |
4549 | 1.00M | case AARCH64_OPND_SHLL_IMM: |
4550 | 1.00M | case AARCH64_OPND_IMM0: |
4551 | 1.00M | case AARCH64_OPND_IMMR: |
4552 | 1.02M | case AARCH64_OPND_IMMS: |
4553 | 9.99M | case AARCH64_OPND_UNDEFINED: |
4554 | 10.0M | case AARCH64_OPND_FBITS: |
4555 | 10.0M | case AARCH64_OPND_TME_UIMM16: |
4556 | 10.0M | case AARCH64_OPND_SIMM5: |
4557 | 10.0M | case AARCH64_OPND_SME_SHRIMM4: |
4558 | 10.0M | case AARCH64_OPND_SME_SHRIMM5: |
4559 | 10.0M | case AARCH64_OPND_SVE_SHLIMM_PRED: |
4560 | 10.0M | case AARCH64_OPND_SVE_SHLIMM_UNPRED: |
4561 | 10.0M | case AARCH64_OPND_SVE_SHLIMM_UNPRED_22: |
4562 | 10.0M | case AARCH64_OPND_SVE_SHRIMM_PRED: |
4563 | 10.0M | case AARCH64_OPND_SVE_SHRIMM_UNPRED: |
4564 | 10.0M | case AARCH64_OPND_SVE_SHRIMM_UNPRED_22: |
4565 | 10.0M | case AARCH64_OPND_SVE_SIMM5: |
4566 | 10.0M | case AARCH64_OPND_SVE_SIMM5B: |
4567 | 10.0M | case AARCH64_OPND_SVE_SIMM6: |
4568 | 10.0M | case AARCH64_OPND_SVE_SIMM8: |
4569 | 10.0M | case AARCH64_OPND_SVE_UIMM3: |
4570 | 10.1M | case AARCH64_OPND_SVE_UIMM7: |
4571 | 10.1M | case AARCH64_OPND_SVE_UIMM8: |
4572 | 10.1M | case AARCH64_OPND_SVE_UIMM4: |
4573 | 10.2M | case AARCH64_OPND_SVE_UIMM8_53: |
4574 | 10.2M | case AARCH64_OPND_IMM_ROT1: |
4575 | 10.2M | case AARCH64_OPND_IMM_ROT2: |
4576 | 10.2M | case AARCH64_OPND_IMM_ROT3: |
4577 | 10.2M | case AARCH64_OPND_SVE_IMM_ROT1: |
4578 | 10.3M | case AARCH64_OPND_SVE_IMM_ROT2: |
4579 | 10.3M | case AARCH64_OPND_SVE_IMM_ROT3: |
4580 | 10.3M | case AARCH64_OPND_CSSC_SIMM8: |
4581 | 10.3M | case AARCH64_OPND_CSSC_UIMM8: |
4582 | 10.3M | snprintf (buf, size, "%s", |
4583 | 10.3M | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
4584 | 10.3M | break; |
4585 | | |
4586 | 90 | case AARCH64_OPND_SVE_I1_HALF_ONE: |
4587 | 211 | case AARCH64_OPND_SVE_I1_HALF_TWO: |
4588 | 1.60k | case AARCH64_OPND_SVE_I1_ZERO_ONE: |
4589 | 1.60k | { |
4590 | 1.60k | single_conv_t c; |
4591 | 1.60k | c.i = opnd->imm.value; |
4592 | 1.60k | snprintf (buf, size, "%s", style_imm (styler, "#%.1f", c.f)); |
4593 | 1.60k | break; |
4594 | 211 | } |
4595 | | |
4596 | 127 | case AARCH64_OPND_SVE_PATTERN: |
4597 | 127 | if (optional_operand_p (opcode, idx) |
4598 | 127 | && opnd->imm.value == get_optional_operand_default_value (opcode)) |
4599 | 30 | break; |
4600 | 97 | enum_value = opnd->imm.value; |
4601 | 97 | assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array)); |
4602 | 97 | if (aarch64_sve_pattern_array[enum_value]) |
4603 | 55 | snprintf (buf, size, "%s", |
4604 | 55 | style_reg (styler, aarch64_sve_pattern_array[enum_value])); |
4605 | 42 | else |
4606 | 42 | snprintf (buf, size, "%s", |
4607 | 42 | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
4608 | 97 | break; |
4609 | | |
4610 | 12.6k | case AARCH64_OPND_SVE_PATTERN_SCALED: |
4611 | 12.6k | if (optional_operand_p (opcode, idx) |
4612 | 12.6k | && !opnd->shifter.operator_present |
4613 | 12.6k | && opnd->imm.value == get_optional_operand_default_value (opcode)) |
4614 | 515 | break; |
4615 | 12.1k | enum_value = opnd->imm.value; |
4616 | 12.1k | assert (enum_value < ARRAY_SIZE (aarch64_sve_pattern_array)); |
4617 | 12.1k | if (aarch64_sve_pattern_array[opnd->imm.value]) |
4618 | 8.69k | snprintf (buf, size, "%s", |
4619 | 8.69k | style_reg (styler, |
4620 | 8.69k | aarch64_sve_pattern_array[opnd->imm.value])); |
4621 | 3.47k | else |
4622 | 3.47k | snprintf (buf, size, "%s", |
4623 | 3.47k | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
4624 | 12.1k | if (opnd->shifter.operator_present) |
4625 | 11.3k | { |
4626 | 11.3k | size_t len = strlen (buf); |
4627 | 11.3k | const char *shift_name |
4628 | 11.3k | = aarch64_operand_modifiers[opnd->shifter.kind].name; |
4629 | 11.3k | snprintf (buf + len, size - len, ", %s %s", |
4630 | 11.3k | style_sub_mnem (styler, shift_name), |
4631 | 11.3k | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4632 | 11.3k | } |
4633 | 12.1k | break; |
4634 | | |
4635 | 163k | case AARCH64_OPND_SVE_PRFOP: |
4636 | 163k | enum_value = opnd->imm.value; |
4637 | 163k | assert (enum_value < ARRAY_SIZE (aarch64_sve_prfop_array)); |
4638 | 163k | if (aarch64_sve_prfop_array[enum_value]) |
4639 | 146k | snprintf (buf, size, "%s", |
4640 | 146k | style_reg (styler, aarch64_sve_prfop_array[enum_value])); |
4641 | 17.6k | else |
4642 | 17.6k | snprintf (buf, size, "%s", |
4643 | 17.6k | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
4644 | 163k | break; |
4645 | | |
4646 | 184k | case AARCH64_OPND_IMM_MOV: |
4647 | 184k | switch (aarch64_get_qualifier_esize (opnds[0].qualifier)) |
4648 | 184k | { |
4649 | 67.3k | case 4: /* e.g. MOV Wd, #<imm32>. */ |
4650 | 67.3k | { |
4651 | 67.3k | int imm32 = opnd->imm.value; |
4652 | 67.3k | snprintf (buf, size, "%s", |
4653 | 67.3k | style_imm (styler, "#0x%-20x", imm32)); |
4654 | 67.3k | snprintf (comment, comment_size, "#%d", imm32); |
4655 | 67.3k | } |
4656 | 67.3k | break; |
4657 | 116k | case 8: /* e.g. MOV Xd, #<imm64>. */ |
4658 | 116k | snprintf (buf, size, "%s", style_imm (styler, "#0x%-20" PRIx64, |
4659 | 116k | opnd->imm.value)); |
4660 | 116k | snprintf (comment, comment_size, "#%" PRIi64, opnd->imm.value); |
4661 | 116k | break; |
4662 | 0 | default: |
4663 | 0 | snprintf (buf, size, "<invalid>"); |
4664 | 0 | break; |
4665 | 184k | } |
4666 | 184k | break; |
4667 | | |
4668 | 184k | case AARCH64_OPND_FPIMM0: |
4669 | 1.04k | snprintf (buf, size, "%s", style_imm (styler, "#0.0")); |
4670 | 1.04k | break; |
4671 | | |
4672 | 366k | case AARCH64_OPND_LIMM: |
4673 | 1.03M | case AARCH64_OPND_AIMM: |
4674 | 1.16M | case AARCH64_OPND_HALF: |
4675 | 1.16M | case AARCH64_OPND_SVE_INV_LIMM: |
4676 | 1.36M | case AARCH64_OPND_SVE_LIMM: |
4677 | 1.36M | case AARCH64_OPND_SVE_LIMM_MOV: |
4678 | 1.36M | if (opnd->shifter.amount) |
4679 | 305k | snprintf (buf, size, "%s, %s %s", |
4680 | 305k | style_imm (styler, "#0x%" PRIx64, opnd->imm.value), |
4681 | 305k | style_sub_mnem (styler, "lsl"), |
4682 | 305k | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4683 | 1.06M | else |
4684 | 1.06M | snprintf (buf, size, "%s", |
4685 | 1.06M | style_imm (styler, "#0x%" PRIx64, opnd->imm.value)); |
4686 | 1.36M | break; |
4687 | | |
4688 | 1.66k | case AARCH64_OPND_SIMD_IMM: |
4689 | 10.5k | case AARCH64_OPND_SIMD_IMM_SFT: |
4690 | 10.5k | if ((! opnd->shifter.amount && opnd->shifter.kind == AARCH64_MOD_LSL) |
4691 | 10.5k | || opnd->shifter.kind == AARCH64_MOD_NONE) |
4692 | 5.53k | snprintf (buf, size, "%s", |
4693 | 5.53k | style_imm (styler, "#0x%" PRIx64, opnd->imm.value)); |
4694 | 5.01k | else |
4695 | 5.01k | snprintf (buf, size, "%s, %s %s", |
4696 | 5.01k | style_imm (styler, "#0x%" PRIx64, opnd->imm.value), |
4697 | 5.01k | style_sub_mnem (styler, aarch64_operand_modifiers[opnd->shifter.kind].name), |
4698 | 5.01k | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4699 | 10.5k | break; |
4700 | | |
4701 | 1.98k | case AARCH64_OPND_SVE_AIMM: |
4702 | 66.4k | case AARCH64_OPND_SVE_ASIMM: |
4703 | 66.4k | if (opnd->shifter.amount) |
4704 | 225 | snprintf (buf, size, "%s, %s %s", |
4705 | 225 | style_imm (styler, "#%" PRIi64, opnd->imm.value), |
4706 | 225 | style_sub_mnem (styler, "lsl"), |
4707 | 225 | style_imm (styler, "#%" PRIi64, opnd->shifter.amount)); |
4708 | 66.1k | else |
4709 | 66.1k | snprintf (buf, size, "%s", |
4710 | 66.1k | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
4711 | 66.4k | break; |
4712 | | |
4713 | 302 | case AARCH64_OPND_FPIMM: |
4714 | 8.57k | case AARCH64_OPND_SIMD_FPIMM: |
4715 | 10.9k | case AARCH64_OPND_SVE_FPIMM8: |
4716 | 10.9k | switch (aarch64_get_qualifier_esize (opnds[0].qualifier)) |
4717 | 10.9k | { |
4718 | 8.19k | case 2: /* e.g. FMOV <Hd>, #<imm>. */ |
4719 | 8.19k | { |
4720 | 8.19k | half_conv_t c; |
4721 | 8.19k | c.i = expand_fp_imm (2, opnd->imm.value); |
4722 | 8.19k | snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f)); |
4723 | 8.19k | } |
4724 | 8.19k | break; |
4725 | 903 | case 4: /* e.g. FMOV <Vd>.4S, #<imm>. */ |
4726 | 903 | { |
4727 | 903 | single_conv_t c; |
4728 | 903 | c.i = expand_fp_imm (4, opnd->imm.value); |
4729 | 903 | snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.f)); |
4730 | 903 | } |
4731 | 903 | break; |
4732 | 1.83k | case 8: /* e.g. FMOV <Sd>, #<imm>. */ |
4733 | 1.83k | { |
4734 | 1.83k | double_conv_t c; |
4735 | 1.83k | c.i = expand_fp_imm (8, opnd->imm.value); |
4736 | 1.83k | snprintf (buf, size, "%s", style_imm (styler, "#%.18e", c.d)); |
4737 | 1.83k | } |
4738 | 1.83k | break; |
4739 | 0 | default: |
4740 | 0 | snprintf (buf, size, "<invalid>"); |
4741 | 0 | break; |
4742 | 10.9k | } |
4743 | 10.9k | break; |
4744 | | |
4745 | 10.9k | case AARCH64_OPND_CCMP_IMM: |
4746 | 25.2k | case AARCH64_OPND_NZCV: |
4747 | 27.9k | case AARCH64_OPND_EXCEPTION: |
4748 | 28.0k | case AARCH64_OPND_UIMM4: |
4749 | 46.7k | case AARCH64_OPND_UIMM4_ADDG: |
4750 | 46.9k | case AARCH64_OPND_UIMM7: |
4751 | 65.5k | case AARCH64_OPND_UIMM10: |
4752 | 65.5k | if (optional_operand_p (opcode, idx) |
4753 | 65.5k | && (opnd->imm.value == |
4754 | 811 | (int64_t) get_optional_operand_default_value (opcode))) |
4755 | | /* Omit the operand, e.g. DCPS1. */ |
4756 | 23 | break; |
4757 | 65.5k | snprintf (buf, size, "%s", |
4758 | 65.5k | style_imm (styler, "#0x%x", (unsigned int) opnd->imm.value)); |
4759 | 65.5k | break; |
4760 | | |
4761 | 43.7k | case AARCH64_OPND_COND: |
4762 | 46.2k | case AARCH64_OPND_COND1: |
4763 | 46.2k | snprintf (buf, size, "%s", |
4764 | 46.2k | style_sub_mnem (styler, opnd->cond->names[0])); |
4765 | 46.2k | num_conds = ARRAY_SIZE (opnd->cond->names); |
4766 | 88.6k | for (i = 1; i < num_conds && opnd->cond->names[i]; ++i) |
4767 | 42.3k | { |
4768 | 42.3k | size_t len = comment != NULL ? strlen (comment) : 0; |
4769 | 42.3k | if (i == 1) |
4770 | 35.3k | snprintf (comment + len, comment_size - len, "%s = %s", |
4771 | 35.3k | opnd->cond->names[0], opnd->cond->names[i]); |
4772 | 6.97k | else |
4773 | 6.97k | snprintf (comment + len, comment_size - len, ", %s", |
4774 | 6.97k | opnd->cond->names[i]); |
4775 | 42.3k | } |
4776 | 46.2k | break; |
4777 | | |
4778 | 465k | case AARCH64_OPND_ADDR_ADRP: |
4779 | 465k | addr = ((pc + AARCH64_PCREL_OFFSET) & ~(uint64_t)0xfff) |
4780 | 465k | + opnd->imm.value; |
4781 | 465k | if (pcrel_p) |
4782 | 465k | *pcrel_p = 1; |
4783 | 465k | if (address) |
4784 | 465k | *address = addr; |
4785 | | /* This is not necessary during the disassembling, as print_address_func |
4786 | | in the disassemble_info will take care of the printing. But some |
4787 | | other callers may be still interested in getting the string in *STR, |
4788 | | so here we do snprintf regardless. */ |
4789 | 465k | snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64 , addr)); |
4790 | 465k | break; |
4791 | | |
4792 | 299k | case AARCH64_OPND_ADDR_PCREL9: |
4793 | 787k | case AARCH64_OPND_ADDR_PCREL14: |
4794 | 2.25M | case AARCH64_OPND_ADDR_PCREL19: |
4795 | 3.58M | case AARCH64_OPND_ADDR_PCREL21: |
4796 | 4.43M | case AARCH64_OPND_ADDR_PCREL26: |
4797 | 4.43M | addr = pc + AARCH64_PCREL_OFFSET + opnd->imm.value; |
4798 | 4.43M | if (pcrel_p) |
4799 | 4.43M | *pcrel_p = 1; |
4800 | 4.43M | if (address) |
4801 | 4.43M | *address = addr; |
4802 | | /* This is not necessary during the disassembling, as print_address_func |
4803 | | in the disassemble_info will take care of the printing. But some |
4804 | | other callers may be still interested in getting the string in *STR, |
4805 | | so here we do snprintf regardless. */ |
4806 | 4.43M | snprintf (buf, size, "%s", style_addr (styler, "#0x%" PRIx64, addr)); |
4807 | 4.43M | break; |
4808 | | |
4809 | 1.47M | case AARCH64_OPND_ADDR_SIMPLE: |
4810 | 1.74M | case AARCH64_OPND_SIMD_ADDR_SIMPLE: |
4811 | 1.87M | case AARCH64_OPND_SIMD_ADDR_POST: |
4812 | 1.87M | name = get_64bit_int_reg_name (opnd->addr.base_regno, 1); |
4813 | 1.87M | if (opnd->type == AARCH64_OPND_SIMD_ADDR_POST) |
4814 | 131k | { |
4815 | 131k | if (opnd->addr.offset.is_reg) |
4816 | 126k | snprintf (buf, size, "[%s], %s", |
4817 | 126k | style_reg (styler, name), |
4818 | 126k | style_reg (styler, "x%d", opnd->addr.offset.regno)); |
4819 | 5.79k | else |
4820 | 5.79k | snprintf (buf, size, "[%s], %s", |
4821 | 5.79k | style_reg (styler, name), |
4822 | 5.79k | style_imm (styler, "#%d", opnd->addr.offset.imm)); |
4823 | 131k | } |
4824 | 1.74M | else |
4825 | 1.74M | snprintf (buf, size, "[%s]", style_reg (styler, name)); |
4826 | 1.87M | break; |
4827 | | |
4828 | 51.7k | case AARCH64_OPND_ADDR_REGOFF: |
4829 | 95.2k | case AARCH64_OPND_SVE_ADDR_RR: |
4830 | 112k | case AARCH64_OPND_SVE_ADDR_RR_LSL1: |
4831 | 135k | case AARCH64_OPND_SVE_ADDR_RR_LSL2: |
4832 | 184k | case AARCH64_OPND_SVE_ADDR_RR_LSL3: |
4833 | 213k | case AARCH64_OPND_SVE_ADDR_RR_LSL4: |
4834 | 241k | case AARCH64_OPND_SVE_ADDR_RM: |
4835 | 248k | case AARCH64_OPND_SVE_ADDR_RM_LSL1: |
4836 | 255k | case AARCH64_OPND_SVE_ADDR_RM_LSL2: |
4837 | 264k | case AARCH64_OPND_SVE_ADDR_RM_LSL3: |
4838 | 264k | case AARCH64_OPND_SVE_ADDR_RM_LSL4: |
4839 | 303k | case AARCH64_OPND_SVE_ADDR_RX: |
4840 | 324k | case AARCH64_OPND_SVE_ADDR_RX_LSL1: |
4841 | 427k | case AARCH64_OPND_SVE_ADDR_RX_LSL2: |
4842 | 443k | case AARCH64_OPND_SVE_ADDR_RX_LSL3: |
4843 | 451k | case AARCH64_OPND_SVE_ADDR_RX_LSL4: |
4844 | 451k | print_register_offset_address |
4845 | 451k | (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1), |
4846 | 451k | get_offset_int_reg_name (opnd), styler); |
4847 | 451k | break; |
4848 | | |
4849 | 46.7k | case AARCH64_OPND_SVE_ADDR_ZX: |
4850 | 46.7k | print_register_offset_address |
4851 | 46.7k | (buf, size, opnd, |
4852 | 46.7k | get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier), |
4853 | 46.7k | get_64bit_int_reg_name (opnd->addr.offset.regno, 0), styler); |
4854 | 46.7k | break; |
4855 | | |
4856 | 47.8k | case AARCH64_OPND_SVE_ADDR_RZ: |
4857 | 52.3k | case AARCH64_OPND_SVE_ADDR_RZ_LSL1: |
4858 | 57.8k | case AARCH64_OPND_SVE_ADDR_RZ_LSL2: |
4859 | 62.4k | case AARCH64_OPND_SVE_ADDR_RZ_LSL3: |
4860 | 81.9k | case AARCH64_OPND_SVE_ADDR_RZ_XTW_14: |
4861 | 307k | case AARCH64_OPND_SVE_ADDR_RZ_XTW_22: |
4862 | 312k | case AARCH64_OPND_SVE_ADDR_RZ_XTW1_14: |
4863 | 335k | case AARCH64_OPND_SVE_ADDR_RZ_XTW1_22: |
4864 | 340k | case AARCH64_OPND_SVE_ADDR_RZ_XTW2_14: |
4865 | 357k | case AARCH64_OPND_SVE_ADDR_RZ_XTW2_22: |
4866 | 359k | case AARCH64_OPND_SVE_ADDR_RZ_XTW3_14: |
4867 | 378k | case AARCH64_OPND_SVE_ADDR_RZ_XTW3_22: |
4868 | 378k | print_register_offset_address |
4869 | 378k | (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1), |
4870 | 378k | get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier), |
4871 | 378k | styler); |
4872 | 378k | break; |
4873 | | |
4874 | 1.36M | case AARCH64_OPND_ADDR_SIMM7: |
4875 | 1.97M | case AARCH64_OPND_ADDR_SIMM9: |
4876 | 1.97M | case AARCH64_OPND_ADDR_SIMM9_2: |
4877 | 2.02M | case AARCH64_OPND_ADDR_SIMM10: |
4878 | 2.08M | case AARCH64_OPND_ADDR_SIMM11: |
4879 | 2.10M | case AARCH64_OPND_ADDR_SIMM13: |
4880 | 2.12M | case AARCH64_OPND_RCPC3_ADDR_OFFSET: |
4881 | 2.16M | case AARCH64_OPND_ADDR_OFFSET: |
4882 | 2.16M | case AARCH64_OPND_RCPC3_ADDR_OPT_POSTIND: |
4883 | 2.18M | case AARCH64_OPND_RCPC3_ADDR_OPT_PREIND_WB: |
4884 | 2.18M | case AARCH64_OPND_RCPC3_ADDR_POSTIND: |
4885 | 2.18M | case AARCH64_OPND_RCPC3_ADDR_PREIND_WB: |
4886 | 2.18M | case AARCH64_OPND_SME_ADDR_RI_U4xVL: |
4887 | 2.18M | case AARCH64_OPND_SVE_ADDR_RI_S4x16: |
4888 | 2.19M | case AARCH64_OPND_SVE_ADDR_RI_S4x32: |
4889 | 2.26M | case AARCH64_OPND_SVE_ADDR_RI_S4xVL: |
4890 | 2.28M | case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL: |
4891 | 2.29M | case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL: |
4892 | 2.30M | case AARCH64_OPND_SVE_ADDR_RI_S4x4xVL: |
4893 | 2.31M | case AARCH64_OPND_SVE_ADDR_RI_S6xVL: |
4894 | 2.35M | case AARCH64_OPND_SVE_ADDR_RI_S9xVL: |
4895 | 2.45M | case AARCH64_OPND_SVE_ADDR_RI_U6: |
4896 | 2.46M | case AARCH64_OPND_SVE_ADDR_RI_U6x2: |
4897 | 2.48M | case AARCH64_OPND_SVE_ADDR_RI_U6x4: |
4898 | 2.49M | case AARCH64_OPND_SVE_ADDR_RI_U6x8: |
4899 | 2.49M | print_immediate_offset_address |
4900 | 2.49M | (buf, size, opnd, get_64bit_int_reg_name (opnd->addr.base_regno, 1), |
4901 | 2.49M | styler); |
4902 | 2.49M | break; |
4903 | | |
4904 | 28.5k | case AARCH64_OPND_SVE_ADDR_ZI_U5: |
4905 | 46.6k | case AARCH64_OPND_SVE_ADDR_ZI_U5x2: |
4906 | 75.0k | case AARCH64_OPND_SVE_ADDR_ZI_U5x4: |
4907 | 77.2k | case AARCH64_OPND_SVE_ADDR_ZI_U5x8: |
4908 | 77.2k | print_immediate_offset_address |
4909 | 77.2k | (buf, size, opnd, |
4910 | 77.2k | get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier), |
4911 | 77.2k | styler); |
4912 | 77.2k | break; |
4913 | | |
4914 | 1.60k | case AARCH64_OPND_SVE_ADDR_ZZ_LSL: |
4915 | 2.09k | case AARCH64_OPND_SVE_ADDR_ZZ_SXTW: |
4916 | 2.74k | case AARCH64_OPND_SVE_ADDR_ZZ_UXTW: |
4917 | 2.74k | print_register_offset_address |
4918 | 2.74k | (buf, size, opnd, |
4919 | 2.74k | get_addr_sve_reg_name (opnd->addr.base_regno, opnd->qualifier), |
4920 | 2.74k | get_addr_sve_reg_name (opnd->addr.offset.regno, opnd->qualifier), |
4921 | 2.74k | styler); |
4922 | 2.74k | break; |
4923 | | |
4924 | 909k | case AARCH64_OPND_ADDR_UIMM12: |
4925 | 909k | name = get_64bit_int_reg_name (opnd->addr.base_regno, 1); |
4926 | 909k | if (opnd->addr.offset.imm) |
4927 | 801k | snprintf (buf, size, "[%s, %s]", |
4928 | 801k | style_reg (styler, name), |
4929 | 801k | style_imm (styler, "#%d", opnd->addr.offset.imm)); |
4930 | 108k | else |
4931 | 108k | snprintf (buf, size, "[%s]", style_reg (styler, name)); |
4932 | 909k | break; |
4933 | | |
4934 | 17.4k | case AARCH64_OPND_SYSREG: |
4935 | 21.1k | case AARCH64_OPND_SYSREG128: |
4936 | 25.8M | for (i = 0; aarch64_sys_regs[i].name; ++i) |
4937 | 25.8M | { |
4938 | 25.8M | const aarch64_sys_reg *sr = aarch64_sys_regs + i; |
4939 | | |
4940 | 25.8M | bool exact_match |
4941 | 25.8M | = (!(sr->flags & (F_REG_READ | F_REG_WRITE)) |
4942 | 25.8M | || (sr->flags & opnd->sysreg.flags) == opnd->sysreg.flags) |
4943 | 25.8M | && AARCH64_CPU_HAS_ALL_FEATURES (features, sr->features); |
4944 | | |
4945 | | /* Try and find an exact match, But if that fails, return the first |
4946 | | partial match that was found. */ |
4947 | 25.8M | if (aarch64_sys_regs[i].value == opnd->sysreg.value |
4948 | 25.8M | && ! aarch64_sys_reg_deprecated_p (aarch64_sys_regs[i].flags) |
4949 | 25.8M | && ! aarch64_sys_reg_alias_p (aarch64_sys_regs[i].flags) |
4950 | 25.8M | && (name == NULL || exact_match)) |
4951 | 1.43k | { |
4952 | 1.43k | name = aarch64_sys_regs[i].name; |
4953 | 1.43k | if (exact_match) |
4954 | 1.14k | { |
4955 | 1.14k | if (notes) |
4956 | 1.14k | *notes = NULL; |
4957 | 1.14k | break; |
4958 | 1.14k | } |
4959 | | |
4960 | | /* If we didn't match exactly, that means the presense of a flag |
4961 | | indicates what we didn't want for this instruction. e.g. If |
4962 | | F_REG_READ is there, that means we were looking for a write |
4963 | | register. See aarch64_ext_sysreg. */ |
4964 | 289 | if (aarch64_sys_regs[i].flags & F_REG_WRITE) |
4965 | 67 | *notes = _("reading from a write-only register"); |
4966 | 222 | else if (aarch64_sys_regs[i].flags & F_REG_READ) |
4967 | 196 | *notes = _("writing to a read-only register"); |
4968 | 289 | } |
4969 | 25.8M | } |
4970 | | |
4971 | 21.1k | if (name) |
4972 | 1.43k | snprintf (buf, size, "%s", style_reg (styler, name)); |
4973 | 19.7k | else |
4974 | 19.7k | { |
4975 | | /* Implementation defined system register. */ |
4976 | 19.7k | unsigned int value = opnd->sysreg.value; |
4977 | 19.7k | snprintf (buf, size, "%s", |
4978 | 19.7k | style_reg (styler, "s%u_%u_c%u_c%u_%u", |
4979 | 19.7k | (value >> 14) & 0x3, (value >> 11) & 0x7, |
4980 | 19.7k | (value >> 7) & 0xf, (value >> 3) & 0xf, |
4981 | 19.7k | value & 0x7)); |
4982 | 19.7k | } |
4983 | 21.1k | break; |
4984 | | |
4985 | 66 | case AARCH64_OPND_PSTATEFIELD: |
4986 | 245 | for (i = 0; aarch64_pstatefields[i].name; ++i) |
4987 | 245 | if (aarch64_pstatefields[i].value == opnd->pstatefield) |
4988 | 66 | { |
4989 | | /* PSTATEFIELD name is encoded partially in CRm[3:1] for SVCRSM, |
4990 | | SVCRZA and SVCRSMZA. */ |
4991 | 66 | uint32_t flags = aarch64_pstatefields[i].flags; |
4992 | 66 | if (flags & F_REG_IN_CRM |
4993 | 66 | && (PSTATE_DECODE_CRM (opnd->sysreg.flags) |
4994 | 0 | != PSTATE_DECODE_CRM (flags))) |
4995 | 0 | continue; |
4996 | 66 | break; |
4997 | 66 | } |
4998 | 66 | assert (aarch64_pstatefields[i].name); |
4999 | 66 | snprintf (buf, size, "%s", |
5000 | 66 | style_reg (styler, aarch64_pstatefields[i].name)); |
5001 | 66 | break; |
5002 | | |
5003 | 134 | case AARCH64_OPND_SYSREG_AT: |
5004 | 165 | case AARCH64_OPND_SYSREG_DC: |
5005 | 204 | case AARCH64_OPND_SYSREG_IC: |
5006 | 392 | case AARCH64_OPND_SYSREG_TLBI: |
5007 | 405 | case AARCH64_OPND_SYSREG_TLBIP: |
5008 | 405 | case AARCH64_OPND_SYSREG_SR: |
5009 | 405 | snprintf (buf, size, "%s", style_reg (styler, opnd->sysins_op->name)); |
5010 | 405 | break; |
5011 | | |
5012 | 31 | case AARCH64_OPND_BARRIER: |
5013 | 72 | case AARCH64_OPND_BARRIER_DSB_NXS: |
5014 | 72 | { |
5015 | 72 | if (opnd->barrier->name[0] == '#') |
5016 | 26 | snprintf (buf, size, "%s", style_imm (styler, opnd->barrier->name)); |
5017 | 46 | else |
5018 | 46 | snprintf (buf, size, "%s", |
5019 | 46 | style_sub_mnem (styler, opnd->barrier->name)); |
5020 | 72 | } |
5021 | 72 | break; |
5022 | | |
5023 | 264 | case AARCH64_OPND_BARRIER_ISB: |
5024 | | /* Operand can be omitted, e.g. in DCPS1. */ |
5025 | 264 | if (! optional_operand_p (opcode, idx) |
5026 | 264 | || (opnd->barrier->value |
5027 | 264 | != get_optional_operand_default_value (opcode))) |
5028 | 22 | snprintf (buf, size, "%s", |
5029 | 22 | style_imm (styler, "#0x%x", opnd->barrier->value)); |
5030 | 264 | break; |
5031 | | |
5032 | 206k | case AARCH64_OPND_PRFOP: |
5033 | 206k | if (opnd->prfop->name != NULL) |
5034 | 166k | snprintf (buf, size, "%s", style_sub_mnem (styler, opnd->prfop->name)); |
5035 | 40.0k | else |
5036 | 40.0k | snprintf (buf, size, "%s", style_imm (styler, "#0x%02x", |
5037 | 40.0k | opnd->prfop->value)); |
5038 | 206k | break; |
5039 | | |
5040 | 7.26k | case AARCH64_OPND_RPRFMOP: |
5041 | 7.26k | enum_value = opnd->imm.value; |
5042 | 7.26k | if (enum_value < ARRAY_SIZE (aarch64_rprfmop_array) |
5043 | 7.26k | && aarch64_rprfmop_array[enum_value]) |
5044 | 1.04k | snprintf (buf, size, "%s", |
5045 | 1.04k | style_reg (styler, aarch64_rprfmop_array[enum_value])); |
5046 | 6.22k | else |
5047 | 6.22k | snprintf (buf, size, "%s", |
5048 | 6.22k | style_imm (styler, "#%" PRIi64, opnd->imm.value)); |
5049 | 7.26k | break; |
5050 | | |
5051 | 84 | case AARCH64_OPND_BARRIER_PSB: |
5052 | 84 | snprintf (buf, size, "%s", style_sub_mnem (styler, "csync")); |
5053 | 84 | break; |
5054 | | |
5055 | 0 | case AARCH64_OPND_X16: |
5056 | 0 | snprintf (buf, size, "%s", style_reg (styler, "x16")); |
5057 | 0 | break; |
5058 | | |
5059 | 3.34k | case AARCH64_OPND_SME_ZT0: |
5060 | 3.34k | snprintf (buf, size, "%s", style_reg (styler, "zt0")); |
5061 | 3.34k | break; |
5062 | | |
5063 | 22 | case AARCH64_OPND_SME_ZT0_INDEX: |
5064 | 22 | snprintf (buf, size, "%s[%s]", style_reg (styler, "zt0"), |
5065 | 22 | style_imm (styler, "%d", (int) opnd->imm.value)); |
5066 | 22 | break; |
5067 | 20 | case AARCH64_OPND_SME_ZT0_INDEX_MUL_VL: |
5068 | 20 | snprintf (buf, size, "%s[%s, %s]", style_reg (styler, "zt0"), |
5069 | 20 | style_imm (styler, "%d", (int) opnd->imm.value), |
5070 | 20 | style_sub_mnem (styler, "mul vl")); |
5071 | 20 | break; |
5072 | | |
5073 | 14 | case AARCH64_OPND_SME_ZT0_LIST: |
5074 | 14 | snprintf (buf, size, "{%s}", style_reg (styler, "zt0")); |
5075 | 14 | break; |
5076 | | |
5077 | 3 | case AARCH64_OPND_BARRIER_GCSB: |
5078 | 3 | snprintf (buf, size, "%s", style_sub_mnem (styler, "dsync")); |
5079 | 3 | break; |
5080 | | |
5081 | 447 | case AARCH64_OPND_BTI_TARGET: |
5082 | 447 | if ((HINT_FLAG (opnd->hint_option->value) & HINT_OPD_F_NOPRINT) == 0) |
5083 | 447 | snprintf (buf, size, "%s", |
5084 | 447 | style_sub_mnem (styler, opnd->hint_option->name)); |
5085 | 447 | break; |
5086 | | |
5087 | 17.6k | case AARCH64_OPND_MOPS_ADDR_Rd: |
5088 | 30.3k | case AARCH64_OPND_MOPS_ADDR_Rs: |
5089 | 30.3k | snprintf (buf, size, "[%s]!", |
5090 | 30.3k | style_reg (styler, |
5091 | 30.3k | get_int_reg_name (opnd->reg.regno, |
5092 | 30.3k | AARCH64_OPND_QLF_X, 0))); |
5093 | 30.3k | break; |
5094 | | |
5095 | 17.6k | case AARCH64_OPND_MOPS_WB_Rn: |
5096 | 17.6k | snprintf (buf, size, "%s!", |
5097 | 17.6k | style_reg (styler, get_int_reg_name (opnd->reg.regno, |
5098 | 17.6k | AARCH64_OPND_QLF_X, 0))); |
5099 | 17.6k | break; |
5100 | | |
5101 | 0 | default: |
5102 | 0 | snprintf (buf, size, "<invalid>"); |
5103 | 0 | break; |
5104 | 56.1M | } |
5105 | 56.1M | } |
5106 | | |
5107 | | #define CPENC(op0,op1,crn,crm,op2) \ |
5108 | | ((((op0) << 19) | ((op1) << 16) | ((crn) << 12) | ((crm) << 8) | ((op2) << 5)) >> 5) |
5109 | | /* for 3.9.3 Instructions for Accessing Special Purpose Registers */ |
5110 | | #define CPEN_(op1,crm,op2) CPENC(3,(op1),4,(crm),(op2)) |
5111 | | /* for 3.9.10 System Instructions */ |
5112 | | #define CPENS(op1,crn,crm,op2) CPENC(1,(op1),(crn),(crm),(op2)) |
5113 | | |
5114 | | #define C0 0 |
5115 | | #define C1 1 |
5116 | | #define C2 2 |
5117 | | #define C3 3 |
5118 | | #define C4 4 |
5119 | | #define C5 5 |
5120 | | #define C6 6 |
5121 | | #define C7 7 |
5122 | | #define C8 8 |
5123 | | #define C9 9 |
5124 | | #define C10 10 |
5125 | | #define C11 11 |
5126 | | #define C12 12 |
5127 | | #define C13 13 |
5128 | | #define C14 14 |
5129 | | #define C15 15 |
5130 | | |
5131 | | /* TODO there is one more issues need to be resolved |
5132 | | 1. handle cpu-implementation-defined system registers. |
5133 | | |
5134 | | Note that the F_REG_{READ,WRITE} flags mean read-only and write-only |
5135 | | respectively. If neither of these are set then the register is read-write. */ |
5136 | | const aarch64_sys_reg aarch64_sys_regs [] = |
5137 | | { |
5138 | | #define SYSREG(name, encoding, flags, features) \ |
5139 | | { name, encoding, flags, features }, |
5140 | | #include "aarch64-sys-regs.def" |
5141 | | { 0, CPENC (0,0,0,0,0), 0, AARCH64_NO_FEATURES } |
5142 | | #undef SYSREG |
5143 | | }; |
5144 | | |
5145 | | bool |
5146 | | aarch64_sys_reg_deprecated_p (const uint32_t reg_flags) |
5147 | 1.43k | { |
5148 | 1.43k | return (reg_flags & F_DEPRECATED) != 0; |
5149 | 1.43k | } |
5150 | | |
5151 | | bool |
5152 | | aarch64_sys_reg_128bit_p (const uint32_t reg_flags) |
5153 | 0 | { |
5154 | 0 | return (reg_flags & F_REG_128) != 0; |
5155 | 0 | } |
5156 | | |
5157 | | bool |
5158 | | aarch64_sys_reg_alias_p (const uint32_t reg_flags) |
5159 | 1.43k | { |
5160 | 1.43k | return (reg_flags & F_REG_ALIAS) != 0; |
5161 | 1.43k | } |
5162 | | |
5163 | | /* The CPENC below is fairly misleading, the fields |
5164 | | here are not in CPENC form. They are in op2op1 form. The fields are encoded |
5165 | | by ins_pstatefield, which just shifts the value by the width of the fields |
5166 | | in a loop. So if you CPENC them only the first value will be set, the rest |
5167 | | are masked out to 0. As an example. op2 = 3, op1=2. CPENC would produce a |
5168 | | value of 0b110000000001000000 (0x30040) while what you want is |
5169 | | 0b011010 (0x1a). */ |
5170 | | const aarch64_sys_reg aarch64_pstatefields [] = |
5171 | | { |
5172 | | { "spsel", 0x05, F_REG_MAX_VALUE (1), AARCH64_NO_FEATURES }, |
5173 | | { "daifset", 0x1e, F_REG_MAX_VALUE (15), AARCH64_NO_FEATURES }, |
5174 | | { "daifclr", 0x1f, F_REG_MAX_VALUE (15), AARCH64_NO_FEATURES }, |
5175 | | { "pan", 0x04, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (PAN) }, |
5176 | | { "uao", 0x03, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (V8_2A) }, |
5177 | | { "ssbs", 0x19, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (SSBS) }, |
5178 | | { "dit", 0x1a, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (V8_4A) }, |
5179 | | { "tco", 0x1c, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5180 | | { "svcrsm", 0x1b, PSTATE_ENCODE_CRM_AND_IMM (0x2,0x1) | F_REG_MAX_VALUE (1) |
5181 | | | F_ARCHEXT, AARCH64_FEATURE (SME) }, |
5182 | | { "svcrza", 0x1b, PSTATE_ENCODE_CRM_AND_IMM (0x4,0x1) | F_REG_MAX_VALUE (1) |
5183 | | | F_ARCHEXT, AARCH64_FEATURE (SME) }, |
5184 | | { "svcrsmza", 0x1b, PSTATE_ENCODE_CRM_AND_IMM (0x6,0x1) | F_REG_MAX_VALUE (1) |
5185 | | | F_ARCHEXT, AARCH64_FEATURE (SME) }, |
5186 | | { "allint", 0x08, F_REG_MAX_VALUE (1) | F_ARCHEXT, AARCH64_FEATURE (V8_8A) }, |
5187 | | { 0, CPENC (0,0,0,0,0), 0, AARCH64_NO_FEATURES }, |
5188 | | }; |
5189 | | |
5190 | | bool |
5191 | | aarch64_pstatefield_supported_p (const aarch64_feature_set features, |
5192 | | const aarch64_sys_reg *reg) |
5193 | 0 | { |
5194 | 0 | if (!(reg->flags & F_ARCHEXT)) |
5195 | 0 | return true; |
5196 | | |
5197 | 0 | return AARCH64_CPU_HAS_ALL_FEATURES (features, reg->features); |
5198 | 0 | } |
5199 | | |
5200 | | const aarch64_sys_ins_reg aarch64_sys_regs_ic[] = |
5201 | | { |
5202 | | { "ialluis", CPENS(0,C7,C1,0), 0, AARCH64_NO_FEATURES }, |
5203 | | { "iallu", CPENS(0,C7,C5,0), 0, AARCH64_NO_FEATURES }, |
5204 | | { "ivau", CPENS (3, C7, C5, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5205 | | { 0, CPENS(0,0,0,0), 0, AARCH64_NO_FEATURES } |
5206 | | }; |
5207 | | |
5208 | | const aarch64_sys_ins_reg aarch64_sys_regs_dc[] = |
5209 | | { |
5210 | | { "zva", CPENS (3, C7, C4, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5211 | | { "gva", CPENS (3, C7, C4, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5212 | | { "gzva", CPENS (3, C7, C4, 4), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5213 | | { "ivac", CPENS (0, C7, C6, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5214 | | { "igvac", CPENS (0, C7, C6, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5215 | | { "igsw", CPENS (0, C7, C6, 4), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5216 | | { "isw", CPENS (0, C7, C6, 2), F_HASXT, AARCH64_NO_FEATURES }, |
5217 | | { "igdvac", CPENS (0, C7, C6, 5), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5218 | | { "igdsw", CPENS (0, C7, C6, 6), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5219 | | { "cvac", CPENS (3, C7, C10, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5220 | | { "cgvac", CPENS (3, C7, C10, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5221 | | { "cgdvac", CPENS (3, C7, C10, 5), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5222 | | { "cvaoc", CPENS (3, C7, C11, 0), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (OCCMO) }, |
5223 | | { "cgdvaoc", CPENS (3, C7, C11, 7), F_HASXT | F_ARCHEXT, AARCH64_FEATURES (2, OCCMO, MEMTAG) }, |
5224 | | { "csw", CPENS (0, C7, C10, 2), F_HASXT, AARCH64_NO_FEATURES }, |
5225 | | { "cgsw", CPENS (0, C7, C10, 4), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5226 | | { "cgdsw", CPENS (0, C7, C10, 6), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5227 | | { "cvau", CPENS (3, C7, C11, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5228 | | { "cvap", CPENS (3, C7, C12, 1), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (V8_2A) }, |
5229 | | { "cgvap", CPENS (3, C7, C12, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5230 | | { "cgdvap", CPENS (3, C7, C12, 5), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5231 | | { "cvadp", CPENS (3, C7, C13, 1), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (CVADP) }, |
5232 | | { "cgvadp", CPENS (3, C7, C13, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5233 | | { "cgdvadp", CPENS (3, C7, C13, 5), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5234 | | { "civac", CPENS (3, C7, C14, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5235 | | { "cigvac", CPENS (3, C7, C14, 3), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5236 | | { "cigdvac", CPENS (3, C7, C14, 5), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5237 | | { "cisw", CPENS (0, C7, C14, 2), F_HASXT, AARCH64_NO_FEATURES }, |
5238 | | { "cigsw", CPENS (0, C7, C14, 4), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5239 | | { "cigdsw", CPENS (0, C7, C14, 6), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (MEMTAG) }, |
5240 | | { "civaoc", CPENS (3, C7, C15, 0), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (OCCMO) }, |
5241 | | { "cigdvaoc", CPENS (3, C7, C15, 7), F_HASXT | F_ARCHEXT, AARCH64_FEATURES (2, OCCMO, MEMTAG) }, |
5242 | | { "cipae", CPENS (4, C7, C14, 0), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (V8_7A) }, |
5243 | | { "cigdpae", CPENS (4, C7, C14, 7), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (V8_7A) }, |
5244 | | { "cipapa", CPENS (6, C7, C14, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5245 | | { "cigdpapa", CPENS (6, C7, C14, 5), F_HASXT, AARCH64_NO_FEATURES }, |
5246 | | { 0, CPENS(0,0,0,0), 0, AARCH64_NO_FEATURES } |
5247 | | }; |
5248 | | |
5249 | | const aarch64_sys_ins_reg aarch64_sys_regs_at[] = |
5250 | | { |
5251 | | { "s1e1r", CPENS (0, C7, C8, 0), F_HASXT, AARCH64_NO_FEATURES }, |
5252 | | { "s1e1w", CPENS (0, C7, C8, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5253 | | { "s1e0r", CPENS (0, C7, C8, 2), F_HASXT, AARCH64_NO_FEATURES }, |
5254 | | { "s1e0w", CPENS (0, C7, C8, 3), F_HASXT, AARCH64_NO_FEATURES }, |
5255 | | { "s12e1r", CPENS (4, C7, C8, 4), F_HASXT, AARCH64_NO_FEATURES }, |
5256 | | { "s12e1w", CPENS (4, C7, C8, 5), F_HASXT, AARCH64_NO_FEATURES }, |
5257 | | { "s12e0r", CPENS (4, C7, C8, 6), F_HASXT, AARCH64_NO_FEATURES }, |
5258 | | { "s12e0w", CPENS (4, C7, C8, 7), F_HASXT, AARCH64_NO_FEATURES }, |
5259 | | { "s1e2r", CPENS (4, C7, C8, 0), F_HASXT, AARCH64_NO_FEATURES }, |
5260 | | { "s1e2w", CPENS (4, C7, C8, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5261 | | { "s1e3r", CPENS (6, C7, C8, 0), F_HASXT, AARCH64_NO_FEATURES }, |
5262 | | { "s1e3w", CPENS (6, C7, C8, 1), F_HASXT, AARCH64_NO_FEATURES }, |
5263 | | { "s1e1rp", CPENS (0, C7, C9, 0), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (V8_2A) }, |
5264 | | { "s1e1wp", CPENS (0, C7, C9, 1), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (V8_2A) }, |
5265 | | { "s1e1a", CPENS (0, C7, C9, 2), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (ATS1A) }, |
5266 | | { "s1e2a", CPENS (4, C7, C9, 2), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (ATS1A) }, |
5267 | | { "s1e3a", CPENS (6, C7, C9, 2), F_HASXT | F_ARCHEXT, AARCH64_FEATURE (ATS1A) }, |
5268 | | { 0, CPENS(0,0,0,0), 0, AARCH64_NO_FEATURES } |
5269 | | }; |
5270 | | |
5271 | | const aarch64_sys_ins_reg aarch64_sys_regs_tlbi[] = |
5272 | | { |
5273 | | { "rpaos", CPENS (6, C8, C4, 3), F_HASXT, AARCH64_NO_FEATURES }, |
5274 | | { "rpalos", CPENS (6, C8, C4, 7), F_HASXT, AARCH64_NO_FEATURES }, |
5275 | | { "paallos", CPENS (6, C8, C1, 4), 0, AARCH64_NO_FEATURES }, |
5276 | | { "paall", CPENS (6, C8, C7, 4), 0, AARCH64_NO_FEATURES }, |
5277 | | |
5278 | | #define TLBI_XS_OP(OP, CODE, FLAGS) \ |
5279 | | { OP, CODE, FLAGS, AARCH64_NO_FEATURES }, \ |
5280 | | { OP "nxs", CODE | CPENS (0, C9, 0, 0), FLAGS | F_ARCHEXT, AARCH64_FEATURE (XS) }, |
5281 | | |
5282 | | TLBI_XS_OP ( "vmalle1", CPENS (0, C8, C7, 0), 0) |
5283 | | TLBI_XS_OP ( "vae1", CPENS (0, C8, C7, 1), F_HASXT | F_REG_128) |
5284 | | TLBI_XS_OP ( "aside1", CPENS (0, C8, C7, 2), F_HASXT ) |
5285 | | TLBI_XS_OP ( "vaae1", CPENS (0, C8, C7, 3), F_HASXT | F_REG_128) |
5286 | | TLBI_XS_OP ( "vmalle1is", CPENS (0, C8, C3, 0), 0) |
5287 | | TLBI_XS_OP ( "vae1is", CPENS (0, C8, C3, 1), F_HASXT | F_REG_128) |
5288 | | TLBI_XS_OP ( "aside1is", CPENS (0, C8, C3, 2), F_HASXT ) |
5289 | | TLBI_XS_OP ( "vaae1is", CPENS (0, C8, C3, 3), F_HASXT | F_REG_128) |
5290 | | TLBI_XS_OP ( "ipas2e1is", CPENS (4, C8, C0, 1), F_HASXT | F_REG_128) |
5291 | | TLBI_XS_OP ( "ipas2le1is",CPENS (4, C8, C0, 5), F_HASXT | F_REG_128) |
5292 | | TLBI_XS_OP ( "ipas2e1", CPENS (4, C8, C4, 1), F_HASXT | F_REG_128) |
5293 | | TLBI_XS_OP ( "ipas2le1", CPENS (4, C8, C4, 5), F_HASXT | F_REG_128) |
5294 | | TLBI_XS_OP ( "vae2", CPENS (4, C8, C7, 1), F_HASXT | F_REG_128) |
5295 | | TLBI_XS_OP ( "vae2is", CPENS (4, C8, C3, 1), F_HASXT | F_REG_128) |
5296 | | TLBI_XS_OP ( "vmalls12e1",CPENS (4, C8, C7, 6), 0) |
5297 | | TLBI_XS_OP ( "vmalls12e1is",CPENS(4,C8, C3, 6), 0) |
5298 | | TLBI_XS_OP ( "vae3", CPENS (6, C8, C7, 1), F_HASXT | F_REG_128) |
5299 | | TLBI_XS_OP ( "vae3is", CPENS (6, C8, C3, 1), F_HASXT | F_REG_128) |
5300 | | TLBI_XS_OP ( "alle2", CPENS (4, C8, C7, 0), 0) |
5301 | | TLBI_XS_OP ( "alle2is", CPENS (4, C8, C3, 0), 0) |
5302 | | TLBI_XS_OP ( "alle1", CPENS (4, C8, C7, 4), 0) |
5303 | | TLBI_XS_OP ( "alle1is", CPENS (4, C8, C3, 4), 0) |
5304 | | TLBI_XS_OP ( "alle3", CPENS (6, C8, C7, 0), 0) |
5305 | | TLBI_XS_OP ( "alle3is", CPENS (6, C8, C3, 0), 0) |
5306 | | TLBI_XS_OP ( "vale1is", CPENS (0, C8, C3, 5), F_HASXT | F_REG_128) |
5307 | | TLBI_XS_OP ( "vale2is", CPENS (4, C8, C3, 5), F_HASXT | F_REG_128) |
5308 | | TLBI_XS_OP ( "vale3is", CPENS (6, C8, C3, 5), F_HASXT | F_REG_128) |
5309 | | TLBI_XS_OP ( "vaale1is", CPENS (0, C8, C3, 7), F_HASXT | F_REG_128) |
5310 | | TLBI_XS_OP ( "vale1", CPENS (0, C8, C7, 5), F_HASXT | F_REG_128) |
5311 | | TLBI_XS_OP ( "vale2", CPENS (4, C8, C7, 5), F_HASXT | F_REG_128) |
5312 | | TLBI_XS_OP ( "vale3", CPENS (6, C8, C7, 5), F_HASXT | F_REG_128) |
5313 | | TLBI_XS_OP ( "vaale1", CPENS (0, C8, C7, 7), F_HASXT | F_REG_128) |
5314 | | |
5315 | | #undef TLBI_XS_OP |
5316 | | #define TLBI_XS_OP(OP, CODE, FLAGS) \ |
5317 | | { OP, CODE, FLAGS | F_ARCHEXT, AARCH64_FEATURE (V8_4A) }, \ |
5318 | | { OP "nxs", CODE | CPENS (0, C9, 0, 0), FLAGS | F_ARCHEXT, AARCH64_FEATURE (XS) }, |
5319 | | |
5320 | | TLBI_XS_OP ( "vmalle1os", CPENS (0, C8, C1, 0), 0 ) |
5321 | | TLBI_XS_OP ( "vae1os", CPENS (0, C8, C1, 1), F_HASXT | F_REG_128 ) |
5322 | | TLBI_XS_OP ( "aside1os", CPENS (0, C8, C1, 2), F_HASXT ) |
5323 | | TLBI_XS_OP ( "vaae1os", CPENS (0, C8, C1, 3), F_HASXT | F_REG_128 ) |
5324 | | TLBI_XS_OP ( "vale1os", CPENS (0, C8, C1, 5), F_HASXT | F_REG_128 ) |
5325 | | TLBI_XS_OP ( "vaale1os", CPENS (0, C8, C1, 7), F_HASXT | F_REG_128 ) |
5326 | | TLBI_XS_OP ( "ipas2e1os", CPENS (4, C8, C4, 0), F_HASXT | F_REG_128 ) |
5327 | | TLBI_XS_OP ( "ipas2le1os", CPENS (4, C8, C4, 4), F_HASXT | F_REG_128 ) |
5328 | | TLBI_XS_OP ( "vae2os", CPENS (4, C8, C1, 1), F_HASXT | F_REG_128 ) |
5329 | | TLBI_XS_OP ( "vale2os", CPENS (4, C8, C1, 5), F_HASXT | F_REG_128 ) |
5330 | | TLBI_XS_OP ( "vmalls12e1os", CPENS (4, C8, C1, 6), 0 ) |
5331 | | TLBI_XS_OP ( "vae3os", CPENS (6, C8, C1, 1), F_HASXT | F_REG_128 ) |
5332 | | TLBI_XS_OP ( "vale3os", CPENS (6, C8, C1, 5), F_HASXT | F_REG_128 ) |
5333 | | TLBI_XS_OP ( "alle2os", CPENS (4, C8, C1, 0), 0 ) |
5334 | | TLBI_XS_OP ( "alle1os", CPENS (4, C8, C1, 4), 0 ) |
5335 | | TLBI_XS_OP ( "alle3os", CPENS (6, C8, C1, 0), 0 ) |
5336 | | |
5337 | | TLBI_XS_OP ( "rvae1", CPENS (0, C8, C6, 1), F_HASXT | F_REG_128 ) |
5338 | | TLBI_XS_OP ( "rvaae1", CPENS (0, C8, C6, 3), F_HASXT | F_REG_128 ) |
5339 | | TLBI_XS_OP ( "rvale1", CPENS (0, C8, C6, 5), F_HASXT | F_REG_128 ) |
5340 | | TLBI_XS_OP ( "rvaale1", CPENS (0, C8, C6, 7), F_HASXT | F_REG_128 ) |
5341 | | TLBI_XS_OP ( "rvae1is", CPENS (0, C8, C2, 1), F_HASXT | F_REG_128 ) |
5342 | | TLBI_XS_OP ( "rvaae1is", CPENS (0, C8, C2, 3), F_HASXT | F_REG_128 ) |
5343 | | TLBI_XS_OP ( "rvale1is", CPENS (0, C8, C2, 5), F_HASXT | F_REG_128 ) |
5344 | | TLBI_XS_OP ( "rvaale1is", CPENS (0, C8, C2, 7), F_HASXT | F_REG_128 ) |
5345 | | TLBI_XS_OP ( "rvae1os", CPENS (0, C8, C5, 1), F_HASXT | F_REG_128 ) |
5346 | | TLBI_XS_OP ( "rvaae1os", CPENS (0, C8, C5, 3), F_HASXT | F_REG_128 ) |
5347 | | TLBI_XS_OP ( "rvale1os", CPENS (0, C8, C5, 5), F_HASXT | F_REG_128 ) |
5348 | | TLBI_XS_OP ( "rvaale1os", CPENS (0, C8, C5, 7), F_HASXT | F_REG_128 ) |
5349 | | TLBI_XS_OP ( "ripas2e1is", CPENS (4, C8, C0, 2), F_HASXT | F_REG_128 ) |
5350 | | TLBI_XS_OP ( "ripas2le1is",CPENS (4, C8, C0, 6), F_HASXT | F_REG_128 ) |
5351 | | TLBI_XS_OP ( "ripas2e1", CPENS (4, C8, C4, 2), F_HASXT | F_REG_128 ) |
5352 | | TLBI_XS_OP ( "ripas2le1", CPENS (4, C8, C4, 6), F_HASXT | F_REG_128 ) |
5353 | | TLBI_XS_OP ( "ripas2e1os", CPENS (4, C8, C4, 3), F_HASXT | F_REG_128 ) |
5354 | | TLBI_XS_OP ( "ripas2le1os",CPENS (4, C8, C4, 7), F_HASXT | F_REG_128 ) |
5355 | | TLBI_XS_OP ( "rvae2", CPENS (4, C8, C6, 1), F_HASXT | F_REG_128 ) |
5356 | | TLBI_XS_OP ( "rvale2", CPENS (4, C8, C6, 5), F_HASXT | F_REG_128 ) |
5357 | | TLBI_XS_OP ( "rvae2is", CPENS (4, C8, C2, 1), F_HASXT | F_REG_128 ) |
5358 | | TLBI_XS_OP ( "rvale2is", CPENS (4, C8, C2, 5), F_HASXT | F_REG_128 ) |
5359 | | TLBI_XS_OP ( "rvae2os", CPENS (4, C8, C5, 1), F_HASXT | F_REG_128 ) |
5360 | | TLBI_XS_OP ( "rvale2os", CPENS (4, C8, C5, 5), F_HASXT | F_REG_128 ) |
5361 | | TLBI_XS_OP ( "rvae3", CPENS (6, C8, C6, 1), F_HASXT | F_REG_128 ) |
5362 | | TLBI_XS_OP ( "rvale3", CPENS (6, C8, C6, 5), F_HASXT | F_REG_128 ) |
5363 | | TLBI_XS_OP ( "rvae3is", CPENS (6, C8, C2, 1), F_HASXT | F_REG_128 ) |
5364 | | TLBI_XS_OP ( "rvale3is", CPENS (6, C8, C2, 5), F_HASXT | F_REG_128 ) |
5365 | | TLBI_XS_OP ( "rvae3os", CPENS (6, C8, C5, 1), F_HASXT | F_REG_128 ) |
5366 | | TLBI_XS_OP ( "rvale3os", CPENS (6, C8, C5, 5), F_HASXT | F_REG_128 ) |
5367 | | |
5368 | | #undef TLBI_XS_OP |
5369 | | |
5370 | | { 0, CPENS(0,0,0,0), 0, AARCH64_NO_FEATURES } |
5371 | | }; |
5372 | | |
5373 | | const aarch64_sys_ins_reg aarch64_sys_regs_sr[] = |
5374 | | { |
5375 | | /* RCTX is somewhat unique in a way that it has different values |
5376 | | (op2) based on the instruction in which it is used (cfp/dvp/cpp). |
5377 | | Thus op2 is masked out and instead encoded directly in the |
5378 | | aarch64_opcode_table entries for the respective instructions. */ |
5379 | | { "rctx", CPENS(3,C7,C3,0), F_HASXT | F_ARCHEXT | F_REG_WRITE, AARCH64_FEATURE (PREDRES) }, /* WO */ |
5380 | | { 0, CPENS(0,0,0,0), 0, AARCH64_NO_FEATURES } |
5381 | | }; |
5382 | | |
5383 | | bool |
5384 | | aarch64_sys_ins_reg_has_xt (const aarch64_sys_ins_reg *sys_ins_reg) |
5385 | 480 | { |
5386 | 480 | return (sys_ins_reg->flags & F_HASXT) != 0; |
5387 | 480 | } |
5388 | | |
5389 | | extern bool |
5390 | | aarch64_sys_ins_reg_supported_p (const aarch64_feature_set features, |
5391 | | const char *reg_name, |
5392 | | uint32_t reg_flags, |
5393 | | const aarch64_feature_set *reg_features) |
5394 | 0 | { |
5395 | | /* Armv8-R has no EL3. */ |
5396 | 0 | if (AARCH64_CPU_HAS_FEATURE (features, V8R)) |
5397 | 0 | { |
5398 | 0 | const char *suffix = strrchr (reg_name, '_'); |
5399 | 0 | if (suffix && !strcmp (suffix, "_el3")) |
5400 | 0 | return false; |
5401 | 0 | } |
5402 | | |
5403 | 0 | if (!(reg_flags & F_ARCHEXT)) |
5404 | 0 | return true; |
5405 | | |
5406 | 0 | return AARCH64_CPU_HAS_ALL_FEATURES (features, *reg_features); |
5407 | 0 | } |
5408 | | |
5409 | | #undef C0 |
5410 | | #undef C1 |
5411 | | #undef C2 |
5412 | | #undef C3 |
5413 | | #undef C4 |
5414 | | #undef C5 |
5415 | | #undef C6 |
5416 | | #undef C7 |
5417 | | #undef C8 |
5418 | | #undef C9 |
5419 | | #undef C10 |
5420 | | #undef C11 |
5421 | | #undef C12 |
5422 | | #undef C13 |
5423 | | #undef C14 |
5424 | | #undef C15 |
5425 | | |
5426 | 245k | #define BIT(INSN,BT) (((INSN) >> (BT)) & 1) |
5427 | 372k | #define BITS(INSN,HI,LO) (((INSN) >> (LO)) & ((1 << (((HI) - (LO)) + 1)) - 1)) |
5428 | | |
5429 | | static enum err_type |
5430 | | verify_ldpsw (const struct aarch64_inst *inst ATTRIBUTE_UNUSED, |
5431 | | const aarch64_insn insn, bfd_vma pc ATTRIBUTE_UNUSED, |
5432 | | bool encoding ATTRIBUTE_UNUSED, |
5433 | | aarch64_operand_error *mismatch_detail ATTRIBUTE_UNUSED, |
5434 | | aarch64_instr_sequence *insn_sequence ATTRIBUTE_UNUSED) |
5435 | 124k | { |
5436 | 124k | int t = BITS (insn, 4, 0); |
5437 | 124k | int n = BITS (insn, 9, 5); |
5438 | 124k | int t2 = BITS (insn, 14, 10); |
5439 | | |
5440 | 124k | if (BIT (insn, 23)) |
5441 | 37.8k | { |
5442 | | /* Write back enabled. */ |
5443 | 37.8k | if ((t == n || t2 == n) && n != 31) |
5444 | 3.32k | return ERR_UND; |
5445 | 37.8k | } |
5446 | | |
5447 | 120k | if (BIT (insn, 22)) |
5448 | 120k | { |
5449 | | /* Load */ |
5450 | 120k | if (t == t2) |
5451 | 8.37k | return ERR_UND; |
5452 | 120k | } |
5453 | | |
5454 | 112k | return ERR_OK; |
5455 | 120k | } |
5456 | | |
5457 | | /* Verifier for vector by element 3 operands functions where the |
5458 | | conditions `if sz:L == 11 then UNDEFINED` holds. */ |
5459 | | |
5460 | | static enum err_type |
5461 | | verify_elem_sd (const struct aarch64_inst *inst, const aarch64_insn insn, |
5462 | | bfd_vma pc ATTRIBUTE_UNUSED, bool encoding, |
5463 | | aarch64_operand_error *mismatch_detail ATTRIBUTE_UNUSED, |
5464 | | aarch64_instr_sequence *insn_sequence ATTRIBUTE_UNUSED) |
5465 | 10.3k | { |
5466 | 10.3k | const aarch64_insn undef_pattern = 0x3; |
5467 | 10.3k | aarch64_insn value; |
5468 | | |
5469 | 10.3k | assert (inst->opcode); |
5470 | 10.3k | assert (inst->opcode->operands[2] == AARCH64_OPND_Em); |
5471 | 10.3k | value = encoding ? inst->value : insn; |
5472 | 10.3k | assert (value); |
5473 | | |
5474 | 10.3k | if (undef_pattern == extract_fields (value, 0, 2, FLD_sz, FLD_L)) |
5475 | 2.88k | return ERR_UND; |
5476 | | |
5477 | 7.49k | return ERR_OK; |
5478 | 10.3k | } |
5479 | | |
5480 | | /* Check an instruction that takes three register operands and that |
5481 | | requires the register numbers to be distinct from one another. */ |
5482 | | |
5483 | | static enum err_type |
5484 | | verify_three_different_regs (const struct aarch64_inst *inst, |
5485 | | const aarch64_insn insn ATTRIBUTE_UNUSED, |
5486 | | bfd_vma pc ATTRIBUTE_UNUSED, |
5487 | | bool encoding ATTRIBUTE_UNUSED, |
5488 | | aarch64_operand_error *mismatch_detail |
5489 | | ATTRIBUTE_UNUSED, |
5490 | | aarch64_instr_sequence *insn_sequence |
5491 | | ATTRIBUTE_UNUSED) |
5492 | 18.9k | { |
5493 | 18.9k | int rd, rs, rn; |
5494 | | |
5495 | 18.9k | rd = inst->operands[0].reg.regno; |
5496 | 18.9k | rs = inst->operands[1].reg.regno; |
5497 | 18.9k | rn = inst->operands[2].reg.regno; |
5498 | 18.9k | if (rd == rs || rd == rn || rs == rn) |
5499 | 1.28k | { |
5500 | 1.28k | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5501 | 1.28k | mismatch_detail->error |
5502 | 1.28k | = _("the three register operands must be distinct from one another"); |
5503 | 1.28k | mismatch_detail->index = -1; |
5504 | 1.28k | return ERR_UND; |
5505 | 1.28k | } |
5506 | | |
5507 | 17.6k | return ERR_OK; |
5508 | 18.9k | } |
5509 | | |
5510 | | /* Add INST to the end of INSN_SEQUENCE. */ |
5511 | | |
5512 | | static void |
5513 | | add_insn_to_sequence (const struct aarch64_inst *inst, |
5514 | | aarch64_instr_sequence *insn_sequence) |
5515 | 14.0k | { |
5516 | 14.0k | insn_sequence->instr[insn_sequence->num_added_insns++] = *inst; |
5517 | 14.0k | } |
5518 | | |
5519 | | /* Initialize an instruction sequence insn_sequence with the instruction INST. |
5520 | | If INST is NULL the given insn_sequence is cleared and the sequence is left |
5521 | | uninitialized. */ |
5522 | | |
5523 | | void |
5524 | | init_insn_sequence (const struct aarch64_inst *inst, |
5525 | | aarch64_instr_sequence *insn_sequence) |
5526 | 30.6k | { |
5527 | 30.6k | int num_req_entries = 0; |
5528 | | |
5529 | 30.6k | if (insn_sequence->instr) |
5530 | 13.8k | { |
5531 | 13.8k | XDELETE (insn_sequence->instr); |
5532 | 13.8k | insn_sequence->instr = NULL; |
5533 | 13.8k | } |
5534 | | |
5535 | | /* Handle all the cases here. May need to think of something smarter than |
5536 | | a giant if/else chain if this grows. At that time, a lookup table may be |
5537 | | best. */ |
5538 | 30.6k | if (inst && inst->opcode->constraints & C_SCAN_MOVPRFX) |
5539 | 3.14k | num_req_entries = 1; |
5540 | 30.6k | if (inst && (inst->opcode->constraints & C_SCAN_MOPS_PME) == C_SCAN_MOPS_P) |
5541 | 10.7k | num_req_entries = 2; |
5542 | | |
5543 | 30.6k | insn_sequence->num_added_insns = 0; |
5544 | 30.6k | insn_sequence->num_allocated_insns = num_req_entries; |
5545 | | |
5546 | 30.6k | if (num_req_entries != 0) |
5547 | 13.8k | { |
5548 | 13.8k | insn_sequence->instr = XCNEWVEC (aarch64_inst, num_req_entries); |
5549 | 13.8k | add_insn_to_sequence (inst, insn_sequence); |
5550 | 13.8k | } |
5551 | 30.6k | } |
5552 | | |
5553 | | /* Subroutine of verify_constraints. Check whether the instruction |
5554 | | is part of a MOPS P/M/E sequence and, if so, whether sequencing |
5555 | | expectations are met. Return true if the check passes, otherwise |
5556 | | describe the problem in MISMATCH_DETAIL. |
5557 | | |
5558 | | IS_NEW_SECTION is true if INST is assumed to start a new section. |
5559 | | The other arguments are as for verify_constraints. */ |
5560 | | |
5561 | | static bool |
5562 | | verify_mops_pme_sequence (const struct aarch64_inst *inst, |
5563 | | bool is_new_section, |
5564 | | aarch64_operand_error *mismatch_detail, |
5565 | | aarch64_instr_sequence *insn_sequence) |
5566 | 869k | { |
5567 | 869k | const struct aarch64_opcode *opcode; |
5568 | 869k | const struct aarch64_inst *prev_insn; |
5569 | 869k | int i; |
5570 | | |
5571 | 869k | opcode = inst->opcode; |
5572 | 869k | if (insn_sequence->instr) |
5573 | 13.8k | prev_insn = insn_sequence->instr + (insn_sequence->num_added_insns - 1); |
5574 | 855k | else |
5575 | 855k | prev_insn = NULL; |
5576 | | |
5577 | 869k | if (prev_insn |
5578 | 869k | && (prev_insn->opcode->constraints & C_SCAN_MOPS_PME) |
5579 | 869k | && prev_insn->opcode != opcode - 1) |
5580 | 10.6k | { |
5581 | 10.6k | mismatch_detail->kind = AARCH64_OPDE_EXPECTED_A_AFTER_B; |
5582 | 10.6k | mismatch_detail->error = NULL; |
5583 | 10.6k | mismatch_detail->index = -1; |
5584 | 10.6k | mismatch_detail->data[0].s = prev_insn->opcode[1].name; |
5585 | 10.6k | mismatch_detail->data[1].s = prev_insn->opcode->name; |
5586 | 10.6k | mismatch_detail->non_fatal = true; |
5587 | 10.6k | return false; |
5588 | 10.6k | } |
5589 | | |
5590 | 858k | if (opcode->constraints & C_SCAN_MOPS_PME) |
5591 | 6.97k | { |
5592 | 6.97k | if (is_new_section || !prev_insn || prev_insn->opcode != opcode - 1) |
5593 | 6.79k | { |
5594 | 6.79k | mismatch_detail->kind = AARCH64_OPDE_A_SHOULD_FOLLOW_B; |
5595 | 6.79k | mismatch_detail->error = NULL; |
5596 | 6.79k | mismatch_detail->index = -1; |
5597 | 6.79k | mismatch_detail->data[0].s = opcode->name; |
5598 | 6.79k | mismatch_detail->data[1].s = opcode[-1].name; |
5599 | 6.79k | mismatch_detail->non_fatal = true; |
5600 | 6.79k | return false; |
5601 | 6.79k | } |
5602 | | |
5603 | 315 | for (i = 0; i < 3; ++i) |
5604 | | /* There's no specific requirement for the data register to be |
5605 | | the same between consecutive SET* instructions. */ |
5606 | 305 | if ((opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd |
5607 | 305 | || opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs |
5608 | 305 | || opcode->operands[i] == AARCH64_OPND_MOPS_WB_Rn) |
5609 | 305 | && prev_insn->operands[i].reg.regno != inst->operands[i].reg.regno) |
5610 | 164 | { |
5611 | 164 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5612 | 164 | if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rd) |
5613 | 105 | mismatch_detail->error = _("destination register differs from " |
5614 | 59 | "preceding instruction"); |
5615 | 59 | else if (opcode->operands[i] == AARCH64_OPND_MOPS_ADDR_Rs) |
5616 | 7 | mismatch_detail->error = _("source register differs from " |
5617 | 52 | "preceding instruction"); |
5618 | 52 | else |
5619 | 52 | mismatch_detail->error = _("size register differs from " |
5620 | 164 | "preceding instruction"); |
5621 | 164 | mismatch_detail->index = i; |
5622 | 164 | mismatch_detail->non_fatal = true; |
5623 | 164 | return false; |
5624 | 164 | } |
5625 | 174 | } |
5626 | | |
5627 | 851k | return true; |
5628 | 858k | } |
5629 | | |
5630 | | /* This function verifies that the instruction INST adheres to its specified |
5631 | | constraints. If it does then ERR_OK is returned, if not then ERR_VFI is |
5632 | | returned and MISMATCH_DETAIL contains the reason why verification failed. |
5633 | | |
5634 | | The function is called both during assembly and disassembly. If assembling |
5635 | | then ENCODING will be TRUE, else FALSE. If dissassembling PC will be set |
5636 | | and will contain the PC of the current instruction w.r.t to the section. |
5637 | | |
5638 | | If ENCODING and PC=0 then you are at a start of a section. The constraints |
5639 | | are verified against the given state insn_sequence which is updated as it |
5640 | | transitions through the verification. */ |
5641 | | |
5642 | | enum err_type |
5643 | | verify_constraints (const struct aarch64_inst *inst, |
5644 | | const aarch64_insn insn ATTRIBUTE_UNUSED, |
5645 | | bfd_vma pc, |
5646 | | bool encoding, |
5647 | | aarch64_operand_error *mismatch_detail, |
5648 | | aarch64_instr_sequence *insn_sequence) |
5649 | 26.8M | { |
5650 | 26.8M | assert (inst); |
5651 | 26.8M | assert (inst->opcode); |
5652 | | |
5653 | 26.8M | const struct aarch64_opcode *opcode = inst->opcode; |
5654 | 26.8M | if (!opcode->constraints && !insn_sequence->instr) |
5655 | 25.9M | return ERR_OK; |
5656 | | |
5657 | 883k | assert (insn_sequence); |
5658 | | |
5659 | 883k | enum err_type res = ERR_OK; |
5660 | | |
5661 | | /* This instruction puts a constraint on the insn_sequence. */ |
5662 | 883k | if (opcode->flags & F_SCAN) |
5663 | 13.8k | { |
5664 | 13.8k | if (insn_sequence->instr) |
5665 | 150 | { |
5666 | 150 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5667 | 150 | mismatch_detail->error = _("instruction opens new dependency " |
5668 | 150 | "sequence without ending previous one"); |
5669 | 150 | mismatch_detail->index = -1; |
5670 | 150 | mismatch_detail->non_fatal = true; |
5671 | 150 | res = ERR_VFI; |
5672 | 150 | } |
5673 | | |
5674 | 13.8k | init_insn_sequence (inst, insn_sequence); |
5675 | 13.8k | return res; |
5676 | 13.8k | } |
5677 | | |
5678 | 869k | bool is_new_section = (!encoding && pc == 0); |
5679 | 869k | if (!verify_mops_pme_sequence (inst, is_new_section, mismatch_detail, |
5680 | 869k | insn_sequence)) |
5681 | 17.6k | { |
5682 | 17.6k | res = ERR_VFI; |
5683 | 17.6k | if ((opcode->constraints & C_SCAN_MOPS_PME) != C_SCAN_MOPS_M) |
5684 | 13.7k | init_insn_sequence (NULL, insn_sequence); |
5685 | 17.6k | } |
5686 | | |
5687 | | /* Verify constraints on an existing sequence. */ |
5688 | 869k | if (insn_sequence->instr) |
5689 | 3.25k | { |
5690 | 3.25k | const struct aarch64_opcode* inst_opcode = insn_sequence->instr->opcode; |
5691 | | /* If we're decoding and we hit PC=0 with an open sequence then we haven't |
5692 | | closed a previous one that we should have. */ |
5693 | 3.25k | if (is_new_section && res == ERR_OK) |
5694 | 0 | { |
5695 | 0 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5696 | 0 | mismatch_detail->error = _("previous `movprfx' sequence not closed"); |
5697 | 0 | mismatch_detail->index = -1; |
5698 | 0 | mismatch_detail->non_fatal = true; |
5699 | 0 | res = ERR_VFI; |
5700 | | /* Reset the sequence. */ |
5701 | 0 | init_insn_sequence (NULL, insn_sequence); |
5702 | 0 | return res; |
5703 | 0 | } |
5704 | | |
5705 | | /* Validate C_SCAN_MOVPRFX constraints. Move this to a lookup table. */ |
5706 | 3.25k | if (inst_opcode->constraints & C_SCAN_MOVPRFX) |
5707 | 3.07k | { |
5708 | | /* Check to see if the MOVPRFX SVE instruction is followed by an SVE |
5709 | | instruction for better error messages. */ |
5710 | 3.07k | if (!opcode->avariant |
5711 | 3.07k | || (!AARCH64_CPU_HAS_FEATURE (*opcode->avariant, SVE) |
5712 | 3.07k | && !AARCH64_CPU_HAS_FEATURE (*opcode->avariant, SVE2) |
5713 | 3.07k | && !AARCH64_CPU_HAS_FEATURE (*opcode->avariant, SVE2p1))) |
5714 | 1.59k | { |
5715 | 1.59k | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5716 | 1.59k | mismatch_detail->error = _("SVE instruction expected after " |
5717 | 1.59k | "`movprfx'"); |
5718 | 1.59k | mismatch_detail->index = -1; |
5719 | 1.59k | mismatch_detail->non_fatal = true; |
5720 | 1.59k | res = ERR_VFI; |
5721 | 1.59k | goto done; |
5722 | 1.59k | } |
5723 | | |
5724 | | /* Check to see if the MOVPRFX SVE instruction is followed by an SVE |
5725 | | instruction that is allowed to be used with a MOVPRFX. */ |
5726 | 1.47k | if (!(opcode->constraints & C_SCAN_MOVPRFX)) |
5727 | 551 | { |
5728 | 551 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5729 | 551 | mismatch_detail->error = _("SVE `movprfx' compatible instruction " |
5730 | 551 | "expected"); |
5731 | 551 | mismatch_detail->index = -1; |
5732 | 551 | mismatch_detail->non_fatal = true; |
5733 | 551 | res = ERR_VFI; |
5734 | 551 | goto done; |
5735 | 551 | } |
5736 | | |
5737 | | /* Next check for usage of the predicate register. */ |
5738 | 926 | aarch64_opnd_info blk_dest = insn_sequence->instr->operands[0]; |
5739 | 926 | aarch64_opnd_info blk_pred, inst_pred; |
5740 | 926 | memset (&blk_pred, 0, sizeof (aarch64_opnd_info)); |
5741 | 926 | memset (&inst_pred, 0, sizeof (aarch64_opnd_info)); |
5742 | 926 | bool predicated = false; |
5743 | 926 | assert (blk_dest.type == AARCH64_OPND_SVE_Zd); |
5744 | | |
5745 | | /* Determine if the movprfx instruction used is predicated or not. */ |
5746 | 926 | if (insn_sequence->instr->operands[1].type == AARCH64_OPND_SVE_Pg3) |
5747 | 908 | { |
5748 | 908 | predicated = true; |
5749 | 908 | blk_pred = insn_sequence->instr->operands[1]; |
5750 | 908 | } |
5751 | | |
5752 | 926 | unsigned char max_elem_size = 0; |
5753 | 926 | unsigned char current_elem_size; |
5754 | 926 | int num_op_used = 0, last_op_usage = 0; |
5755 | 926 | int i, inst_pred_idx = -1; |
5756 | 926 | int num_ops = aarch64_num_of_operands (opcode); |
5757 | 4.51k | for (i = 0; i < num_ops; i++) |
5758 | 3.58k | { |
5759 | 3.58k | aarch64_opnd_info inst_op = inst->operands[i]; |
5760 | 3.58k | switch (inst_op.type) |
5761 | 3.58k | { |
5762 | 1.13k | case AARCH64_OPND_SVE_Zd: |
5763 | 1.74k | case AARCH64_OPND_SVE_Zm_5: |
5764 | 1.95k | case AARCH64_OPND_SVE_Zm_16: |
5765 | 2.20k | case AARCH64_OPND_SVE_Zn: |
5766 | 2.20k | case AARCH64_OPND_SVE_Zt: |
5767 | 2.21k | case AARCH64_OPND_SVE_Vm: |
5768 | 2.22k | case AARCH64_OPND_SVE_Vn: |
5769 | 2.22k | case AARCH64_OPND_Va: |
5770 | 2.22k | case AARCH64_OPND_Vn: |
5771 | 2.22k | case AARCH64_OPND_Vm: |
5772 | 2.22k | case AARCH64_OPND_Sn: |
5773 | 2.22k | case AARCH64_OPND_Sm: |
5774 | 2.22k | if (inst_op.reg.regno == blk_dest.reg.regno) |
5775 | 572 | { |
5776 | 572 | num_op_used++; |
5777 | 572 | last_op_usage = i; |
5778 | 572 | } |
5779 | 2.22k | current_elem_size |
5780 | 2.22k | = aarch64_get_qualifier_esize (inst_op.qualifier); |
5781 | 2.22k | if (current_elem_size > max_elem_size) |
5782 | 931 | max_elem_size = current_elem_size; |
5783 | 2.22k | break; |
5784 | 0 | case AARCH64_OPND_SVE_Pd: |
5785 | 835 | case AARCH64_OPND_SVE_Pg3: |
5786 | 835 | case AARCH64_OPND_SVE_Pg4_5: |
5787 | 835 | case AARCH64_OPND_SVE_Pg4_10: |
5788 | 885 | case AARCH64_OPND_SVE_Pg4_16: |
5789 | 885 | case AARCH64_OPND_SVE_Pm: |
5790 | 885 | case AARCH64_OPND_SVE_Pn: |
5791 | 885 | case AARCH64_OPND_SVE_Pt: |
5792 | 885 | case AARCH64_OPND_SME_Pm: |
5793 | 885 | inst_pred = inst_op; |
5794 | 885 | inst_pred_idx = i; |
5795 | 885 | break; |
5796 | 478 | default: |
5797 | 478 | break; |
5798 | 3.58k | } |
5799 | 3.58k | } |
5800 | | |
5801 | 926 | assert (max_elem_size != 0); |
5802 | 926 | aarch64_opnd_info inst_dest = inst->operands[0]; |
5803 | | /* Determine the size that should be used to compare against the |
5804 | | movprfx size. */ |
5805 | 926 | current_elem_size |
5806 | 926 | = opcode->constraints & C_MAX_ELEM |
5807 | 926 | ? max_elem_size |
5808 | 926 | : aarch64_get_qualifier_esize (inst_dest.qualifier); |
5809 | | |
5810 | | /* If movprfx is predicated do some extra checks. */ |
5811 | 926 | if (predicated) |
5812 | 908 | { |
5813 | | /* The instruction must be predicated. */ |
5814 | 908 | if (inst_pred_idx < 0) |
5815 | 41 | { |
5816 | 41 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5817 | 41 | mismatch_detail->error = _("predicated instruction expected " |
5818 | 41 | "after `movprfx'"); |
5819 | 41 | mismatch_detail->index = -1; |
5820 | 41 | mismatch_detail->non_fatal = true; |
5821 | 41 | res = ERR_VFI; |
5822 | 41 | goto done; |
5823 | 41 | } |
5824 | | |
5825 | | /* The instruction must have a merging predicate. */ |
5826 | 867 | if (inst_pred.qualifier != AARCH64_OPND_QLF_P_M) |
5827 | 27 | { |
5828 | 27 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5829 | 27 | mismatch_detail->error = _("merging predicate expected due " |
5830 | 27 | "to preceding `movprfx'"); |
5831 | 27 | mismatch_detail->index = inst_pred_idx; |
5832 | 27 | mismatch_detail->non_fatal = true; |
5833 | 27 | res = ERR_VFI; |
5834 | 27 | goto done; |
5835 | 27 | } |
5836 | | |
5837 | | /* The same register must be used in instruction. */ |
5838 | 840 | if (blk_pred.reg.regno != inst_pred.reg.regno) |
5839 | 482 | { |
5840 | 482 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5841 | 482 | mismatch_detail->error = _("predicate register differs " |
5842 | 482 | "from that in preceding " |
5843 | 482 | "`movprfx'"); |
5844 | 482 | mismatch_detail->index = inst_pred_idx; |
5845 | 482 | mismatch_detail->non_fatal = true; |
5846 | 482 | res = ERR_VFI; |
5847 | 482 | goto done; |
5848 | 482 | } |
5849 | 840 | } |
5850 | | |
5851 | | /* Destructive operations by definition must allow one usage of the |
5852 | | same register. */ |
5853 | 376 | int allowed_usage |
5854 | 376 | = aarch64_is_destructive_by_operands (opcode) ? 2 : 1; |
5855 | | |
5856 | | /* Operand is not used at all. */ |
5857 | 376 | if (num_op_used == 0) |
5858 | 106 | { |
5859 | 106 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5860 | 106 | mismatch_detail->error = _("output register of preceding " |
5861 | 106 | "`movprfx' not used in current " |
5862 | 106 | "instruction"); |
5863 | 106 | mismatch_detail->index = 0; |
5864 | 106 | mismatch_detail->non_fatal = true; |
5865 | 106 | res = ERR_VFI; |
5866 | 106 | goto done; |
5867 | 106 | } |
5868 | | |
5869 | | /* We now know it's used, now determine exactly where it's used. */ |
5870 | 270 | if (blk_dest.reg.regno != inst_dest.reg.regno) |
5871 | 88 | { |
5872 | 88 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5873 | 88 | mismatch_detail->error = _("output register of preceding " |
5874 | 88 | "`movprfx' expected as output"); |
5875 | 88 | mismatch_detail->index = 0; |
5876 | 88 | mismatch_detail->non_fatal = true; |
5877 | 88 | res = ERR_VFI; |
5878 | 88 | goto done; |
5879 | 88 | } |
5880 | | |
5881 | | /* Operand used more than allowed for the specific opcode type. */ |
5882 | 182 | if (num_op_used > allowed_usage) |
5883 | 141 | { |
5884 | 141 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5885 | 141 | mismatch_detail->error = _("output register of preceding " |
5886 | 141 | "`movprfx' used as input"); |
5887 | 141 | mismatch_detail->index = last_op_usage; |
5888 | 141 | mismatch_detail->non_fatal = true; |
5889 | 141 | res = ERR_VFI; |
5890 | 141 | goto done; |
5891 | 141 | } |
5892 | | |
5893 | | /* Now the only thing left is the qualifiers checks. The register |
5894 | | must have the same maximum element size. */ |
5895 | 41 | if (inst_dest.qualifier |
5896 | 41 | && blk_dest.qualifier |
5897 | 41 | && current_elem_size |
5898 | 23 | != aarch64_get_qualifier_esize (blk_dest.qualifier)) |
5899 | 10 | { |
5900 | 10 | mismatch_detail->kind = AARCH64_OPDE_SYNTAX_ERROR; |
5901 | 10 | mismatch_detail->error = _("register size not compatible with " |
5902 | 10 | "previous `movprfx'"); |
5903 | 10 | mismatch_detail->index = 0; |
5904 | 10 | mismatch_detail->non_fatal = true; |
5905 | 10 | res = ERR_VFI; |
5906 | 10 | goto done; |
5907 | 10 | } |
5908 | 41 | } |
5909 | | |
5910 | 3.25k | done: |
5911 | 3.25k | if (insn_sequence->num_added_insns == insn_sequence->num_allocated_insns) |
5912 | | /* We've checked the last instruction in the sequence and so |
5913 | | don't need the sequence any more. */ |
5914 | 3.07k | init_insn_sequence (NULL, insn_sequence); |
5915 | 182 | else |
5916 | 182 | add_insn_to_sequence (inst, insn_sequence); |
5917 | 3.25k | } |
5918 | | |
5919 | 869k | return res; |
5920 | 869k | } |
5921 | | |
5922 | | |
5923 | | /* Return true if VALUE cannot be moved into an SVE register using DUP |
5924 | | (with any element size, not just ESIZE) and if using DUPM would |
5925 | | therefore be OK. ESIZE is the number of bytes in the immediate. */ |
5926 | | |
5927 | | bool |
5928 | | aarch64_sve_dupm_mov_immediate_p (uint64_t uvalue, int esize) |
5929 | 9.76k | { |
5930 | 9.76k | int64_t svalue = uvalue; |
5931 | 9.76k | uint64_t upper = (uint64_t) -1 << (esize * 4) << (esize * 4); |
5932 | | |
5933 | 9.76k | if ((uvalue & ~upper) != uvalue && (uvalue | upper) != uvalue) |
5934 | 0 | return false; |
5935 | 9.76k | if (esize <= 4 || (uint32_t) uvalue == (uint32_t) (uvalue >> 32)) |
5936 | 7.85k | { |
5937 | 7.85k | svalue = (int32_t) uvalue; |
5938 | 7.85k | if (esize <= 2 || (uint16_t) uvalue == (uint16_t) (uvalue >> 16)) |
5939 | 1.21k | { |
5940 | 1.21k | svalue = (int16_t) uvalue; |
5941 | 1.21k | if (esize == 1 || (uint8_t) uvalue == (uint8_t) (uvalue >> 8)) |
5942 | 935 | return false; |
5943 | 1.21k | } |
5944 | 7.85k | } |
5945 | 8.83k | if ((svalue & 0xff) == 0) |
5946 | 4.60k | svalue /= 256; |
5947 | 8.83k | return svalue < -128 || svalue >= 128; |
5948 | 9.76k | } |
5949 | | |
5950 | | /* Return true if a CPU with the AARCH64_FEATURE_* bits in CPU_VARIANT |
5951 | | supports the instruction described by INST. */ |
5952 | | |
5953 | | bool |
5954 | | aarch64_cpu_supports_inst_p (aarch64_feature_set cpu_variant, |
5955 | | aarch64_inst *inst) |
5956 | 0 | { |
5957 | 0 | if (!inst->opcode->avariant |
5958 | 0 | || !AARCH64_CPU_HAS_ALL_FEATURES (cpu_variant, *inst->opcode->avariant)) |
5959 | 0 | return false; |
5960 | | |
5961 | 0 | if (inst->opcode->iclass == sme_fp_sd |
5962 | 0 | && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D |
5963 | 0 | && !AARCH64_CPU_HAS_FEATURE (cpu_variant, SME_F64F64)) |
5964 | 0 | return false; |
5965 | | |
5966 | 0 | if (inst->opcode->iclass == sme_int_sd |
5967 | 0 | && inst->operands[0].qualifier == AARCH64_OPND_QLF_S_D |
5968 | 0 | && !AARCH64_CPU_HAS_FEATURE (cpu_variant, SME_I16I64)) |
5969 | 0 | return false; |
5970 | | |
5971 | 0 | return true; |
5972 | 0 | } |
5973 | | |
5974 | | /* Include the opcode description table as well as the operand description |
5975 | | table. */ |
5976 | | #define VERIFIER(x) verify_##x |
5977 | | #include "aarch64-tbl.h" |