1 /* ppc-opc.c -- PowerPC opcode list
2 Copyright (C) 1994-2021 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support
5 This file is part of the GNU opcodes library.
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)
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.
17 You should have received a copy of the GNU General Public License
18 along with this file; see the file COPYING. If not, write to the
19 Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
24 #include "opcode/ppc.h"
27 /* This file holds the PowerPC opcode table. The opcode table
28 includes almost all of the extended instruction mnemonics. This
29 permits the disassembler to use them, and simplifies the assembler
30 logic, at the cost of increasing the table size. The table is
31 strictly constant data, so the compiler should be able to put it in
34 This file also holds the operand table. All knowledge about
35 inserting operands into instructions and vice-versa is kept in this
38 /* The functions used to insert and extract complicated operands. */
40 /* The ARX, ARY, RX and RY operands are alternate encodings of GPRs. */
43 insert_arx (uint64_t insn
,
45 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
46 const char **errmsg ATTRIBUTE_UNUSED
)
49 if (value
< 0 || value
>= 16)
51 *errmsg
= _("invalid register");
58 extract_arx (uint64_t insn
,
59 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
60 int *invalid ATTRIBUTE_UNUSED
)
62 return (insn
& 0xf) + 8;
66 insert_ary (uint64_t insn
,
68 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
69 const char **errmsg ATTRIBUTE_UNUSED
)
72 if (value
< 0 || value
>= 16)
74 *errmsg
= _("invalid register");
77 return insn
| (value
<< 4);
81 extract_ary (uint64_t insn
,
82 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
83 int *invalid ATTRIBUTE_UNUSED
)
85 return ((insn
>> 4) & 0xf) + 8;
89 insert_rx (uint64_t insn
,
91 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
94 if (value
>= 0 && value
< 8)
96 else if (value
>= 24 && value
<= 31)
100 *errmsg
= _("invalid register");
107 extract_rx (uint64_t insn
,
108 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
109 int *invalid ATTRIBUTE_UNUSED
)
111 int64_t value
= insn
& 0xf;
112 if (value
>= 0 && value
< 8)
119 insert_ry (uint64_t insn
,
121 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
124 if (value
>= 0 && value
< 8)
126 else if (value
>= 24 && value
<= 31)
130 *errmsg
= _("invalid register");
133 return insn
| (value
<< 4);
137 extract_ry (uint64_t insn
,
138 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
139 int *invalid ATTRIBUTE_UNUSED
)
141 int64_t value
= (insn
>> 4) & 0xf;
142 if (value
>= 0 && value
< 8)
148 /* The BA and BB fields in an XL form instruction or the RA and RB fields or
149 VRA and VRB fields in a VX form instruction when they must be the same.
150 This is used for extended mnemonics like crclr. The extraction function
151 enforces that the fields are the same. */
154 insert_bab (uint64_t insn
,
156 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
157 const char **errmsg ATTRIBUTE_UNUSED
)
160 return insn
| (value
<< 16) | (value
<< 11);
164 extract_bab (uint64_t insn
,
165 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
168 int64_t ba
= (insn
>> 16) & 0x1f;
169 int64_t bb
= (insn
>> 11) & 0x1f;
176 /* The BT, BA and BB fields in an XL form instruction when they must all be
177 the same. This is used for extended mnemonics like crclr. The extraction
178 function enforces that the fields are the same. */
181 insert_btab (uint64_t insn
,
187 return (value
<< 21) | insert_bab (insn
, value
, dialect
, errmsg
);
191 extract_btab (uint64_t insn
,
195 int64_t bt
= (insn
>> 21) & 0x1f;
196 int64_t bab
= extract_bab (insn
, dialect
, invalid
);
203 /* The BD field in a B form instruction when the - modifier is used.
204 This modifier means that the branch is not expected to be taken.
205 For chips built to versions of the architecture prior to version 2
206 (ie. not Power4 compatible), we set the y bit of the BO field to 1
207 if the offset is negative. When extracting, we require that the y
208 bit be 1 and that the offset be positive, since if the y bit is 0
209 we just want to print the normal form of the instruction.
210 Power4 compatible targets use two bits, "a", and "t", instead of
211 the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable,
212 "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001
213 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000
214 for branch on CTR. We only handle the taken/not-taken hint here.
215 Note that we don't relax the conditions tested here when
216 disassembling with -Many because insns using extract_bdm and
217 extract_bdp always occur in pairs. One or the other will always
220 #define ISA_V2 (PPC_OPCODE_POWER4 | PPC_OPCODE_E500MC | PPC_OPCODE_TITAN)
223 insert_bdm (uint64_t insn
,
226 const char **errmsg ATTRIBUTE_UNUSED
)
228 if ((dialect
& ISA_V2
) == 0)
230 if ((value
& 0x8000) != 0)
235 if ((insn
& (0x14 << 21)) == (0x04 << 21))
237 else if ((insn
& (0x14 << 21)) == (0x10 << 21))
240 return insn
| (value
& 0xfffc);
244 extract_bdm (uint64_t insn
,
248 if ((dialect
& ISA_V2
) == 0)
250 if (((insn
& (1 << 21)) == 0) != ((insn
& (1 << 15)) == 0))
255 if ((insn
& (0x17 << 21)) != (0x06 << 21)
256 && (insn
& (0x1d << 21)) != (0x18 << 21))
260 return ((insn
& 0xfffc) ^ 0x8000) - 0x8000;
263 /* The BD field in a B form instruction when the + modifier is used.
264 This is like BDM, above, except that the branch is expected to be
268 insert_bdp (uint64_t insn
,
271 const char **errmsg ATTRIBUTE_UNUSED
)
273 if ((dialect
& ISA_V2
) == 0)
275 if ((value
& 0x8000) == 0)
280 if ((insn
& (0x14 << 21)) == (0x04 << 21))
282 else if ((insn
& (0x14 << 21)) == (0x10 << 21))
285 return insn
| (value
& 0xfffc);
289 extract_bdp (uint64_t insn
,
293 if ((dialect
& ISA_V2
) == 0)
295 if (((insn
& (1 << 21)) == 0) == ((insn
& (1 << 15)) == 0))
300 if ((insn
& (0x17 << 21)) != (0x07 << 21)
301 && (insn
& (0x1d << 21)) != (0x19 << 21))
305 return ((insn
& 0xfffc) ^ 0x8000) - 0x8000;
309 valid_bo_pre_v2 (int64_t value
)
311 /* Certain encodings have bits that are required to be zero.
312 These are (z must be zero, y may be anything):
323 if ((value
& 0x14) == 0)
324 /* BO: 0000y, 0001y, 0100y, 0101y. */
326 else if ((value
& 0x14) == 0x4)
327 /* BO: 001zy, 011zy. */
328 return (value
& 0x2) == 0;
329 else if ((value
& 0x14) == 0x10)
330 /* BO: 1z00y, 1z01y. */
331 return (value
& 0x8) == 0;
334 return value
== 0x14;
338 valid_bo_post_v2 (int64_t value
)
340 /* Certain encodings have bits that are required to be zero.
341 These are (z must be zero, a & t may be anything):
352 if ((value
& 0x14) == 0)
353 /* BO: 0000z, 0001z, 0100z, 0101z. */
354 return (value
& 0x1) == 0;
355 else if ((value
& 0x14) == 0x14)
357 return value
== 0x14;
358 else if ((value
& 0x14) == 0x4)
359 /* BO: 001at, 011at, with "at" == 0b01 being reserved. */
360 return (value
& 0x3) != 1;
361 else if ((value
& 0x14) == 0x10)
362 /* BO: 1a00t, 1a01t, with "at" == 0b01 being reserved. */
363 return (value
& 0x9) != 1;
368 /* Check for legal values of a BO field. */
371 valid_bo (int64_t value
, ppc_cpu_t dialect
, int extract
)
373 int valid_y
= valid_bo_pre_v2 (value
);
374 int valid_at
= valid_bo_post_v2 (value
);
376 /* When disassembling with -Many, accept either encoding on the
377 second pass through opcodes. */
378 if (extract
&& dialect
== ~(ppc_cpu_t
) PPC_OPCODE_ANY
)
379 return valid_y
|| valid_at
;
380 if ((dialect
& ISA_V2
) == 0)
386 /* The BO field in a B form instruction. Warn about attempts to set
387 the field to an illegal value. */
390 insert_bo (uint64_t insn
,
395 if (!valid_bo (value
, dialect
, 0))
396 *errmsg
= _("invalid conditional option");
397 else if (PPC_OP (insn
) == 19
398 && (((insn
>> 1) & 0x3ff) == 528) && ! (value
& 4))
399 *errmsg
= _("invalid counter access");
400 return insn
| ((value
& 0x1f) << 21);
404 extract_bo (uint64_t insn
,
408 int64_t value
= (insn
>> 21) & 0x1f;
409 if (!valid_bo (value
, dialect
, 1))
414 /* For the given BO value, return a bit mask detailing which bits
415 define the branch hints. */
418 get_bo_hint_mask (int64_t bo
, ppc_cpu_t dialect
)
420 if ((dialect
& ISA_V2
) == 0)
422 if ((bo
& 0x14) != 0x14)
423 /* BO: 0000y, 0001y, 001zy, 0100y, 0101y, 011zy, 1z00y, 1z01y . */
431 if ((bo
& 0x14) == 0x4)
432 /* BO: 001at, 011at. */
434 else if ((bo
& 0x14) == 0x10)
435 /* BO: 1a00t, 1a01t. */
438 /* BO: 0000z, 0001z, 0100z, 0101z, 1z1zz. */
443 /* The BO field in a B form instruction when the + or - modifier is used. */
446 insert_boe (uint64_t insn
,
452 int64_t implied_hint
;
453 int64_t hint_mask
= get_bo_hint_mask (value
, dialect
);
456 implied_hint
= hint_mask
;
458 implied_hint
= hint_mask
& ~1;
460 /* The branch hint bit(s) in the BO field must either be zero or exactly
461 match the branch hint bits implied by the '+' or '-' modifier. */
462 if (implied_hint
== 0)
463 *errmsg
= _("BO value implies no branch hint, when using + or - modifier");
464 else if ((value
& hint_mask
) != 0
465 && (value
& hint_mask
) != implied_hint
)
467 if ((dialect
& ISA_V2
) == 0)
468 *errmsg
= _("attempt to set y bit when using + or - modifier");
470 *errmsg
= _("attempt to set 'at' bits when using + or - modifier");
473 value
|= implied_hint
;
475 return insert_bo (insn
, value
, dialect
, errmsg
);
479 extract_boe (uint64_t insn
,
484 int64_t value
= (insn
>> 21) & 0x1f;
485 int64_t implied_hint
;
486 int64_t hint_mask
= get_bo_hint_mask (value
, dialect
);
489 implied_hint
= hint_mask
;
491 implied_hint
= hint_mask
& ~1;
493 if (!valid_bo (value
, dialect
, 1)
495 || (value
& hint_mask
) != implied_hint
)
500 /* The BO field in a B form instruction when the - modifier is used. */
503 insert_bom (uint64_t insn
,
508 return insert_boe (insn
, value
, dialect
, errmsg
, 0);
512 extract_bom (uint64_t insn
,
516 return extract_boe (insn
, dialect
, invalid
, 0);
519 /* The BO field in a B form instruction when the + modifier is used. */
522 insert_bop (uint64_t insn
,
527 return insert_boe (insn
, value
, dialect
, errmsg
, 1);
531 extract_bop (uint64_t insn
,
535 return extract_boe (insn
, dialect
, invalid
, 1);
538 /* The DCMX field in a X form instruction when the field is split
539 into separate DC, DM and DX fields. */
542 insert_dcmxs (uint64_t insn
,
544 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
545 const char **errmsg ATTRIBUTE_UNUSED
)
548 | ((value
& 0x1f) << 16)
549 | ((value
& 0x20) >> 3)
554 extract_dcmxs (uint64_t insn
,
555 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
556 int *invalid ATTRIBUTE_UNUSED
)
558 return (insn
& 0x40) | ((insn
<< 3) & 0x20) | ((insn
>> 16) & 0x1f);
561 /* The DW field in a X form instruction when the field is split
562 into separate D and DX fields. */
565 insert_dw (uint64_t insn
,
567 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
568 const char **errmsg ATTRIBUTE_UNUSED
)
570 /* DW offsets must be in the range [-512, -8] and be a multiple of 8. */
573 || (value
& 0x7) != 0)
574 *errmsg
= _("invalid offset: must be in the range [-512, -8] "
575 "and be a multiple of 8");
577 return insn
| ((value
& 0xf8) << 18) | ((value
>> 8) & 1);
581 extract_dw (uint64_t insn
,
582 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
583 int *invalid ATTRIBUTE_UNUSED
)
585 int64_t dw
= ((insn
& 1) << 8) | ((insn
>> 18) & 0xf8);
589 /* The D field in a DX form instruction when the field is split
590 into separate D0, D1 and D2 fields. */
593 insert_dxd (uint64_t insn
,
595 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
596 const char **errmsg ATTRIBUTE_UNUSED
)
598 return insn
| (value
& 0xffc1) | ((value
& 0x3e) << 15);
602 extract_dxd (uint64_t insn
,
603 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
604 int *invalid ATTRIBUTE_UNUSED
)
606 uint64_t dxd
= (insn
& 0xffc1) | ((insn
>> 15) & 0x3e);
607 return (dxd
^ 0x8000) - 0x8000;
611 insert_dxdn (uint64_t insn
,
613 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
614 const char **errmsg ATTRIBUTE_UNUSED
)
616 return insert_dxd (insn
, -value
, dialect
, errmsg
);
620 extract_dxdn (uint64_t insn
,
621 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
624 return -extract_dxd (insn
, dialect
, invalid
);
627 /* The D field in a 64-bit D form prefix instruction when the field is split
628 into separate D0 and D1 fields. */
631 insert_d34 (uint64_t insn
,
633 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
634 const char **errmsg ATTRIBUTE_UNUSED
)
636 return insn
| ((value
& 0x3ffff0000ULL
) << 16) | (value
& 0xffff);
640 extract_d34 (uint64_t insn
,
641 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
642 int *invalid ATTRIBUTE_UNUSED
)
644 int64_t mask
= 1ULL << 33;
645 int64_t value
= ((insn
>> 16) & 0x3ffff0000ULL
) | (insn
& 0xffff);
646 value
= (value
^ mask
) - mask
;
650 /* The NSI34 field in an 8-byte D form prefix instruction. This is the same
651 as the SI34 field, only negated. The extraction function always marks it
652 as invalid, since we never want to recognize an instruction which uses
653 a field of this type. */
656 insert_nsi34 (uint64_t insn
,
661 return insert_d34 (insn
, -value
, dialect
, errmsg
);
665 extract_nsi34 (uint64_t insn
,
669 int64_t value
= extract_d34 (insn
, dialect
, invalid
);
674 /* The split IMM32 field in a vector splat insn. */
677 insert_imm32 (uint64_t insn
,
679 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
680 const char **errmsg ATTRIBUTE_UNUSED
)
682 return insn
| ((value
& 0xffff0000) << 16) | (value
& 0xffff);
686 extract_imm32 (uint64_t insn
,
687 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
688 int *invalid ATTRIBUTE_UNUSED
)
690 return (insn
& 0xffff) | ((insn
>> 16) & 0xffff0000);
693 /* The R field in an 8-byte prefix instruction when there are restrictions
694 between R's value and the RA value (ie, they cannot both be non zero). */
697 insert_pcrel (uint64_t insn
,
699 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
703 int64_t ra
= (insn
>> 16) & 0x1f;
704 if (ra
!= 0 && value
!= 0)
705 *errmsg
= _("invalid R operand");
707 return insn
| (value
<< 52);
711 extract_pcrel (uint64_t insn
,
712 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
715 /* If called with *invalid < 0 to return the value for missing
716 operands, *invalid will be the negative count of missing operands
717 including this one. Return a default value of 1 if the PRA0/PRAQ
718 operand was also omitted (ie. *invalid is -2). Return a default
719 value of 0 if the PRA0/PRAQ operand was not omitted
720 (ie. *invalid is -1). */
722 return ~ *invalid
& 1;
724 int64_t ra
= (insn
>> 16) & 0x1f;
725 int64_t pcrel
= (insn
>> 52) & 0x1;
726 if (ra
!= 0 && pcrel
!= 0)
732 /* Variant of extract_pcrel that sets invalid for R bit set. The idea
733 is to disassemble "paddi rt,0,offset,1" as "pla rt,offset". */
736 extract_pcrel0 (uint64_t insn
,
740 int64_t pcrel
= extract_pcrel (insn
, dialect
, invalid
);
746 /* FXM mask in mfcr and mtcrf instructions. */
749 insert_fxm (uint64_t insn
,
754 /* If we're handling the mfocrf and mtocrf insns ensure that exactly
755 one bit of the mask field is set. */
756 if ((insn
& (1 << 20)) != 0)
758 if (value
== 0 || (value
& -value
) != value
)
760 *errmsg
= _("invalid mask field");
765 /* If only one bit of the FXM field is set, we can use the new form
766 of the instruction, which is faster. Unlike the Power4 branch hint
767 encoding, this is not backward compatible. Do not generate the
768 new form unless -mpower4 has been given, or -many and the two
769 operand form of mfcr was used. */
771 && (value
& -value
) == value
772 && ((dialect
& PPC_OPCODE_POWER4
) != 0
773 || ((dialect
& PPC_OPCODE_ANY
) != 0
774 && (insn
& (0x3ff << 1)) == 19 << 1)))
777 /* Any other value on mfcr is an error. */
778 else if ((insn
& (0x3ff << 1)) == 19 << 1)
780 /* A value of -1 means we used the one operand form of
781 mfcr which is valid. */
783 *errmsg
= _("invalid mfcr mask");
787 return insn
| ((value
& 0xff) << 12);
791 extract_fxm (uint64_t insn
,
792 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
795 /* Return a value of -1 for a missing optional operand, which is
796 used as a flag by insert_fxm. */
800 int64_t mask
= (insn
>> 12) & 0xff;
801 /* Is this a Power4 insn? */
802 if ((insn
& (1 << 20)) != 0)
804 /* Exactly one bit of MASK should be set. */
805 if (mask
== 0 || (mask
& -mask
) != mask
)
809 /* Check that non-power4 form of mfcr has a zero MASK. */
810 else if ((insn
& (0x3ff << 1)) == 19 << 1)
821 /* L field in the paste. instruction. */
824 insert_l1opt (uint64_t insn
,
826 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
827 const char **errmsg ATTRIBUTE_UNUSED
)
829 return insn
| ((value
& 1) << 21);
833 extract_l1opt (uint64_t insn
,
834 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
837 /* Return a value of 1 for a missing optional operand. */
841 return (insn
>> 21) & 1;
845 insert_li20 (uint64_t insn
,
847 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
848 const char **errmsg ATTRIBUTE_UNUSED
)
851 | ((value
& 0xf0000) >> 5)
852 | ((value
& 0x0f800) << 5)
857 extract_li20 (uint64_t insn
,
858 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
859 int *invalid ATTRIBUTE_UNUSED
)
861 return ((((insn
<< 5) & 0xf0000)
862 | ((insn
>> 5) & 0xf800)
863 | (insn
& 0x7ff)) ^ 0x80000) - 0x80000;
866 /* The 2-bit/3-bit L or 2-bit WC field in a SYNC, DCBF or WAIT instruction.
867 For SYNC, some L values are reserved:
868 * Values 6 and 7 are reserved on newer server cpus.
869 * Value 3 is reserved on all server cpus.
870 * Value 2 is reserved on all other cpus.
871 For DCBF, some L values are reserved:
872 * Values 2, 5 and 7 are reserved on all cpus.
873 For WAIT, some WC values are reserved:
874 * Value 3 is reserved on all server cpus.
875 * Values 1 and 2 are reserved on older server cpus. */
878 insert_ls (uint64_t insn
,
885 if (((insn
>> 1) & 0x3ff) == 598)
887 /* For SYNC, some L values are illegal. */
888 mask
= (dialect
& PPC_OPCODE_POWER10
) ? 0x7 : 0x3;
890 /* If the value is within range, check for other illegal values. */
891 if ((value
& mask
) == value
)
895 if (dialect
& PPC_OPCODE_POWER4
)
901 *errmsg
= _("illegal L operand value");
907 else if (((insn
>> 1) & 0x3ff) == 86)
909 /* For DCBF, some L values are illegal. */
910 mask
= (dialect
& PPC_OPCODE_POWER10
) ? 0x7 : 0x3;
912 /* If the value is within range, check for other illegal values. */
913 if ((value
& mask
) == value
)
919 *errmsg
= _("illegal L operand value");
927 /* For WAIT, some WC values are illegal. */
930 /* If the value is within range, check for other illegal values. */
931 if ((dialect
& PPC_OPCODE_A2
) == 0
932 && (dialect
& PPC_OPCODE_E500MC
) == 0
933 && (value
& mask
) == value
)
938 if (dialect
& PPC_OPCODE_POWER10
)
942 *errmsg
= _("illegal WC operand value");
949 return insn
| ((value
& mask
) << 21);
953 extract_ls (uint64_t insn
,
959 /* Missing optional operands have a value of zero. */
963 if (((insn
>> 1) & 0x3ff) == 598)
965 /* For SYNC, some L values are illegal. */
966 int64_t mask
= (dialect
& PPC_OPCODE_POWER10
) ? 0x7 : 0x3;
968 value
= (insn
>> 21) & mask
;
972 if (dialect
& PPC_OPCODE_POWER4
)
984 else if (((insn
>> 1) & 0x3ff) == 86)
986 /* For DCBF, some L values are illegal. */
987 int64_t mask
= (dialect
& PPC_OPCODE_POWER10
) ? 0x7 : 0x3;
989 value
= (insn
>> 21) & mask
;
1003 /* For WAIT, some WC values are illegal. */
1004 value
= (insn
>> 21) & 0x3;
1005 if ((dialect
& PPC_OPCODE_A2
) == 0
1006 && (dialect
& PPC_OPCODE_E500MC
) == 0)
1011 if (dialect
& PPC_OPCODE_POWER10
)
1025 /* The 4-bit E field in a sync instruction that accepts 2 operands.
1026 If ESYNC is non-zero, then the L field must be either 0 or 1 and
1027 the complement of ESYNC-bit2. */
1030 insert_esync (uint64_t insn
,
1032 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1033 const char **errmsg
)
1035 uint64_t ls
= (insn
>> 21) & 0x03;
1038 && ((~value
>> 1) & 0x1) != ls
)
1039 *errmsg
= _("incompatible L operand value");
1041 return insn
| ((value
& 0xf) << 16);
1045 extract_esync (uint64_t insn
,
1046 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1049 /* Missing optional operands have a value of zero. */
1053 uint64_t ls
= (insn
>> 21) & 0x3;
1054 uint64_t value
= (insn
>> 16) & 0xf;
1056 && ((~value
>> 1) & 0x1) != ls
)
1061 /* The MB and ME fields in an M form instruction expressed as a single
1062 operand which is itself a bitmask. The extraction function always
1063 marks it as invalid, since we never want to recognize an
1064 instruction which uses a field of this type. */
1067 insert_mbe (uint64_t insn
,
1069 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1070 const char **errmsg
)
1072 uint64_t uval
, mask
;
1073 long mb
, me
, mx
, count
, last
;
1079 *errmsg
= _("illegal bitmask");
1085 if ((uval
& 1) != 0)
1091 /* mb: location of last 0->1 transition */
1092 /* me: location of last 1->0 transition */
1093 /* count: # transitions */
1095 for (mx
= 0, mask
= (uint64_t) 1 << 31; mx
< 32; ++mx
, mask
>>= 1)
1097 if ((uval
& mask
) && !last
)
1103 else if (!(uval
& mask
) && last
)
1113 if (count
!= 2 && (count
!= 0 || ! last
))
1114 *errmsg
= _("illegal bitmask");
1116 return insn
| (mb
<< 6) | ((me
- 1) << 1);
1120 extract_mbe (uint64_t insn
,
1121 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1130 mb
= (insn
>> 6) & 0x1f;
1131 me
= (insn
>> 1) & 0x1f;
1135 for (i
= mb
; i
<= me
; i
++)
1136 ret
|= (uint64_t) 1 << (31 - i
);
1138 else if (mb
== me
+ 1)
1140 else /* (mb > me + 1) */
1143 for (i
= me
+ 1; i
< mb
; i
++)
1144 ret
&= ~((uint64_t) 1 << (31 - i
));
1149 /* The MB or ME field in an MD or MDS form instruction. The high bit
1150 is wrapped to the low end. */
1153 insert_mb6 (uint64_t insn
,
1155 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1156 const char **errmsg ATTRIBUTE_UNUSED
)
1158 return insn
| ((value
& 0x1f) << 6) | (value
& 0x20);
1162 extract_mb6 (uint64_t insn
,
1163 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1164 int *invalid ATTRIBUTE_UNUSED
)
1166 return ((insn
>> 6) & 0x1f) | (insn
& 0x20);
1169 /* The NB field in an X form instruction. The value 32 is stored as
1173 extract_nb (uint64_t insn
,
1174 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1175 int *invalid ATTRIBUTE_UNUSED
)
1179 ret
= (insn
>> 11) & 0x1f;
1185 /* The NB field in an lswi instruction, which has special value
1186 restrictions. The value 32 is stored as 0. */
1189 insert_nbi (uint64_t insn
,
1191 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1192 const char **errmsg ATTRIBUTE_UNUSED
)
1194 int64_t rtvalue
= (insn
>> 21) & 0x1f;
1195 int64_t ravalue
= (insn
>> 16) & 0x1f;
1199 if (rtvalue
+ (value
+ 3) / 4 > (rtvalue
> ravalue
? ravalue
+ 32
1201 *errmsg
= _("address register in load range");
1202 return insn
| ((value
& 0x1f) << 11);
1205 /* The NSI field in a D form instruction. This is the same as the SI
1206 field, only negated. The extraction function always marks it as
1207 invalid, since we never want to recognize an instruction which uses
1208 a field of this type. */
1211 insert_nsi (uint64_t insn
,
1213 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1214 const char **errmsg ATTRIBUTE_UNUSED
)
1216 return insn
| (-value
& 0xffff);
1220 extract_nsi (uint64_t insn
,
1221 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1225 return -(((insn
& 0xffff) ^ 0x8000) - 0x8000);
1228 /* The 2-bit SC field in a SYNC or PL field in a WAIT instruction.
1229 For WAIT, some PL values are reserved:
1230 * Values 1, 2 and 3 are reserved. */
1233 insert_pl (uint64_t insn
,
1235 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1236 const char **errmsg
)
1238 /* For WAIT, some PL values are illegal. */
1239 if (((insn
>> 1) & 0x3ff) == 30
1241 *errmsg
= _("illegal PL operand value");
1242 return insn
| ((value
& 0x3) << 16);
1246 extract_pl (uint64_t insn
,
1247 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1250 /* Missing optional operands have a value of zero. */
1254 uint64_t value
= (insn
>> 16) & 0x3;
1256 /* For WAIT, some PL values are illegal. */
1257 if (((insn
>> 1) & 0x3ff) == 30
1263 /* The RA field in a D or X form instruction which is an updating
1264 load, which means that the RA field may not be zero and may not
1265 equal the RT field. */
1268 insert_ral (uint64_t insn
,
1270 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1271 const char **errmsg
)
1274 || (uint64_t) value
== ((insn
>> 21) & 0x1f))
1275 *errmsg
= "invalid register operand when updating";
1276 return insn
| ((value
& 0x1f) << 16);
1280 extract_ral (uint64_t insn
,
1281 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1284 int64_t rtvalue
= (insn
>> 21) & 0x1f;
1285 int64_t ravalue
= (insn
>> 16) & 0x1f;
1287 if (rtvalue
== ravalue
|| ravalue
== 0)
1292 /* The RA field in an lmw instruction, which has special value
1296 insert_ram (uint64_t insn
,
1298 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1299 const char **errmsg
)
1301 if ((uint64_t) value
>= ((insn
>> 21) & 0x1f))
1302 *errmsg
= _("index register in load range");
1303 return insn
| ((value
& 0x1f) << 16);
1307 extract_ram (uint64_t insn
,
1308 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1311 uint64_t rtvalue
= (insn
>> 21) & 0x1f;
1312 uint64_t ravalue
= (insn
>> 16) & 0x1f;
1314 if (ravalue
>= rtvalue
)
1319 /* The RA field in the DQ form lq or an lswx instruction, which have special
1320 value restrictions. */
1323 insert_raq (uint64_t insn
,
1325 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1326 const char **errmsg
)
1328 int64_t rtvalue
= (insn
>> 21) & 0x1f;
1330 if (value
== rtvalue
)
1331 *errmsg
= _("source and target register operands must be different");
1332 return insn
| ((value
& 0x1f) << 16);
1336 extract_raq (uint64_t insn
,
1337 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1340 /* Missing optional operands have a value of zero. */
1344 uint64_t rtvalue
= (insn
>> 21) & 0x1f;
1345 uint64_t ravalue
= (insn
>> 16) & 0x1f;
1346 if (ravalue
== rtvalue
)
1351 /* The RA field in a D or X form instruction which is an updating
1352 store or an updating floating point load, which means that the RA
1353 field may not be zero. */
1356 insert_ras (uint64_t insn
,
1358 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1359 const char **errmsg
)
1362 *errmsg
= _("invalid register operand when updating");
1363 return insn
| ((value
& 0x1f) << 16);
1367 extract_ras (uint64_t insn
,
1368 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1371 uint64_t ravalue
= (insn
>> 16) & 0x1f;
1378 /* The RS and RB fields in an X form instruction when they must be the same.
1379 This is used for extended mnemonics like mr. The extraction function
1380 enforces that the fields are the same. */
1383 insert_rsb (uint64_t insn
,
1385 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1386 const char **errmsg ATTRIBUTE_UNUSED
)
1389 return insn
| (value
<< 21) | (value
<< 11);
1393 extract_rsb (uint64_t insn
,
1394 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1397 int64_t rs
= (insn
>> 21) & 0x1f;
1398 int64_t rb
= (insn
>> 11) & 0x1f;
1405 /* The RB field in an lswx instruction, which has special value
1409 insert_rbx (uint64_t insn
,
1411 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1412 const char **errmsg
)
1414 int64_t rtvalue
= (insn
>> 21) & 0x1f;
1416 if (value
== rtvalue
)
1417 *errmsg
= _("source and target register operands must be different");
1418 return insn
| ((value
& 0x1f) << 11);
1422 extract_rbx (uint64_t insn
,
1423 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1426 uint64_t rtvalue
= (insn
>> 21) & 0x1f;
1427 uint64_t rbvalue
= (insn
>> 11) & 0x1f;
1429 if (rbvalue
== rtvalue
)
1434 /* The SCI8 field is made up of SCL and {U,N}I8 fields. */
1436 insert_sci8 (uint64_t insn
,
1438 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1439 const char **errmsg
)
1441 uint64_t fill_scale
= 0;
1442 uint64_t ui8
= value
;
1444 if ((ui8
& 0xffffff00) == 0)
1446 else if ((ui8
& 0xffffff00) == 0xffffff00)
1448 else if ((ui8
& 0xffff00ff) == 0)
1450 fill_scale
= 1 << 8;
1453 else if ((ui8
& 0xffff00ff) == 0xffff00ff)
1455 fill_scale
= 0x400 | (1 << 8);
1458 else if ((ui8
& 0xff00ffff) == 0)
1460 fill_scale
= 2 << 8;
1463 else if ((ui8
& 0xff00ffff) == 0xff00ffff)
1465 fill_scale
= 0x400 | (2 << 8);
1468 else if ((ui8
& 0x00ffffff) == 0)
1470 fill_scale
= 3 << 8;
1473 else if ((ui8
& 0x00ffffff) == 0x00ffffff)
1475 fill_scale
= 0x400 | (3 << 8);
1480 *errmsg
= _("illegal immediate value");
1484 return insn
| fill_scale
| (ui8
& 0xff);
1488 extract_sci8 (uint64_t insn
,
1489 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1490 int *invalid ATTRIBUTE_UNUSED
)
1492 int64_t fill
= insn
& 0x400;
1493 int64_t scale_factor
= (insn
& 0x300) >> 5;
1494 int64_t value
= (insn
& 0xff) << scale_factor
;
1497 value
|= ~((int64_t) 0xff << scale_factor
);
1502 insert_sci8n (uint64_t insn
,
1505 const char **errmsg
)
1507 return insert_sci8 (insn
, -value
, dialect
, errmsg
);
1511 extract_sci8n (uint64_t insn
,
1515 return -extract_sci8 (insn
, dialect
, invalid
);
1519 insert_oimm (uint64_t insn
,
1521 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1522 const char **errmsg ATTRIBUTE_UNUSED
)
1524 return insn
| (((value
- 1) & 0x1f) << 4);
1528 extract_oimm (uint64_t insn
,
1529 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1530 int *invalid ATTRIBUTE_UNUSED
)
1532 return ((insn
>> 4) & 0x1f) + 1;
1535 /* The SH field in an MD form instruction. This is split. */
1538 insert_sh6 (uint64_t insn
,
1540 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1541 const char **errmsg ATTRIBUTE_UNUSED
)
1543 return insn
| ((value
& 0x1f) << 11) | ((value
& 0x20) >> 4);
1547 extract_sh6 (uint64_t insn
,
1548 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1549 int *invalid ATTRIBUTE_UNUSED
)
1551 return ((insn
>> 11) & 0x1f) | ((insn
<< 4) & 0x20);
1554 /* The SPR field in an XFX form instruction. This is flipped--the
1555 lower 5 bits are stored in the upper 5 and vice- versa. */
1558 insert_spr (uint64_t insn
,
1560 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1561 const char **errmsg ATTRIBUTE_UNUSED
)
1563 return insn
| ((value
& 0x1f) << 16) | ((value
& 0x3e0) << 6);
1567 extract_spr (uint64_t insn
,
1568 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1569 int *invalid ATTRIBUTE_UNUSED
)
1571 return ((insn
>> 16) & 0x1f) | ((insn
>> 6) & 0x3e0);
1574 /* Some dialects have 8 [DI]BAT registers instead of the standard 4. */
1575 #define ALLOW8_BAT (PPC_OPCODE_750)
1578 insert_sprbat (uint64_t insn
,
1581 const char **errmsg
)
1583 if ((uint64_t) value
> 7
1584 || ((uint64_t) value
> 3 && (dialect
& ALLOW8_BAT
) == 0))
1585 *errmsg
= _("invalid bat number");
1587 /* If this is [di]bat4..7 then use spr 560..575, otherwise 528..543. */
1588 if ((uint64_t) value
> 3)
1589 value
= ((value
& 3) << 6) | 1;
1593 return insn
| (value
<< 11);
1597 extract_sprbat (uint64_t insn
,
1601 uint64_t val
= (insn
>> 17) & 0x3;
1603 val
= val
+ ((insn
>> 9) & 0x4);
1604 if (val
> 3 && (dialect
& ALLOW8_BAT
) == 0)
1609 /* Some dialects have 8 SPRG registers instead of the standard 4. */
1610 #define ALLOW8_SPRG (PPC_OPCODE_BOOKE | PPC_OPCODE_405)
1613 insert_sprg (uint64_t insn
,
1616 const char **errmsg
)
1618 if ((uint64_t) value
> 7
1619 || ((uint64_t) value
> 3 && (dialect
& ALLOW8_SPRG
) == 0))
1620 *errmsg
= _("invalid sprg number");
1622 /* If this is mfsprg4..7 then use spr 260..263 which can be read in
1623 user mode. Anything else must use spr 272..279. */
1624 if ((uint64_t) value
<= 3 || (insn
& 0x100) != 0)
1627 return insn
| ((value
& 0x17) << 16);
1631 extract_sprg (uint64_t insn
,
1635 uint64_t val
= (insn
>> 16) & 0x1f;
1637 /* mfsprg can use 260..263 and 272..279. mtsprg only uses spr 272..279
1638 If not BOOKE, 405 or VLE, then both use only 272..275. */
1639 if ((val
- 0x10 > 3 && (dialect
& ALLOW8_SPRG
) == 0)
1640 || (val
- 0x10 > 7 && (insn
& 0x100) != 0)
1647 /* The TBR field in an XFX instruction. This is just like SPR, but it
1651 insert_tbr (uint64_t insn
,
1653 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1654 const char **errmsg
)
1656 if (value
!= 268 && value
!= 269)
1657 *errmsg
= _("invalid tbr number");
1658 return insn
| ((value
& 0x1f) << 16) | ((value
& 0x3e0) << 6);
1662 extract_tbr (uint64_t insn
,
1663 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1666 /* Missing optional operands have a value of 268. */
1670 int64_t ret
= ((insn
>> 16) & 0x1f) | ((insn
>> 6) & 0x3e0);
1671 if (ret
!= 268 && ret
!= 269)
1676 /* The XT and XS fields in an XX1 or XX3 form instruction. This is split. */
1679 insert_xt6 (uint64_t insn
,
1681 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1682 const char **errmsg ATTRIBUTE_UNUSED
)
1684 return insn
| ((value
& 0x1f) << 21) | ((value
& 0x20) >> 5);
1688 extract_xt6 (uint64_t insn
,
1689 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1690 int *invalid ATTRIBUTE_UNUSED
)
1692 return ((insn
<< 5) & 0x20) | ((insn
>> 21) & 0x1f);
1695 /* The XT and XS fields in an DQ form VSX instruction. This is split. */
1697 insert_xtq6 (uint64_t insn
,
1699 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1700 const char **errmsg ATTRIBUTE_UNUSED
)
1702 return insn
| ((value
& 0x1f) << 21) | ((value
& 0x20) >> 2);
1706 extract_xtq6 (uint64_t insn
,
1707 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1708 int *invalid ATTRIBUTE_UNUSED
)
1710 return ((insn
<< 2) & 0x20) | ((insn
>> 21) & 0x1f);
1713 /* The XA field in an XX3 form instruction. This is split. */
1716 insert_xa6 (uint64_t insn
,
1718 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1719 const char **errmsg ATTRIBUTE_UNUSED
)
1721 return insn
| ((value
& 0x1f) << 16) | ((value
& 0x20) >> 3);
1725 extract_xa6 (uint64_t insn
,
1726 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1727 int *invalid ATTRIBUTE_UNUSED
)
1729 return ((insn
<< 3) & 0x20) | ((insn
>> 16) & 0x1f);
1732 /* The XA field in an MMA XX3 form instruction. This is split
1733 and must not overlap with the ACC operand. */
1736 insert_xa6a (uint64_t insn
,
1739 const char **errmsg
)
1741 int64_t acc
= (insn
>> 23) & 0x7;
1742 if ((value
>> 2) == acc
)
1743 *errmsg
= _("VSR overlaps ACC operand");
1744 return insert_xa6 (insn
, value
, dialect
, errmsg
);
1748 extract_xa6a (uint64_t insn
,
1752 int64_t acc
= (insn
>> 23) & 0x7;
1753 int64_t value
= extract_xa6 (insn
, dialect
, invalid
);
1754 if ((value
>> 2) == acc
)
1759 /* The XB field in an XX3 form instruction. This is split. */
1762 insert_xb6 (uint64_t insn
,
1764 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1765 const char **errmsg ATTRIBUTE_UNUSED
)
1767 return insn
| ((value
& 0x1f) << 11) | ((value
& 0x20) >> 4);
1771 extract_xb6 (uint64_t insn
,
1772 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1773 int *invalid ATTRIBUTE_UNUSED
)
1775 return ((insn
<< 4) & 0x20) | ((insn
>> 11) & 0x1f);
1778 /* The XB field in an MMA XX3 form instruction. This is split
1779 and must not overlap with the ACC operand. */
1782 insert_xb6a (uint64_t insn
,
1785 const char **errmsg
)
1787 int64_t acc
= (insn
>> 23) & 0x7;
1788 if ((value
>> 2) == acc
)
1789 *errmsg
= _("VSR overlaps ACC operand");
1790 return insert_xb6 (insn
, value
, dialect
, errmsg
);
1794 extract_xb6a (uint64_t insn
,
1798 int64_t acc
= (insn
>> 23) & 0x7;
1799 int64_t value
= extract_xb6 (insn
, dialect
, invalid
);
1800 if ((value
>> 2) == acc
)
1805 /* The XA and XB fields in an XX3 form instruction when they must be the same.
1806 This is used for extended mnemonics like xvmovdp. The extraction function
1807 enforces that the fields are the same. */
1810 insert_xab6 (uint64_t insn
,
1813 const char **errmsg
)
1815 return insert_xa6 (insn
, value
, dialect
, errmsg
)
1816 | insert_xb6 (insn
, value
, dialect
, errmsg
);
1820 extract_xab6 (uint64_t insn
,
1824 int64_t xa6
= extract_xa6 (insn
, dialect
, invalid
);
1825 int64_t xb6
= extract_xb6 (insn
, dialect
, invalid
);
1832 /* The XC field in an XX4 form instruction. This is split. */
1835 insert_xc6 (uint64_t insn
,
1837 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1838 const char **errmsg ATTRIBUTE_UNUSED
)
1840 return insn
| ((value
& 0x1f) << 6) | ((value
& 0x20) >> 2);
1844 extract_xc6 (uint64_t insn
,
1845 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1846 int *invalid ATTRIBUTE_UNUSED
)
1848 return ((insn
<< 2) & 0x20) | ((insn
>> 6) & 0x1f);
1851 /* The split XTp field in a vector paired insn. */
1854 insert_xtp (uint64_t insn
,
1856 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1857 const char **errmsg ATTRIBUTE_UNUSED
)
1859 return insn
| ((value
& 0x1e) << 21) | ((value
& 0x20) << (21 - 5));
1863 extract_xtp (uint64_t insn
,
1864 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1865 int *invalid ATTRIBUTE_UNUSED
)
1867 return ((insn
>> (21 - 5)) & 0x20) | ((insn
>> 21) & 0x1e);
1870 /* The split XT field in a vector splat insn. */
1873 insert_xts (uint64_t insn
,
1875 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1876 const char **errmsg ATTRIBUTE_UNUSED
)
1878 return insn
| ((value
& 0x1f) << 21) | ((value
& 0x20) << (16 - 5));
1882 extract_xts (uint64_t insn
,
1883 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1884 int *invalid ATTRIBUTE_UNUSED
)
1886 return ((insn
>> (16 - 5)) & 0x20) | ((insn
>> 21) & 0x1f);
1890 insert_dm (uint64_t insn
,
1892 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1893 const char **errmsg
)
1895 if (value
!= 0 && value
!= 1)
1896 *errmsg
= _("invalid constant");
1897 return insn
| (((value
) ? 3 : 0) << 8);
1901 extract_dm (uint64_t insn
,
1902 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1905 int64_t value
= (insn
>> 8) & 3;
1906 if (value
!= 0 && value
!= 3)
1908 return (value
) ? 1 : 0;
1911 /* The VLESIMM field in an I16A form instruction. This is split. */
1914 insert_vlesi (uint64_t insn
,
1916 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1917 const char **errmsg ATTRIBUTE_UNUSED
)
1919 return insn
| ((value
& 0xf800) << 10) | (value
& 0x7ff);
1923 extract_vlesi (uint64_t insn
,
1924 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1925 int *invalid ATTRIBUTE_UNUSED
)
1927 int64_t value
= ((insn
>> 10) & 0xf800) | (insn
& 0x7ff);
1928 value
= (value
^ 0x8000) - 0x8000;
1933 insert_vlensi (uint64_t insn
,
1935 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1936 const char **errmsg ATTRIBUTE_UNUSED
)
1939 return insn
| ((value
& 0xf800) << 10) | (value
& 0x7ff);
1942 extract_vlensi (uint64_t insn
,
1943 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1946 int64_t value
= ((insn
>> 10) & 0xf800) | (insn
& 0x7ff);
1947 value
= (value
^ 0x8000) - 0x8000;
1948 /* Don't use for disassembly. */
1953 /* The VLEUIMM field in an I16A form instruction. This is split. */
1956 insert_vleui (uint64_t insn
,
1958 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1959 const char **errmsg ATTRIBUTE_UNUSED
)
1961 return insn
| ((value
& 0xf800) << 10) | (value
& 0x7ff);
1965 extract_vleui (uint64_t insn
,
1966 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1967 int *invalid ATTRIBUTE_UNUSED
)
1969 return ((insn
>> 10) & 0xf800) | (insn
& 0x7ff);
1972 /* The VLEUIMML field in an I16L form instruction. This is split. */
1975 insert_vleil (uint64_t insn
,
1977 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1978 const char **errmsg ATTRIBUTE_UNUSED
)
1980 return insn
| ((value
& 0xf800) << 5) | (value
& 0x7ff);
1984 extract_vleil (uint64_t insn
,
1985 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1986 int *invalid ATTRIBUTE_UNUSED
)
1988 return ((insn
>> 5) & 0xf800) | (insn
& 0x7ff);
1992 insert_evuimm1_ex0 (uint64_t insn
,
1994 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
1995 const char **errmsg
)
1997 if (value
<= 0 || value
> 0x1f)
1998 *errmsg
= _("UIMM = 00000 is illegal");
1999 return insn
| ((value
& 0x1f) << 11);
2003 extract_evuimm1_ex0 (uint64_t insn
,
2004 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2007 int64_t value
= ((insn
>> 11) & 0x1f);
2015 insert_evuimm2_ex0 (uint64_t insn
,
2017 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2018 const char **errmsg
)
2020 if (value
<= 0 || value
> 0x3e)
2021 *errmsg
= _("UIMM = 00000 is illegal");
2022 return insn
| ((value
& 0x3e) << 10);
2026 extract_evuimm2_ex0 (uint64_t insn
,
2027 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2030 int64_t value
= ((insn
>> 10) & 0x3e);
2038 insert_evuimm4_ex0 (uint64_t insn
,
2040 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2041 const char **errmsg
)
2043 if (value
<= 0 || value
> 0x7c)
2044 *errmsg
= _("UIMM = 00000 is illegal");
2045 return insn
| ((value
& 0x7c) << 9);
2049 extract_evuimm4_ex0 (uint64_t insn
,
2050 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2053 int64_t value
= ((insn
>> 9) & 0x7c);
2061 insert_evuimm8_ex0 (uint64_t insn
,
2063 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2064 const char **errmsg
)
2066 if (value
<= 0 || value
> 0xf8)
2067 *errmsg
= _("UIMM = 00000 is illegal");
2068 return insn
| ((value
& 0xf8) << 8);
2072 extract_evuimm8_ex0 (uint64_t insn
,
2073 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2076 int64_t value
= ((insn
>> 8) & 0xf8);
2084 insert_evuimm_lt8 (uint64_t insn
,
2086 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2087 const char **errmsg
)
2089 if (value
< 0 || value
> 7)
2090 *errmsg
= _("UIMM values >7 are illegal");
2091 return insn
| ((value
& 0x7) << 11);
2095 extract_evuimm_lt8 (uint64_t insn
,
2096 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2099 int64_t value
= ((insn
>> 11) & 0x1f);
2107 insert_evuimm_lt16 (uint64_t insn
,
2109 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2110 const char **errmsg
)
2112 if (value
< 0 || value
> 15)
2113 *errmsg
= _("UIMM values >15 are illegal");
2114 return insn
| ((value
& 0xf) << 11);
2118 extract_evuimm_lt16 (uint64_t insn
,
2119 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2122 int64_t value
= ((insn
>> 11) & 0x1f);
2130 insert_rD_rS_even (uint64_t insn
,
2132 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2133 const char **errmsg
)
2135 if ((value
& 0x1) != 0)
2136 *errmsg
= _("GPR odd is illegal");
2137 return insn
| ((value
& 0x1e) << 21);
2141 extract_rD_rS_even (uint64_t insn
,
2142 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2145 int64_t value
= ((insn
>> 21) & 0x1f);
2146 if ((value
& 0x1) != 0)
2153 insert_off_lsp (uint64_t insn
,
2155 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2156 const char **errmsg
)
2158 if (value
<= 0 || value
> 0x3)
2159 *errmsg
= _("invalid offset");
2160 return insn
| (value
& 0x3);
2164 extract_off_lsp (uint64_t insn
,
2165 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2168 int64_t value
= (insn
& 0x3);
2176 insert_off_spe2 (uint64_t insn
,
2178 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2179 const char **errmsg
)
2181 if (value
<= 0 || value
> 0x7)
2182 *errmsg
= _("invalid offset");
2183 return insn
| (value
& 0x7);
2187 extract_off_spe2 (uint64_t insn
,
2188 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2191 int64_t value
= (insn
& 0x7);
2199 insert_Ddd (uint64_t insn
,
2201 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2202 const char **errmsg
)
2204 if (value
< 0 || value
> 0x7)
2205 *errmsg
= _("invalid Ddd value");
2206 return insn
| ((value
& 0x3) << 11) | ((value
& 0x4) >> 2);
2210 extract_Ddd (uint64_t insn
,
2211 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2212 int *invalid ATTRIBUTE_UNUSED
)
2214 return ((insn
>> 11) & 0x3) | ((insn
<< 2) & 0x4);
2218 insert_sxl (uint64_t insn
,
2220 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2221 const char **errmsg ATTRIBUTE_UNUSED
)
2223 return insn
| ((value
& 0x1) << 11);
2227 extract_sxl (uint64_t insn
,
2228 ppc_cpu_t dialect ATTRIBUTE_UNUSED
,
2231 /* Missing optional operands have a value of one. */
2234 return (insn
>> 11) & 0x1;
2237 /* The operands table.
2239 The fields are bitm, shift, insert, extract, flags.
2241 We used to put parens around the various additions, like the one
2242 for BA just below. However, that caused trouble with feeble
2243 compilers with a limit on depth of a parenthesized expression, like
2244 (reportedly) the compiler in Microsoft Developer Studio 5. So we
2245 omit the parens, since the macros are never used in a context where
2246 the addition will be ambiguous. */
2248 const struct powerpc_operand powerpc_operands
[] =
2250 /* The zero index is used to indicate the end of the list of
2253 { 0, 0, NULL
, NULL
, 0 },
2255 /* The BA field in an XL form instruction. */
2256 #define BA UNUSED + 1
2257 /* The BI field in a B form or XL form instruction. */
2259 #define BI_MASK (0x1f << 16)
2260 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_CR_BIT
},
2262 /* The BT, BA and BB fields in a XL form instruction when they must all
2265 { 0x1f, 21, insert_btab
, extract_btab
, PPC_OPERAND_CR_BIT
},
2267 /* The BB field in an XL form instruction. */
2269 #define BB_MASK (0x1f << 11)
2270 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_CR_BIT
},
2272 /* The BA and BB fields in a XL form instruction when they must be
2275 { 0x1f, 16, insert_bab
, extract_bab
, PPC_OPERAND_CR_BIT
},
2277 /* The VRA and VRB fields in a VX form instruction when they must be the same.
2278 This is used for extended mnemonics like vmr. */
2280 { 0x1f, 16, insert_bab
, extract_bab
, PPC_OPERAND_VR
},
2282 /* The RA and RB fields in a VX form instruction when they must be the same.
2283 This is used for extended mnemonics like evmr. */
2285 { 0x1f, 16, insert_bab
, extract_bab
, PPC_OPERAND_GPR
},
2287 /* The BD field in a B form instruction. The lower two bits are
2290 { 0xfffc, 0, NULL
, NULL
, PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2292 /* The BD field in a B form instruction when absolute addressing is
2295 { 0xfffc, 0, NULL
, NULL
, PPC_OPERAND_ABSOLUTE
| PPC_OPERAND_SIGNED
},
2297 /* The BD field in a B form instruction when the - modifier is used.
2298 This sets the y bit of the BO field appropriately. */
2300 { 0xfffc, 0, insert_bdm
, extract_bdm
,
2301 PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2303 /* The BD field in a B form instruction when the - modifier is used
2304 and absolute address is used. */
2305 #define BDMA BDM + 1
2306 { 0xfffc, 0, insert_bdm
, extract_bdm
,
2307 PPC_OPERAND_ABSOLUTE
| PPC_OPERAND_SIGNED
},
2309 /* The BD field in a B form instruction when the + modifier is used.
2310 This sets the y bit of the BO field appropriately. */
2311 #define BDP BDMA + 1
2312 { 0xfffc, 0, insert_bdp
, extract_bdp
,
2313 PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2315 /* The BD field in a B form instruction when the + modifier is used
2316 and absolute addressing is used. */
2317 #define BDPA BDP + 1
2318 { 0xfffc, 0, insert_bdp
, extract_bdp
,
2319 PPC_OPERAND_ABSOLUTE
| PPC_OPERAND_SIGNED
},
2321 /* The BF field in an X or XL form instruction. */
2323 /* The CRFD field in an X form instruction. */
2325 /* The CRD field in an XL form instruction. */
2327 { 0x7, 23, NULL
, NULL
, PPC_OPERAND_CR_REG
},
2329 /* The BF field in an X or XL form instruction. */
2331 { 0x7, 23, NULL
, NULL
, 0 },
2333 /* The ACC field in a VSX ACC 8LS:D-form instruction. */
2335 { 0x7, 23, NULL
, NULL
, PPC_OPERAND_ACC
},
2337 /* An optional BF field. This is used for comparison instructions,
2338 in which an omitted BF field is taken as zero. */
2340 { 0x7, 23, NULL
, NULL
, PPC_OPERAND_CR_REG
| PPC_OPERAND_OPTIONAL
},
2342 /* The BFA field in an X or XL form instruction. */
2344 { 0x7, 18, NULL
, NULL
, PPC_OPERAND_CR_REG
},
2346 /* The BO field in a B form instruction. Certain values are
2349 #define BO_MASK (0x1f << 21)
2350 { 0x1f, 21, insert_bo
, extract_bo
, 0 },
2352 /* The BO field in a B form instruction when the - modifier is used. */
2354 { 0x1f, 21, insert_bom
, extract_bom
, 0 },
2356 /* The BO field in a B form instruction when the + modifier is used. */
2358 { 0x1f, 21, insert_bop
, extract_bop
, 0 },
2360 /* The RM field in an X form instruction. */
2363 { 0x3, 11, NULL
, NULL
, 0 },
2366 { 0x3, 11, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
2368 /* The BT field in an X or XL form instruction. */
2370 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_CR_BIT
},
2372 /* The BT field in a mtfsb0 or mtfsb1 instruction. */
2374 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_CR_BIT
| PPC_OPERAND_CR_REG
},
2376 /* The BI16 field in a BD8 form instruction. */
2377 #define BI16 BTF + 1
2378 { 0x3, 8, NULL
, NULL
, PPC_OPERAND_CR_BIT
},
2380 /* The BI32 field in a BD15 form instruction. */
2381 #define BI32 BI16 + 1
2382 { 0xf, 16, NULL
, NULL
, PPC_OPERAND_CR_BIT
},
2384 /* The BO32 field in a BD15 form instruction. */
2385 #define BO32 BI32 + 1
2386 { 0x3, 20, NULL
, NULL
, 0 },
2388 /* The B8 field in a BD8 form instruction. */
2390 { 0x1fe, -1, NULL
, NULL
, PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2392 /* The B15 field in a BD15 form instruction. The lowest bit is
2395 { 0xfffe, 0, NULL
, NULL
, PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2397 /* The B24 field in a BD24 form instruction. The lowest bit is
2400 { 0x1fffffe, 0, NULL
, NULL
, PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2402 /* The condition register number portion of the BI field in a B form
2403 or XL form instruction. This is used for the extended
2404 conditional branch mnemonics, which set the lower two bits of the
2405 BI field. This field is optional. */
2407 { 0x7, 18, NULL
, NULL
, PPC_OPERAND_CR_REG
| PPC_OPERAND_OPTIONAL
},
2409 /* The CRB field in an X form instruction. */
2411 /* The MB field in an M form instruction. */
2413 #define MB_MASK (0x1f << 6)
2414 { 0x1f, 6, NULL
, NULL
, 0 },
2416 /* The CRD32 field in an XL form instruction. */
2417 #define CRD32 CRB + 1
2418 { 0x3, 21, NULL
, NULL
, PPC_OPERAND_CR_REG
},
2420 /* The CRFS field in an X form instruction. */
2421 #define CRFS CRD32 + 1
2422 { 0x7, 0, NULL
, NULL
, PPC_OPERAND_CR_REG
},
2424 #define CRS CRFS + 1
2425 { 0x3, 18, NULL
, NULL
, PPC_OPERAND_CR_REG
| PPC_OPERAND_OPTIONAL
},
2427 /* The CT field in an X form instruction. */
2429 /* The MO field in an mbar instruction. */
2431 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
2433 /* The D field in a D form instruction. This is a displacement off
2434 a register, and implies that the next operand is a register in
2437 { 0xffff, 0, NULL
, NULL
, PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
},
2439 /* The D8 field in a D form instruction. This is a displacement off
2440 a register, and implies that the next operand is a register in
2443 { 0xff, 0, NULL
, NULL
, PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
},
2445 /* The DCMX field in an X form instruction. */
2447 { 0x7f, 16, NULL
, NULL
, 0 },
2449 /* The split DCMX field in an X form instruction. */
2450 #define DCMXS DCMX + 1
2451 { 0x7f, PPC_OPSHIFT_INV
, insert_dcmxs
, extract_dcmxs
, 0 },
2453 /* The DQ field in a DQ form instruction. This is like D, but the
2454 lower four bits are forced to zero. */
2455 #define DQ DCMXS + 1
2456 { 0xfff0, 0, NULL
, NULL
,
2457 PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
| PPC_OPERAND_DQ
},
2459 /* The DS field in a DS form instruction. This is like D, but the
2460 lower two bits are forced to zero. */
2462 { 0xfffc, 0, NULL
, NULL
,
2463 PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
| PPC_OPERAND_DS
},
2465 /* The D field in an 8-byte D form prefix instruction. This is a displacement
2466 off a register, and implies that the next operand is a register in
2469 { UINT64_C(0x3ffffffff), PPC_OPSHIFT_INV
, insert_d34
, extract_d34
,
2470 PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
},
2472 /* The SI field in an 8-byte D form prefix instruction. */
2473 #define SI34 D34 + 1
2474 { UINT64_C(0x3ffffffff), PPC_OPSHIFT_INV
, insert_d34
, extract_d34
, PPC_OPERAND_SIGNED
},
2476 /* The NSI field in an 8-byte D form prefix instruction. This is the
2477 same as the SI34 field, only negated. */
2478 #define NSI34 SI34 + 1
2479 { UINT64_C(0x3ffffffff), PPC_OPSHIFT_INV
, insert_nsi34
, extract_nsi34
,
2480 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
},
2482 /* The IMM32 field in a vector splat immediate prefix instruction. */
2483 #define IMM32 NSI34 + 1
2484 { 0xffffffff, PPC_OPSHIFT_INV
, insert_imm32
, extract_imm32
, 0},
2486 /* The UIM field in a vector permute extended prefix instruction. */
2487 #define UIM3 IMM32 + 1
2488 { 0x7, 32, NULL
, NULL
, 0},
2490 /* The UIM field in a vector eval prefix instruction. */
2491 #define UIM8 UIM3 + 1
2492 { 0xff, 32, NULL
, NULL
, 0},
2494 /* The IX field in xxsplti32dx. */
2496 { 0x1, 17, NULL
, NULL
, 0 },
2498 /* The PMSK field in GER rank 8 prefix instructions. */
2499 #define PMSK8 IX + 1
2500 { 0xff, 40, NULL
, NULL
, 0 },
2502 /* The PMSK field in GER rank 4 prefix instructions. */
2503 #define PMSK4 PMSK8 + 1
2504 { 0xf, 44, NULL
, NULL
, 0 },
2506 /* The PMSK field in GER rank 2 prefix instructions. */
2507 #define PMSK2 PMSK4 + 1
2508 { 0x3, 46, NULL
, NULL
, 0 },
2510 /* The XMSK field in GER prefix instructions. */
2511 #define XMSK PMSK2 + 1
2512 { 0xf, 36, NULL
, NULL
, 0 },
2514 /* The YMSK field in GER prefix instructions. */
2515 #define YMSK XMSK + 1
2516 { 0xf, 32, NULL
, NULL
, 0 },
2518 /* The YMSK field in 64-bit GER prefix instructions. */
2519 #define YMSK2 YMSK + 1
2520 { 0x3, 34, NULL
, NULL
, 0 },
2522 /* The DUIS or BHRBE fields in a XFX form instruction, 10 bits
2523 unsigned imediate */
2524 #define DUIS YMSK2 + 1
2526 { 0x3ff, 11, NULL
, NULL
, 0 },
2528 /* The split DW field in a X form instruction. */
2530 { -1, PPC_OPSHIFT_INV
, insert_dw
, extract_dw
,
2531 PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
},
2533 /* The split D field in a DX form instruction. */
2535 { 0xffff, PPC_OPSHIFT_INV
, insert_dxd
, extract_dxd
,
2536 PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
2538 /* The split ND field in a DX form instruction.
2539 This is the same as the DX field, only negated. */
2540 #define NDXD DXD + 1
2541 { 0xffff, PPC_OPSHIFT_INV
, insert_dxdn
, extract_dxdn
,
2542 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
2544 /* The E field in a wrteei instruction. */
2545 /* And the W bit in the pair singles instructions. */
2546 /* And the ST field in a VX form instruction. */
2550 { 0x1, 15, NULL
, NULL
, 0 },
2552 /* The FL1 field in a POWER SC form instruction. */
2554 /* The U field in an X form instruction. */
2556 { 0xf, 12, NULL
, NULL
, 0 },
2558 /* The FL2 field in a POWER SC form instruction. */
2560 { 0x7, 2, NULL
, NULL
, 0 },
2562 /* The FLM field in an XFL form instruction. */
2564 { 0xff, 17, NULL
, NULL
, 0 },
2566 /* The FRA field in an X or A form instruction. */
2568 #define FRA_MASK (0x1f << 16)
2569 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_FPR
},
2571 /* The FRAp field of DFP instructions. */
2572 #define FRAp FRA + 1
2573 { 0x1e, 16, NULL
, NULL
, PPC_OPERAND_FPR
},
2575 /* The FRB field in an X or A form instruction. */
2576 #define FRB FRAp + 1
2577 #define FRB_MASK (0x1f << 11)
2578 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_FPR
},
2580 /* The FRBp field of DFP instructions. */
2581 #define FRBp FRB + 1
2582 { 0x1e, 11, NULL
, NULL
, PPC_OPERAND_FPR
},
2584 /* The FRC field in an A form instruction. */
2585 #define FRC FRBp + 1
2586 #define FRC_MASK (0x1f << 6)
2587 { 0x1f, 6, NULL
, NULL
, PPC_OPERAND_FPR
},
2589 /* The FRS field in an X form instruction or the FRT field in a D, X
2590 or A form instruction. */
2593 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_FPR
},
2595 /* The FRSp field of stfdp or the FRTp field of lfdp and DFP
2597 #define FRSp FRS + 1
2599 { 0x1e, 21, NULL
, NULL
, PPC_OPERAND_FPR
},
2601 /* The FXM field in an XFX instruction. */
2602 #define FXM FRSp + 1
2603 { 0xff, 12, insert_fxm
, extract_fxm
, 0 },
2605 /* Power4 version for mfcr. */
2606 #define FXM4 FXM + 1
2607 { 0xff, 12, insert_fxm
, extract_fxm
, PPC_OPERAND_OPTIONAL
},
2609 /* The IMM20 field in an LI instruction. */
2610 #define IMM20 FXM4 + 1
2611 { 0xfffff, PPC_OPSHIFT_INV
, insert_li20
, extract_li20
, PPC_OPERAND_SIGNED
},
2613 /* The L field in a D or X form instruction. */
2615 { 0x1, 21, NULL
, NULL
, 0 },
2617 /* The optional L field in tlbie and tlbiel instructions. */
2619 /* The R field in a HTM X form instruction. */
2621 { 0x1, 21, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
2623 /* The optional L field in the paste. instruction. This is similar to LOPT
2624 above, but with a default value of 1. */
2625 #define L1OPT LOPT + 1
2626 { 0x1, 21, insert_l1opt
, extract_l1opt
, PPC_OPERAND_OPTIONAL
},
2628 /* The optional (for 32-bit) L field in cmp[l][i] instructions. */
2629 #define L32OPT L1OPT + 1
2630 { 0x1, 21, NULL
, NULL
, PPC_OPERAND_OPTIONAL
| PPC_OPERAND_OPTIONAL32
},
2632 /* The 2-bit L or WC field in an X (sync, dcbf or wait) form instruction. */
2633 #define L2OPT L32OPT + 1
2636 { 0x3, 21, insert_ls
, extract_ls
, PPC_OPERAND_OPTIONAL
},
2638 /* The LEV field in a POWER SVC / POWER9 SCV form instruction. */
2639 #define SVC_LEV L2OPT + 1
2640 { 0x7f, 5, NULL
, NULL
, 0 },
2642 /* The LEV field in an SC form instruction. */
2643 #define LEV SVC_LEV + 1
2644 { 0x7f, 5, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
2646 /* The LI field in an I form instruction. The lower two bits are
2649 { 0x3fffffc, 0, NULL
, NULL
, PPC_OPERAND_RELATIVE
| PPC_OPERAND_SIGNED
},
2651 /* The LI field in an I form instruction when used as an absolute
2654 { 0x3fffffc, 0, NULL
, NULL
, PPC_OPERAND_ABSOLUTE
| PPC_OPERAND_SIGNED
},
2656 /* The 3-bit L field in a sync or dcbf instruction. */
2659 { 0x7, 21, insert_ls
, extract_ls
, PPC_OPERAND_OPTIONAL
},
2661 /* The ME field in an M form instruction. */
2663 #define ME_MASK (0x1f << 1)
2664 { 0x1f, 1, NULL
, NULL
, 0 },
2666 /* The MB and ME fields in an M form instruction expressed a single
2667 operand which is a bitmask indicating which bits to select. This
2668 is a two operand form using PPC_OPERAND_NEXT. See the
2669 description in opcode/ppc.h for what this means. */
2671 { 0x1f, 6, NULL
, NULL
, PPC_OPERAND_OPTIONAL
| PPC_OPERAND_NEXT
},
2672 { -1, 0, insert_mbe
, extract_mbe
, 0 },
2674 /* The MB or ME field in an MD or MDS form instruction. The high
2675 bit is wrapped to the low end. */
2678 #define MB6_MASK (0x3f << 5)
2679 { 0x3f, 5, insert_mb6
, extract_mb6
, 0 },
2681 /* The NB field in an X form instruction. The value 32 is stored as
2684 { 0x1f, 11, NULL
, extract_nb
, PPC_OPERAND_PLUS1
},
2686 /* The NBI field in an lswi instruction, which has special value
2687 restrictions. The value 32 is stored as 0. */
2689 { 0x1f, 11, insert_nbi
, extract_nb
, PPC_OPERAND_PLUS1
},
2691 /* The NSI field in a D form instruction. This is the same as the
2692 SI field, only negated. */
2694 { 0xffff, 0, insert_nsi
, extract_nsi
,
2695 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
},
2697 /* The NSI field in a D form instruction when we accept a wide range
2698 of positive values. */
2699 #define NSISIGNOPT NSI + 1
2700 { 0xffff, 0, insert_nsi
, extract_nsi
,
2701 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
2703 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */
2704 #define RA NSISIGNOPT + 1
2705 #define RA_MASK (0x1f << 16)
2706 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_GPR
},
2708 /* As above, but 0 in the RA field means zero, not r0. */
2710 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_GPR_0
},
2712 /* Similar to above, but optional. */
2713 #define PRA0 RA0 + 1
2714 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_GPR_0
| PPC_OPERAND_OPTIONAL
},
2716 /* The RA field in the DQ form lq or an lswx instruction, which have
2717 special value restrictions. */
2718 #define RAQ PRA0 + 1
2720 { 0x1f, 16, insert_raq
, extract_raq
, PPC_OPERAND_GPR_0
},
2722 /* Similar to above, but optional. */
2723 #define PRAQ RAQ + 1
2724 { 0x1f, 16, insert_raq
, extract_raq
,
2725 PPC_OPERAND_GPR_0
| PPC_OPERAND_OPTIONAL
},
2727 /* The R field in an 8-byte D, DS, DQ or X form prefix instruction. */
2728 #define PCREL PRAQ + 1
2729 #define PCREL_MASK (1ULL << 52)
2730 { 0x1, 52, insert_pcrel
, extract_pcrel
, PPC_OPERAND_OPTIONAL
},
2732 #define PCREL0 PCREL + 1
2733 { 0x1, 52, insert_pcrel
, extract_pcrel0
, PPC_OPERAND_OPTIONAL
},
2735 /* The RA field in a D or X form instruction which is an updating
2736 load, which means that the RA field may not be zero and may not
2737 equal the RT field. */
2738 #define RAL PCREL0 + 1
2739 { 0x1f, 16, insert_ral
, extract_ral
, PPC_OPERAND_GPR_0
},
2741 /* The RA field in an lmw instruction, which has special value
2744 { 0x1f, 16, insert_ram
, extract_ram
, PPC_OPERAND_GPR_0
},
2746 /* The RA field in a D or X form instruction which is an updating
2747 store or an updating floating point load, which means that the RA
2748 field may not be zero. */
2750 { 0x1f, 16, insert_ras
, extract_ras
, PPC_OPERAND_GPR_0
},
2752 /* The RA field of the tlbwe, dccci and iccci instructions,
2753 which are optional. */
2754 #define RAOPT RAS + 1
2755 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_GPR
| PPC_OPERAND_OPTIONAL
},
2757 /* The RB field in an X, XO, M, or MDS form instruction. */
2758 #define RB RAOPT + 1
2759 #define RB_MASK (0x1f << 11)
2760 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_GPR
},
2762 /* The RS and RB fields in an X form instruction when they must be the same.
2763 This is used for extended mnemonics like mr. */
2765 { 0x1f, 11, insert_rsb
, extract_rsb
, PPC_OPERAND_GPR
},
2767 /* The RB field in an lswx instruction, which has special value
2770 { 0x1f, 11, insert_rbx
, extract_rbx
, PPC_OPERAND_GPR
},
2772 /* The RB field of the dccci and iccci instructions, which are optional. */
2773 #define RBOPT RBX + 1
2774 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_GPR
| PPC_OPERAND_OPTIONAL
},
2776 /* The RC register field in an maddld, maddhd or maddhdu instruction. */
2777 #define RC RBOPT + 1
2778 { 0x1f, 6, NULL
, NULL
, PPC_OPERAND_GPR
},
2780 /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form
2781 instruction or the RT field in a D, DS, X, XFX or XO form
2785 #define RT_MASK (0x1f << 21)
2787 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_GPR
},
2789 #define RD_EVEN RS + 1
2790 #define RS_EVEN RD_EVEN
2791 { 0x1f, 21, insert_rD_rS_even
, extract_rD_rS_even
, PPC_OPERAND_GPR
},
2793 /* The RS and RT fields of the DS form stq and DQ form lq instructions,
2794 which have special value restrictions. */
2795 #define RSQ RS_EVEN + 1
2797 #define Q_MASK (1 << 21)
2798 { 0x1e, 21, NULL
, NULL
, PPC_OPERAND_GPR
},
2800 /* The RS field of the tlbwe instruction, which is optional. */
2803 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_GPR
| PPC_OPERAND_OPTIONAL
},
2805 /* The RX field of the SE_RR form instruction. */
2807 { 0x1f, PPC_OPSHIFT_INV
, insert_rx
, extract_rx
, PPC_OPERAND_GPR
},
2809 /* The ARX field of the SE_RR form instruction. */
2811 { 0x1f, PPC_OPSHIFT_INV
, insert_arx
, extract_arx
, PPC_OPERAND_GPR
},
2813 /* The RY field of the SE_RR form instruction. */
2816 { 0x1f, PPC_OPSHIFT_INV
, insert_ry
, extract_ry
, PPC_OPERAND_GPR
},
2818 /* The ARY field of the SE_RR form instruction. */
2820 { 0x1f, PPC_OPSHIFT_INV
, insert_ary
, extract_ary
, PPC_OPERAND_GPR
},
2822 /* The SCLSCI8 field in a D form instruction. */
2823 #define SCLSCI8 ARY + 1
2824 { 0xffffffff, PPC_OPSHIFT_INV
, insert_sci8
, extract_sci8
, 0 },
2826 /* The SCLSCI8N field in a D form instruction. This is the same as the
2827 SCLSCI8 field, only negated. */
2828 #define SCLSCI8N SCLSCI8 + 1
2829 { 0xffffffff, PPC_OPSHIFT_INV
, insert_sci8n
, extract_sci8n
,
2830 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
},
2832 /* The SD field of the SD4 form instruction. */
2833 #define SE_SD SCLSCI8N + 1
2834 { 0xf, 8, NULL
, NULL
, PPC_OPERAND_PARENS
},
2836 /* The SD field of the SD4 form instruction, for halfword. */
2837 #define SE_SDH SE_SD + 1
2838 { 0x1e, 7, NULL
, NULL
, PPC_OPERAND_PARENS
},
2840 /* The SD field of the SD4 form instruction, for word. */
2841 #define SE_SDW SE_SDH + 1
2842 { 0x3c, 6, NULL
, NULL
, PPC_OPERAND_PARENS
},
2844 /* The SH field in an X or M form instruction. */
2845 #define SH SE_SDW + 1
2846 #define SH_MASK (0x1f << 11)
2847 /* The other UIMM field in a EVX form instruction. */
2849 /* The FC field in an atomic X form instruction. */
2852 { 0x1f, 11, NULL
, NULL
, 0 },
2854 #define EVUIMM_LT8 SH + 1
2855 { 0x1f, 11, insert_evuimm_lt8
, extract_evuimm_lt8
, 0 },
2857 #define EVUIMM_LT16 EVUIMM_LT8 + 1
2858 { 0x1f, 11, insert_evuimm_lt16
, extract_evuimm_lt16
, 0 },
2860 /* The SI field in a HTM X form instruction. */
2861 #define HTM_SI EVUIMM_LT16 + 1
2862 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_SIGNED
},
2864 /* The SH field in an MD form instruction. This is split. */
2865 #define SH6 HTM_SI + 1
2866 #define SH6_MASK ((0x1f << 11) | (1 << 1))
2867 { 0x3f, PPC_OPSHIFT_INV
, insert_sh6
, extract_sh6
, 0 },
2869 /* The SH field of some variants of the tlbre and tlbwe
2870 instructions, and the ELEV field of the e_sc instruction. */
2873 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
2875 /* The SI field in a D form instruction. */
2877 { 0xffff, 0, NULL
, NULL
, PPC_OPERAND_SIGNED
},
2879 /* The SI field in a D form instruction when we accept a wide range
2880 of positive values. */
2881 #define SISIGNOPT SI + 1
2882 { 0xffff, 0, NULL
, NULL
, PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
2884 /* The SI8 field in a D form instruction. */
2885 #define SI8 SISIGNOPT + 1
2886 { 0xff, 0, NULL
, NULL
, PPC_OPERAND_SIGNED
},
2888 /* The SPR field in an XFX form instruction. This is flipped--the
2889 lower 5 bits are stored in the upper 5 and vice- versa. */
2893 #define SPR_MASK (0x3ff << 11)
2894 { 0x3ff, 11, insert_spr
, extract_spr
, PPC_OPERAND_SPR
},
2896 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */
2897 #define SPRBAT SPR + 1
2898 #define SPRBAT_MASK (0xc1 << 11)
2899 { 0x7, PPC_OPSHIFT_INV
, insert_sprbat
, extract_sprbat
, PPC_OPERAND_SPR
},
2901 /* The GQR index number in an XFX form m[ft]gqr instruction. */
2902 #define SPRGQR SPRBAT + 1
2903 #define SPRGQR_MASK (0x7 << 16)
2904 { 0x7, 16, NULL
, NULL
, PPC_OPERAND_GQR
},
2906 /* The SPRG register number in an XFX form m[ft]sprg instruction. */
2907 #define SPRG SPRGQR + 1
2908 { 0x1f, 16, insert_sprg
, extract_sprg
, PPC_OPERAND_SPR
},
2910 /* The SR field in an X form instruction. */
2912 /* The 4-bit UIMM field in a VX form instruction. */
2914 { 0xf, 16, NULL
, NULL
, 0 },
2916 /* The STRM field in an X AltiVec form instruction. */
2918 /* The T field in a tlbilx form instruction. */
2920 /* The L field in wclr instructions. */
2922 { 0x3, 21, NULL
, NULL
, 0 },
2924 /* The ESYNC field in an X (sync) form instruction. */
2925 #define ESYNC STRM + 1
2926 { 0xf, 16, insert_esync
, extract_esync
, PPC_OPERAND_OPTIONAL
},
2928 /* The SV field in a POWER SC form instruction. */
2929 #define SV ESYNC + 1
2930 { 0x3fff, 2, NULL
, NULL
, 0 },
2932 /* The TBR field in an XFX form instruction. This is like the SPR
2933 field, but it is optional. */
2935 { 0x3ff, 11, insert_tbr
, extract_tbr
,
2936 PPC_OPERAND_SPR
| PPC_OPERAND_OPTIONAL
},
2938 /* The TO field in a D or X form instruction. */
2941 #define TO_MASK (0x1f << 21)
2942 { 0x1f, 21, NULL
, NULL
, 0 },
2944 /* The UI field in a D form instruction. */
2946 { 0xffff, 0, NULL
, NULL
, 0 },
2948 #define UISIGNOPT UI + 1
2949 { 0xffff, 0, NULL
, NULL
, PPC_OPERAND_SIGNOPT
},
2951 /* The IMM field in an SE_IM5 instruction. */
2952 #define UI5 UISIGNOPT + 1
2953 { 0x1f, 4, NULL
, NULL
, 0 },
2955 /* The OIMM field in an SE_OIM5 instruction. */
2956 #define OIMM5 UI5 + 1
2957 { 0x1f, 4, insert_oimm
, extract_oimm
, PPC_OPERAND_PLUS1
},
2959 /* The UI7 field in an SE_LI instruction. */
2960 #define UI7 OIMM5 + 1
2961 { 0x7f, 4, NULL
, NULL
, 0 },
2963 /* The VA field in a VA, VX or VXR form instruction. */
2965 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_VR
},
2967 /* The VB field in a VA, VX or VXR form instruction. */
2969 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_VR
},
2971 /* The VC field in a VA form instruction. */
2973 { 0x1f, 6, NULL
, NULL
, PPC_OPERAND_VR
},
2975 /* The VD or VS field in a VA, VX, VXR or X form instruction. */
2978 { 0x1f, 21, NULL
, NULL
, PPC_OPERAND_VR
},
2980 /* The SIMM field in a VX form instruction, and TE in Z form. */
2983 { 0x1f, 16, NULL
, NULL
, PPC_OPERAND_SIGNED
},
2985 /* The UIMM field in a VX form instruction. */
2986 #define UIMM SIMM + 1
2988 { 0x1f, 16, NULL
, NULL
, 0 },
2990 /* The 3-bit UIMM field in a VX form instruction. */
2991 #define UIMM3 UIMM + 1
2992 { 0x7, 16, NULL
, NULL
, 0 },
2994 /* The 6-bit UIM field in a X form instruction. */
2995 #define UIM6 UIMM3 + 1
2996 { 0x3f, 16, NULL
, NULL
, 0 },
2998 /* The SIX field in a VX form instruction. */
2999 #define SIX UIM6 + 1
3001 { 0xf, 11, NULL
, NULL
, 0 },
3003 /* The PS field in a VX form instruction. */
3005 { 0x1, 9, NULL
, NULL
, 0 },
3007 /* The SH field in a vector shift double by bit immediate instruction. */
3009 { 0x7, 6, NULL
, NULL
, 0 },
3011 /* The SHB field in a VA form instruction. */
3013 { 0xf, 6, NULL
, NULL
, 0 },
3015 /* The other UIMM field in a half word EVX form instruction. */
3016 #define EVUIMM_1 SHB + 1
3017 { 0x1f, 11, NULL
, NULL
, PPC_OPERAND_PARENS
},
3019 #define EVUIMM_1_EX0 EVUIMM_1 + 1
3020 { 0x1f, 11, insert_evuimm1_ex0
, extract_evuimm1_ex0
, PPC_OPERAND_PARENS
},
3022 #define EVUIMM_2 EVUIMM_1_EX0 + 1
3023 { 0x3e, 10, NULL
, NULL
, PPC_OPERAND_PARENS
},
3025 #define EVUIMM_2_EX0 EVUIMM_2 + 1
3026 { 0x3e, 10, insert_evuimm2_ex0
, extract_evuimm2_ex0
, PPC_OPERAND_PARENS
},
3028 /* The other UIMM field in a word EVX form instruction. */
3029 #define EVUIMM_4 EVUIMM_2_EX0 + 1
3030 { 0x7c, 9, NULL
, NULL
, PPC_OPERAND_PARENS
},
3032 #define EVUIMM_4_EX0 EVUIMM_4 + 1
3033 { 0x7c, 9, insert_evuimm4_ex0
, extract_evuimm4_ex0
, PPC_OPERAND_PARENS
},
3035 /* The other UIMM field in a double EVX form instruction. */
3036 #define EVUIMM_8 EVUIMM_4_EX0 + 1
3037 { 0xf8, 8, NULL
, NULL
, PPC_OPERAND_PARENS
},
3039 #define EVUIMM_8_EX0 EVUIMM_8 + 1
3040 { 0xf8, 8, insert_evuimm8_ex0
, extract_evuimm8_ex0
, PPC_OPERAND_PARENS
},
3042 /* The WS or DRM field in an X form instruction. */
3043 #define WS EVUIMM_8_EX0 + 1
3045 /* The NNN field in a VX form instruction for SPE2 */
3047 { 0x7, 11, NULL
, NULL
, 0 },
3049 /* PowerPC paired singles extensions. */
3050 /* W bit in the pair singles instructions for x type instructions. */
3052 /* The BO16 field in a BD8 form instruction. */
3054 { 0x1, 10, 0, 0, 0 },
3056 /* IDX bits for quantization in the pair singles instructions. */
3057 #define PSQ PSWM + 1
3058 { 0x7, 12, 0, 0, PPC_OPERAND_GQR
},
3060 /* IDX bits for quantization in the pair singles x-type instructions. */
3061 #define PSQM PSQ + 1
3062 { 0x7, 7, 0, 0, PPC_OPERAND_GQR
},
3064 /* Smaller D field for quantization in the pair singles instructions. */
3065 #define PSD PSQM + 1
3066 { 0xfff, 0, 0, 0, PPC_OPERAND_PARENS
| PPC_OPERAND_SIGNED
},
3068 /* The L field in an mtmsrd or A form instruction or R or W in an
3073 { 0x1, 16, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3075 /* The RMC or CY field in a Z23 form instruction. */
3078 { 0x3, 9, NULL
, NULL
, 0 },
3082 { 0x1, 16, NULL
, NULL
, 0 },
3085 { 0x3, 18, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3088 { 0x1, 17, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3091 { 0x3, 19, NULL
, NULL
, 0 },
3094 { 0x1, 20, NULL
, NULL
, 0 },
3096 /* The S field in a XL form instruction. */
3098 { 0x1, 11, insert_sxl
, extract_sxl
, PPC_OPERAND_OPTIONAL
},
3100 /* SH field starting at bit position 16. */
3101 #define SH16 SXL + 1
3102 /* The DCM and DGM fields in a Z form instruction. */
3105 { 0x3f, 10, NULL
, NULL
, 0 },
3107 /* The EH field in larx instruction. */
3109 { 0x1, 0, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3111 /* The L field in an mtfsf or XFL form instruction. */
3112 /* The A field in a HTM X form instruction. */
3113 #define XFL_L EH + 1
3115 { 0x1, 25, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3117 /* Xilinx APU related masks and macros */
3118 #define FCRT XFL_L + 1
3119 #define FCRT_MASK (0x1f << 21)
3120 { 0x1f, 21, 0, 0, PPC_OPERAND_FCR
},
3122 /* Xilinx FSL related masks and macros */
3123 #define FSL FCRT + 1
3124 #define FSL_MASK (0x1f << 11)
3125 { 0x1f, 11, 0, 0, PPC_OPERAND_FSL
},
3127 /* Xilinx UDI related masks and macros */
3129 { 0x1f, 21, 0, 0, PPC_OPERAND_UDI
},
3132 { 0x1f, 16, 0, 0, PPC_OPERAND_UDI
},
3135 { 0x1f, 11, 0, 0, PPC_OPERAND_UDI
},
3138 { 0x1f, 6, 0, 0, PPC_OPERAND_UDI
},
3140 /* The VLESIMM field in a D form instruction. */
3141 #define VLESIMM URC + 1
3142 { 0xffff, PPC_OPSHIFT_INV
, insert_vlesi
, extract_vlesi
,
3143 PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
3145 /* The VLENSIMM field in a D form instruction. */
3146 #define VLENSIMM VLESIMM + 1
3147 { 0xffff, PPC_OPSHIFT_INV
, insert_vlensi
, extract_vlensi
,
3148 PPC_OPERAND_NEGATIVE
| PPC_OPERAND_SIGNED
| PPC_OPERAND_SIGNOPT
},
3150 /* The VLEUIMM field in a D form instruction. */
3151 #define VLEUIMM VLENSIMM + 1
3152 { 0xffff, PPC_OPSHIFT_INV
, insert_vleui
, extract_vleui
, 0 },
3154 /* The VLEUIMML field in a D form instruction. */
3155 #define VLEUIMML VLEUIMM + 1
3156 { 0xffff, PPC_OPSHIFT_INV
, insert_vleil
, extract_vleil
, 0 },
3158 /* The XT and XS fields in an XX1 or XX3 form instruction. This is
3160 #define XS6 VLEUIMML + 1
3162 { 0x3f, PPC_OPSHIFT_INV
, insert_xt6
, extract_xt6
, PPC_OPERAND_VSR
},
3164 /* The XT and XS fields in an DQ form VSX instruction. This is split. */
3165 #define XSQ6 XT6 + 1
3167 { 0x3f, PPC_OPSHIFT_INV
, insert_xtq6
, extract_xtq6
, PPC_OPERAND_VSR
},
3169 /* The split XTp field in a vector paired instruction. */
3170 #define XTP XSQ6 + 1
3171 { 0x3e, PPC_OPSHIFT_INV
, insert_xtp
, extract_xtp
, PPC_OPERAND_VSR
},
3174 { 0x3f, PPC_OPSHIFT_INV
, insert_xts
, extract_xts
, PPC_OPERAND_VSR
},
3176 /* The XT field in a plxv instruction. Runs into the OP field. */
3177 #define XTOP XTS + 1
3178 { 0x3f, 21, NULL
, NULL
, PPC_OPERAND_VSR
},
3180 /* The XA field in an XX3 form instruction. This is split. */
3181 #define XA6 XTOP + 1
3182 { 0x3f, PPC_OPSHIFT_INV
, insert_xa6
, extract_xa6
, PPC_OPERAND_VSR
},
3184 /* The XA field in an MMA XX3 form instruction. This is split and
3185 must not overlap with the ACC operand. */
3186 #define XA6a XA6 + 1
3187 { 0x3f, PPC_OPSHIFT_INV
, insert_xa6a
, extract_xa6a
, PPC_OPERAND_VSR
},
3189 /* The XAp field in an MMA XX3 form instruction. This is split.
3190 This is like XA6a, but must be even. */
3191 #define XA6ap XA6a + 1
3192 { 0x3e, PPC_OPSHIFT_INV
, insert_xa6a
, extract_xa6a
, PPC_OPERAND_VSR
},
3194 /* The XB field in an XX2 or XX3 form instruction. This is split. */
3195 #define XB6 XA6ap + 1
3196 { 0x3f, PPC_OPSHIFT_INV
, insert_xb6
, extract_xb6
, PPC_OPERAND_VSR
},
3198 /* The XB field in an XX3 form instruction. This is split and
3199 must not overlap with the ACC operand. */
3200 #define XB6a XB6 + 1
3201 { 0x3f, PPC_OPSHIFT_INV
, insert_xb6a
, extract_xb6a
, PPC_OPERAND_VSR
},
3203 /* The XA and XB fields in an XX3 form instruction when they must be the same.
3204 This is used in extended mnemonics like xvmovdp. This is split. */
3205 #define XAB6 XB6a + 1
3206 { 0x3f, PPC_OPSHIFT_INV
, insert_xab6
, extract_xab6
, PPC_OPERAND_VSR
},
3208 /* The XC field in an XX4 form instruction. This is split. */
3209 #define XC6 XAB6 + 1
3210 { 0x3f, PPC_OPSHIFT_INV
, insert_xc6
, extract_xc6
, PPC_OPERAND_VSR
},
3212 /* The DM or SHW field in an XX3 form instruction. */
3215 { 0x3, 8, NULL
, NULL
, 0 },
3217 /* The DM field in an extended mnemonic XX3 form instruction. */
3219 { 0x3, 8, insert_dm
, extract_dm
, 0 },
3221 /* The UIM field in an XX2 form instruction. */
3222 #define UIM DMEX + 1
3223 /* The 2-bit UIMM field in a VX form instruction. */
3225 /* The 2-bit L field in a darn instruction. */
3227 { 0x3, 16, NULL
, NULL
, 0 },
3229 #define ERAT_T UIM + 1
3230 { 0x7, 21, NULL
, NULL
, 0 },
3232 #define IH ERAT_T + 1
3233 { 0x7, 21, NULL
, NULL
, PPC_OPERAND_OPTIONAL
},
3235 /* The 2-bit SC or PL field in an X form instruction. */
3238 { 0x3, 16, insert_pl
, extract_pl
, PPC_OPERAND_OPTIONAL
},
3240 /* The 8-bit IMM8 field in a XX1 form instruction. */
3241 #define IMM8 SC2 + 1
3242 { 0xff, 11, NULL
, NULL
, PPC_OPERAND_SIGNOPT
},
3244 #define VX_OFF IMM8 + 1
3245 { 0x3, 0, insert_off_lsp
, extract_off_lsp
, 0 },
3247 #define VX_OFF_SPE2 VX_OFF + 1
3248 { 0x7, 0, insert_off_spe2
, extract_off_spe2
, 0 },
3250 #define BBB VX_OFF_SPE2 + 1
3251 { 0x7, 13, NULL
, NULL
, 0 },
3254 #define VX_MASK_DDD (VX_MASK & ~0x1)
3255 { 0x7, PPC_OPSHIFT_INV
, insert_Ddd
, extract_Ddd
, 0 },
3258 { 0x3, 13, NULL
, NULL
, 0 },
3261 const unsigned int num_powerpc_operands
= (sizeof (powerpc_operands
)
3262 / sizeof (powerpc_operands
[0]));
3264 /* Macros used to form opcodes. */
3266 /* The main opcode. */
3267 #define OP(x) ((((uint64_t)(x)) & 0x3f) << 26)
3268 #define OP_MASK OP (0x3f)
3270 /* The prefix opcode. */
3271 #define PREFIX_OP (1ULL << 58)
3273 /* The 2-bit prefix form. */
3274 #define PREFIX_FORM(x) ((x & 3ULL) << 56)
3276 #define SUFFIX_MASK ((1ULL << 32) - 1)
3277 #define PREFIX_MASK (SUFFIX_MASK << 32)
3279 /* Prefix insn, eight byte load/store form 8LS. */
3280 #define P8LS (PREFIX_OP | PREFIX_FORM (0))
3282 /* Prefix insn, eight byte register to register form 8RR. */
3283 #define P8RR (PREFIX_OP | PREFIX_FORM (1))
3285 /* Prefix insn, modified load/store form MLS. */
3286 #define PMLS (PREFIX_OP | PREFIX_FORM (2))
3288 /* Prefix insn, modified register to register form MRR. */
3289 #define PMRR (PREFIX_OP | PREFIX_FORM (3))
3291 /* Prefix insn, modified masked immediate register to register form MMIRR. */
3292 #define PMMIRR (PREFIX_OP | PREFIX_FORM (3) | (9ULL << 52))
3294 /* An 8-byte D form prefix instruction. */
3295 #define P_D_MASK (((-1ULL << 50) & ~PCREL_MASK) | OP_MASK)
3297 /* The same as P_D_MASK, but with the RA and PCREL fields specified. */
3298 #define P_DRAPCREL_MASK (P_D_MASK | PCREL_MASK | RA_MASK)
3300 /* Mask for prefix X form instructions. */
3301 #define P_X_MASK (PREFIX_MASK | X_MASK)
3302 #define P_XX1_MASK (PREFIX_MASK | XX1_MASK)
3304 /* Mask for prefix vector permute insns. */
3305 #define P_XX4_MASK (PREFIX_MASK | XX4_MASK)
3306 #define P_UXX4_MASK (P_XX4_MASK & ~(7ULL << 32))
3307 #define P_U8XX4_MASK (P_XX4_MASK & ~(0xffULL << 32))
3309 /* MMIRR:XX3-form 8-byte outer product instructions. */
3310 #define P_GER_MASK ((-1ULL << 40) | XX3_MASK | (3 << 21) | 1)
3311 #define P_GER2_MASK (P_GER_MASK & ~(3ULL << 46))
3312 #define P_GER4_MASK (P_GER_MASK & ~(15ULL << 44))
3313 #define P_GER8_MASK (P_GER_MASK & ~(255ULL << 40))
3314 #define P_GER64_MASK (P_GER_MASK | (3ULL << 32))
3316 /* Vector splat immediate op. */
3317 #define VSOP(op, xop) (OP (op) | (xop << 17))
3318 #define P_VS_MASK ((-1ULL << 48) | VSOP (0x3f, 0xf))
3319 #define P_VSI_MASK ((-1ULL << 48) | VSOP (0x3f, 0xe))
3321 /* The main opcode combined with a trap code in the TO field of a D
3322 form instruction. Used for extended mnemonics for the trap
3324 #define OPTO(x,to) (OP (x) | ((((uint64_t)(to)) & 0x1f) << 21))
3325 #define OPTO_MASK (OP_MASK | TO_MASK)
3327 /* The main opcode combined with a comparison size bit in the L field
3328 of a D form or X form instruction. Used for extended mnemonics for
3329 the comparison instructions. */
3330 #define OPL(x,l) (OP (x) | ((((uint64_t)(l)) & 1) << 21))
3331 #define OPL_MASK OPL (0x3f,1)
3333 /* The main opcode combined with an update code in D form instruction.
3334 Used for extended mnemonics for VLE memory instructions. */
3335 #define OPVUP(x,vup) (OP (x) | ((((uint64_t)(vup)) & 0xff) << 8))
3336 #define OPVUP_MASK OPVUP (0x3f, 0xff)
3338 /* The main opcode combined with an update code and the RT fields
3339 specified in D form instruction. Used for VLE volatile context
3340 save/restore instructions. */
3341 #define OPVUPRT(x,vup,rt) \
3343 | ((((uint64_t)(rt)) & 0x1f) << 21))
3344 #define OPVUPRT_MASK OPVUPRT (0x3f, 0xff, 0x1f)
3346 /* An A form instruction. */
3347 #define A(op, xop, rc) \
3349 | ((((uint64_t)(xop)) & 0x1f) << 1) \
3350 | (((uint64_t)(rc)) & 1))
3351 #define A_MASK A (0x3f, 0x1f, 1)
3353 /* An A_MASK with the FRB field fixed. */
3354 #define AFRB_MASK (A_MASK | FRB_MASK)
3356 /* An A_MASK with the FRC field fixed. */
3357 #define AFRC_MASK (A_MASK | FRC_MASK)
3359 /* An A_MASK with the FRA and FRC fields fixed. */
3360 #define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK)
3362 /* An AFRAFRC_MASK, but with L bit clear. */
3363 #define AFRALFRC_MASK (AFRAFRC_MASK & ~((uint64_t) 1 << 16))
3365 /* A B form instruction. */
3366 #define B(op, aa, lk) \
3368 | ((((uint64_t)(aa)) & 1) << 1) \
3370 #define B_MASK B (0x3f, 1, 1)
3372 /* A BD8 form instruction. This is a 16-bit instruction. */
3373 #define BD8(op, aa, lk) \
3374 (((((uint64_t)(op)) & 0x3f) << 10) \
3375 | (((aa) & 1) << 9) \
3376 | (((lk) & 1) << 8))
3377 #define BD8_MASK BD8 (0x3f, 1, 1)
3379 /* Another BD8 form instruction. This is a 16-bit instruction. */
3380 #define BD8IO(op) ((((uint64_t)(op)) & 0x1f) << 11)
3381 #define BD8IO_MASK BD8IO (0x1f)
3383 /* A BD8 form instruction for simplified mnemonics. */
3384 #define EBD8IO(op, bo, bi) (BD8IO ((op)) | ((bo) << 10) | ((bi) << 8))
3385 /* A mask that excludes BO32 and BI32. */
3386 #define EBD8IO1_MASK 0xf800
3387 /* A mask that includes BO32 and excludes BI32. */
3388 #define EBD8IO2_MASK 0xfc00
3389 /* A mask that include BO32 AND BI32. */
3390 #define EBD8IO3_MASK 0xff00
3392 /* A BD15 form instruction. */
3393 #define BD15(op, aa, lk) \
3395 | ((((uint64_t)(aa)) & 0xf) << 22) \
3397 #define BD15_MASK BD15 (0x3f, 0xf, 1)
3399 /* A BD15 form instruction for extended conditional branch mnemonics. */
3400 #define EBD15(op, aa, bo, lk) \
3401 (((op) & 0x3fu) << 26) \
3402 | (((aa) & 0xf) << 22) \
3403 | (((bo) & 0x3) << 20) \
3405 #define EBD15_MASK 0xfff00001
3407 /* A BD15 form instruction for extended conditional branch mnemonics
3409 #define EBD15BI(op, aa, bo, bi, lk) \
3410 ((((op) & 0x3fu) << 26) \
3411 | (((aa) & 0xf) << 22) \