1 /* TILEPro opcode information.
3 * Copyright (C) 2011-2024 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 #ifndef opcode_tilepro_h
22 #define opcode_tilepro_h
24 typedef unsigned long long tilepro_bundle_bits
;
29 TILEPRO_MAX_OPERANDS
= 5 /* mm */
40 TILEPRO_OPC_LW_TLS_SN
,
46 TILEPRO_OPC_MOVELI_SN
,
55 TILEPRO_OPC_ADDBS_U_SN
,
72 TILEPRO_OPC_ADIFFB_U_SN
,
74 TILEPRO_OPC_ADIFFH_SN
,
81 TILEPRO_OPC_AVGB_U_SN
,
105 TILEPRO_OPC_BLEZT_SN
,
115 TILEPRO_OPC_BYTEX_SN
,
122 TILEPRO_OPC_CRC32_32
,
123 TILEPRO_OPC_CRC32_32_SN
,
125 TILEPRO_OPC_CRC32_8_SN
,
130 TILEPRO_OPC_DWORD_ALIGN
,
131 TILEPRO_OPC_DWORD_ALIGN_SN
,
138 TILEPRO_OPC_INTHB_SN
,
140 TILEPRO_OPC_INTHH_SN
,
142 TILEPRO_OPC_INTLB_SN
,
144 TILEPRO_OPC_INTLH_SN
,
160 TILEPRO_OPC_LBADD_SN
,
162 TILEPRO_OPC_LBADD_U_SN
,
168 TILEPRO_OPC_LHADD_SN
,
170 TILEPRO_OPC_LHADD_U_SN
,
176 TILEPRO_OPC_LW_NA_SN
,
178 TILEPRO_OPC_LWADD_SN
,
179 TILEPRO_OPC_LWADD_NA
,
180 TILEPRO_OPC_LWADD_NA_SN
,
182 TILEPRO_OPC_MAXB_U_SN
,
186 TILEPRO_OPC_MAXIB_U_SN
,
188 TILEPRO_OPC_MAXIH_SN
,
192 TILEPRO_OPC_MINB_U_SN
,
196 TILEPRO_OPC_MINIB_U_SN
,
198 TILEPRO_OPC_MINIH_SN
,
207 TILEPRO_OPC_MULHH_SS
,
208 TILEPRO_OPC_MULHH_SS_SN
,
209 TILEPRO_OPC_MULHH_SU
,
210 TILEPRO_OPC_MULHH_SU_SN
,
211 TILEPRO_OPC_MULHH_UU
,
212 TILEPRO_OPC_MULHH_UU_SN
,
213 TILEPRO_OPC_MULHHA_SS
,
214 TILEPRO_OPC_MULHHA_SS_SN
,
215 TILEPRO_OPC_MULHHA_SU
,
216 TILEPRO_OPC_MULHHA_SU_SN
,
217 TILEPRO_OPC_MULHHA_UU
,
218 TILEPRO_OPC_MULHHA_UU_SN
,
219 TILEPRO_OPC_MULHHSA_UU
,
220 TILEPRO_OPC_MULHHSA_UU_SN
,
221 TILEPRO_OPC_MULHL_SS
,
222 TILEPRO_OPC_MULHL_SS_SN
,
223 TILEPRO_OPC_MULHL_SU
,
224 TILEPRO_OPC_MULHL_SU_SN
,
225 TILEPRO_OPC_MULHL_US
,
226 TILEPRO_OPC_MULHL_US_SN
,
227 TILEPRO_OPC_MULHL_UU
,
228 TILEPRO_OPC_MULHL_UU_SN
,
229 TILEPRO_OPC_MULHLA_SS
,
230 TILEPRO_OPC_MULHLA_SS_SN
,
231 TILEPRO_OPC_MULHLA_SU
,
232 TILEPRO_OPC_MULHLA_SU_SN
,
233 TILEPRO_OPC_MULHLA_US
,
234 TILEPRO_OPC_MULHLA_US_SN
,
235 TILEPRO_OPC_MULHLA_UU
,
236 TILEPRO_OPC_MULHLA_UU_SN
,
237 TILEPRO_OPC_MULHLSA_UU
,
238 TILEPRO_OPC_MULHLSA_UU_SN
,
239 TILEPRO_OPC_MULLL_SS
,
240 TILEPRO_OPC_MULLL_SS_SN
,
241 TILEPRO_OPC_MULLL_SU
,
242 TILEPRO_OPC_MULLL_SU_SN
,
243 TILEPRO_OPC_MULLL_UU
,
244 TILEPRO_OPC_MULLL_UU_SN
,
245 TILEPRO_OPC_MULLLA_SS
,
246 TILEPRO_OPC_MULLLA_SS_SN
,
247 TILEPRO_OPC_MULLLA_SU
,
248 TILEPRO_OPC_MULLLA_SU_SN
,
249 TILEPRO_OPC_MULLLA_UU
,
250 TILEPRO_OPC_MULLLA_UU_SN
,
251 TILEPRO_OPC_MULLLSA_UU
,
252 TILEPRO_OPC_MULLLSA_UU_SN
,
271 TILEPRO_OPC_PACKBS_U
,
272 TILEPRO_OPC_PACKBS_U_SN
,
274 TILEPRO_OPC_PACKHB_SN
,
276 TILEPRO_OPC_PACKHS_SN
,
278 TILEPRO_OPC_PACKLB_SN
,
292 TILEPRO_OPC_SADAB_U_SN
,
294 TILEPRO_OPC_SADAH_SN
,
296 TILEPRO_OPC_SADAH_U_SN
,
298 TILEPRO_OPC_SADB_U_SN
,
302 TILEPRO_OPC_SADH_U_SN
,
314 TILEPRO_OPC_SEQIB_SN
,
316 TILEPRO_OPC_SEQIH_SN
,
328 TILEPRO_OPC_SHLIB_SN
,
330 TILEPRO_OPC_SHLIH_SN
,
340 TILEPRO_OPC_SHRIB_SN
,
342 TILEPRO_OPC_SHRIH_SN
,
346 TILEPRO_OPC_SLT_U_SN
,
350 TILEPRO_OPC_SLTB_U_SN
,
354 TILEPRO_OPC_SLTE_U_SN
,
356 TILEPRO_OPC_SLTEB_SN
,
358 TILEPRO_OPC_SLTEB_U_SN
,
360 TILEPRO_OPC_SLTEH_SN
,
362 TILEPRO_OPC_SLTEH_U_SN
,
366 TILEPRO_OPC_SLTH_U_SN
,
370 TILEPRO_OPC_SLTI_U_SN
,
372 TILEPRO_OPC_SLTIB_SN
,
374 TILEPRO_OPC_SLTIB_U_SN
,
376 TILEPRO_OPC_SLTIH_SN
,
378 TILEPRO_OPC_SLTIH_U_SN
,
394 TILEPRO_OPC_SRAIB_SN
,
396 TILEPRO_OPC_SRAIH_SN
,
402 TILEPRO_OPC_SUBBS_U_SN
,
406 TILEPRO_OPC_SUBHS_SN
,
415 TILEPRO_OPC_TBLIDXB0
,
416 TILEPRO_OPC_TBLIDXB0_SN
,
417 TILEPRO_OPC_TBLIDXB1
,
418 TILEPRO_OPC_TBLIDXB1_SN
,
419 TILEPRO_OPC_TBLIDXB2
,
420 TILEPRO_OPC_TBLIDXB2_SN
,
421 TILEPRO_OPC_TBLIDXB3
,
422 TILEPRO_OPC_TBLIDXB3_SN
,
433 /* 64-bit pattern for a { bpt ; nop } bundle. */
434 #define TILEPRO_BPT_BUNDLE 0x400b3cae70166000ULL
440 TILEPRO_SN_MAX_OPERANDS
= 6 /* route */
451 TILEPRO_SN_OPC_MOVEI
,
457 TILEPRO_SN_OPC_JALRR
,
463 TILEPRO_SN_OPC_SHL8II
,
466 TILEPRO_SN_OPC_ROUTE
,
468 } tilepro_sn_mnemonic
;
470 extern const unsigned char tilepro_sn_route_encode
[6 * 6 * 6];
471 extern const signed char tilepro_sn_route_decode
[256][3];
472 extern const char tilepro_sn_direction_names
[6][5];
473 extern const signed char tilepro_sn_dest_map
[6][6];
474 #endif /* DISASM_ONLY */
477 static __inline
unsigned int
478 get_BrOff_SN(tilepro_bundle_bits num
)
480 const unsigned int n
= (unsigned int)num
;
481 return (((n
>> 0)) & 0x3ff);
484 static __inline
unsigned int
485 get_BrOff_X1(tilepro_bundle_bits n
)
487 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
488 (((unsigned int)(n
>> 20)) & 0x00018000);
491 static __inline
unsigned int
492 get_BrType_X1(tilepro_bundle_bits n
)
494 return (((unsigned int)(n
>> 31)) & 0xf);
497 static __inline
unsigned int
498 get_Dest_Imm8_X1(tilepro_bundle_bits n
)
500 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
501 (((unsigned int)(n
>> 43)) & 0x000000c0);
504 static __inline
unsigned int
505 get_Dest_SN(tilepro_bundle_bits num
)
507 const unsigned int n
= (unsigned int)num
;
508 return (((n
>> 2)) & 0x3);
511 static __inline
unsigned int
512 get_Dest_X0(tilepro_bundle_bits num
)
514 const unsigned int n
= (unsigned int)num
;
515 return (((n
>> 0)) & 0x3f);
518 static __inline
unsigned int
519 get_Dest_X1(tilepro_bundle_bits n
)
521 return (((unsigned int)(n
>> 31)) & 0x3f);
524 static __inline
unsigned int
525 get_Dest_Y0(tilepro_bundle_bits num
)
527 const unsigned int n
= (unsigned int)num
;
528 return (((n
>> 0)) & 0x3f);
531 static __inline
unsigned int
532 get_Dest_Y1(tilepro_bundle_bits n
)
534 return (((unsigned int)(n
>> 31)) & 0x3f);
537 static __inline
unsigned int
538 get_Imm16_X0(tilepro_bundle_bits num
)
540 const unsigned int n
= (unsigned int)num
;
541 return (((n
>> 12)) & 0xffff);
544 static __inline
unsigned int
545 get_Imm16_X1(tilepro_bundle_bits n
)
547 return (((unsigned int)(n
>> 43)) & 0xffff);
550 static __inline
unsigned int
551 get_Imm8_SN(tilepro_bundle_bits num
)
553 const unsigned int n
= (unsigned int)num
;
554 return (((n
>> 0)) & 0xff);
557 static __inline
unsigned int
558 get_Imm8_X0(tilepro_bundle_bits num
)
560 const unsigned int n
= (unsigned int)num
;
561 return (((n
>> 12)) & 0xff);
564 static __inline
unsigned int
565 get_Imm8_X1(tilepro_bundle_bits n
)
567 return (((unsigned int)(n
>> 43)) & 0xff);
570 static __inline
unsigned int
571 get_Imm8_Y0(tilepro_bundle_bits num
)
573 const unsigned int n
= (unsigned int)num
;
574 return (((n
>> 12)) & 0xff);
577 static __inline
unsigned int
578 get_Imm8_Y1(tilepro_bundle_bits n
)
580 return (((unsigned int)(n
>> 43)) & 0xff);
583 static __inline
unsigned int
584 get_ImmOpcodeExtension_X0(tilepro_bundle_bits num
)
586 const unsigned int n
= (unsigned int)num
;
587 return (((n
>> 20)) & 0x7f);
590 static __inline
unsigned int
591 get_ImmOpcodeExtension_X1(tilepro_bundle_bits n
)
593 return (((unsigned int)(n
>> 51)) & 0x7f);
596 static __inline
unsigned int
597 get_ImmRROpcodeExtension_SN(tilepro_bundle_bits num
)
599 const unsigned int n
= (unsigned int)num
;
600 return (((n
>> 8)) & 0x3);
603 static __inline
unsigned int
604 get_JOffLong_X1(tilepro_bundle_bits n
)
606 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
607 (((unsigned int)(n
>> 20)) & 0x00018000) |
608 (((unsigned int)(n
>> 14)) & 0x001e0000) |
609 (((unsigned int)(n
>> 16)) & 0x07e00000) |
610 (((unsigned int)(n
>> 31)) & 0x18000000);
613 static __inline
unsigned int
614 get_JOff_X1(tilepro_bundle_bits n
)
616 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
617 (((unsigned int)(n
>> 20)) & 0x00018000) |
618 (((unsigned int)(n
>> 14)) & 0x001e0000) |
619 (((unsigned int)(n
>> 16)) & 0x07e00000) |
620 (((unsigned int)(n
>> 31)) & 0x08000000);
623 static __inline
unsigned int
624 get_MF_Imm15_X1(tilepro_bundle_bits n
)
626 return (((unsigned int)(n
>> 37)) & 0x00003fff) |
627 (((unsigned int)(n
>> 44)) & 0x00004000);
630 static __inline
unsigned int
631 get_MMEnd_X0(tilepro_bundle_bits num
)
633 const unsigned int n
= (unsigned int)num
;
634 return (((n
>> 18)) & 0x1f);
637 static __inline
unsigned int
638 get_MMEnd_X1(tilepro_bundle_bits n
)
640 return (((unsigned int)(n
>> 49)) & 0x1f);
643 static __inline
unsigned int
644 get_MMStart_X0(tilepro_bundle_bits num
)
646 const unsigned int n
= (unsigned int)num
;
647 return (((n
>> 23)) & 0x1f);
650 static __inline
unsigned int
651 get_MMStart_X1(tilepro_bundle_bits n
)
653 return (((unsigned int)(n
>> 54)) & 0x1f);
656 static __inline
unsigned int
657 get_MT_Imm15_X1(tilepro_bundle_bits n
)
659 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
660 (((unsigned int)(n
>> 37)) & 0x00003fc0) |
661 (((unsigned int)(n
>> 44)) & 0x00004000);
664 static __inline
unsigned int
665 get_Mode(tilepro_bundle_bits n
)
667 return (((unsigned int)(n
>> 63)) & 0x1);
670 static __inline
unsigned int
671 get_NoRegOpcodeExtension_SN(tilepro_bundle_bits num
)
673 const unsigned int n
= (unsigned int)num
;
674 return (((n
>> 0)) & 0xf);
677 static __inline
unsigned int
678 get_Opcode_SN(tilepro_bundle_bits num
)
680 const unsigned int n
= (unsigned int)num
;
681 return (((n
>> 10)) & 0x3f);
684 static __inline
unsigned int
685 get_Opcode_X0(tilepro_bundle_bits num
)
687 const unsigned int n
= (unsigned int)num
;
688 return (((n
>> 28)) & 0x7);
691 static __inline
unsigned int
692 get_Opcode_X1(tilepro_bundle_bits n
)
694 return (((unsigned int)(n
>> 59)) & 0xf);
697 static __inline
unsigned int
698 get_Opcode_Y0(tilepro_bundle_bits num
)
700 const unsigned int n
= (unsigned int)num
;
701 return (((n
>> 27)) & 0xf);
704 static __inline
unsigned int
705 get_Opcode_Y1(tilepro_bundle_bits n
)
707 return (((unsigned int)(n
>> 59)) & 0xf);
710 static __inline
unsigned int
711 get_Opcode_Y2(tilepro_bundle_bits n
)
713 return (((unsigned int)(n
>> 56)) & 0x7);
716 static __inline
unsigned int
717 get_RROpcodeExtension_SN(tilepro_bundle_bits num
)
719 const unsigned int n
= (unsigned int)num
;
720 return (((n
>> 4)) & 0xf);
723 static __inline
unsigned int
724 get_RRROpcodeExtension_X0(tilepro_bundle_bits num
)
726 const unsigned int n
= (unsigned int)num
;
727 return (((n
>> 18)) & 0x1ff);
730 static __inline
unsigned int
731 get_RRROpcodeExtension_X1(tilepro_bundle_bits n
)
733 return (((unsigned int)(n
>> 49)) & 0x1ff);
736 static __inline
unsigned int
737 get_RRROpcodeExtension_Y0(tilepro_bundle_bits num
)
739 const unsigned int n
= (unsigned int)num
;
740 return (((n
>> 18)) & 0x3);
743 static __inline
unsigned int
744 get_RRROpcodeExtension_Y1(tilepro_bundle_bits n
)
746 return (((unsigned int)(n
>> 49)) & 0x3);
749 static __inline
unsigned int
750 get_RouteOpcodeExtension_SN(tilepro_bundle_bits num
)
752 const unsigned int n
= (unsigned int)num
;
753 return (((n
>> 0)) & 0x3ff);
756 static __inline
unsigned int
757 get_S_X0(tilepro_bundle_bits num
)
759 const unsigned int n
= (unsigned int)num
;
760 return (((n
>> 27)) & 0x1);
763 static __inline
unsigned int
764 get_S_X1(tilepro_bundle_bits n
)
766 return (((unsigned int)(n
>> 58)) & 0x1);
769 static __inline
unsigned int
770 get_ShAmt_X0(tilepro_bundle_bits num
)
772 const unsigned int n
= (unsigned int)num
;
773 return (((n
>> 12)) & 0x1f);
776 static __inline
unsigned int
777 get_ShAmt_X1(tilepro_bundle_bits n
)
779 return (((unsigned int)(n
>> 43)) & 0x1f);
782 static __inline
unsigned int
783 get_ShAmt_Y0(tilepro_bundle_bits num
)
785 const unsigned int n
= (unsigned int)num
;
786 return (((n
>> 12)) & 0x1f);
789 static __inline
unsigned int
790 get_ShAmt_Y1(tilepro_bundle_bits n
)
792 return (((unsigned int)(n
>> 43)) & 0x1f);
795 static __inline
unsigned int
796 get_SrcA_X0(tilepro_bundle_bits num
)
798 const unsigned int n
= (unsigned int)num
;
799 return (((n
>> 6)) & 0x3f);
802 static __inline
unsigned int
803 get_SrcA_X1(tilepro_bundle_bits n
)
805 return (((unsigned int)(n
>> 37)) & 0x3f);
808 static __inline
unsigned int
809 get_SrcA_Y0(tilepro_bundle_bits num
)
811 const unsigned int n
= (unsigned int)num
;
812 return (((n
>> 6)) & 0x3f);
815 static __inline
unsigned int
816 get_SrcA_Y1(tilepro_bundle_bits n
)
818 return (((unsigned int)(n
>> 37)) & 0x3f);
821 static __inline
unsigned int
822 get_SrcA_Y2(tilepro_bundle_bits n
)
824 return (((n
>> 26)) & 0x00000001) |
825 (((unsigned int)(n
>> 50)) & 0x0000003e);
828 static __inline
unsigned int
829 get_SrcBDest_Y2(tilepro_bundle_bits num
)
831 const unsigned int n
= (unsigned int)num
;
832 return (((n
>> 20)) & 0x3f);
835 static __inline
unsigned int
836 get_SrcB_X0(tilepro_bundle_bits num
)
838 const unsigned int n
= (unsigned int)num
;
839 return (((n
>> 12)) & 0x3f);
842 static __inline
unsigned int
843 get_SrcB_X1(tilepro_bundle_bits n
)
845 return (((unsigned int)(n
>> 43)) & 0x3f);
848 static __inline
unsigned int
849 get_SrcB_Y0(tilepro_bundle_bits num
)
851 const unsigned int n
= (unsigned int)num
;
852 return (((n
>> 12)) & 0x3f);
855 static __inline
unsigned int
856 get_SrcB_Y1(tilepro_bundle_bits n
)
858 return (((unsigned int)(n
>> 43)) & 0x3f);
861 static __inline
unsigned int
862 get_Src_SN(tilepro_bundle_bits num
)
864 const unsigned int n
= (unsigned int)num
;
865 return (((n
>> 0)) & 0x3);
868 static __inline
unsigned int
869 get_UnOpcodeExtension_X0(tilepro_bundle_bits num
)
871 const unsigned int n
= (unsigned int)num
;
872 return (((n
>> 12)) & 0x1f);
875 static __inline
unsigned int
876 get_UnOpcodeExtension_X1(tilepro_bundle_bits n
)
878 return (((unsigned int)(n
>> 43)) & 0x1f);
881 static __inline
unsigned int
882 get_UnOpcodeExtension_Y0(tilepro_bundle_bits num
)
884 const unsigned int n
= (unsigned int)num
;
885 return (((n
>> 12)) & 0x1f);
888 static __inline
unsigned int
889 get_UnOpcodeExtension_Y1(tilepro_bundle_bits n
)
891 return (((unsigned int)(n
>> 43)) & 0x1f);
894 static __inline
unsigned int
895 get_UnShOpcodeExtension_X0(tilepro_bundle_bits num
)
897 const unsigned int n
= (unsigned int)num
;
898 return (((n
>> 17)) & 0x3ff);
901 static __inline
unsigned int
902 get_UnShOpcodeExtension_X1(tilepro_bundle_bits n
)
904 return (((unsigned int)(n
>> 48)) & 0x3ff);
907 static __inline
unsigned int
908 get_UnShOpcodeExtension_Y0(tilepro_bundle_bits num
)
910 const unsigned int n
= (unsigned int)num
;
911 return (((n
>> 17)) & 0x7);
914 static __inline
unsigned int
915 get_UnShOpcodeExtension_Y1(tilepro_bundle_bits n
)
917 return (((unsigned int)(n
>> 48)) & 0x7);
922 sign_extend(int n
, int num_bits
)
924 int shift
= (int)(sizeof(int) * 8 - num_bits
);
925 return (n
<< shift
) >> shift
;
930 static __inline tilepro_bundle_bits
931 create_BrOff_SN(int num
)
933 const unsigned int n
= (unsigned int)num
;
934 return ((n
& 0x3ff) << 0);
937 static __inline tilepro_bundle_bits
938 create_BrOff_X1(int num
)
940 const unsigned int n
= (unsigned int)num
;
941 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
942 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20);
945 static __inline tilepro_bundle_bits
946 create_BrType_X1(int num
)
948 const unsigned int n
= (unsigned int)num
;
949 return (((tilepro_bundle_bits
)(n
& 0xf)) << 31);
952 static __inline tilepro_bundle_bits
953 create_Dest_Imm8_X1(int num
)
955 const unsigned int n
= (unsigned int)num
;
956 return (((tilepro_bundle_bits
)(n
& 0x0000003f)) << 31) |
957 (((tilepro_bundle_bits
)(n
& 0x000000c0)) << 43);
960 static __inline tilepro_bundle_bits
961 create_Dest_SN(int num
)
963 const unsigned int n
= (unsigned int)num
;
964 return ((n
& 0x3) << 2);
967 static __inline tilepro_bundle_bits
968 create_Dest_X0(int num
)
970 const unsigned int n
= (unsigned int)num
;
971 return ((n
& 0x3f) << 0);
974 static __inline tilepro_bundle_bits
975 create_Dest_X1(int num
)
977 const unsigned int n
= (unsigned int)num
;
978 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 31);
981 static __inline tilepro_bundle_bits
982 create_Dest_Y0(int num
)
984 const unsigned int n
= (unsigned int)num
;
985 return ((n
& 0x3f) << 0);
988 static __inline tilepro_bundle_bits
989 create_Dest_Y1(int num
)
991 const unsigned int n
= (unsigned int)num
;
992 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 31);
995 static __inline tilepro_bundle_bits
996 create_Imm16_X0(int num
)
998 const unsigned int n
= (unsigned int)num
;
999 return ((n
& 0xffff) << 12);
1002 static __inline tilepro_bundle_bits
1003 create_Imm16_X1(int num
)
1005 const unsigned int n
= (unsigned int)num
;
1006 return (((tilepro_bundle_bits
)(n
& 0xffff)) << 43);
1009 static __inline tilepro_bundle_bits
1010 create_Imm8_SN(int num
)
1012 const unsigned int n
= (unsigned int)num
;
1013 return ((n
& 0xff) << 0);
1016 static __inline tilepro_bundle_bits
1017 create_Imm8_X0(int num
)
1019 const unsigned int n
= (unsigned int)num
;
1020 return ((n
& 0xff) << 12);
1023 static __inline tilepro_bundle_bits
1024 create_Imm8_X1(int num
)
1026 const unsigned int n
= (unsigned int)num
;
1027 return (((tilepro_bundle_bits
)(n
& 0xff)) << 43);
1030 static __inline tilepro_bundle_bits
1031 create_Imm8_Y0(int num
)
1033 const unsigned int n
= (unsigned int)num
;
1034 return ((n
& 0xff) << 12);
1037 static __inline tilepro_bundle_bits
1038 create_Imm8_Y1(int num
)
1040 const unsigned int n
= (unsigned int)num
;
1041 return (((tilepro_bundle_bits
)(n
& 0xff)) << 43);
1044 static __inline tilepro_bundle_bits
1045 create_ImmOpcodeExtension_X0(int num
)
1047 const unsigned int n
= (unsigned int)num
;
1048 return ((n
& 0x7f) << 20);
1051 static __inline tilepro_bundle_bits
1052 create_ImmOpcodeExtension_X1(int num
)
1054 const unsigned int n
= (unsigned int)num
;
1055 return (((tilepro_bundle_bits
)(n
& 0x7f)) << 51);
1058 static __inline tilepro_bundle_bits
1059 create_ImmRROpcodeExtension_SN(int num
)
1061 const unsigned int n
= (unsigned int)num
;
1062 return ((n
& 0x3) << 8);
1065 static __inline tilepro_bundle_bits
1066 create_JOffLong_X1(int num
)
1068 const unsigned int n
= (unsigned int)num
;
1069 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
1070 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20) |
1071 (((tilepro_bundle_bits
)(n
& 0x001e0000)) << 14) |
1072 (((tilepro_bundle_bits
)(n
& 0x07e00000)) << 16) |
1073 (((tilepro_bundle_bits
)(n
& 0x18000000)) << 31);
1076 static __inline tilepro_bundle_bits
1077 create_JOff_X1(int num
)
1079 const unsigned int n
= (unsigned int)num
;
1080 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
1081 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20) |
1082 (((tilepro_bundle_bits
)(n
& 0x001e0000)) << 14) |
1083 (((tilepro_bundle_bits
)(n
& 0x07e00000)) << 16) |
1084 (((tilepro_bundle_bits
)(n
& 0x08000000)) << 31);
1087 static __inline tilepro_bundle_bits
1088 create_MF_Imm15_X1(int num
)
1090 const unsigned int n
= (unsigned int)num
;
1091 return (((tilepro_bundle_bits
)(n
& 0x00003fff)) << 37) |
1092 (((tilepro_bundle_bits
)(n
& 0x00004000)) << 44);
1095 static __inline tilepro_bundle_bits
1096 create_MMEnd_X0(int num
)
1098 const unsigned int n
= (unsigned int)num
;
1099 return ((n
& 0x1f) << 18);
1102 static __inline tilepro_bundle_bits
1103 create_MMEnd_X1(int num
)
1105 const unsigned int n
= (unsigned int)num
;
1106 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 49);
1109 static __inline tilepro_bundle_bits
1110 create_MMStart_X0(int num
)
1112 const unsigned int n
= (unsigned int)num
;
1113 return ((n
& 0x1f) << 23);
1116 static __inline tilepro_bundle_bits
1117 create_MMStart_X1(int num
)
1119 const unsigned int n
= (unsigned int)num
;
1120 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 54);
1123 static __inline tilepro_bundle_bits
1124 create_MT_Imm15_X1(int num
)
1126 const unsigned int n
= (unsigned int)num
;
1127 return (((tilepro_bundle_bits
)(n
& 0x0000003f)) << 31) |
1128 (((tilepro_bundle_bits
)(n
& 0x00003fc0)) << 37) |
1129 (((tilepro_bundle_bits
)(n
& 0x00004000)) << 44);
1132 static __inline tilepro_bundle_bits
1133 create_Mode(int num
)
1135 const unsigned int n
= (unsigned int)num
;
1136 return (((tilepro_bundle_bits
)(n
& 0x1)) << 63);
1139 static __inline tilepro_bundle_bits
1140 create_NoRegOpcodeExtension_SN(int num
)
1142 const unsigned int n
= (unsigned int)num
;
1143 return ((n
& 0xf) << 0);
1146 static __inline tilepro_bundle_bits
1147 create_Opcode_SN(int num
)
1149 const unsigned int n
= (unsigned int)num
;
1150 return ((n
& 0x3f) << 10);
1153 static __inline tilepro_bundle_bits
1154 create_Opcode_X0(int num
)
1156 const unsigned int n
= (unsigned int)num
;
1157 return ((n
& 0x7) << 28);
1160 static __inline tilepro_bundle_bits
1161 create_Opcode_X1(int num
)
1163 const unsigned int n
= (unsigned int)num
;
1164 return (((tilepro_bundle_bits
)(n
& 0xf)) << 59);
1167 static __inline tilepro_bundle_bits
1168 create_Opcode_Y0(int num
)
1170 const unsigned int n
= (unsigned int)num
;
1171 return ((n
& 0xf) << 27);
1174 static __inline tilepro_bundle_bits
1175 create_Opcode_Y1(int num
)
1177 const unsigned int n
= (unsigned int)num
;
1178 return (((tilepro_bundle_bits
)(n
& 0xf)) << 59);
1181 static __inline tilepro_bundle_bits
1182 create_Opcode_Y2(int num
)
1184 const unsigned int n
= (unsigned int)num
;
1185 return (((tilepro_bundle_bits
)(n
& 0x7)) << 56);
1188 static __inline tilepro_bundle_bits
1189 create_RROpcodeExtension_SN(int num
)
1191 const unsigned int n
= (unsigned int)num
;
1192 return ((n
& 0xf) << 4);
1195 static __inline tilepro_bundle_bits
1196 create_RRROpcodeExtension_X0(int num
)
1198 const unsigned int n
= (unsigned int)num
;
1199 return ((n
& 0x1ff) << 18);
1202 static __inline tilepro_bundle_bits
1203 create_RRROpcodeExtension_X1(int num
)
1205 const unsigned int n
= (unsigned int)num
;
1206 return (((tilepro_bundle_bits
)(n
& 0x1ff)) << 49);
1209 static __inline tilepro_bundle_bits
1210 create_RRROpcodeExtension_Y0(int num
)
1212 const unsigned int n
= (unsigned int)num
;
1213 return ((n
& 0x3) << 18);
1216 static __inline tilepro_bundle_bits
1217 create_RRROpcodeExtension_Y1(int num
)
1219 const unsigned int n
= (unsigned int)num
;
1220 return (((tilepro_bundle_bits
)(n
& 0x3)) << 49);
1223 static __inline tilepro_bundle_bits
1224 create_RouteOpcodeExtension_SN(int num
)
1226 const unsigned int n
= (unsigned int)num
;
1227 return ((n
& 0x3ff) << 0);
1230 static __inline tilepro_bundle_bits
1231 create_S_X0(int num
)
1233 const unsigned int n
= (unsigned int)num
;
1234 return ((n
& 0x1) << 27);
1237 static __inline tilepro_bundle_bits
1238 create_S_X1(int num
)
1240 const unsigned int n
= (unsigned int)num
;
1241 return (((tilepro_bundle_bits
)(n
& 0x1)) << 58);
1244 static __inline tilepro_bundle_bits
1245 create_ShAmt_X0(int num
)
1247 const unsigned int n
= (unsigned int)num
;
1248 return ((n
& 0x1f) << 12);
1251 static __inline tilepro_bundle_bits
1252 create_ShAmt_X1(int num
)
1254 const unsigned int n
= (unsigned int)num
;
1255 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1258 static __inline tilepro_bundle_bits
1259 create_ShAmt_Y0(int num
)
1261 const unsigned int n
= (unsigned int)num
;
1262 return ((n
& 0x1f) << 12);
1265 static __inline tilepro_bundle_bits
1266 create_ShAmt_Y1(int num
)
1268 const unsigned int n
= (unsigned int)num
;
1269 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1272 static __inline tilepro_bundle_bits
1273 create_SrcA_X0(int num
)
1275 const unsigned int n
= (unsigned int)num
;
1276 return ((n
& 0x3f) << 6);
1279 static __inline tilepro_bundle_bits
1280 create_SrcA_X1(int num
)
1282 const unsigned int n
= (unsigned int)num
;
1283 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 37);
1286 static __inline tilepro_bundle_bits
1287 create_SrcA_Y0(int num
)
1289 const unsigned int n
= (unsigned int)num
;
1290 return ((n
& 0x3f) << 6);
1293 static __inline tilepro_bundle_bits
1294 create_SrcA_Y1(int num
)
1296 const unsigned int n
= (unsigned int)num
;
1297 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 37);
1300 static __inline tilepro_bundle_bits
1301 create_SrcA_Y2(int num
)
1303 const unsigned int n
= (unsigned int)num
;
1304 return ((n
& 0x00000001) << 26) |
1305 (((tilepro_bundle_bits
)(n
& 0x0000003e)) << 50);
1308 static __inline tilepro_bundle_bits
1309 create_SrcBDest_Y2(int num
)
1311 const unsigned int n
= (unsigned int)num
;
1312 return ((n
& 0x3f) << 20);
1315 static __inline tilepro_bundle_bits
1316 create_SrcB_X0(int num
)
1318 const unsigned int n
= (unsigned int)num
;
1319 return ((n
& 0x3f) << 12);
1322 static __inline tilepro_bundle_bits
1323 create_SrcB_X1(int num
)
1325 const unsigned int n
= (unsigned int)num
;
1326 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 43);
1329 static __inline tilepro_bundle_bits
1330 create_SrcB_Y0(int num
)
1332 const unsigned int n
= (unsigned int)num
;
1333 return ((n
& 0x3f) << 12);
1336 static __inline tilepro_bundle_bits
1337 create_SrcB_Y1(int num
)
1339 const unsigned int n
= (unsigned int)num
;
1340 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 43);
1343 static __inline tilepro_bundle_bits
1344 create_Src_SN(int num
)
1346 const unsigned int n
= (unsigned int)num
;
1347 return ((n
& 0x3) << 0);
1350 static __inline tilepro_bundle_bits
1351 create_UnOpcodeExtension_X0(int num
)
1353 const unsigned int n
= (unsigned int)num
;
1354 return ((n
& 0x1f) << 12);
1357 static __inline tilepro_bundle_bits
1358 create_UnOpcodeExtension_X1(int num
)
1360 const unsigned int n
= (unsigned int)num
;
1361 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1364 static __inline tilepro_bundle_bits
1365 create_UnOpcodeExtension_Y0(int num
)
1367 const unsigned int n
= (unsigned int)num
;
1368 return ((n
& 0x1f) << 12);
1371 static __inline tilepro_bundle_bits
1372 create_UnOpcodeExtension_Y1(int num
)
1374 const unsigned int n
= (unsigned int)num
;
1375 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1378 static __inline tilepro_bundle_bits
1379 create_UnShOpcodeExtension_X0(int num
)
1381 const unsigned int n
= (unsigned int)num
;
1382 return ((n
& 0x3ff) << 17);
1385 static __inline tilepro_bundle_bits
1386 create_UnShOpcodeExtension_X1(int num
)
1388 const unsigned int n
= (unsigned int)num
;
1389 return (((tilepro_bundle_bits
)(n
& 0x3ff)) << 48);
1392 static __inline tilepro_bundle_bits
1393 create_UnShOpcodeExtension_Y0(int num
)
1395 const unsigned int n
= (unsigned int)num
;
1396 return ((n
& 0x7) << 17);
1399 static __inline tilepro_bundle_bits
1400 create_UnShOpcodeExtension_Y1(int num
)
1402 const unsigned int n
= (unsigned int)num
;
1403 return (((tilepro_bundle_bits
)(n
& 0x7)) << 48);
1410 TILEPRO_PIPELINE_X0
,
1411 TILEPRO_PIPELINE_X1
,
1412 TILEPRO_PIPELINE_Y0
,
1413 TILEPRO_PIPELINE_Y1
,
1414 TILEPRO_PIPELINE_Y2
,
1415 TILEPRO_NUM_PIPELINE_ENCODINGS
1418 #define tilepro_is_x_pipeline(p) ((int)(p) <= (int)TILEPRO_PIPELINE_X1)
1422 TILEPRO_OP_TYPE_REGISTER
,
1423 TILEPRO_OP_TYPE_IMMEDIATE
,
1424 TILEPRO_OP_TYPE_ADDRESS
,
1426 } tilepro_operand_type
;
1428 /* This is the bit that determines if a bundle is in the Y encoding. */
1429 #define TILEPRO_BUNDLE_Y_ENCODING_MASK ((tilepro_bundle_bits)1 << 63)
1433 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1434 TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1436 /* Log base 2 of TILEPRO_BUNDLE_SIZE_IN_BYTES. */
1437 TILEPRO_LOG2_BUNDLE_SIZE_IN_BYTES
= 3,
1439 /* Instructions take this many bytes. */
1440 TILEPRO_BUNDLE_SIZE_IN_BYTES
= 1 << TILEPRO_LOG2_BUNDLE_SIZE_IN_BYTES
,
1442 /* Log base 2 of TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES. */
1443 TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
= 3,
1445 /* Bundles should be aligned modulo this number of bytes. */
1446 TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES
=
1447 (1 << TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
),
1449 /* Log base 2 of TILEPRO_SN_INSTRUCTION_SIZE_IN_BYTES. */
1450 TILEPRO_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES
= 1,
1452 /* Static network instructions take this many bytes. */
1453 TILEPRO_SN_INSTRUCTION_SIZE_IN_BYTES
=
1454 (1 << TILEPRO_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES
),
1456 /* Number of registers (some are magic, such as network I/O). */
1457 TILEPRO_NUM_REGISTERS
= 64,
1459 /* Number of static network registers. */
1460 TILEPRO_NUM_SN_REGISTERS
= 4
1464 struct tilepro_operand
1466 /* Is this operand a register, immediate or address? */
1467 tilepro_operand_type type
;
1469 /* The default relocation type for this operand. */
1470 signed int default_reloc
: 16;
1472 /* How many bits is this value? (used for range checking) */
1473 unsigned int num_bits
: 5;
1475 /* Is the value signed? (used for range checking) */
1476 unsigned int is_signed
: 1;
1478 /* Is this operand a source register? */
1479 unsigned int is_src_reg
: 1;
1481 /* Is this operand written? (i.e. is it a destination register) */
1482 unsigned int is_dest_reg
: 1;
1484 /* Is this operand PC-relative? */
1485 unsigned int is_pc_relative
: 1;
1487 /* By how many bits do we right shift the value before inserting? */
1488 unsigned int rightshift
: 2;
1490 /* Return the bits for this operand to be ORed into an existing bundle. */
1491 tilepro_bundle_bits (*insert
) (int op
);
1493 /* Extract this operand and return it. */
1494 unsigned int (*extract
) (tilepro_bundle_bits bundle
);
1498 extern const struct tilepro_operand tilepro_operands
[];
1500 /* One finite-state machine per pipe for rapid instruction decoding. */
1501 extern const unsigned short * const
1502 tilepro_bundle_decoder_fsms
[TILEPRO_NUM_PIPELINE_ENCODINGS
];
1505 struct tilepro_opcode
1507 /* The opcode mnemonic, e.g. "add" */
1510 /* The enum value for this mnemonic. */
1511 tilepro_mnemonic mnemonic
;
1513 /* A bit mask of which of the five pipes this instruction
1520 unsigned char pipes
;
1522 /* How many operands are there? */
1523 unsigned char num_operands
;
1525 /* Which register does this write implicitly, or TREG_ZERO if none? */
1526 unsigned char implicitly_written_register
;
1528 /* Can this be bundled with other instructions (almost always true). */
1529 unsigned char can_bundle
;
1531 /* The description of the operands. Each of these is an
1532 * index into the tilepro_operands[] table. */
1533 unsigned char operands
[TILEPRO_NUM_PIPELINE_ENCODINGS
][TILEPRO_MAX_OPERANDS
];
1535 #if !defined(__KERNEL__) && !defined(_LIBC)
1536 /* A mask of which bits have predefined values for each pipeline.
1537 * This is useful for disassembly. */
1538 tilepro_bundle_bits fixed_bit_masks
[TILEPRO_NUM_PIPELINE_ENCODINGS
];
1540 /* For each bit set in fixed_bit_masks, what the value is for this
1542 tilepro_bundle_bits fixed_bit_values
[TILEPRO_NUM_PIPELINE_ENCODINGS
];
1546 extern const struct tilepro_opcode tilepro_opcodes
[];
1548 #if !defined(__KERNEL__) && !defined(_LIBC)
1550 typedef unsigned short tilepro_sn_instruction_bits
;
1552 struct tilepro_sn_opcode
1554 /* The opcode mnemonic, e.g. "add" */
1557 /* The enum value for this mnemonic. */
1558 tilepro_sn_mnemonic mnemonic
;
1560 /* How many operands are there? */
1561 unsigned char num_operands
;
1563 /* The description of the operands. Each of these is an
1564 * index into the tilepro_operands[] table. */
1565 unsigned char operands
[TILEPRO_SN_MAX_OPERANDS
];
1567 /* A mask of which bits have predefined values.
1568 * This is useful for disassembly. */
1569 tilepro_sn_instruction_bits fixed_bit_mask
;
1571 /* For each bit set in fixed_bit_masks, what its value is. */
1572 tilepro_sn_instruction_bits fixed_bit_values
;
1575 extern const struct tilepro_sn_opcode tilepro_sn_opcodes
[];
1577 #endif /* !__KERNEL__ && !_LIBC */
1579 /* Used for non-textual disassembly into structs. */
1580 struct tilepro_decoded_instruction
1582 const struct tilepro_opcode
*opcode
;
1583 const struct tilepro_operand
*operands
[TILEPRO_MAX_OPERANDS
];
1584 int operand_values
[TILEPRO_MAX_OPERANDS
];
1588 /* Disassemble a bundle into a struct for machine processing. */
1589 extern int parse_insn_tilepro(tilepro_bundle_bits bits
,
1591 struct tilepro_decoded_instruction
1592 decoded
[TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE
]);
1595 /* Given a set of bundle bits and a specific pipe, returns which
1596 * instruction the bundle contains in that pipe.
1598 extern const struct tilepro_opcode
*
1599 find_opcode(tilepro_bundle_bits bits
, tilepro_pipeline pipe
);
1602 #if !defined(__KERNEL__) && !defined(_LIBC)
1603 /* Canonical names of all the registers. */
1604 /* ISSUE: This table lives in "tilepro-dis.c" */
1605 extern const char * const tilepro_register_names
[];
1607 /* Descriptor for a special-purpose register. */
1617 /* List of all the SPRs; ordered by increasing number. */
1618 extern const struct tilepro_spr tilepro_sprs
[];
1620 /* Number of special-purpose registers. */
1621 extern const int tilepro_num_sprs
;
1624 get_tilepro_spr_name (int num
);
1625 #endif /* !__KERNEL__ && !_LIBC */
1627 /* Make a few "tile_" variables to simply common code between
1630 typedef tilepro_bundle_bits tile_bundle_bits
;
1631 #define TILE_BUNDLE_SIZE_IN_BYTES TILEPRO_BUNDLE_SIZE_IN_BYTES
1632 #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEPRO_BUNDLE_ALIGNMENT_IN_BYTES
1633 #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1634 TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1636 #endif /* opcode_tilepro_h */