1 /* TILEPro opcode information.
3 * Copyright 2011 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 */
44 TILEPRO_OPC_MOVELI_SN
,
53 TILEPRO_OPC_ADDBS_U_SN
,
70 TILEPRO_OPC_ADIFFB_U_SN
,
72 TILEPRO_OPC_ADIFFH_SN
,
79 TILEPRO_OPC_AVGB_U_SN
,
103 TILEPRO_OPC_BLEZT_SN
,
113 TILEPRO_OPC_BYTEX_SN
,
120 TILEPRO_OPC_CRC32_32
,
121 TILEPRO_OPC_CRC32_32_SN
,
123 TILEPRO_OPC_CRC32_8_SN
,
128 TILEPRO_OPC_DWORD_ALIGN
,
129 TILEPRO_OPC_DWORD_ALIGN_SN
,
136 TILEPRO_OPC_INTHB_SN
,
138 TILEPRO_OPC_INTHH_SN
,
140 TILEPRO_OPC_INTLB_SN
,
142 TILEPRO_OPC_INTLH_SN
,
158 TILEPRO_OPC_LBADD_SN
,
160 TILEPRO_OPC_LBADD_U_SN
,
166 TILEPRO_OPC_LHADD_SN
,
168 TILEPRO_OPC_LHADD_U_SN
,
174 TILEPRO_OPC_LW_NA_SN
,
176 TILEPRO_OPC_LWADD_SN
,
177 TILEPRO_OPC_LWADD_NA
,
178 TILEPRO_OPC_LWADD_NA_SN
,
180 TILEPRO_OPC_MAXB_U_SN
,
184 TILEPRO_OPC_MAXIB_U_SN
,
186 TILEPRO_OPC_MAXIH_SN
,
190 TILEPRO_OPC_MINB_U_SN
,
194 TILEPRO_OPC_MINIB_U_SN
,
196 TILEPRO_OPC_MINIH_SN
,
205 TILEPRO_OPC_MULHH_SS
,
206 TILEPRO_OPC_MULHH_SS_SN
,
207 TILEPRO_OPC_MULHH_SU
,
208 TILEPRO_OPC_MULHH_SU_SN
,
209 TILEPRO_OPC_MULHH_UU
,
210 TILEPRO_OPC_MULHH_UU_SN
,
211 TILEPRO_OPC_MULHHA_SS
,
212 TILEPRO_OPC_MULHHA_SS_SN
,
213 TILEPRO_OPC_MULHHA_SU
,
214 TILEPRO_OPC_MULHHA_SU_SN
,
215 TILEPRO_OPC_MULHHA_UU
,
216 TILEPRO_OPC_MULHHA_UU_SN
,
217 TILEPRO_OPC_MULHHSA_UU
,
218 TILEPRO_OPC_MULHHSA_UU_SN
,
219 TILEPRO_OPC_MULHL_SS
,
220 TILEPRO_OPC_MULHL_SS_SN
,
221 TILEPRO_OPC_MULHL_SU
,
222 TILEPRO_OPC_MULHL_SU_SN
,
223 TILEPRO_OPC_MULHL_US
,
224 TILEPRO_OPC_MULHL_US_SN
,
225 TILEPRO_OPC_MULHL_UU
,
226 TILEPRO_OPC_MULHL_UU_SN
,
227 TILEPRO_OPC_MULHLA_SS
,
228 TILEPRO_OPC_MULHLA_SS_SN
,
229 TILEPRO_OPC_MULHLA_SU
,
230 TILEPRO_OPC_MULHLA_SU_SN
,
231 TILEPRO_OPC_MULHLA_US
,
232 TILEPRO_OPC_MULHLA_US_SN
,
233 TILEPRO_OPC_MULHLA_UU
,
234 TILEPRO_OPC_MULHLA_UU_SN
,
235 TILEPRO_OPC_MULHLSA_UU
,
236 TILEPRO_OPC_MULHLSA_UU_SN
,
237 TILEPRO_OPC_MULLL_SS
,
238 TILEPRO_OPC_MULLL_SS_SN
,
239 TILEPRO_OPC_MULLL_SU
,
240 TILEPRO_OPC_MULLL_SU_SN
,
241 TILEPRO_OPC_MULLL_UU
,
242 TILEPRO_OPC_MULLL_UU_SN
,
243 TILEPRO_OPC_MULLLA_SS
,
244 TILEPRO_OPC_MULLLA_SS_SN
,
245 TILEPRO_OPC_MULLLA_SU
,
246 TILEPRO_OPC_MULLLA_SU_SN
,
247 TILEPRO_OPC_MULLLA_UU
,
248 TILEPRO_OPC_MULLLA_UU_SN
,
249 TILEPRO_OPC_MULLLSA_UU
,
250 TILEPRO_OPC_MULLLSA_UU_SN
,
269 TILEPRO_OPC_PACKBS_U
,
270 TILEPRO_OPC_PACKBS_U_SN
,
272 TILEPRO_OPC_PACKHB_SN
,
274 TILEPRO_OPC_PACKHS_SN
,
276 TILEPRO_OPC_PACKLB_SN
,
290 TILEPRO_OPC_SADAB_U_SN
,
292 TILEPRO_OPC_SADAH_SN
,
294 TILEPRO_OPC_SADAH_U_SN
,
296 TILEPRO_OPC_SADB_U_SN
,
300 TILEPRO_OPC_SADH_U_SN
,
312 TILEPRO_OPC_SEQIB_SN
,
314 TILEPRO_OPC_SEQIH_SN
,
326 TILEPRO_OPC_SHLIB_SN
,
328 TILEPRO_OPC_SHLIH_SN
,
338 TILEPRO_OPC_SHRIB_SN
,
340 TILEPRO_OPC_SHRIH_SN
,
344 TILEPRO_OPC_SLT_U_SN
,
348 TILEPRO_OPC_SLTB_U_SN
,
352 TILEPRO_OPC_SLTE_U_SN
,
354 TILEPRO_OPC_SLTEB_SN
,
356 TILEPRO_OPC_SLTEB_U_SN
,
358 TILEPRO_OPC_SLTEH_SN
,
360 TILEPRO_OPC_SLTEH_U_SN
,
364 TILEPRO_OPC_SLTH_U_SN
,
368 TILEPRO_OPC_SLTI_U_SN
,
370 TILEPRO_OPC_SLTIB_SN
,
372 TILEPRO_OPC_SLTIB_U_SN
,
374 TILEPRO_OPC_SLTIH_SN
,
376 TILEPRO_OPC_SLTIH_U_SN
,
392 TILEPRO_OPC_SRAIB_SN
,
394 TILEPRO_OPC_SRAIH_SN
,
400 TILEPRO_OPC_SUBBS_U_SN
,
404 TILEPRO_OPC_SUBHS_SN
,
413 TILEPRO_OPC_TBLIDXB0
,
414 TILEPRO_OPC_TBLIDXB0_SN
,
415 TILEPRO_OPC_TBLIDXB1
,
416 TILEPRO_OPC_TBLIDXB1_SN
,
417 TILEPRO_OPC_TBLIDXB2
,
418 TILEPRO_OPC_TBLIDXB2_SN
,
419 TILEPRO_OPC_TBLIDXB3
,
420 TILEPRO_OPC_TBLIDXB3_SN
,
431 /* 64-bit pattern for a { bpt ; nop } bundle. */
432 #define TILEPRO_BPT_BUNDLE 0x400b3cae70166000ULL
438 TILEPRO_SN_MAX_OPERANDS
= 6 /* route */
449 TILEPRO_SN_OPC_MOVEI
,
455 TILEPRO_SN_OPC_JALRR
,
461 TILEPRO_SN_OPC_SHL8II
,
464 TILEPRO_SN_OPC_ROUTE
,
466 } tilepro_sn_mnemonic
;
468 extern const unsigned char tilepro_sn_route_encode
[6 * 6 * 6];
469 extern const signed char tilepro_sn_route_decode
[256][3];
470 extern const char tilepro_sn_direction_names
[6][5];
471 extern const signed char tilepro_sn_dest_map
[6][6];
472 #endif /* DISASM_ONLY */
475 static __inline
unsigned int
476 get_BrOff_SN(tilepro_bundle_bits num
)
478 const unsigned int n
= (unsigned int)num
;
479 return (((n
>> 0)) & 0x3ff);
482 static __inline
unsigned int
483 get_BrOff_X1(tilepro_bundle_bits n
)
485 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
486 (((unsigned int)(n
>> 20)) & 0x00018000);
489 static __inline
unsigned int
490 get_BrType_X1(tilepro_bundle_bits n
)
492 return (((unsigned int)(n
>> 31)) & 0xf);
495 static __inline
unsigned int
496 get_Dest_Imm8_X1(tilepro_bundle_bits n
)
498 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
499 (((unsigned int)(n
>> 43)) & 0x000000c0);
502 static __inline
unsigned int
503 get_Dest_SN(tilepro_bundle_bits num
)
505 const unsigned int n
= (unsigned int)num
;
506 return (((n
>> 2)) & 0x3);
509 static __inline
unsigned int
510 get_Dest_X0(tilepro_bundle_bits num
)
512 const unsigned int n
= (unsigned int)num
;
513 return (((n
>> 0)) & 0x3f);
516 static __inline
unsigned int
517 get_Dest_X1(tilepro_bundle_bits n
)
519 return (((unsigned int)(n
>> 31)) & 0x3f);
522 static __inline
unsigned int
523 get_Dest_Y0(tilepro_bundle_bits num
)
525 const unsigned int n
= (unsigned int)num
;
526 return (((n
>> 0)) & 0x3f);
529 static __inline
unsigned int
530 get_Dest_Y1(tilepro_bundle_bits n
)
532 return (((unsigned int)(n
>> 31)) & 0x3f);
535 static __inline
unsigned int
536 get_Imm16_X0(tilepro_bundle_bits num
)
538 const unsigned int n
= (unsigned int)num
;
539 return (((n
>> 12)) & 0xffff);
542 static __inline
unsigned int
543 get_Imm16_X1(tilepro_bundle_bits n
)
545 return (((unsigned int)(n
>> 43)) & 0xffff);
548 static __inline
unsigned int
549 get_Imm8_SN(tilepro_bundle_bits num
)
551 const unsigned int n
= (unsigned int)num
;
552 return (((n
>> 0)) & 0xff);
555 static __inline
unsigned int
556 get_Imm8_X0(tilepro_bundle_bits num
)
558 const unsigned int n
= (unsigned int)num
;
559 return (((n
>> 12)) & 0xff);
562 static __inline
unsigned int
563 get_Imm8_X1(tilepro_bundle_bits n
)
565 return (((unsigned int)(n
>> 43)) & 0xff);
568 static __inline
unsigned int
569 get_Imm8_Y0(tilepro_bundle_bits num
)
571 const unsigned int n
= (unsigned int)num
;
572 return (((n
>> 12)) & 0xff);
575 static __inline
unsigned int
576 get_Imm8_Y1(tilepro_bundle_bits n
)
578 return (((unsigned int)(n
>> 43)) & 0xff);
581 static __inline
unsigned int
582 get_ImmOpcodeExtension_X0(tilepro_bundle_bits num
)
584 const unsigned int n
= (unsigned int)num
;
585 return (((n
>> 20)) & 0x7f);
588 static __inline
unsigned int
589 get_ImmOpcodeExtension_X1(tilepro_bundle_bits n
)
591 return (((unsigned int)(n
>> 51)) & 0x7f);
594 static __inline
unsigned int
595 get_ImmRROpcodeExtension_SN(tilepro_bundle_bits num
)
597 const unsigned int n
= (unsigned int)num
;
598 return (((n
>> 8)) & 0x3);
601 static __inline
unsigned int
602 get_JOffLong_X1(tilepro_bundle_bits n
)
604 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
605 (((unsigned int)(n
>> 20)) & 0x00018000) |
606 (((unsigned int)(n
>> 14)) & 0x001e0000) |
607 (((unsigned int)(n
>> 16)) & 0x07e00000) |
608 (((unsigned int)(n
>> 31)) & 0x18000000);
611 static __inline
unsigned int
612 get_JOff_X1(tilepro_bundle_bits n
)
614 return (((unsigned int)(n
>> 43)) & 0x00007fff) |
615 (((unsigned int)(n
>> 20)) & 0x00018000) |
616 (((unsigned int)(n
>> 14)) & 0x001e0000) |
617 (((unsigned int)(n
>> 16)) & 0x07e00000) |
618 (((unsigned int)(n
>> 31)) & 0x08000000);
621 static __inline
unsigned int
622 get_MF_Imm15_X1(tilepro_bundle_bits n
)
624 return (((unsigned int)(n
>> 37)) & 0x00003fff) |
625 (((unsigned int)(n
>> 44)) & 0x00004000);
628 static __inline
unsigned int
629 get_MMEnd_X0(tilepro_bundle_bits num
)
631 const unsigned int n
= (unsigned int)num
;
632 return (((n
>> 18)) & 0x1f);
635 static __inline
unsigned int
636 get_MMEnd_X1(tilepro_bundle_bits n
)
638 return (((unsigned int)(n
>> 49)) & 0x1f);
641 static __inline
unsigned int
642 get_MMStart_X0(tilepro_bundle_bits num
)
644 const unsigned int n
= (unsigned int)num
;
645 return (((n
>> 23)) & 0x1f);
648 static __inline
unsigned int
649 get_MMStart_X1(tilepro_bundle_bits n
)
651 return (((unsigned int)(n
>> 54)) & 0x1f);
654 static __inline
unsigned int
655 get_MT_Imm15_X1(tilepro_bundle_bits n
)
657 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
658 (((unsigned int)(n
>> 37)) & 0x00003fc0) |
659 (((unsigned int)(n
>> 44)) & 0x00004000);
662 static __inline
unsigned int
663 get_Mode(tilepro_bundle_bits n
)
665 return (((unsigned int)(n
>> 63)) & 0x1);
668 static __inline
unsigned int
669 get_NoRegOpcodeExtension_SN(tilepro_bundle_bits num
)
671 const unsigned int n
= (unsigned int)num
;
672 return (((n
>> 0)) & 0xf);
675 static __inline
unsigned int
676 get_Opcode_SN(tilepro_bundle_bits num
)
678 const unsigned int n
= (unsigned int)num
;
679 return (((n
>> 10)) & 0x3f);
682 static __inline
unsigned int
683 get_Opcode_X0(tilepro_bundle_bits num
)
685 const unsigned int n
= (unsigned int)num
;
686 return (((n
>> 28)) & 0x7);
689 static __inline
unsigned int
690 get_Opcode_X1(tilepro_bundle_bits n
)
692 return (((unsigned int)(n
>> 59)) & 0xf);
695 static __inline
unsigned int
696 get_Opcode_Y0(tilepro_bundle_bits num
)
698 const unsigned int n
= (unsigned int)num
;
699 return (((n
>> 27)) & 0xf);
702 static __inline
unsigned int
703 get_Opcode_Y1(tilepro_bundle_bits n
)
705 return (((unsigned int)(n
>> 59)) & 0xf);
708 static __inline
unsigned int
709 get_Opcode_Y2(tilepro_bundle_bits n
)
711 return (((unsigned int)(n
>> 56)) & 0x7);
714 static __inline
unsigned int
715 get_RROpcodeExtension_SN(tilepro_bundle_bits num
)
717 const unsigned int n
= (unsigned int)num
;
718 return (((n
>> 4)) & 0xf);
721 static __inline
unsigned int
722 get_RRROpcodeExtension_X0(tilepro_bundle_bits num
)
724 const unsigned int n
= (unsigned int)num
;
725 return (((n
>> 18)) & 0x1ff);
728 static __inline
unsigned int
729 get_RRROpcodeExtension_X1(tilepro_bundle_bits n
)
731 return (((unsigned int)(n
>> 49)) & 0x1ff);
734 static __inline
unsigned int
735 get_RRROpcodeExtension_Y0(tilepro_bundle_bits num
)
737 const unsigned int n
= (unsigned int)num
;
738 return (((n
>> 18)) & 0x3);
741 static __inline
unsigned int
742 get_RRROpcodeExtension_Y1(tilepro_bundle_bits n
)
744 return (((unsigned int)(n
>> 49)) & 0x3);
747 static __inline
unsigned int
748 get_RouteOpcodeExtension_SN(tilepro_bundle_bits num
)
750 const unsigned int n
= (unsigned int)num
;
751 return (((n
>> 0)) & 0x3ff);
754 static __inline
unsigned int
755 get_S_X0(tilepro_bundle_bits num
)
757 const unsigned int n
= (unsigned int)num
;
758 return (((n
>> 27)) & 0x1);
761 static __inline
unsigned int
762 get_S_X1(tilepro_bundle_bits n
)
764 return (((unsigned int)(n
>> 58)) & 0x1);
767 static __inline
unsigned int
768 get_ShAmt_X0(tilepro_bundle_bits num
)
770 const unsigned int n
= (unsigned int)num
;
771 return (((n
>> 12)) & 0x1f);
774 static __inline
unsigned int
775 get_ShAmt_X1(tilepro_bundle_bits n
)
777 return (((unsigned int)(n
>> 43)) & 0x1f);
780 static __inline
unsigned int
781 get_ShAmt_Y0(tilepro_bundle_bits num
)
783 const unsigned int n
= (unsigned int)num
;
784 return (((n
>> 12)) & 0x1f);
787 static __inline
unsigned int
788 get_ShAmt_Y1(tilepro_bundle_bits n
)
790 return (((unsigned int)(n
>> 43)) & 0x1f);
793 static __inline
unsigned int
794 get_SrcA_X0(tilepro_bundle_bits num
)
796 const unsigned int n
= (unsigned int)num
;
797 return (((n
>> 6)) & 0x3f);
800 static __inline
unsigned int
801 get_SrcA_X1(tilepro_bundle_bits n
)
803 return (((unsigned int)(n
>> 37)) & 0x3f);
806 static __inline
unsigned int
807 get_SrcA_Y0(tilepro_bundle_bits num
)
809 const unsigned int n
= (unsigned int)num
;
810 return (((n
>> 6)) & 0x3f);
813 static __inline
unsigned int
814 get_SrcA_Y1(tilepro_bundle_bits n
)
816 return (((unsigned int)(n
>> 37)) & 0x3f);
819 static __inline
unsigned int
820 get_SrcA_Y2(tilepro_bundle_bits n
)
822 return (((n
>> 26)) & 0x00000001) |
823 (((unsigned int)(n
>> 50)) & 0x0000003e);
826 static __inline
unsigned int
827 get_SrcBDest_Y2(tilepro_bundle_bits num
)
829 const unsigned int n
= (unsigned int)num
;
830 return (((n
>> 20)) & 0x3f);
833 static __inline
unsigned int
834 get_SrcB_X0(tilepro_bundle_bits num
)
836 const unsigned int n
= (unsigned int)num
;
837 return (((n
>> 12)) & 0x3f);
840 static __inline
unsigned int
841 get_SrcB_X1(tilepro_bundle_bits n
)
843 return (((unsigned int)(n
>> 43)) & 0x3f);
846 static __inline
unsigned int
847 get_SrcB_Y0(tilepro_bundle_bits num
)
849 const unsigned int n
= (unsigned int)num
;
850 return (((n
>> 12)) & 0x3f);
853 static __inline
unsigned int
854 get_SrcB_Y1(tilepro_bundle_bits n
)
856 return (((unsigned int)(n
>> 43)) & 0x3f);
859 static __inline
unsigned int
860 get_Src_SN(tilepro_bundle_bits num
)
862 const unsigned int n
= (unsigned int)num
;
863 return (((n
>> 0)) & 0x3);
866 static __inline
unsigned int
867 get_UnOpcodeExtension_X0(tilepro_bundle_bits num
)
869 const unsigned int n
= (unsigned int)num
;
870 return (((n
>> 12)) & 0x1f);
873 static __inline
unsigned int
874 get_UnOpcodeExtension_X1(tilepro_bundle_bits n
)
876 return (((unsigned int)(n
>> 43)) & 0x1f);
879 static __inline
unsigned int
880 get_UnOpcodeExtension_Y0(tilepro_bundle_bits num
)
882 const unsigned int n
= (unsigned int)num
;
883 return (((n
>> 12)) & 0x1f);
886 static __inline
unsigned int
887 get_UnOpcodeExtension_Y1(tilepro_bundle_bits n
)
889 return (((unsigned int)(n
>> 43)) & 0x1f);
892 static __inline
unsigned int
893 get_UnShOpcodeExtension_X0(tilepro_bundle_bits num
)
895 const unsigned int n
= (unsigned int)num
;
896 return (((n
>> 17)) & 0x3ff);
899 static __inline
unsigned int
900 get_UnShOpcodeExtension_X1(tilepro_bundle_bits n
)
902 return (((unsigned int)(n
>> 48)) & 0x3ff);
905 static __inline
unsigned int
906 get_UnShOpcodeExtension_Y0(tilepro_bundle_bits num
)
908 const unsigned int n
= (unsigned int)num
;
909 return (((n
>> 17)) & 0x7);
912 static __inline
unsigned int
913 get_UnShOpcodeExtension_Y1(tilepro_bundle_bits n
)
915 return (((unsigned int)(n
>> 48)) & 0x7);
920 sign_extend(int n
, int num_bits
)
922 int shift
= (int)(sizeof(int) * 8 - num_bits
);
923 return (n
<< shift
) >> shift
;
928 static __inline tilepro_bundle_bits
929 create_BrOff_SN(int num
)
931 const unsigned int n
= (unsigned int)num
;
932 return ((n
& 0x3ff) << 0);
935 static __inline tilepro_bundle_bits
936 create_BrOff_X1(int num
)
938 const unsigned int n
= (unsigned int)num
;
939 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
940 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20);
943 static __inline tilepro_bundle_bits
944 create_BrType_X1(int num
)
946 const unsigned int n
= (unsigned int)num
;
947 return (((tilepro_bundle_bits
)(n
& 0xf)) << 31);
950 static __inline tilepro_bundle_bits
951 create_Dest_Imm8_X1(int num
)
953 const unsigned int n
= (unsigned int)num
;
954 return (((tilepro_bundle_bits
)(n
& 0x0000003f)) << 31) |
955 (((tilepro_bundle_bits
)(n
& 0x000000c0)) << 43);
958 static __inline tilepro_bundle_bits
959 create_Dest_SN(int num
)
961 const unsigned int n
= (unsigned int)num
;
962 return ((n
& 0x3) << 2);
965 static __inline tilepro_bundle_bits
966 create_Dest_X0(int num
)
968 const unsigned int n
= (unsigned int)num
;
969 return ((n
& 0x3f) << 0);
972 static __inline tilepro_bundle_bits
973 create_Dest_X1(int num
)
975 const unsigned int n
= (unsigned int)num
;
976 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 31);
979 static __inline tilepro_bundle_bits
980 create_Dest_Y0(int num
)
982 const unsigned int n
= (unsigned int)num
;
983 return ((n
& 0x3f) << 0);
986 static __inline tilepro_bundle_bits
987 create_Dest_Y1(int num
)
989 const unsigned int n
= (unsigned int)num
;
990 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 31);
993 static __inline tilepro_bundle_bits
994 create_Imm16_X0(int num
)
996 const unsigned int n
= (unsigned int)num
;
997 return ((n
& 0xffff) << 12);
1000 static __inline tilepro_bundle_bits
1001 create_Imm16_X1(int num
)
1003 const unsigned int n
= (unsigned int)num
;
1004 return (((tilepro_bundle_bits
)(n
& 0xffff)) << 43);
1007 static __inline tilepro_bundle_bits
1008 create_Imm8_SN(int num
)
1010 const unsigned int n
= (unsigned int)num
;
1011 return ((n
& 0xff) << 0);
1014 static __inline tilepro_bundle_bits
1015 create_Imm8_X0(int num
)
1017 const unsigned int n
= (unsigned int)num
;
1018 return ((n
& 0xff) << 12);
1021 static __inline tilepro_bundle_bits
1022 create_Imm8_X1(int num
)
1024 const unsigned int n
= (unsigned int)num
;
1025 return (((tilepro_bundle_bits
)(n
& 0xff)) << 43);
1028 static __inline tilepro_bundle_bits
1029 create_Imm8_Y0(int num
)
1031 const unsigned int n
= (unsigned int)num
;
1032 return ((n
& 0xff) << 12);
1035 static __inline tilepro_bundle_bits
1036 create_Imm8_Y1(int num
)
1038 const unsigned int n
= (unsigned int)num
;
1039 return (((tilepro_bundle_bits
)(n
& 0xff)) << 43);
1042 static __inline tilepro_bundle_bits
1043 create_ImmOpcodeExtension_X0(int num
)
1045 const unsigned int n
= (unsigned int)num
;
1046 return ((n
& 0x7f) << 20);
1049 static __inline tilepro_bundle_bits
1050 create_ImmOpcodeExtension_X1(int num
)
1052 const unsigned int n
= (unsigned int)num
;
1053 return (((tilepro_bundle_bits
)(n
& 0x7f)) << 51);
1056 static __inline tilepro_bundle_bits
1057 create_ImmRROpcodeExtension_SN(int num
)
1059 const unsigned int n
= (unsigned int)num
;
1060 return ((n
& 0x3) << 8);
1063 static __inline tilepro_bundle_bits
1064 create_JOffLong_X1(int num
)
1066 const unsigned int n
= (unsigned int)num
;
1067 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
1068 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20) |
1069 (((tilepro_bundle_bits
)(n
& 0x001e0000)) << 14) |
1070 (((tilepro_bundle_bits
)(n
& 0x07e00000)) << 16) |
1071 (((tilepro_bundle_bits
)(n
& 0x18000000)) << 31);
1074 static __inline tilepro_bundle_bits
1075 create_JOff_X1(int num
)
1077 const unsigned int n
= (unsigned int)num
;
1078 return (((tilepro_bundle_bits
)(n
& 0x00007fff)) << 43) |
1079 (((tilepro_bundle_bits
)(n
& 0x00018000)) << 20) |
1080 (((tilepro_bundle_bits
)(n
& 0x001e0000)) << 14) |
1081 (((tilepro_bundle_bits
)(n
& 0x07e00000)) << 16) |
1082 (((tilepro_bundle_bits
)(n
& 0x08000000)) << 31);
1085 static __inline tilepro_bundle_bits
1086 create_MF_Imm15_X1(int num
)
1088 const unsigned int n
= (unsigned int)num
;
1089 return (((tilepro_bundle_bits
)(n
& 0x00003fff)) << 37) |
1090 (((tilepro_bundle_bits
)(n
& 0x00004000)) << 44);
1093 static __inline tilepro_bundle_bits
1094 create_MMEnd_X0(int num
)
1096 const unsigned int n
= (unsigned int)num
;
1097 return ((n
& 0x1f) << 18);
1100 static __inline tilepro_bundle_bits
1101 create_MMEnd_X1(int num
)
1103 const unsigned int n
= (unsigned int)num
;
1104 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 49);
1107 static __inline tilepro_bundle_bits
1108 create_MMStart_X0(int num
)
1110 const unsigned int n
= (unsigned int)num
;
1111 return ((n
& 0x1f) << 23);
1114 static __inline tilepro_bundle_bits
1115 create_MMStart_X1(int num
)
1117 const unsigned int n
= (unsigned int)num
;
1118 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 54);
1121 static __inline tilepro_bundle_bits
1122 create_MT_Imm15_X1(int num
)
1124 const unsigned int n
= (unsigned int)num
;
1125 return (((tilepro_bundle_bits
)(n
& 0x0000003f)) << 31) |
1126 (((tilepro_bundle_bits
)(n
& 0x00003fc0)) << 37) |
1127 (((tilepro_bundle_bits
)(n
& 0x00004000)) << 44);
1130 static __inline tilepro_bundle_bits
1131 create_Mode(int num
)
1133 const unsigned int n
= (unsigned int)num
;
1134 return (((tilepro_bundle_bits
)(n
& 0x1)) << 63);
1137 static __inline tilepro_bundle_bits
1138 create_NoRegOpcodeExtension_SN(int num
)
1140 const unsigned int n
= (unsigned int)num
;
1141 return ((n
& 0xf) << 0);
1144 static __inline tilepro_bundle_bits
1145 create_Opcode_SN(int num
)
1147 const unsigned int n
= (unsigned int)num
;
1148 return ((n
& 0x3f) << 10);
1151 static __inline tilepro_bundle_bits
1152 create_Opcode_X0(int num
)
1154 const unsigned int n
= (unsigned int)num
;
1155 return ((n
& 0x7) << 28);
1158 static __inline tilepro_bundle_bits
1159 create_Opcode_X1(int num
)
1161 const unsigned int n
= (unsigned int)num
;
1162 return (((tilepro_bundle_bits
)(n
& 0xf)) << 59);
1165 static __inline tilepro_bundle_bits
1166 create_Opcode_Y0(int num
)
1168 const unsigned int n
= (unsigned int)num
;
1169 return ((n
& 0xf) << 27);
1172 static __inline tilepro_bundle_bits
1173 create_Opcode_Y1(int num
)
1175 const unsigned int n
= (unsigned int)num
;
1176 return (((tilepro_bundle_bits
)(n
& 0xf)) << 59);
1179 static __inline tilepro_bundle_bits
1180 create_Opcode_Y2(int num
)
1182 const unsigned int n
= (unsigned int)num
;
1183 return (((tilepro_bundle_bits
)(n
& 0x7)) << 56);
1186 static __inline tilepro_bundle_bits
1187 create_RROpcodeExtension_SN(int num
)
1189 const unsigned int n
= (unsigned int)num
;
1190 return ((n
& 0xf) << 4);
1193 static __inline tilepro_bundle_bits
1194 create_RRROpcodeExtension_X0(int num
)
1196 const unsigned int n
= (unsigned int)num
;
1197 return ((n
& 0x1ff) << 18);
1200 static __inline tilepro_bundle_bits
1201 create_RRROpcodeExtension_X1(int num
)
1203 const unsigned int n
= (unsigned int)num
;
1204 return (((tilepro_bundle_bits
)(n
& 0x1ff)) << 49);
1207 static __inline tilepro_bundle_bits
1208 create_RRROpcodeExtension_Y0(int num
)
1210 const unsigned int n
= (unsigned int)num
;
1211 return ((n
& 0x3) << 18);
1214 static __inline tilepro_bundle_bits
1215 create_RRROpcodeExtension_Y1(int num
)
1217 const unsigned int n
= (unsigned int)num
;
1218 return (((tilepro_bundle_bits
)(n
& 0x3)) << 49);
1221 static __inline tilepro_bundle_bits
1222 create_RouteOpcodeExtension_SN(int num
)
1224 const unsigned int n
= (unsigned int)num
;
1225 return ((n
& 0x3ff) << 0);
1228 static __inline tilepro_bundle_bits
1229 create_S_X0(int num
)
1231 const unsigned int n
= (unsigned int)num
;
1232 return ((n
& 0x1) << 27);
1235 static __inline tilepro_bundle_bits
1236 create_S_X1(int num
)
1238 const unsigned int n
= (unsigned int)num
;
1239 return (((tilepro_bundle_bits
)(n
& 0x1)) << 58);
1242 static __inline tilepro_bundle_bits
1243 create_ShAmt_X0(int num
)
1245 const unsigned int n
= (unsigned int)num
;
1246 return ((n
& 0x1f) << 12);
1249 static __inline tilepro_bundle_bits
1250 create_ShAmt_X1(int num
)
1252 const unsigned int n
= (unsigned int)num
;
1253 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1256 static __inline tilepro_bundle_bits
1257 create_ShAmt_Y0(int num
)
1259 const unsigned int n
= (unsigned int)num
;
1260 return ((n
& 0x1f) << 12);
1263 static __inline tilepro_bundle_bits
1264 create_ShAmt_Y1(int num
)
1266 const unsigned int n
= (unsigned int)num
;
1267 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1270 static __inline tilepro_bundle_bits
1271 create_SrcA_X0(int num
)
1273 const unsigned int n
= (unsigned int)num
;
1274 return ((n
& 0x3f) << 6);
1277 static __inline tilepro_bundle_bits
1278 create_SrcA_X1(int num
)
1280 const unsigned int n
= (unsigned int)num
;
1281 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 37);
1284 static __inline tilepro_bundle_bits
1285 create_SrcA_Y0(int num
)
1287 const unsigned int n
= (unsigned int)num
;
1288 return ((n
& 0x3f) << 6);
1291 static __inline tilepro_bundle_bits
1292 create_SrcA_Y1(int num
)
1294 const unsigned int n
= (unsigned int)num
;
1295 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 37);
1298 static __inline tilepro_bundle_bits
1299 create_SrcA_Y2(int num
)
1301 const unsigned int n
= (unsigned int)num
;
1302 return ((n
& 0x00000001) << 26) |
1303 (((tilepro_bundle_bits
)(n
& 0x0000003e)) << 50);
1306 static __inline tilepro_bundle_bits
1307 create_SrcBDest_Y2(int num
)
1309 const unsigned int n
= (unsigned int)num
;
1310 return ((n
& 0x3f) << 20);
1313 static __inline tilepro_bundle_bits
1314 create_SrcB_X0(int num
)
1316 const unsigned int n
= (unsigned int)num
;
1317 return ((n
& 0x3f) << 12);
1320 static __inline tilepro_bundle_bits
1321 create_SrcB_X1(int num
)
1323 const unsigned int n
= (unsigned int)num
;
1324 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 43);
1327 static __inline tilepro_bundle_bits
1328 create_SrcB_Y0(int num
)
1330 const unsigned int n
= (unsigned int)num
;
1331 return ((n
& 0x3f) << 12);
1334 static __inline tilepro_bundle_bits
1335 create_SrcB_Y1(int num
)
1337 const unsigned int n
= (unsigned int)num
;
1338 return (((tilepro_bundle_bits
)(n
& 0x3f)) << 43);
1341 static __inline tilepro_bundle_bits
1342 create_Src_SN(int num
)
1344 const unsigned int n
= (unsigned int)num
;
1345 return ((n
& 0x3) << 0);
1348 static __inline tilepro_bundle_bits
1349 create_UnOpcodeExtension_X0(int num
)
1351 const unsigned int n
= (unsigned int)num
;
1352 return ((n
& 0x1f) << 12);
1355 static __inline tilepro_bundle_bits
1356 create_UnOpcodeExtension_X1(int num
)
1358 const unsigned int n
= (unsigned int)num
;
1359 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1362 static __inline tilepro_bundle_bits
1363 create_UnOpcodeExtension_Y0(int num
)
1365 const unsigned int n
= (unsigned int)num
;
1366 return ((n
& 0x1f) << 12);
1369 static __inline tilepro_bundle_bits
1370 create_UnOpcodeExtension_Y1(int num
)
1372 const unsigned int n
= (unsigned int)num
;
1373 return (((tilepro_bundle_bits
)(n
& 0x1f)) << 43);
1376 static __inline tilepro_bundle_bits
1377 create_UnShOpcodeExtension_X0(int num
)
1379 const unsigned int n
= (unsigned int)num
;
1380 return ((n
& 0x3ff) << 17);
1383 static __inline tilepro_bundle_bits
1384 create_UnShOpcodeExtension_X1(int num
)
1386 const unsigned int n
= (unsigned int)num
;
1387 return (((tilepro_bundle_bits
)(n
& 0x3ff)) << 48);
1390 static __inline tilepro_bundle_bits
1391 create_UnShOpcodeExtension_Y0(int num
)
1393 const unsigned int n
= (unsigned int)num
;
1394 return ((n
& 0x7) << 17);
1397 static __inline tilepro_bundle_bits
1398 create_UnShOpcodeExtension_Y1(int num
)
1400 const unsigned int n
= (unsigned int)num
;
1401 return (((tilepro_bundle_bits
)(n
& 0x7)) << 48);
1408 TILEPRO_PIPELINE_X0
,
1409 TILEPRO_PIPELINE_X1
,
1410 TILEPRO_PIPELINE_Y0
,
1411 TILEPRO_PIPELINE_Y1
,
1412 TILEPRO_PIPELINE_Y2
,
1415 #define tilepro_is_x_pipeline(p) ((int)(p) <= (int)TILEPRO_PIPELINE_X1)
1419 TILEPRO_OP_TYPE_REGISTER
,
1420 TILEPRO_OP_TYPE_IMMEDIATE
,
1421 TILEPRO_OP_TYPE_ADDRESS
,
1423 } tilepro_operand_type
;
1425 /* This is the bit that determines if a bundle is in the Y encoding. */
1426 #define TILEPRO_BUNDLE_Y_ENCODING_MASK ((tilepro_bundle_bits)1 << 63)
1430 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1431 TILEPRO_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1433 /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1434 TILEPRO_NUM_PIPELINE_ENCODINGS
= 5,
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 */