Debian Codegraph @

arm64/instgen/encodings.go

raw symbols SCIP
1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package main
6
7 var defaultEncodingTmpl string = `// TODO: implement this.
8 // Note: the raw value v is from obj.Prog, starting at bit 0.
9 // e.g. If it's a register, then its value is following the ones defined in a.out.go
10 // If it's a constant, then its value is the constant value.
11 return 0, false` // The %s will be replaced by the symbol name in the operand initialiser.
12
13 // encodingImpls are the known implementations of encoding functions, key is their description, value is their implementation.
14 type encodingImpl struct {
15 name string
16 body string
17 encodedIn string
18 }
19
20 // encodingImpls are the known implementations of encoding functions, key is their description, value is their implementation.
21 var encodingImpls = map[string]encodingImpl{
22 "Check this is a B arrangement": {"encodeArngBCheck", `if v == ARNG_B {
23 return 0, true
24 }
25 return 0, false`, "enc_NIL"},
26 "Check this is a D arrangement": {"encodeArngDCheck", `if v == ARNG_D {
27 return 0, true
28 }
29 return 0, false`, "enc_NIL"},
30 "Check this is a H arrangement": {"encodeArngHCheck", `if v == ARNG_H {
31 return 0, true
32 }
33 return 0, false`, "enc_NIL"},
34 "Check this is a Q arrangement": {"encodeArngQCheck", `if v == ARNG_Q {
35 return 0, true
36 }
37 return 0, false`, "enc_NIL"},
38 "Check this is a S arrangement": {"encodeArngSCheck", `if v == ARNG_S {
39 return 0, true
40 }
41 return 0, false`, "enc_NIL"},
42 "Check this is a merging predication": {"encodeMergePredCheck", `if v == PRED_M {
43 return 0, true
44 }
45 return 0, false`, "enc_NIL"},
46 "Check this is a zeroing predication": {"encodeZeroPredCheck", `if v == PRED_Z {
47 return 0, true
48 }
49 return 0, false`, "enc_NIL"},
50 `For the "Byte and halfword" variant: is the size specifier,
51 sz <T>
52 0 B
53 1 H
54 bit range mappings:
55 sz: [22:23)
56 `: {"encodeSzByteHalfword", `switch v {
57 case ARNG_B:
58 return 0, true
59 case ARNG_H:
60 return 1 << 22, true
61 }
62 return 0, false`, "enc_sz"},
63 `For the "Byte, merging" and "Byte, zeroing" variants: is the size specifier,
64 size <T>
65 00 RESERVED
66 01 H
67 10 S
68 11 D
69 bit range mappings:
70 size: [22:24)
71 `: {"encodeSizeByteMergeZero", `switch v {
72 case ARNG_H:
73 return 1 << 22, true
74 case ARNG_S:
75 return 2 << 22, true
76 case ARNG_D:
77 return 3 << 22, true
78 }
79 return 0, false`, "enc_size"},
80 `For the "Halfword, merging" and "Halfword, zeroing" variants: is the size specifier,
81 size[0] <T>
82 0 S
83 1 D
84 bit range mappings:
85 size: [22:23)
86 `: {"encodeSize0HalfwordMergeZero", `switch v {
87 case ARNG_S:
88 return 0, true
89 case ARNG_D:
90 return 1 << 22, true
91 }
92 return 0, false`, "enc_size0"},
93 `For the "Word and doubleword" variant: is the size specifier,
94 sz <T>
95 0 S
96 1 D
97 bit range mappings:
98 sz: [22:23)
99 `: {"encodeSzWordDoubleword", `switch v {
100 case ARNG_S:
101 return 0, true
102 case ARNG_D:
103 return 1 << 22, true
104 }
105 return 0, false`, "enc_sz"},
106 `Is an arrangement specifier,
107 size <T>
108 00 16B
109 01 8H
110 10 4S
111 11 2D
112 bit range mappings:
113 size: [22:24)
114 `: {"encodeSize16B8H4S2D", `switch v {
115 case ARNG_16B:
116 return 0, true
117 case ARNG_8H:
118 return 1 << 22, true
119 case ARNG_4S:
120 return 2 << 22, true
121 case ARNG_2D:
122 return 3 << 22, true
123 }
124 return 0, false`, "enc_size"},
125 `Is an arrangement specifier,
126 size <T>
127 00 RESERVED
128 01 8H
129 10 4S
130 11 2D
131 bit range mappings:
132 size: [22:24)
133 `: {"encodeSize8H4S2D", `switch v {
134 case ARNG_8H:
135 return 1 << 22, true
136 case ARNG_4S:
137 return 2 << 22, true
138 case ARNG_2D:
139 return 3 << 22, true
140 }
141 return 0, false`, "enc_size"},
142 `Is the name of the destination SIMD&FP register, encoded in the "Vd" field.
143 bit range mappings:
144 Vd: [0:5)
145 `: {"encodeVd", `return v & 31, true`, "enc_Vd"},
146 `Is the name of the destination scalable predicate register PN8-PN15, with predicate-as-counter encoding, encoded in the "PNd" field.
147 bit range mappings:
148 PNd: [0:3)
149 `: {"encodePNd", `if v >= 24 && v <= 31 {
150 // PN registers starts from 16.
151 return v - 24, true
152 }
153 return 0, false`, "enc_PNd"},
154 `Is the name of the destination scalable predicate register, encoded in the "Pd" field.
155 bit range mappings:
156 Pd: [0:4)
157 `: {"encodePd", `return v, true`, "enc_Pd"},
158 `Is the name of the destination scalable vector register, encoded in the "Zd" field.
159 bit range mappings:
160 Zd: [0:5)
161 `: {"encodeZd", `if !stripRawZ(&v) {
162 return 0, false
163 }
164 return v, true`, "enc_Zd"},
165 `Is the name of the first source and destination scalable predicate register, encoded in the "Pdn" field.
166 bit range mappings:
167 Pdn: [0:4)
168 `: {"encodePdnDest", `return v, true`, "enc_Pdn"},
169 `Is the name of the first source and destination scalable vector register, encoded in the "Zdn" field.
170 bit range mappings:
171 Zdn: [0:5)
172 `: {"encodeZdnDest", `if !stripRawZ(&v) {
173 return 0, false
174 }
175 return v, true`, "enc_Zdn"},
176 `Is the name of the first source scalable predicate register, encoded in the "Pn" field.
177 bit range mappings:
178 Pn: [5:9)
179 `: {"encodePn59", `return v << 5, true`, "enc_Pn"},
180 `Is the name of the first source scalable vector register, encoded in the "Zn" field.
181 bit range mappings:
182 Zn: [5:10)
183 `: {"encodeZn510V1", `if !stripRawZ(&v) {
184 return 0, false
185 }
186 return v << 5, true`, "enc_Zn"},
187 `Is the name of the governing scalable predicate register P0-P7, encoded in the "Pg" field.
188 bit range mappings:
189 Pg: [10:13)
190 `: {"encodePg1013", `if v <= 7 {
191 return v << 10, true
192 }
193 return 0, false`, "enc_Pg"},
194 `Is the name of the governing scalable predicate register, encoded in the "Pg" field.
195 bit range mappings:
196 Pg: [10:14)
197 `: {"encodePg1014", `return v << 10, true`, "enc_Pg"},
198 `Is the name of the governing scalable predicate register, encoded in the "Pg" field.
199 bit range mappings:
200 Pg: [5:9)
201 `: {"encodePg59", `return v << 5, true`, "enc_Pg"},
202 `Is the name of the second source and destination scalable predicate register, encoded in the "Pdm" field.
203 bit range mappings:
204 Pdm: [0:4)
205 `: {"encodePdmDest", `return v, true`, "enc_Pdm"},
206 `Is the name of the second source and destination scalable vector register, encoded in the "Zda" field.
207 bit range mappings:
208 Zda: [0:5)
209 `: {"encodeZdaDest", `if !stripRawZ(&v) {
210 return 0, false
211 }
212 return v, true`, "enc_Zda"},
213 `Is the name of the second source scalable predicate register, encoded in the "Pm" field.
214 bit range mappings:
215 Pm: [16:20)
216 `: {"encodePm1620", `return v << 16, true`, "enc_Pm"},
217 `Is the name of the second source scalable vector register, encoded in the "Zm" field.
218 bit range mappings:
219 Zm: [16:21)
220 `: {"encodeZm1621V2", `if !stripRawZ(&v) {
221 return 0, false
222 }
223 return v << 16, true`, "enc_Zm"},
224 `Is the name of the second source scalable vector register, encoded in the "Zm" field.
225 bit range mappings:
226 Zm: [5:10)
227 `: {"encodeZm510V1", `if !stripRawZ(&v) {
228 return 0, false
229 }
230 return (v & 31) << 5, true`, "enc_Zm"},
231 `Is the name of the source and destination scalable predicate register, encoded in the "Pdn" field.
232 bit range mappings:
233 Pdn: [0:4)
234 `: {"encodePdnSrcDst", `return v, true`, "enc_Pdn"},
235 `Is the name of the source and destination scalable vector register, encoded in the "Zdn" field.
236 bit range mappings:
237 Zdn: [0:5)
238 `: {"encodeZdnSrcDst", `if !stripRawZ(&v) {
239 return 0, false
240 }
241 return v, true`, "enc_Zdn"},
242 `Is the name of the source scalable predicate register, encoded in the "Pm" field.
243 bit range mappings:
244 Pm: [5:9)
245 `: {"encodePm59V1", `return v << 5, true`, "enc_Pm"},
246 `Is the name of the source scalable predicate register, encoded in the "Pn" field.
247 bit range mappings:
248 Pn: [5:9)
249 `: {"encodePn59V2", `return v << 5, true`, "enc_Pn"},
250 `Is the name of the source scalable vector register, encoded in the "Zn" field.
251 bit range mappings:
252 Zn: [5:10)
253 `: {"encodeZn510Src", `if !stripRawZ(&v) {
254 return 0, false
255 }
256 return (v & 31) << 5, true`, "enc_Zn"},
257 `Is the name of the third source and destination scalable vector register, encoded in the "Zda" field.
258 bit range mappings:
259 Zda: [0:5)
260 `: {"encodeZda3RdSrcDst", `if !stripRawZ(&v) {
261 return 0, false
262 }
263 return v, true`, "enc_Zda"},
264 `Is the name of the third source scalable vector register, encoded in the "Za" field.
265 bit range mappings:
266 Za: [16:21)
267 `: {"encodeZa16213Rd", `if !stripRawZ(&v) {
268 return 0, false
269 }
270 return v << 16, true`, "enc_Za"},
271 `Is the name of the third source scalable vector register, encoded in the "Za" field.
272 bit range mappings:
273 Za: [5:10)
274 `: {"encodeZa5103Rd", `if !stripRawZ(&v) {
275 return 0, false
276 }
277 return v << 5, true`, "enc_Za"},
278 `Is the name of the third source scalable vector register, encoded in the "Zk" field.
279 bit range mappings:
280 Zk: [5:10)
281 `: {"encodeZk5103Rd", `if !stripRawZ(&v) {
282 return 0, false
283 }
284 return v << 5, true`, "enc_Zk"},
285 `Is the name of the vector select predicate register P0-P7, encoded in the "Pv" field.
286 bit range mappings:
287 Pv: [10:13)
288 `: {"encodePv1013", `return v << 10, true`, "enc_Pv"},
289 `Is the name of the vector select predicate register, encoded in the "Pv" field.
290 bit range mappings:
291 Pv: [10:14)
292 `: {"encodePv1014", `return v << 10, true`, "enc_Pv"},
293 `Is the name of the vector select predicate register, encoded in the "Pv" field.
294 bit range mappings:
295 Pv: [5:9)
296 `: {"encodePv59", `return v << 5, true`, "enc_Pv"},
297 `Is the predication qualifier,
298 M <ZM>
299 0 Z
300 1 M
301 bit range mappings:
302 M: [16:17)
303 `: {"encodePredQualM1617", `switch v {
304 case PRED_Z:
305 return 0, true
306 case PRED_M:
307 return 1 << 16, true
308 }
309 return 0, false`, "enc_M"},
310 `Is the predication qualifier,
311 M <ZM>
312 0 Z
313 1 M
314 bit range mappings:
315 M: [4:5)
316 `: {"encodePredQualM45", `switch v {
317 case PRED_Z:
318 return 0, true
319 case PRED_M:
320 return 1 << 4, true
321 }
322 return 0, false`, "enc_M"},
323 `Is the size specifier,
324 size <T>
325 00 B
326 01 H
327 10 S
328 11 D
329 bit range mappings:
330 size: [22:24)
331 `: {"encodeSizeBHSD2224", `switch v {
332 case ARNG_B:
333 return 0 << 22, true
334 case ARNG_H:
335 return 1 << 22, true
336 case ARNG_S:
337 return 2 << 22, true
338 case ARNG_D:
339 return 3 << 22, true
340 }
341 return 0, false`, "enc_size"},
342 `Is the size specifier,
343 size <T>
344 00 B
345 01 H
346 10 S
347 11 RESERVED
348 bit range mappings:
349 size: [22:24)
350 `: {"encodeSizeBHS2224", `switch v {
351 case ARNG_B:
352 return 0 << 22, true
353 case ARNG_H:
354 return 1 << 22, true
355 case ARNG_S:
356 return 2 << 22, true
357 }
358 return 0, false`, "enc_size"},
359 `Is the size specifier,
360 size <T>
361 00 RESERVED
362 01 B
363 10 H
364 11 S
365 bit range mappings:
366 size: [22:24)
367 `: {"encodeSizeBHS2224Offset1", `switch v {
368 case ARNG_B:
369 return 1 << 22, true
370 case ARNG_H:
371 return 2 << 22, true
372 case ARNG_S:
373 return 3 << 22, true
374 }
375 return 0, false`, "enc_size"},
376 `Is the size specifier,
377 size <T>
378 00 RESERVED
379 01 H
380 10 S
381 11 D
382 bit range mappings:
383 size: [13:15)
384 `: {"encodeSizeHSD1315", `switch v {
385 case ARNG_H:
386 return 1 << 13, true
387 case ARNG_S:
388 return 2 << 13, true
389 case ARNG_D:
390 return 3 << 13, true
391 }
392 return 0, false`, "enc_size"},
393 `Is the size specifier,
394 size <T>
395 00 RESERVED
396 01 H
397 10 S
398 11 D
399 bit range mappings:
400 size: [17:19)
401 `: {"encodeSizeHSD1719", `switch v {
402 case ARNG_H:
403 return 1 << 17, true
404 case ARNG_S:
405 return 2 << 17, true
406 case ARNG_D:
407 return 3 << 17, true
408 }
409 return 0, false`, "enc_size"},
410 `Is the size specifier,
411 size <T>
412 00 RESERVED
413 01 H
414 10 S
415 11 D
416 bit range mappings:
417 size: [22:24)
418 `: {"encodeSizeHSD2224", `switch v {
419 case ARNG_H:
420 return 1 << 22, true
421 case ARNG_S:
422 return 2 << 22, true
423 case ARNG_D:
424 return 3 << 22, true
425 }
426 return 0, false`, "enc_size"},
427 `Is the size specifier,
428 size <T>
429 01 H
430 10 S
431 11 D
432 bit range mappings:
433 size: [22:24)
434 `: {"encodeSizeHSD2224No00", `switch v {
435 case ARNG_H:
436 return 1 << 22, true
437 case ARNG_S:
438 return 2 << 22, true
439 case ARNG_D:
440 return 3 << 22, true
441 }
442 return 0, false`, "enc_size"},
443 `Is the size specifier,
444 size <T>
445 01 H
446 1x D
447 bit range mappings:
448 size: [22:24)
449 `: {"encodeSizeHD2224", `switch v {
450 case ARNG_H:
451 return 1 << 22, true
452 case ARNG_D:
453 return 3 << 22, true
454 }
455 return 0, false`, "enc_size"},
456 `Is the size specifier,
457 size <Tb>
458 00 B
459 01 H
460 10 S
461 11 D
462 bit range mappings:
463 size: [22:24)
464 `: {"encodeSizeTbBHSD2224", `switch v {
465 case ARNG_B:
466 return 0 << 22, true
467 case ARNG_H:
468 return 1 << 22, true
469 case ARNG_S:
470 return 2 << 22, true
471 case ARNG_D:
472 return 3 << 22, true
473 }
474 return 0, false`, "enc_size"},
475 `Is the size specifier,
476 size <Tb>
477 00 RESERVED
478 01 B
479 10 H
480 11 S
481 bit range mappings:
482 size: [22:24)
483 `: {"encodeSizeTbBHS2224", `switch v {
484 case ARNG_B:
485 return 1 << 22, true
486 case ARNG_H:
487 return 2 << 22, true
488 case ARNG_S:
489 return 3 << 22, true
490 }
491 return 0, false`, "enc_size"},
492 `Is the size specifier,
493 size <Tb>
494 00 RESERVED
495 01 H
496 10 S
497 11 D
498 bit range mappings:
499 size: [22:24)
500 `: {"encodeSizeTbHSD2224Offset1", `switch v {
501 case ARNG_H:
502 return 1 << 22, true
503 case ARNG_S:
504 return 2 << 22, true
505 case ARNG_D:
506 return 3 << 22, true
507 }
508 return 0, false`, "enc_size"},
509 `Is the size specifier,
510 size <Tb>
511 01 B
512 1x S
513 bit range mappings:
514 size: [22:24)
515 `: {"encodeSizeTbBS2224", `switch v {
516 case ARNG_B:
517 return 1 << 22, true
518 case ARNG_S:
519 return 3 << 22, true
520 }
521 return 0, false`, "enc_size"},
522 `Is the size specifier,
523 size[0] <T>
524 0 B
525 1 H
526 bit range mappings:
527 size: [22:23)
528 `: {"encodeSize0BH2223", `switch v {
529 case ARNG_B:
530 return 0 << 22, true
531 case ARNG_H:
532 return 1 << 22, true
533 }
534 return 0, false`, "enc_size0"},
535 `Is the size specifier,
536 size[0] <T>
537 0 S
538 1 D
539 bit range mappings:
540 size: [22:23)
541 `: {"encodeSize0SD2223", `switch v {
542 case ARNG_S:
543 return 0 << 22, true
544 case ARNG_D:
545 return 1 << 22, true
546 }
547 return 0, false`, "enc_size0"},
548 `Is the size specifier,
549 size[0] <Tb>
550 0 B
551 1 H
552 bit range mappings:
553 size: [22:23)
554 `: {"encodeSize0TbBH2223", `switch v {
555 case ARNG_B:
556 return 0 << 22, true
557 case ARNG_H:
558 return 1 << 22, true
559 }
560 return 0, false`, "enc_size0"},
561 `Is the size specifier,
562 sz <T>
563 0 S
564 1 D
565 bit range mappings:
566 sz: [14:15)
567 `: {"encodeSzSD1415", `switch v {
568 case ARNG_S:
569 return 0 << 14, true
570 case ARNG_D:
571 return 1 << 14, true
572 }
573 return 0, false`, "enc_sz"},
574 `Is the size specifier,
575 sz <T>
576 0 S
577 1 D
578 bit range mappings:
579 sz: [17:18)
580 `: {"encodeSzSD1718", `switch v {
581 case ARNG_S:
582 return 0 << 17, true
583 case ARNG_D:
584 return 1 << 17, true
585 }
586 return 0, false`, "enc_sz"},
587 `Is the size specifier,
588 sz <T>
589 0 S
590 1 D
591 bit range mappings:
592 sz: [22:23)
593 `: {"encodeSzSD2223", `switch v {
594 case ARNG_S:
595 return 0 << 22, true
596 case ARNG_D:
597 return 1 << 22, true
598 }
599 return 0, false`, "enc_sz"},
600 `Is the size specifier,
601 tszh tszl <T>
602 0 00 RESERVED
603 0 01 B
604 0 10 H
605 0 11 RESERVED
606 1 00 S
607 1 01 RESERVED
608 1 1x RESERVED
609 bit range mappings:
610 tszh: [22:23)
611 tszl: [19:21)
612 `: {"encodeTszhTszlBHS", `switch v {
613 case ARNG_B:
614 return 0<<22 | 1<<19, true
615 case ARNG_H:
616 return 0<<22 | 2<<19, true
617 case ARNG_S:
618 return 1 << 22, true
619 }
620 return 0, false`, "enc_tszh_tszl"},
621 `Is the size specifier,
622 tszh tszl <Tb>
623 0 00 RESERVED
624 0 01 H
625 0 10 S
626 0 11 RESERVED
627 1 00 D
628 1 01 RESERVED
629 1 1x RESERVED
630 bit range mappings:
631 tszh: [22:23)
632 tszl: [19:21)
633 `: {"encodeTszhTszlTbHSD", `switch v {
634 case ARNG_H:
635 return 0<<22 | 1<<19, true
636 case ARNG_S:
637 return 0<<22 | 2<<19, true
638 case ARNG_D:
639 return 1 << 22, true
640 }
641 return 0, false`, "enc_tszh_tszl"},
642 `No-op check, returns true`: {"encodeNoop", `return 0, true`, "enc_NIL"},
643 `Is the 32-bit name of the source and destination general-purpose register, encoded in the "Rdn" field.
644 bit range mappings:
645 Rdn: [0:5)`: {"encodeWdn05", `if !checkIsR(v) {
646 return 0, false
647 }
648 if v == REG_RSP {
649 return 0, false
650 }
651 return v & 31, true`, "enc_Rdn"},
652 `Is the 64-bit name of the destination SIMD&FP register, encoded in the "Vd" field.
653 bit range mappings:
654 Vd: [0:5)`: {"encodeVd0564", `return v & 31, true`, "enc_Vd"},
655 `Is the 64-bit name of the destination general-purpose register, encoded in the "Rd" field.
656 bit range mappings:
657 Rd: [0:5)`: {"encodeRd05", `if !checkIsR(v) {
658 return 0, false
659 }
660 if v == REG_RSP {
661 return 0, false
662 }
663 return v & 31, true`, "enc_Rd"},
664 `Is the 64-bit name of the first source general-purpose register, encoded in the "Rn" field.
665 bit range mappings:
666 Rn: [5:10)`: {"encodeRn510", `if !checkIsR(v) {
667 return 0, false
668 }
669 if v == REG_RSP {
670 return 0, false
671 }
672 return (v & 31) << 5, true`, "enc_Rn"},
673 `Is the 64-bit name of the second source general-purpose register, encoded in the "Rm" field.
674 bit range mappings:
675 Rm: [16:21)`: {"encodeRm1621V1", `if !checkIsR(v) {
676 return 0, false
677 }
678 if v == REG_RSP {
679 return 0, false
680 }
681 return (v & 31) << 16, true`, "enc_Rm"},
682 `Is the 64-bit name of the source and destination general-purpose register, encoded in the "Rdn" field.
683 bit range mappings:
684 Rdn: [0:5)`: {"encodeXdn05", `if !checkIsR(v) {
685 return 0, false
686 }
687 if v == REG_RSP {
688 return 0, false
689 }
690 return v & 31, true`, "enc_Rdn"},
691 `Is the name of the source scalable vector register, encoded in the "Zm" field.
692 bit range mappings:
693 Zm: [5:10)`: {"encodeZm510V2", `if !stripRawZ(&v) {
694 return 0, false
695 }
696 return (v & 31) << 5, true`, "enc_Zm"},
697 `Is the number [0-30] of the destination general-purpose register or the name ZR (31), encoded in the "Rd" field.
698 bit range mappings:
699 Rd: [0:5)`: {"encodeRd05ZR", `if !checkIsR(v) {
700 return 0, false
701 }
702 if v == REG_RSP {
703 return 0, false
704 }
705 // ZR is just R31
706 return v & 31, true`, "enc_Rd"},
707 `Is the number [0-30] of the general-purpose source register or the name SP (31), encoded in the "Rn" field.
708 bit range mappings:
709 Rn: [5:10)`: {"encodeRn510SPV1", `if !checkIsR(v) {
710 return 0, false
711 }
712 if v == REG_R31 {
713 return 0, false
714 }
715 if v == REG_RSP {
716 return (REG_R31 & 31) << 5, true
717 }
718 return (v & 31) << 5, true`, "enc_Rn"},
719 `Is the number [0-30] of the source and destination general-purpose register or the name ZR (31), encoded in the "Rdn" field.
720 bit range mappings:
721 Rdn: [0:5)`: {"encodeRdn05ZR", `if !checkIsR(v) {
722 return 0, false
723 }
724 if v == REG_RSP {
725 return 0, false
726 }
727 return v & 31, true`, "enc_Rdn"},
728 `Is the number [0-30] of the source general-purpose register or the name ZR (31), encoded in the "Rm" field.
729 bit range mappings:
730 Rm: [16:21)`: {"encodeRm1621ZR", `if !checkIsR(v) {
731 return 0, false
732 }
733 if v == REG_RSP {
734 return 0, false
735 }
736 return (v & 31) << 16, true`, "enc_Rm"},
737 `Is the number [0-30] of the source general-purpose register or the name ZR (31), encoded in the "Rm" field.
738 bit range mappings:
739 Rm: [5:10)`: {"encodeRm510ZR", `if !checkIsR(v) {
740 return 0, false
741 }
742 if v == REG_RSP {
743 return 0, false
744 }
745 return (v & 31) << 5, true`, "enc_Rm"},
746 `Is the number [0-30] of the source general-purpose register or the name ZR (31), encoded in the "Rn" field.
747 bit range mappings:
748 Rn: [5:10)`: {"encodeRn510ZR", `if !checkIsR(v) {
749 return 0, false
750 }
751 if v == REG_RSP {
752 return 0, false
753 }
754 return (v & 31) << 5, true`, "enc_Rn"},
755 `Is the number [0-31] of the destination SIMD&FP register, encoded in the "Vd" field.
756 bit range mappings:
757 Vd: [0:5)`: {"encodeVd05", `return v & 31, true`, "enc_Vd"},
758 `Is the number [0-31] of the source SIMD&FP register, encoded in the "Vm" field.
759 bit range mappings:
760 Vm: [5:10)`: {"encodeVm510", `return (v & 31) << 5, true`, "enc_Vm"},
761 `Is the number [0-31] of the source SIMD&FP register, encoded in the "Vn" field.
762 bit range mappings:
763 Vn: [5:10)`: {"encodeVn510", `return (v & 31) << 5, true`, "enc_Vn"},
764 `Is the number [0-31] of the source and destination SIMD&FP register, encoded in the "Vdn" field.
765 bit range mappings:
766 Vdn: [0:5)`: {"encodeVdn05", `return v & 31, true`, "enc_Vdn"},
767 `For the "16-bit to 32-bit" variant: is the immediate index of a pair of 16-bit elements within each 128-bit vector segment, in the range 0 to 3, encoded in the "i2" field.
768 bit range mappings:
769 i2: [19:21)
770 `: {"encodeI2_1921_16To32Bit", `if v > 3 {
771 return 0, false
772 }
773 return v << 19, true`, "enc_i2"},
774 `For the "16-bit to 64-bit" variant: is the immediate index of a 64-bit group of four 16-bit values within each 128-bit vector segment, in the range 0 to 1, encoded in the "i1" field.
775 bit range mappings:
776 i1: [20:21)
777 `: {"encodeI1_2021_16To64Bit", `if v > 1 {
778 return 0, false
779 }
780 return v << 20, true`, "enc_i1"},
781 `For the "16-bit to 64-bit" variant: is the name of the second source scalable vector register Z0-Z15, encoded in the "Zm" field.
782 bit range mappings:
783 Zm: [16:20)
784 `: {"encodeZm1620_16To64Bit", `if !stripRawZ(&v) {
785 return 0, false
786 }
787 if v > 15 {
788 return 0, false
789 }
790 return v << 16, true`, "enc_Zm"},
791 `For the "16-bit" and "32-bit" variants: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
792 bit range mappings:
793 Zm: [16:19)
794 `: {"encodeZm1619_16Bit32Bit", `if !stripRawZ(&v) {
795 return 0, false
796 }
797 if v > 7 {
798 return 0, false
799 }
800 return v << 16, true`, "enc_Zm"},
801 `For the "16-bit" variant: is the element index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
802 bit range mappings:
803 i3h: [22:23)
804 i3l: [19:21)
805 `: {"encodeI3hI3l_1923_16Bit", `if v > 7 {
806 return 0, false
807 }
808 return (v&3)<<19 | (v>>2)<<22, true`, "enc_i3h_i3l"},
809 `For the "32-bit" variant: is the element index, in the range 0 to 3, encoded in the "i2" field.
810 bit range mappings:
811 i2: [19:21)
812 `: {"encodeI2_1921_32Bit", `if v > 3 {
813 return 0, false
814 }
815 return v << 19, true`, "enc_i2"},
816 `For the "32-bit" variant: is the element index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
817 bit range mappings:
818 i3h: [19:21)
819 i3l: [11:12)
820 `: {"encodeI3hI3l_1119_32Bit", `if v > 7 {
821 return 0, false
822 }
823 return (v&1)<<11 | (v>>1)<<19, true`, "enc_i3h_i3l"},
824 `For the "32-bit" variant: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
825 bit range mappings:
826 Zm: [16:19)
827 `: {"encodeZm1619_32Bit", `if !stripRawZ(&v) {
828 return 0, false
829 }
830 if v > 7 {
831 return 0, false
832 }
833 return v << 16, true`, "enc_Zm"},
834 `For the "64-bit" variant: is the element index, in the range 0 to 1, encoded in the "i1" field.
835 bit range mappings:
836 i1: [20:21)
837 `: {"encodeI1_2021_64Bit", `if v > 1 {
838 return 0, false
839 }
840 return v << 20, true`, "enc_i1"},
841 `For the "64-bit" variant: is the element index, in the range 0 to 3, encoded in the "i2h:i2l" fields.
842 bit range mappings:
843 i2h: [20:21)
844 i2l: [11:12)
845 `: {"encodeI2hI2l_1120_64Bit", `if v > 3 {
846 return 0, false
847 }
848 return (v&1)<<11 | (v>>1)<<20, true`, "enc_i2h_i2l"},
849 `For the "64-bit" variant: is the name of the second source scalable vector register Z0-Z15, encoded in the "Zm" field.
850 bit range mappings:
851 Zm: [16:20)
852 `: {"encodeZm1620_64Bit", `if !stripRawZ(&v) {
853 return 0, false
854 }
855 if v > 15 {
856 return 0, false
857 }
858 return v << 16, true`, "enc_Zm"},
859 `For the "8-bit to 16-bit" variant: is the immediate index of a pair of 8-bit elements within each 128-bit vector segment, in the range 0 to 7, encoded in the "i3h:i3l" fields.
860 bit range mappings:
861 i3h: [22:23)
862 i3l: [19:21)
863 `: {"encodeI3hI3l_1923_8To16Bit", `if v > 7 {
864 return 0, false
865 }
866 return (v&3)<<19 | (v>>2)<<22, true`, "enc_i3h_i3l"},
867 `For the "8-bit to 32-bit" variant: is the immediate index of a 32-bit group of four 8-bit values within each 128-bit vector segment, in the range 0 to 3, encoded in the "i2" field.
868 bit range mappings:
869 i2: [19:21)
870 `: {"encodeI2_1921_8To32Bit", `if v > 3 {
871 return 0, false
872 }
873 return v << 19, true`, "enc_i2"},
874 `For the "8-bit to 32-bit" variant: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
875 bit range mappings:
876 Zm: [16:19)
877 `: {"encodeZm1619_8To32Bit", `if !stripRawZ(&v) {
878 return 0, false
879 }
880 if v > 7 {
881 return 0, false
882 }
883 return v << 16, true`, "enc_Zm"},
884 `For the "Double-precision" variant: is the immediate index, in the range 0 to 1, encoded in the "i1" field.
885 bit range mappings:
886 i1: [20:21)
887 `: {"encodeI1_2021_DoublePrecision", `if v > 1 {
888 return 0, false
889 }
890 return v << 20, true`, "enc_i1"},
891 `For the "Double-precision" variant: is the name of the second source scalable vector register Z0-Z15, encoded in the "Zm" field.
892 bit range mappings:
893 Zm: [16:20)
894 `: {"encodeZm1620_DoublePrecision", `if !stripRawZ(&v) {
895 return 0, false
896 }
897 if v > 15 {
898 return 0, false
899 }
900 return v << 16, true`, "enc_Zm"},
901 `For the "Doubleword" variant: is the optional portion index, in the range 0 to 7, defaulting to 0, encoded in the "i3h:i3l" fields.
902 bit range mappings:
903 i3h: [22:23)
904 i3l: [17:19)
905 `: {"encodeI3hI3l_1722_Doubleword", `if v > 7 {
906 return 0, false
907 }
908 return (v&3)<<17 | (v>>2)<<22, true`, "enc_i3h_i3l"},
909 `For the "Half-precision" and "Single-precision" variants: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
910 bit range mappings:
911 Zm: [16:19)
912 `: {"encodeZm1619_HalfSinglePrecision", `if !stripRawZ(&v) {
913 return 0, false
914 }
915 if v > 7 {
916 return 0, false
917 }
918 return v << 16, true`, "enc_Zm"},
919 `For the "Half-precision" variant: is the immediate index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
920 bit range mappings:
921 i3h: [22:23)
922 i3l: [19:21)
923 `: {"encodeI3hI3l_1923_HalfPrecision", `if v > 7 {
924 return 0, false
925 }
926 return (v&3)<<19 | (v>>2)<<22, true`, "enc_i3h_i3l"},
927 `For the "Halfword" variant: is the optional portion index, in the range 0 to 1, defaulting to 0, encoded in the "i1" field.
928 bit range mappings:
929 i1: [17:18)
930 `: {"encodeI1_1718_Halfword", `if v > 1 {
931 return 0, false
932 }
933 return v << 17, true`, "enc_i1"},
934 `For the "Single-precision" variant: is the immediate index, in the range 0 to 3, encoded in the "i2" field.
935 bit range mappings:
936 i2: [19:21)
937 `: {"encodeI2_1921_SinglePrecision", `if v > 3 {
938 return 0, false
939 }
940 return v << 19, true`, "enc_i2"},
941 `For the "Word" variant: is the optional portion index, in the range 0 to 3, defaulting to 0, encoded in the "i2" field.
942 bit range mappings:
943 i2: [17:19)
944 `: {"encodeI2_1719_Word", `if v > 3 {
945 return 0, false
946 }
947 return v << 17, true`, "enc_i2"},
948 `Is the immediate index of a 32-bit group of four 8-bit values within each 128-bit vector segment, in the range 0 to 3, encoded in the "i2" field.
949 bit range mappings:
950 i2: [19:21)
951 `: {"encodeI2_1921_8BitGroup", `if v > 3 {
952 return 0, false
953 }
954 return v << 19, true`, "enc_i2"},
955 `Is the immediate index of a pair of 16-bit elements within each 128-bit vector segment, in the range 0 to 3, encoded in the "i2" field.
956 bit range mappings:
957 i2: [19:21)
958 `: {"encodeI2_1921_Pair16Bit", `if v > 3 {
959 return 0, false
960 }
961 return v << 19, true`, "enc_i2"},
962 `Is the immediate index of a pair of 8-bit elements within each 128-bit vector segment, in the range 0 to 7, encoded in the "i3h:i3l" fields.
963 bit range mappings:
964 i3h: [19:21)
965 i3l: [11:12)
966 `: {"encodeI3hI3l_1119_Pair8Bit", `if v > 7 {
967 return 0, false
968 }
969 return (v&1)<<11 | (v>>1)<<19, true`, "enc_i3h_i3l"},
970 `Is the immediate index, in the range 0 to 15, encoded in the "i4h:i4l" fields.
971 bit range mappings:
972 i4h: [19:21)
973 i4l: [10:12)
974 `: {"encodeI4hI4l_1019", `if v > 15 {
975 return 0, false
976 }
977 return (v&3)<<10 | (v>>2)<<19, true`, "enc_i4h_i4l"},
978 `Is the immediate index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
979 bit range mappings:
980 i3h: [19:21)
981 i3l: [11:12)
982 `: {"encodeI3hI3l_1119", `if v > 7 {
983 return 0, false
984 }
985 return (v&1)<<11 | (v>>1)<<19, true`, "enc_i3h_i3l"},
986 `Is the immediate index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
987 bit range mappings:
988 i3h: [22:23)
989 i3l: [19:21)
990 `: {"encodeI3hI3l_1922", `if v > 7 {
991 return 0, false
992 }
993 return (v&3)<<19 | (v>>2)<<22, true`, "enc_i3h_i3l"},
994 `Is the immediate index, in the range 0 to one less than the number of elements in 128 bits, encoded in "i1:tsz".
995 bit range mappings:
996 i1: [20:21)
997 tsz: [16:20)
998 `: {"encodeI1Tsz_Delegate", `// The statement "range 0 to one less than the number of elements in 128 bits"
999 // is not possible to handle here, we delegate this to the caller.
1000 return codeI1Tsz, false`, "enc_i1_tsz"},
1001 `Is the immediate index, in the range 0 to one less than the number of elements in 512 bits, encoded in "imm2:tsz".
1002 bit range mappings:
1003 imm2: [22:24)
1004 tsz: [16:21)
1005 `: {"encodeImm2Tsz_Delegate", `// The statement "range 0 to one less than the number of elements in 512 bits"
1006 // is not possible to handle here, we delegate this to the caller.
1007 return codeImm2Tsz, false`, "enc_imm2_tsz"},
1008 `Is the name of the first source scalable predicate register PN8-PN15, with predicate-as-counter encoding, encoded in the "PNn" field.
1009 bit range mappings:
1010 PNn: [5:8)
1011 `: {"encodePnN_58", `if v >= 24 && v <= 31 {
1012 // PN registers starts from 16.
1013 return (v - 24) << 5, true
1014 }
1015 return 0, false`, "enc_PNn"},
1016 `Is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
1017 bit range mappings:
1018 Zm: [16:19)
1019 `: {"encodeZm_1619_Range0_7V2", `if v <= 7 {
1020 return v << 16, true
1021 }
1022 return 0, false`, "enc_Zm"},
1023 `Is the portion index, in the range 0 to 3, encoded in the "imm2" field.
1024 bit range mappings:
1025 imm2: [8:10)
1026 `: {"encodeImm2_810", `if v > 3 {
1027 return 0, false
1028 }
1029 return v << 8, true`, "enc_imm2"},
1030 `Is the size specifier,
1031 tsz <T>
1032 0000 RESERVED
1033 xxx1 B
1034 xx10 H
1035 x100 S
1036 1000 D
1037 bit range mappings:
1038 tsz: [16:20)
1039 `: {"encodeTsz_1620_SizeSpecifier4", `switch v {
1040 case ARNG_B:
1041 return 1 << 16, true
1042 case ARNG_H:
1043 return 2 << 16, true
1044 case ARNG_S:
1045 return 4 << 16, true
1046 case ARNG_D:
1047 return 8 << 16, true
1048 }
1049 return 0, false`, "enc_tsz"},
1050
1051 `Is the size specifier,
1052 tsz <T>
1053 00000 RESERVED
1054 xxxx1 B
1055 xxx10 H
1056 xx100 S
1057 x1000 D
1058 10000 Q
1059 bit range mappings:
1060 tsz: [16:21)
1061 `: {"encodeTsz_1621_SizeSpecifier5", `switch v {
1062 case ARNG_B:
1063 return 1 << 16, true
1064 case ARNG_H:
1065 return 2 << 16, true
1066 case ARNG_S:
1067 return 4 << 16, true
1068 case ARNG_D:
1069 return 8 << 16, true
1070 case ARNG_Q:
1071 return 16 << 16, true
1072 }
1073 return 0, false`, "enc_tsz"},
1074 `Check this is a 64-bit scalar register`: {"encodeXCheck", `return 0, true`, "enc_NIL"},
1075 `Check this is immediate 0.0`: {"encodeFimm0_0_56", `if (v & 0x7FFFFFFF) != 0 {
1076 return 0, false
1077 }
1078 return 0, true`, "enc_NIL"},
1079 `For the "16-bit" variant: is the element index, in the range 0 to 3, encoded in the "i2" field.
1080 bit range mappings:
1081 i2: [19:21)
1082 `: {"encodeI2_1921_16bit", `if v > 3 {
1083 return 0, false
1084 }
1085 return v << 19, true`, "enc_i2"},
1086 `For the "16-bit" variant: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
1087 bit range mappings:
1088 Zm: [16:19)
1089 `: {"encodeZm_1619_Range0_7V1", `if !stripRawZ(&v) {
1090 return 0, false
1091 }
1092 if v <= 7 {
1093 return v << 16, true
1094 }
1095 return 0, false`, "enc_Zm"},
1096 `For the "32-bit" variant: is the element index, in the range 0 to 1, encoded in the "i1" field.
1097 bit range mappings:
1098 i1: [20:21)
1099 `: {"encodeI1_2021_32bit", `if v > 1 {
1100 return 0, false
1101 }
1102 return v << 20, true`, "enc_i1"},
1103 `For the "32-bit" variant: is the name of the second source scalable vector register Z0-Z15, encoded in the "Zm" field.
1104 bit range mappings:
1105 Zm: [16:20)
1106 `: {"encodeZm_1620_Range0_15", `if !stripRawZ(&v) {
1107 return 0, false
1108 }
1109 if v <= 15 {
1110 return v << 16, true
1111 }
1112 return 0, false`, "enc_Zm"},
1113 `For the "Equal", "Greater than or equal", "Greater than", "Less than or equal", "Less than", and "Not equal" variants: is the signed immediate operand, in the range -16 to 15, encoded in the "imm5" field.
1114 bit range mappings:
1115 imm5: [16:21)
1116 `: {"encodeImm5Signed_1621V2", `if int32(v) >= -16 && int32(v) <= 15 {
1117 return (v & 31) << 16, true
1118 }
1119 return 0, false`, "enc_imm5"},
1120 `For the "Half-precision" variant: is the index of a Real and Imaginary pair, in the range 0 to 3, encoded in the "i2" field.
1121 bit range mappings:
1122 i2: [19:21)
1123 `: {"encodeI2_1921_Half", `if v > 3 {
1124 return 0, false
1125 }
1126 return v << 19, true`, "enc_i2"},
1127 `For the "Half-precision" variant: is the name of the second source scalable vector register Z0-Z7, encoded in the "Zm" field.
1128 bit range mappings:
1129 Zm: [16:19)
1130 `: {"encodeZm_1619_Half", `if !stripRawZ(&v) {
1131 return 0, false
1132 }
1133 if v <= 7 {
1134 return v << 16, true
1135 }
1136 return 0, false`, "enc_Zm"},
1137 `For the "Higher or same", "Higher", "Lower or same", and "Lower" variants: is the unsigned immediate operand, in the range 0 to 127, encoded in the "imm7" field.
1138 bit range mappings:
1139 imm7: [14:21)
1140 `: {"encodeImm7Unsigned_1421", `if v <= 127 {
1141 return v << 14, true
1142 }
1143 return 0, false`, "enc_imm7"},
1144 `For the "Single-precision" variant: is the index of a Real and Imaginary pair, in the range 0 to 1, encoded in the "i1" field.
1145 bit range mappings:
1146 i1: [20:21)
1147 `: {"encodeI1_2021_Single", `if v > 1 {
1148 return 0, false
1149 }
1150 return v << 20, true`, "enc_i1"},
1151 `For the "Single-precision" variant: is the name of the second source scalable vector register Z0-Z15, encoded in the "Zm" field.
1152 bit range mappings:
1153 Zm: [16:20)
1154 `: {"encodeZm_1620_Single", `if !stripRawZ(&v) {
1155 return 0, false
1156 }
1157 if v <= 15 {
1158 return v << 16, true
1159 }
1160 return 0, false`, "enc_Zm"},
1161 `Is a 64, 32, 16 or 8-bit bitmask consisting of replicated 2, 4, 8, 16, 32 or 64 bit fields, each field containing a rotated run of non-zero bits, encoded in the "imm13" field.
1162 bit range mappings:
1163 imm13: [5:18)
1164 `: {"encodeImm13_518", `return codeLogicalImmArrEncoding, false`, "enc_imm13"},
1165 `Is a floating-point immediate value expressible as ±n÷16×2^r, where n and r are integers such that 16 ≤ n ≤ 31 and -3 ≤ r ≤ 4, i.e. a normalized binary floating-point encoding with 1 sign bit, 3-bit exponent, and 4-bit fractional part, encoded in the "imm8" field.
1166 bit range mappings:
1167 imm8: [5:13)
1168 `: {"encodeImm8_513_Fimm", `if v <= 255 {
1169 return v << 5, true
1170 }
1171 return 0, false`, "enc_imm8"},
1172 `Is a signed immediate in the range -128 to 127, encoded in the "imm8" field.
1173 bit range mappings:
1174 imm8: [5:13)
1175
1176 Is the optional left shift to apply to the immediate, defaulting to LSL #0 and
1177 sh <shift>
1178 0 LSL #0
1179 1 LSL #8
1180 bit range mappings:
1181 sh: [13:14)
1182 `: {"encodeImm8SignedLsl8", `vi := int32(v)
1183 if vi >= -128 && vi <= 127 {
1184 imm8 := uint32(uint8(int8(vi)))
1185 return (imm8 << 5), true
1186 }
1187 if vi&255 == 0 {
1188 unshifted := vi >> 8
1189 if unshifted >= -128 && unshifted <= 127 {
1190 imm8 := uint32(uint8(int8(unshifted)))
1191 return (imm8 << 5) | (1 << 13), true
1192 }
1193 }
1194 return 0, false`, "enc_imm8"},
1195 `Is an unsigned immediate in the range 0 to 255, encoded in the "imm8" field.
1196 bit range mappings:
1197 imm8: [5:13)
1198
1199 Is the optional left shift to apply to the immediate, defaulting to LSL #0 and
1200 sh <shift>
1201 0 LSL #0
1202 1 LSL #8
1203 bit range mappings:
1204 sh: [13:14)
1205 `: {"encodeImm8UnsignedLsl8", `if v <= 255 {
1206 return v << 5, true
1207 }
1208 if v&255 == 0 {
1209 unshifted := v >> 8
1210 if unshifted <= 255 {
1211 return (unshifted << 5) | (1 << 13), true
1212 }
1213 }
1214 return 0, false`, "enc_imm8"},
1215 `Is the 64-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field.
1216 bit range mappings:
1217 Rd: [0:5)
1218 `: {"encodeRd05_SPAllowed", `if !checkIsR(v) {
1219 return 0, false
1220 }
1221 if v == REG_R31 {
1222 return 0, false
1223 }
1224 if v == REG_RSP {
1225 return 31, true
1226 }
1227 return v & 31, true`, "enc_Rd"},
1228 `Is the 64-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field.
1229 bit range mappings:
1230 Rn: [16:21)
1231 `: {"encodeRn1621_SPAllowed", `if !checkIsR(v) {
1232 return 0, false
1233 }
1234 if v == REG_R31 {
1235 return 0, false
1236 }
1237 if v == REG_RSP {
1238 return 31 << 16, true
1239 }
1240 return (v & 31) << 16, true`, "enc_Rn"},
1241 `Is the const specifier,
1242 rot <const>
1243 0 #90
1244 1 #270
1245 bit range mappings:
1246 rot: [10:11)
1247 `: {"encodeRot90_270_1011", `switch v {
1248 case 90:
1249 return 0, true
1250 case 270:
1251 return 1 << 10, true
1252 }
1253 return 0, false`, "enc_rot"},
1254 `Is the const specifier,
1255 rot <const>
1256 0 #90
1257 1 #270
1258 bit range mappings:
1259 rot: [16:17)
1260 `: {"encodeRot90_270_1617", `switch v {
1261 case 90:
1262 return 0, true
1263 case 270:
1264 return 1 << 16, true
1265 }
1266 return 0, false`, "enc_rot"},
1267 `Is the const specifier,
1268 rot <const>
1269 00 #0
1270 01 #90
1271 10 #180
1272 11 #270
1273 bit range mappings:
1274 rot: [10:12)
1275 `: {"encodeRot0_90_180_270_1012", `switch v {
1276 case 0:
1277 return 0, true
1278 case 90:
1279 return 1 << 10, true
1280 case 180:
1281 return 2 << 10, true
1282 case 270:
1283 return 3 << 10, true
1284 }
1285 return 0, false`, "enc_rot"},
1286 `Is the const specifier,
1287 rot <const>
1288 00 #0
1289 01 #90
1290 10 #180
1291 11 #270
1292 bit range mappings:
1293 rot: [13:15)
1294 `: {"encodeRot0_90_180_270_1315", `switch v {
1295 case 0:
1296 return 0, true
1297 case 90:
1298 return 1 << 13, true
1299 case 180:
1300 return 2 << 13, true
1301 case 270:
1302 return 3 << 13, true
1303 }
1304 return 0, false`, "enc_rot"},
1305 `Is the first signed immediate operand, in the range -16 to 15, encoded in the "imm5" field.
1306 bit range mappings:
1307 imm5: [5:10)
1308 `: {"encodeImm5Signed_510", `if int32(v) >= -16 && int32(v) <= 15 {
1309 return (v & 31) << 5, true
1310 }
1311 return 0, false`, "enc_imm5"},
1312 `Is the floating-point immediate value,
1313 i1 <const>
1314 0 #0.0
1315 1 #1.0
1316 bit range mappings:
1317 i1: [5:6)
1318 `: {"encodeFimm0_0_1_0_56", `switch v {
1319 case 0:
1320 return 0, true
1321 case 0x3F800000: // 1.0
1322 return 1 << 5, true
1323 }
1324 return 0, false`, "enc_i1"},
1325 `Is the floating-point immediate value,
1326 i1 <const>
1327 0 #0.5
1328 1 #1.0
1329 bit range mappings:
1330 i1: [5:6)
1331 `: {"encodeFimm0_5_1_0_56", `switch v {
1332 case 0x3F000000: // 0.5
1333 return 0, true
1334 case 0x3F800000: // 1.0
1335 return 1 << 5, true
1336 }
1337 return 0, false`, "enc_i1"},
1338 `Is the floating-point immediate value,
1339 i1 <const>
1340 0 #0.5
1341 1 #2.0
1342 bit range mappings:
1343 i1: [5:6)
1344 `: {"encodeFimm0_5_2_0_56", `switch v {
1345 case 0x3F000000: // 0.5
1346 return 0, true
1347 case 0x40000000: // 2.0
1348 return 1 << 5, true
1349 }
1350 return 0, false`, "enc_i1"},
1351 `Is the immediate shift amount, in the range 0 to number of bits per element minus 1, encoded in "tszh:tszl:imm3".
1352 bit range mappings:
1353 imm3: [16:19)
1354 tszh: [22:23)
1355 tszl: [19:21)
1356 `: {"encodeShiftTsz1619Range0V1", `return codeShift161919212223, false`, "enc_tszh_tszl_imm3"},
1357 `Is the immediate shift amount, in the range 0 to number of bits per element minus 1, encoded in "tszh:tszl:imm3".
1358 bit range mappings:
1359 imm3: [16:19)
1360 tszh: [22:24)
1361 tszl: [19:21)
1362 `: {"encodeShiftTsz1619Range0V2", `return codeShift161919212224, false`, "enc_tszh_tszl_imm3"},
1363 `Is the immediate shift amount, in the range 0 to number of bits per element minus 1, encoded in "tszh:tszl:imm3".
1364 bit range mappings:
1365 imm3: [5:8)
1366 tszh: [22:24)
1367 tszl: [8:10)
1368 `: {"encodeShiftTsz58Range0", `return codeShift588102224, false`, "enc_tszh_tszl_imm3"},
1369 `Is the immediate shift amount, in the range 1 to number of bits per element, encoded in "tszh:tszl:imm3".
1370 bit range mappings:
1371 imm3: [16:19)
1372 tszh: [22:23)
1373 tszl: [19:21)
1374 `: {"encodeShiftTsz1619Range1V1", `return codeShift161919212223, false`, "enc_tszh_tszl_imm3"},
1375 `Is the immediate shift amount, in the range 1 to number of bits per element, encoded in "tszh:tszl:imm3".
1376 bit range mappings:
1377 imm3: [16:19)
1378 tszh: [22:24)
1379 tszl: [19:21)
1380 `: {"encodeShiftTsz1619Range1V2", `return codeShift161919212224, false`, "enc_tszh_tszl_imm3"},
1381 `Is the immediate shift amount, in the range 1 to number of bits per element, encoded in "tszh:tszl:imm3".
1382 bit range mappings:
1383 imm3: [5:8)
1384 tszh: [22:24)
1385 tszl: [8:10)
1386 `: {"encodeShiftTsz58Range1", `return codeShift588102224, false`, "enc_tszh_tszl_imm3"},
1387 `Is the name of the governing scalable predicate register, encoded in the "Pg" field.
1388 bit range mappings:
1389 Pg: [16:20)
1390 `: {"encodePg1620", `return v << 16, true`, "enc_Pg"},
1391 `Is the second signed immediate operand, in the range -16 to 15, encoded in the "imm5b" field.
1392 bit range mappings:
1393 imm5b: [16:21)
1394 `: {"encodeImm5bSigned_1621", `if int32(v) >= -16 && int32(v) <= 15 {
1395 return (v & 31) << 16, true
1396 }
1397 return 0, false`, "enc_imm5b"},
1398 `Is the signed immediate operand, in the range -128 to 127, encoded in the "imm8" field.
1399 bit range mappings:
1400 imm8: [5:13)
1401 `: {"encodeImm8Signed_513", `if int32(v) >= -128 && int32(v) <= 127 {
1402 return (v & 255) << 5, true
1403 }
1404 return 0, false`, "enc_imm8"},
1405 `Is the signed immediate operand, in the range -16 to 15, encoded in the "imm5" field.
1406 bit range mappings:
1407 imm5: [16:21)
1408 `: {"encodeImm5Signed_1621V1", `if int32(v) >= -16 && int32(v) <= 15 {
1409 return (v & 31) << 16, true
1410 }
1411 return 0, false`, "enc_imm5"},
1412 `Is the signed immediate operand, in the range -16 to 15, encoded in the "imm5" field.
1413 bit range mappings:
1414 imm5: [5:10)
1415 `: {"encodeImm5Signed510Unique", `if int32(v) >= -16 && int32(v) <= 15 {
1416 return (v & 31) << 5, true
1417 }
1418 return 0, false`, "enc_imm5"},
1419 `Is the signed immediate operand, in the range -32 to 31, encoded in the "imm6" field.
1420 bit range mappings:
1421 imm6: [5:11)
1422 `: {"encodeImm6Signed_511", `if int32(v) >= -32 && int32(v) <= 31 {
1423 return (v & 63) << 5, true
1424 }
1425 return 0, false`, "enc_imm6"},
1426 `Is the size specifier,
1427 imm13 <T>
1428 0xxxxxx0xxxxx S
1429 0xxxxxx10xxxx H
1430 0xxxxxx110xxx B
1431 0xxxxxx1110xx B
1432 0xxxxxx11110x B
1433 0xxxxxx11111x RESERVED
1434 1xxxxxxxxxxxx D
1435 bit range mappings:
1436 imm13: [5:18)
1437 `: {"encodeSizeImm13NoOp", `return codeNoOp, false`, "enc_imm13"},
1438 `Is the size specifier,
1439 tszh tszl <T>
1440 0 00 RESERVED
1441 0 01 B
1442 0 1x H
1443 1 xx S
1444 bit range mappings:
1445 tszh: [22:23)
1446 tszl: [19:21)
1447 `: {"encodeSizeBhsTsz1921", `switch v {
1448 case ARNG_B:
1449 return 1 << 19, true
1450 case ARNG_H:
1451 return 2 << 19, true
1452 case ARNG_S:
1453 return 1 << 22, true
1454 }
1455 return 0, false`, "enc_tszh_tszl"},
1456 `Is the size specifier,
1457 tszh tszl <T>
1458 0 00 RESERVED
1459 0 01 H
1460 0 1x S
1461 1 xx D
1462 bit range mappings:
1463 tszh: [22:23)
1464 tszl: [19:21)
1465 `: {"encodeSizeHsdTsz1921", `switch v {
1466 case ARNG_H:
1467 return 1 << 19, true
1468 case ARNG_S:
1469 return 2 << 19, true
1470 case ARNG_D:
1471 return 1 << 22, true
1472 }
1473 return 0, false`, "enc_tszh_tszl"},
1474 `Is the size specifier,
1475 tszh tszl <T>
1476 00 00 RESERVED
1477 00 01 B
1478 00 01 H
1479 01 xx S
1480 1x xx D
1481 bit range mappings:
1482 tszh: [22:24)
1483 tszl: [19:21)
1484 `: {"encodeSizeBhsdTsz1921", `switch v {
1485 case ARNG_B:
1486 return 1 << 19, true
1487 case ARNG_H:
1488 return 2 << 19, true
1489 case ARNG_S:
1490 return 1 << 22, true
1491 case ARNG_D:
1492 return 1 << 23, true
1493 }
1494 return 0, false`, "enc_tszh_tszl"},
1495 `Is the size specifier,
1496 tszh tszl <T>
1497 00 00 RESERVED
1498 00 01 B
1499 00 1x H
1500 01 xx S
1501 1x xx D
1502 bit range mappings:
1503 tszh: [22:24)
1504 tszl: [8:10)
1505 `: {"encodeSizeBhsdTsz810", `switch v {
1506 case ARNG_B:
1507 return 1 << 8, true
1508 case ARNG_H:
1509 return 2 << 8, true
1510 case ARNG_S:
1511 return 1 << 22, true
1512 case ARNG_D:
1513 return 1 << 23, true
1514 }
1515 return 0, false`, "enc_tszh_tszl"},
1516 `Is the size specifier,
1517 tszh tszl <Tb>
1518 0 00 RESERVED
1519 0 01 B
1520 0 1x H
1521 1 xx S
1522 bit range mappings:
1523 tszh: [22:23)
1524 tszl: [19:21)
1525 `: {"encodeSizeBhsTsz1921Unique", `switch v {
1526 case ARNG_B:
1527 return 1 << 19, true
1528 case ARNG_H:
1529 return 2 << 19, true
1530 case ARNG_S:
1531 return 1 << 22, true
1532 }
1533 return 0, false`, "enc_tszh_tszl"},
1534 `Is the size specifier,
1535 tszh tszl <Tb>
1536 0 00 RESERVED
1537 0 01 H
1538 0 1x S
1539 1 xx D
1540 bit range mappings:
1541 tszh: [22:23)
1542 tszl: [19:21)
1543 `: {"encodeSizeHsdTsz1921Unique", `switch v {
1544 case ARNG_H:
1545 return 1 << 19, true
1546 case ARNG_S:
1547 return 2 << 19, true
1548 case ARNG_D:
1549 return 1 << 22, true
1550 }
1551 return 0, false`, "enc_tszh_tszl"},
1552 `Is the unsigned immediate operand, in the range 0 to 15, encoded in the "imm4" field.
1553 bit range mappings:
1554 imm4: [16:20)
1555 `: {"encodeImm4Unsigned_1620", `if v <= 15 {
1556 return v << 16, true
1557 }
1558 return 0, false`, "enc_imm4"},
1559 `Is the unsigned immediate operand, in the range 0 to 255, encoded in the "imm8" field.
1560 bit range mappings:
1561 imm8: [5:13)
1562 `: {"encodeImm8Unsigned_513", `if v <= 255 {
1563 return v << 5, true
1564 }
1565 return 0, false`, "enc_imm8"},
1566 `Is the unsigned immediate operand, in the range 0 to 255, encoded in the "imm8h:imm8l" fields.
1567 bit range mappings:
1568 imm8h: [16:21)
1569 imm8l: [10:13)
1570 `: {"encodeImm8hImm8l_Unsigned", `if v <= 255 {
1571 l := v & 7
1572 h := v >> 3
1573 return (l << 10) | (h << 16), true
1574 }
1575 return 0, false`, "enc_imm8h_imm8l"},
1576 `Is the unsigned immediate operand, in the range 0 to 7, encoded in the "imm3" field.
1577 bit range mappings:
1578 imm3: [16:19)
1579 `: {"encodeImm3Unsigned_1619", `if v <= 7 {
1580 return v << 16, true
1581 }
1582 return 0, false`, "enc_imm3"},
1583 `Is the size specifier,
1584 tszh tszl <T>
1585 00 00 RESERVED
1586 00 01 B
1587 00 1x H
1588 01 xx S
1589 1x xx D
1590 bit range mappings:
1591 tszh: [22:24)
1592 tszl: [19:21)
1593 `: {"encodeSizeBhsdTsz1921", `switch v {
1594 case ARNG_B:
1595 return 1 << 19, true
1596 case ARNG_H:
1597 return 2 << 19, true
1598 case ARNG_S:
1599 return 1 << 22, true
1600 case ARNG_D:
1601 return 1 << 23, true
1602 }
1603 return 0, false`, "enc_tszh_tszl"},
1604 `For the "Byte" variant: is the vector segment index, in the range 0 to 3, encoded in the "i2" field.
1605 bit range mappings:
1606 i2: [22:24)
1607 `: {"encodeI22224", `if v > 3 {
1608 return 0, false
1609 }
1610 return v << 22, true`, "enc_i2"},
1611 `For the "Byte, single register table" variant: is the vector segment index, in the range 0 to 1, encoded in the "i1" field.
1612 bit range mappings:
1613 i1: [23:24)
1614 `: {"encodeI12324B", `if v > 1 {
1615 return 0, false
1616 }
1617 return v << 23, true`, "enc_i1"},
1618 `For the "Halfword" variant: is the vector segment index, in the range 0 to 7, encoded in the "i3h:i3l" fields.
1619 bit range mappings:
1620 i3h: [22:24)
1621 i3l: [12:13)
1622 `: {"encodeI3224I31213", `if v > 7 {
1623 return 0, false
1624 }
1625 return (v&1)<<12 | (v>>1)<<22, true`, "enc_i3h_i3l"},
1626 `For the "Halfword, single register table" and "Halfword, two register table" variants: is the vector segment index, in the range 0 to 3, encoded in the "i2" field.
1627 bit range mappings:
1628 i2: [22:24)
1629 `: {"encodeI22224HW", `if v > 3 {
1630 return 0, false
1631 }
1632 return v << 22, true`, "enc_i2"},
1633 `Is the name of the first destination scalable predicate register, encoded as "Pd" times 2.
1634 bit range mappings:
1635 Pd: [1:4)
1636 `: {"encodePd14", `if v > 14 {
1637 return 0, false
1638 }
1639 if v&1 != 0 {
1640 return 0, false
1641 }
1642 return v, true`, "enc_Pd"},
1643 `Is the name of the first destination scalable predicate register, encoded in the "Pd" field.
1644 bit range mappings:
1645 Pd: [0:4)
1646 `: {"encodePd04", `return v, true`, "enc_Pd"},
1647 `Is the name of the first scalable vector register of the source multi-vector group, encoded in the "Zn" field.
1648 bit range mappings:
1649 Zn: [5:10)
1650 `: {"encodeZn510MultiSrc1", `if !stripRawZ(&v) {
1651 return 0, false
1652 }
1653 return v << 5, true`, "enc_Zn"},
1654 `Is the name of the first table vector register, encoded as "Zn".
1655 bit range mappings:
1656 Zn: [5:10)
1657 `: {"encodeZn510Table1", `return v << 5, true`, "enc_Zn"},
1658 `Is the name of the second destination scalable predicate register, encoded as "Pd" times 2 plus 1.
1659 bit range mappings:
1660 Pd: [1:4)
1661 `: {"encodePd14Plus1", `if v&1 == 0 {
1662 return 0, false
1663 }
1664 return v - 1, true`, "enc_Pd"},
1665 `Is the name of the second destination scalable predicate register, encoded in the "Pd" field.
1666 bit range mappings:
1667 Pd: [0:4)
1668 `: {"encodePd04Plus1", `// This "second destination" incurs Pd + 1 == v
1669 return v - 1, true`, "enc_Pd"},
1670 `Is the name of the second scalable vector register of the source multi-vector group, encoded in the "Zn" field.
1671 bit range mappings:
1672 Zn: [5:10)
1673 `: {"encodeZn510MultiSrc2", `if !stripRawZ(&v) {
1674 return 0, false
1675 }
1676 return (v - 1) << 5, true`, "enc_Zn"},
1677 `Is the name of the second table vector register, encoded as "Zn" plus 1 modulo 32.
1678 bit range mappings:
1679 Zn: [5:10)
1680 `: {"encodeZn510Table2", `return ((v - 1) & 0x1f) << 5, true`, "enc_Zn"},
1681 `Is the name of the source scalable vector register, encoded in the "Zm" field.
1682 bit range mappings:
1683 Zm: [16:21)
1684 `: {"encodeZm1621V1", `if !stripRawZ(&v) {
1685 return 0, false
1686 }
1687 return v << 16, true`, "enc_Zm"},
1688 `Is the name of the table vector register, encoded in the "Zn" field.
1689 bit range mappings:
1690 Zn: [5:10)
1691 `: {"encodeZn510Table3", `return v << 5, true`, "enc_Zn"},
1692 `Is the portion index, in the range 0 to 1, encoded in the "i1" field.
1693 bit range mappings:
1694 i1: [8:9)
1695 `: {"encodeI189", `if v > 1 {
1696 return 0, false
1697 }
1698 return v << 8, true`, "enc_i1"},
1699 `Is the vector segment index, in the range 0 to 1, encoded in the "i1" field.
1700 bit range mappings:
1701 i1: [23:24)
1702 `: {"encodeI12324", `if v > 1 {
1703 return 0, false
1704 }
1705 return v << 23, true`, "enc_i1"},
1706 `Check this is mod amount and is 1
1707 `: {"encodeModAmt1Check", `if v == 1 {
1708 return 0, true
1709 }
1710 return 0, false`, "enc_NIL"},
1711 `Check this is mod amount and is 2
1712 `: {"encodeModAmt2Check", `if v == 2 {
1713 return 0, true
1714 }
1715 return 0, false`, "enc_NIL"},
1716 `Check this is mod amount and is 3
1717 `: {"encodeModAmt3Check", `if v == 3 {
1718 return 0, true
1719 }
1720 return 0, false`, "enc_NIL"},
1721 `Check this is mod amount and is 4
1722 `: {"encodeModAmt4Check", `if v == 4 {
1723 return 0, true
1724 }
1725 return 0, false`, "enc_NIL"},
1726 `Check this is mod and is LSL
1727 `: {"encodeModLSLCheck", `if v&0b100 != 0 {
1728 return 0, true
1729 }
1730 return 0, false`, "enc_NIL"},
1731 `Check this is mod and is SXTW
1732 `: {"encodeModSXTWCheck", `if v&0b10 != 0 {
1733 return 0, true
1734 }
1735 return 0, false`, "enc_NIL"},
1736 `Check this is mod and is UXTW
1737 `: {"encodeModUXTWCheck", `if v&0b1 != 0 {
1738 return 0, true
1739 }
1740 return 0, false`, "enc_NIL"},
1741 `Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the "Rn" field.
1742 bit range mappings:
1743 Rn: [5:10)
1744 `: {"encodeRn510SPV2", `if !checkIsR(v) {
1745 return 0, false
1746 }
1747 if v == REG_R31 {
1748 return 0, false
1749 }
1750 if v == REG_RSP {
1751 return 31 << 5, true
1752 }
1753 return (v & 31) << 5, true`, "enc_Rn"},
1754 `Is the 64-bit name of the general-purpose offset register, encoded in the "Rm" field.
1755 bit range mappings:
1756 Rm: [16:21)
1757 `: {"encodeRm1621V2", `if !checkIsR(v) {
1758 return 0, false
1759 }
1760 if v == REG_RSP {
1761 return 0, false
1762 }
1763 return (v & 31) << 16, true`, "enc_Rm"},
1764 `Is the index extend and shift specifier,
1765 msz <mod>
1766 00 [absent]
1767 x1 LSL
1768 10 LSL
1769 bit range mappings:
1770 msz: [10:12)
1771 `: {"encodeMsz1012", `// This does not accept UXTW and SXTW, check that
1772 if v&0b11 != 0 {
1773 return 0, false
1774 }
1775 // Note: this encoding function's semantic is entailed by its peer that
1776 // encode <amount>, so just do nothing.
1777 return codeNoOp, false`, "enc_msz"},
1778 `Is the index extend and shift specifier,
1779 xs <mod>
1780 0 UXTW
1781 1 SXTW
1782 bit range mappings:
1783 xs: [14:15)
1784 `: {"encodeXs1415", `if v&0b1 != 0 {
1785 return 0, true
1786 } else if v&0b10 != 0 {
1787 return 1 << 14, true
1788 }
1789 return 0, false`, "enc_xs"},
1790 `Is the index extend and shift specifier,
1791 xs <mod>
1792 0 UXTW
1793 1 SXTW
1794 bit range mappings:
1795 xs: [22:23)
1796 `: {"encodeXs2223", `if v&0b1 != 0 {
1797 return 0, true
1798 } else if v&0b10 != 0 {
1799 return 1 << 22, true
1800 }
1801 return 0, false`, "enc_xs"},
1802 `Is the index shift amount,
1803 msz <amount>
1804 00 [absent]
1805 01 #1
1806 10 #2
1807 11 #3
1808 bit range mappings:
1809 msz: [10:12)
1810 `: {"encodeMsz1012Amount", `if v <= 3 {
1811 return v << 10, true
1812 }
1813 return 0, false`, "enc_msz"},
1814 `Is the name of the base scalable vector register, encoded in the "Zn" field.
1815 bit range mappings:
1816 Zn: [5:10)
1817 `: {"encodeZn510V2", `if !stripRawZ(&v) {
1818 return 0, false
1819 }
1820 return v << 5, true`, "enc_Zn"},
1821 `Is the name of the first scalable vector register to be transferred, encoded in the "Zt" field.
1822 bit range mappings:
1823 Zt: [0:5)
1824 `: {"encodeZt051", `if !stripRawZ(&v) {
1825 return 0, false
1826 }
1827 return v, true`, "enc_Zt"},
1828 `Is the name of the fourth scalable vector register to be transferred, encoded as "Zt" plus 3 modulo 32.
1829 bit range mappings:
1830 Zt: [0:5)
1831 `: {"encodeZt054", `if !stripRawZ(&v) {
1832 return 0, false
1833 }
1834 return (v - 3) % 32, true`, "enc_Zt"},
1835 `Is the name of the offset scalable vector register, encoded in the "Zm" field.
1836 bit range mappings:
1837 Zm: [16:21)
1838 `: {"encodeZm1621V3", `if !stripRawZ(&v) {
1839 return 0, false
1840 }
1841 return v << 16, true`, "enc_Zm"},
1842 `Is the name of the scalable vector register to be transferred, encoded in the "Zt" field.
1843 bit range mappings:
1844 Zt: [0:5)
1845 `: {"encodeZt05", `if !stripRawZ(&v) {
1846 return 0, false
1847 }
1848 return v, true`, "enc_Zt"},
1849 `Is the name of the second scalable vector register to be transferred, encoded as "Zt" plus 1 modulo 32.
1850 bit range mappings:
1851 Zt: [0:5)
1852 `: {"encodeZt052", `if !stripRawZ(&v) {
1853 return 0, false
1854 }
1855 return (v - 1) % 32, true`, "enc_Zt"},
1856 `Is the name of the third scalable vector register to be transferred, encoded as "Zt" plus 2 modulo 32.
1857 bit range mappings:
1858 Zt: [0:5)
1859 `: {"encodeZt053", `if !stripRawZ(&v) {
1860 return 0, false
1861 }
1862 return (v - 2) % 32, true`, "enc_Zt"},
1863 `Is the optional 64-bit name of the general-purpose offset register, defaulting to XZR, encoded in the "Rm" field.
1864 bit range mappings:
1865 Rm: [16:21)
1866 `: {"encodeRm1621XZR", `if v == 0 {
1867 // absent case, according to the spec this should be ZR (R31)
1868 return 31, true
1869 }
1870 if !checkIsR(v) {
1871 return 0, false
1872 }
1873 return (v & 31) << 16, true`, "enc_Rm"},
1874 `Is the size specifier,
1875 size <T>
1876 00 B
1877 01 H
1878 10 S
1879 11 D
1880 bit range mappings:
1881 size: [21:23)
1882 `: {"encodeSize2123V1", `switch v {
1883 case ARNG_B:
1884 return 0, true
1885 case ARNG_H:
1886 return 1 << 21, true
1887 case ARNG_S:
1888 return 2 << 21, true
1889 case ARNG_D:
1890 return 3 << 21, true
1891 default:
1892 return 0, false
1893 }`, "enc_size"},
1894 `Is the size specifier,
1895 size <T>
1896 00 RESERVED
1897 01 H
1898 10 S
1899 11 D
1900 bit range mappings:
1901 size: [21:23)
1902 `: {"encodeSize2123V2", `switch v {
1903 case ARNG_H:
1904 return 1 << 21, true
1905 case ARNG_S:
1906 return 2 << 21, true
1907 case ARNG_D:
1908 return 3 << 21, true
1909 }
1910 return 0, false`, "enc_size"},
1911 "Check that there is no modifier (UXTW, SXTW, LSL)": {"encodeNoModCheck", "return 0, v == 0", "enc_NIL"},
1912 "Check that there is no modifier amount": {"encodeNoAmtCheck", "return 0, v == 0", "enc_NIL"},
1913 `Is the name of the source scalable predicate register, with predicate-as-counter encoding, encoded in the "PNn" field.
1914 bit range mappings:
1915 PNn: [5:9)
1916 `: {"encodePNn59", `if v > 15 {
1917 return (v - 16) << 5, true
1918 }
1919 return 0, false`, "enc_PNn"},
1920 `Is the prefetch operation specifier,
1921 prfop <prfop>
1922 0000 PLDL1KEEP
1923 0001 PLDL1STRM
1924 0010 PLDL2KEEP
1925 0011 PLDL2STRM
1926 0100 PLDL3KEEP
1927 0101 PLDL3STRM
1928 x11x #uimm4
1929 1000 PSTL1KEEP
1930 1001 PSTL1STRM
1931 1010 PSTL2KEEP
1932 1011 PSTL2STRM
1933 1100 PSTL3KEEP
1934 1101 PSTL3STRM
1935 bit range mappings:
1936 prfop: [0:4)
1937 `: {"encodePrfop04", `switch SpecialOperand(v) {
1938 case SPOP_PLDL1KEEP:
1939 return 0, true
1940 case SPOP_PLDL1STRM:
1941 return 1, true
1942 case SPOP_PLDL2KEEP:
1943 return 2, true
1944 case SPOP_PLDL2STRM:
1945 return 3, true
1946 case SPOP_PLDL3KEEP:
1947 return 4, true
1948 case SPOP_PLDL3STRM:
1949 return 5, true
1950 case SPOP_PSTL1KEEP:
1951 return 8, true
1952 case SPOP_PSTL1STRM:
1953 return 9, true
1954 case SPOP_PSTL2KEEP:
1955 return 10, true
1956 case SPOP_PSTL2STRM:
1957 return 11, true
1958 case SPOP_PSTL3KEEP:
1959 return 12, true
1960 case SPOP_PSTL3STRM:
1961 return 13, true
1962 default:
1963 return 0, false
1964 }`, "enc_prfop"},
1965 `Is the vl specifier,
1966 vl <vl>
1967 0 VLx2
1968 1 VLx4
1969 bit range mappings:
1970 vl: [10:11)
1971 `: {"encodeVl1011", `switch SpecialOperand(v) {
1972 case SPOP_VLx2:
1973 return 0, true
1974 case SPOP_VLx4:
1975 return 1 << 10, true
1976 default:
1977 return 0, false
1978 }`, "enc_vl"},
1979 `Is the vl specifier,
1980 vl <vl>
1981 0 VLx2
1982 1 VLx4
1983 bit range mappings:
1984 vl: [13:14)
1985 `: {"encodeVl1314", `switch SpecialOperand(v) {
1986 case SPOP_VLx2:
1987 return 0, true
1988 case SPOP_VLx4:
1989 return 1 << 13, true
1990 default:
1991 return 0, false
1992 }`, "enc_vl"},
1993 `Is the optional signed immediate byte offset, a multiple of 16 in the range -128 to 112, defaulting to 0, encoded in the "imm4" field.
1994 bit range mappings:
1995 imm4: [16:20)
1996 `: {"encodeImm41620V1", `vi := int32(v)
1997 if vi >= -128 && vi <= 112 && vi%16 == 0 {
1998 return uint32((vi/16)&15) << 16, true
1999 }
2000 return 0, false`, "enc_imm4"},
2001 `Is the optional signed immediate byte offset, a multiple of 32 in the range -256 to 224, defaulting to 0, encoded in the "imm4" field.
2002 bit range mappings:
2003 imm4: [16:20)
2004 `: {"encodeImm41620V2", `vi := int32(v)
2005 if vi >= -256 && vi <= 224 && vi%32 == 0 {
2006 return uint32((vi/32)&15) << 16, true
2007 }
2008 return 0, false`, "enc_imm4"},
2009 `Is the optional unsigned immediate byte offset, a multiple of 2 in the range 0 to 126, defaulting to 0, encoded in the "imm6" field.
2010 bit range mappings:
2011 imm6: [16:22)
2012 `: {"encodeImm61622V1", `if v <= 126 && v%2 == 0 {
2013 return (v / 2) << 16, true
2014 }
2015 return 0, false`, "enc_imm6"},
2016 `Is the optional unsigned immediate byte offset, a multiple of 2 in the range 0 to 62, defaulting to 0, encoded in the "imm5" field.
2017 bit range mappings:
2018 imm5: [16:21)
2019 `: {"encodeImm51621V1", `if v <= 62 && v%2 == 0 {
2020 return (v / 2) << 16, true
2021 }
2022 return 0, false`, "enc_imm5"},
2023 `Is the optional unsigned immediate byte offset, a multiple of 4 in the range 0 to 124, defaulting to 0, encoded in the "imm5" field.
2024 bit range mappings:
2025 imm5: [16:21)
2026 `: {"encodeImm51621V2", `if v <= 124 && v%4 == 0 {
2027 return (v / 4) << 16, true
2028 }
2029 return 0, false`, "enc_imm5"},
2030 `Is the optional unsigned immediate byte offset, a multiple of 4 in the range 0 to 252, defaulting to 0, encoded in the "imm6" field.
2031 bit range mappings:
2032 imm6: [16:22)
2033 `: {"encodeImm61622V2", `if v <= 252 && v%4 == 0 {
2034 return (v / 4) << 16, true
2035 }
2036 return 0, false`, "enc_imm6"},
2037 `Is the optional unsigned immediate byte offset, a multiple of 8 in the range 0 to 248, defaulting to 0, encoded in the "imm5" field.
2038 bit range mappings:
2039 imm5: [16:21)
2040 `: {"encodeImm51621V3", `if v <= 248 && v%8 == 0 {
2041 return (v / 8) << 16, true
2042 }
2043 return 0, false`, "enc_imm5"},
2044 `Is the optional unsigned immediate byte offset, a multiple of 8 in the range 0 to 504, defaulting to 0, encoded in the "imm6" field.
2045 bit range mappings:
2046 imm6: [16:22)
2047 `: {"encodeImm61622V3", `if v <= 504 && v%8 == 0 {
2048 return (v / 8) << 16, true
2049 }
2050 return 0, false`, "enc_imm6"},
2051 `Is the optional unsigned immediate byte offset, in the range 0 to 31, defaulting to 0, encoded in the "imm5" field.
2052 bit range mappings:
2053 imm5: [16:21)
2054 `: {"encodeImm51621V4", `if v <= 31 {
2055 return v << 16, true
2056 }
2057 return 0, false`, "enc_imm5"},
2058 `Is the optional unsigned immediate byte offset, in the range 0 to 63, defaulting to 0, encoded in the "imm6" field.
2059 bit range mappings:
2060 imm6: [16:22)
2061 `: {"encodeImm61622V4", `if v <= 63 {
2062 return v << 16, true
2063 }
2064 return 0, false`, "enc_imm6"},
2065 `Is the name of the destination scalable predicate register, encoded in the "Pt" field.
2066 bit range mappings:
2067 Pt: [0:4)
2068 `: {"encodePt04V1", `if v > 15 {
2069 return 0, false
2070 }
2071 return v, true`, "enc_Pt"},
2072 `Is the name of the scalable predicate transfer register, encoded in the "Pt" field.
2073 bit range mappings:
2074 Pt: [0:4)
2075 `: {"encodePt04V2", `if v > 15 {
2076 return 0, false
2077 }
2078 return v, true`, "enc_Pt"},
2079 `Is the optional signed immediate vector offset, a multiple of 3 in the range -24 to 21, defaulting to 0, encoded in the "imm4" field.
2080 bit range mappings:
2081 imm4: [16:20)
2082 `: {"encodeImm41620V3", `vi := int32(v)
2083 if vi >= -24 && vi <= 21 && vi%3 == 0 {
2084 return uint32((vi/3)&15) << 16, true
2085 }
2086 return 0, false`, "enc_imm4"},
2087 `Is the optional signed immediate vector offset, a multiple of 4 in the range -32 to 28, defaulting to 0, encoded in the "imm4" field.
2088 bit range mappings:
2089 imm4: [16:20)
2090 `: {"encodeImm41620V4", `vi := int32(v)
2091 if vi >= -32 && vi <= 28 && vi%4 == 0 {
2092 return uint32((vi/4)&15) << 16, true
2093 }
2094 return 0, false`, "enc_imm4"},
2095 `Is the optional signed immediate vector offset, in the range -256 to 255, defaulting to 0, encoded in the "imm9h:imm9l" fields.
2096 bit range mappings:
2097 imm9h: [16:22)
2098 imm9l: [10:13)
2099 `: {"encodeImm9h1622L1013", `vi := int32(v)
2100 if vi >= -256 && vi <= 255 {
2101 val := uint32(vi) & 0x1FF
2102 return ((val & 7) << 10) | ((val >> 3) << 16), true
2103 }
2104 return 0, false`, "enc_imm9h_imm9l"},
2105 `Is the optional signed immediate vector offset, in the range -32 to 31, defaulting to 0, encoded in the "imm6" field.
2106 bit range mappings:
2107 imm6: [16:22)
2108 `: {"encodeImm61622V5", `vi := int32(v)
2109 if vi >= -32 && vi <= 31 {
2110 return (uint32(vi) & 0x3F) << 16, true
2111 }
2112 return 0, false`, "enc_imm6"},
2113 `Is the optional signed immediate vector offset, in the range -8 to 7, defaulting to 0, encoded in the "imm4" field.
2114 bit range mappings:
2115 imm4: [16:20)
2116 `: {"encodeImm41620V5", `vi := int32(v)
2117 if vi >= -8 && vi <= 7 {
2118 return (uint32(vi) & 0xF) << 16, true
2119 }
2120 return 0, false`, "enc_imm4"},
2121 `Is the optional signed immediate vector offset, a multiple of 2 in the range -16 to 14, defaulting to 0, encoded in the "imm4" field.
2122 bit range mappings:
2123 imm4: [16:20)`: {"encodeImm41620V6", `if v&1 != 0 {
2124 return 0, false
2125 }
2126 vi := int32(v)
2127 if vi>=-16 && vi<=14 {
2128 return (uint32(vi/2)&15)<<16, true
2129 }
2130 return 0, false`, "enc_imm4"},
2131 `For the "16-bit" variant: is the immediate shift amount, in the range 1 to 16, encoded in the "imm4" field.
2132 bit range mappings:
2133 imm4: [16:20)
2134 `: {"encodeImm41620V7", `if v < 1 || v > 16 {
2135 return 0, false
2136 }
2137 // From ARM ASL: let shift : integer = esize - UInt(imm3);
2138 // very weird design.
2139 return (16 - v) << 16, true`, "enc_imm4"},
2140 `For the "8-bit" variant: is the immediate shift amount, in the range 1 to 8, encoded in the "imm3" field.
2141 bit range mappings:
2142 imm3: [16:19)
2143 `: {"encodeImm31619", `if v < 1 || v > 8 {
2144 return 0, false
2145 }
2146 return v << 16, true`, "enc_imm3"},
2147 `For the "Four registers" variant: is the name of the first scalable vector register of the destination and first source multi-vector group, encoded as "Zdn" times 4.
2148 bit range mappings:
2149 Zdn: [2:5)
2150 `: {"encodeZdn25V1", `if !stripRawZ(&v) {
2151 return 0, false
2152 }
2153 if v%4 != 0 {
2154 return 0, false
2155 }
2156 return (v / 4) << 2, true`, "enc_Zdn"},
2157 `For the "Four registers" variant: is the name of the first scalable vector register to be transferred, encoded as "Zt" times 4.
2158 bit range mappings:
2159 Zt: [2:5)
2160 `: {"encodeZt25V1", `if !stripRawZ(&v) {
2161 return 0, false
2162 }
2163 if v%4 != 0 {
2164 return 0, false
2165 }
2166 return (v / 4) << 2, true`, "enc_Zt"},
2167 `For the "Four registers" variant: is the optional signed immediate vector offset, a multiple of 4 in the range -32 to 28, defaulting to 0, encoded in the "imm4" field.
2168 bit range mappings:
2169 imm4: [16:20)
2170 `: {"encodeImm41620V8", `val := int32(v)
2171 if val < -32 || val > 28 || val%4 != 0 {
2172 return 0, false
2173 }
2174 encoded := uint32((val >> 2) & 0xf)
2175 return encoded << 16, true`, "enc_imm4"},
2176 `For the "Two registers" variant: is the name of the first scalable vector register of the destination and first source multi-vector group, encoded as "Zdn" times 2.
2177 bit range mappings:
2178 Zdn: [1:5)
2179 `: {"encodeZdn15V1", `if !stripRawZ(&v) {
2180 return 0, false
2181 }
2182 if v%2 != 0 {
2183 return 0, false
2184 }
2185 return (v / 2) << 1, true`, "enc_Zdn"},
2186 `For the "Two registers" variant: is the name of the first scalable vector register to be transferred, encoded as "Zt" times 2.
2187 bit range mappings:
2188 Zt: [1:5)
2189 `: {"encodeZt15V1", `if !stripRawZ(&v) {
2190 return 0, false
2191 }
2192 if v%2 != 0 {
2193 return 0, false
2194 }
2195 return (v / 2) << 1, true`, "enc_Zt"},
2196 `For the "Two registers" variant: is the optional signed immediate vector offset, a multiple of 2 in the range -16 to 14, defaulting to 0, encoded in the "imm4" field.
2197 bit range mappings:
2198 imm4: [16:20)
2199 `: {"encodeImm41620V9", `val := int32(v)
2200 if val < -16 || val > 14 || val%2 != 0 {
2201 return 0, false
2202 }
2203 encoded := uint32((val>>1)&0xf) << 16
2204 return encoded, true`, "enc_imm4"},
2205 `Is the immediate shift amount, in the range 1 to number of bits per element, encoded in "tsize:imm3".
2206 bit range mappings:
2207 imm3: [16:19)
2208 tsize: [19:21)
2209 `: {"encodeImm3Tsize1621Stub", `return codeImm3Tsize1621, false`, "enc_tsize_imm3"},
2210 `Is the name of the first scalable vector register of the destination multi-vector group, encoded as "Zd" times 2.
2211 bit range mappings:
2212 Zd: [1:5)
2213 `: {"encodeZd15V1", `if !stripRawZ(&v) {
2214 return 0, false
2215 }
2216 if v%2 != 0 {
2217 return 0, false
2218 }
2219 return (v / 2) << 1, true`, "enc_Zd"},
2220 `Is the name of the first scalable vector register of the destination multi-vector group, encoded as "Zda" times 2.
2221 bit range mappings:
2222 Zda: [1:5)
2223 `: {"encodeZda15V1", `if !stripRawZ(&v) {
2224 return 0, false
2225 }
2226 if v%2 != 0 {
2227 return 0, false
2228 }
2229 return (v / 2) << 1, true`, "enc_Zda"},
2230 `Is the name of the first scalable vector register of the source multi-vector group, encoded as "Zn" times 2.
2231 bit range mappings:
2232 Zn: [6:10)
2233 `: {"encodeZn610V1", `if !stripRawZ(&v) {
2234 return 0, false
2235 }
2236 if v%2 != 0 {
2237 return 0, false
2238 }
2239 return (v / 2) << 6, true`, "enc_Zn"},
2240 `Is the name of the fourth scalable vector register of the destination and first source multi-vector group, encoded as "Zdn" times 4 plus 3.
2241 bit range mappings:
2242 Zdn: [2:5)
2243 `: {"encodeZdn25V2", `if !stripRawZ(&v) {
2244 return 0, false
2245 }
2246 if v < 3 || (v-3)%4 != 0 {
2247 return 0, false
2248 }
2249 return ((v - 3) / 4) << 2, true`, "enc_Zdn"},
2250 `Is the name of the fourth scalable vector register to be transferred, encoded as "Zt" times 4 plus 3.
2251 bit range mappings:
2252 Zt: [2:5)
2253 `: {"encodeZt25V2", `if !stripRawZ(&v) {
2254 return 0, false
2255 }
2256 if v < 3 || (v-3)%4 != 0 {
2257 return 0, false
2258 }
2259 return ((v - 3) / 4) << 2, true`, "enc_Zt"},
2260 `Is the name of the governing scalable predicate register PN8-PN15, with predicate-as-counter encoding, encoded in the "PNg" field.
2261 bit range mappings:
2262 PNg: [10:13)
2263 `: {"encodePNg1013", `if v < 24 {
2264 return 0, false
2265 }
2266 return (v - 24) << 10, true`, "enc_PNg"},
2267 `Is the name of the second scalable vector register of the destination and first source multi-vector group, encoded as "Zdn" times 2 plus 1.
2268 bit range mappings:
2269 Zdn: [1:5)
2270 `: {"encodeZdn15V2", `if !stripRawZ(&v) {
2271 return 0, false
2272 }
2273 if v < 1 || (v-1)%2 != 0 {
2274 return 0, false
2275 }
2276 return ((v - 1) / 2) << 1, true`, "enc_Zdn"},
2277 `Is the name of the second scalable vector register of the destination multi-vector group, encoded as "Zd" times 2 plus 1.
2278 bit range mappings:
2279 Zd: [1:5)
2280 `: {"encodeZd15V2", `if !stripRawZ(&v) {
2281 return 0, false
2282 }
2283 if v%2 == 0 {
2284 return 0, false
2285 }
2286 return ((v - 1) / 2) << 1, true`, "enc_Zd"},
2287 `Is the name of the second scalable vector register of the destination multi-vector group, encoded as "Zda" times 2 plus 1.
2288 bit range mappings:
2289 Zda: [1:5)
2290 `: {"encodeZda15V2", `if !stripRawZ(&v) {
2291 return 0, false
2292 }
2293 if v%2 == 0 {
2294 return 0, false
2295 }
2296 return ((v - 1) / 2) << 1, true`, "enc_Zda"},
2297 `Is the name of the second scalable vector register of the source multi-vector group, encoded as "Zn" times 2 plus 1.
2298 bit range mappings:
2299 Zn: [6:10)
2300 `: {"encodeZn610V2", `if !stripRawZ(&v) {
2301 return 0, false
2302 }
2303 if v%2 == 0 {
2304 return 0, false
2305 }
2306 return ((v - 1) / 2) << 6, true`, "enc_Zn"},
2307 `Is the name of the second scalable vector register to be transferred, encoded as "Zt" times 2 plus 1.
2308 bit range mappings:
2309 Zt: [1:5)
2310 `: {"encodeZt15V2", `if !stripRawZ(&v) {
2311 return 0, false
2312 }
2313 if v < 1 || (v-1)%2 != 0 {
2314 return 0, false
2315 }
2316 return ((v - 1) / 2) << 1, true`, "enc_Zt"},
2317 `Is the round key index, in the range 0 to 3, encoded in the "i2" field.
2318 bit range mappings:
2319 i2: [19:21)
2320 `: {"encodeI21921", `if v > 3 {
2321 return 0, false
2322 }
2323 return v << 19, true`, "enc_i2"},
2324 `Is the size specifier,
2325 tsize <T>
2326 00 RESERVED
2327 01 B
2328 1x H
2329 bit range mappings:
2330 tsize: [19:21)
2331 `: {"encodeTsize1921V1", `if v == uint32(ARNG_B) {
2332 return 1 << 19, true
2333 }
2334 if v == uint32(ARNG_H) {
2335 return 2 << 19, true // 2 is bit pattern 10 (1x)
2336 }
2337 return 0, false`, "enc_tsize"},
2338 `Is the size specifier,
2339 tsize <Tb>
2340 00 RESERVED
2341 01 H
2342 1x S
2343 bit range mappings:
2344 tsize: [19:21)
2345 `: {"encodeTsize1921V2", `if v == uint32(ARNG_H) {
2346 return 1 << 19, true
2347 }
2348 if v == uint32(ARNG_S) {
2349 return 2 << 19, true // 2 is bit pattern 10 (1x)
2350 }
2351 return 0, false`, "enc_tsize"},
2352 `Is the 32-bit name of the vector select register W12-W15, encoded in the "Rv" field.
2353 bit range mappings:
2354 Rv: [16:18)
2355 `: {"encodeRv1618", `if v < uint32(REG_R12) || v > uint32(REG_R15) {
2356 return 0, false
2357 }
2358 return (v & 3) << 16, true`, "enc_Rv"},
2359 `Is the element index, in the range 0 to one less than the number of vector elements in a 128-bit vector register, encoded in "i1:tszh:tszl".
2360 bit range mappings:
2361 i1: [23:24)
2362 tszh: [22:23)
2363 tszl: [18:21)
2364 `: {"encodeI1TszhTszl1824", `return codeShiftI1TszhTszl, false`, "enc_i1_tszh_tszl"},
2365 `Is the name of the first source scalable predicate register, encoded in the "Pn" field.
2366 bit range mappings:
2367 Pn: [10:14)
2368 `: {"encodePn1014", `if v < 16 {
2369 return v << 10, true
2370 }
2371 return 0, false`, "enc_Pn"},
2372 `Is the name of the second source scalable predicate register, encoded in the "Pm" field.
2373 bit range mappings:
2374 Pm: [5:9)
2375 `: {"encodePm59V2", `if v > 16 {
2376 return 0, false
2377 }
2378 return (v & 15) << 5, true`, "enc_Pm"},
2379 `Is the size specifier,
2380 tszh tszl <T>
2381 0 000 RESERVED
2382 x xx1 B
2383 x x10 H
2384 x 100 S
2385 1 000 D
2386 bit range mappings:
2387 tszh: [22:23)
2388 tszl: [18:21)
2389 `: {"encodeTszhTszl1823", `switch v {
2390 case 9: // B
2391 return 1 << 18, true
2392 case 10: // H
2393 return 1 << 19, true
2394 case 11: // S
2395 return 1 << 20, true
2396 case 12: // D
2397 return 1 << 22, true
2398 }
2399 return 0, false`, "enc_tszh_tszl"},
2400 `Is the name of the first scalable vector register of the first source multi-vector group, encoded in the "Zn" field.
2401 bit range mappings:
2402 Zn: [5:10)
2403 `: {"encodeGenZn510V1", `if !stripRawZ(&v) {
2404 return 0, false
2405 }
2406 return v << 5, true`, "enc_Zn"},
2407 `Is the name of the second scalable vector register of the first source multi-vector group, encoded in the "Zn" field.
2408 bit range mappings:
2409 Zn: [5:10)
2410 `: {"encodeGenZn510V2", `if !stripRawZ(&v) {
2411 return 0, false
2412 }
2413 return (v - 1) << 5, true`, "enc_Zn"},
2414 `Is the size specifier,
2415 sz <T>
2416 0 S
2417 1 D
2418 bit range mappings:
2419 sz: [21:22)
2420 `: {"encodeSz2122", `switch v {
2421 case ARNG_S:
2422 return 0, true
2423 case ARNG_D:
2424 return 1 << 21, true
2425 }
2426 return 0, false`, "enc_sz"},
2427 }