1 /* tile.h -- Header file for TILE opcode table
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Contributed by Tilera Corp. */
8 typedef unsigned long long tile_bundle_bits;
13 TILE_MAX_OPERANDS = 5 /* mm */
104 TILE_OPC_CRC32_32_SN,
111 TILE_OPC_DWORD_ALIGN,
112 TILE_OPC_DWORD_ALIGN_SN,
161 TILE_OPC_LWADD_NA_SN,
189 TILE_OPC_MULHH_SS_SN,
191 TILE_OPC_MULHH_SU_SN,
193 TILE_OPC_MULHH_UU_SN,
195 TILE_OPC_MULHHA_SS_SN,
197 TILE_OPC_MULHHA_SU_SN,
199 TILE_OPC_MULHHA_UU_SN,
201 TILE_OPC_MULHHSA_UU_SN,
203 TILE_OPC_MULHL_SS_SN,
205 TILE_OPC_MULHL_SU_SN,
207 TILE_OPC_MULHL_US_SN,
209 TILE_OPC_MULHL_UU_SN,
211 TILE_OPC_MULHLA_SS_SN,
213 TILE_OPC_MULHLA_SU_SN,
215 TILE_OPC_MULHLA_US_SN,
217 TILE_OPC_MULHLA_UU_SN,
219 TILE_OPC_MULHLSA_UU_SN,
221 TILE_OPC_MULLL_SS_SN,
223 TILE_OPC_MULLL_SU_SN,
225 TILE_OPC_MULLL_UU_SN,
227 TILE_OPC_MULLLA_SS_SN,
229 TILE_OPC_MULLLA_SU_SN,
231 TILE_OPC_MULLLA_UU_SN,
233 TILE_OPC_MULLLSA_UU_SN,
253 TILE_OPC_PACKBS_U_SN,
397 TILE_OPC_TBLIDXB0_SN,
399 TILE_OPC_TBLIDXB1_SN,
401 TILE_OPC_TBLIDXB2_SN,
403 TILE_OPC_TBLIDXB3_SN,
414 /* 64-bit pattern for a { bpt ; nop } bundle. */
415 #define TILE_BPT_BUNDLE 0x400b3cae70166000ULL
418 #define TILE_ELF_MACHINE_CODE EM_TILEPRO
420 #define TILE_ELF_NAME "elf32-tilepro"
424 TILE_SN_MAX_OPERANDS = 6 /* route */
454 extern const unsigned char tile_sn_route_encode[6 * 6 * 6];
455 extern const signed char tile_sn_route_decode[256][3];
456 extern const char tile_sn_direction_names[6][5];
457 extern const signed char tile_sn_dest_map[6][6];
460 static __inline unsigned int
461 get_BrOff_SN(tile_bundle_bits num)
463 const unsigned int n = (unsigned int)num;
464 return (((n >> 0)) & 0x3ff);
467 static __inline unsigned int
468 get_BrOff_X1(tile_bundle_bits n)
470 return (((unsigned int)(n >> 43)) & 0x00007fff) |
471 (((unsigned int)(n >> 20)) & 0x00018000);
474 static __inline unsigned int
475 get_BrType_X1(tile_bundle_bits n)
477 return (((unsigned int)(n >> 31)) & 0xf);
480 static __inline unsigned int
481 get_Dest_Imm8_X1(tile_bundle_bits n)
483 return (((unsigned int)(n >> 31)) & 0x0000003f) |
484 (((unsigned int)(n >> 43)) & 0x000000c0);
487 static __inline unsigned int
488 get_Dest_SN(tile_bundle_bits num)
490 const unsigned int n = (unsigned int)num;
491 return (((n >> 2)) & 0x3);
494 static __inline unsigned int
495 get_Dest_X0(tile_bundle_bits num)
497 const unsigned int n = (unsigned int)num;
498 return (((n >> 0)) & 0x3f);
501 static __inline unsigned int
502 get_Dest_X1(tile_bundle_bits n)
504 return (((unsigned int)(n >> 31)) & 0x3f);
507 static __inline unsigned int
508 get_Dest_Y0(tile_bundle_bits num)
510 const unsigned int n = (unsigned int)num;
511 return (((n >> 0)) & 0x3f);
514 static __inline unsigned int
515 get_Dest_Y1(tile_bundle_bits n)
517 return (((unsigned int)(n >> 31)) & 0x3f);
520 static __inline unsigned int
521 get_Imm16_X0(tile_bundle_bits num)
523 const unsigned int n = (unsigned int)num;
524 return (((n >> 12)) & 0xffff);
527 static __inline unsigned int
528 get_Imm16_X1(tile_bundle_bits n)
530 return (((unsigned int)(n >> 43)) & 0xffff);
533 static __inline unsigned int
534 get_Imm8_SN(tile_bundle_bits num)
536 const unsigned int n = (unsigned int)num;
537 return (((n >> 0)) & 0xff);
540 static __inline unsigned int
541 get_Imm8_X0(tile_bundle_bits num)
543 const unsigned int n = (unsigned int)num;
544 return (((n >> 12)) & 0xff);
547 static __inline unsigned int
548 get_Imm8_X1(tile_bundle_bits n)
550 return (((unsigned int)(n >> 43)) & 0xff);
553 static __inline unsigned int
554 get_Imm8_Y0(tile_bundle_bits num)
556 const unsigned int n = (unsigned int)num;
557 return (((n >> 12)) & 0xff);
560 static __inline unsigned int
561 get_Imm8_Y1(tile_bundle_bits n)
563 return (((unsigned int)(n >> 43)) & 0xff);
566 static __inline unsigned int
567 get_ImmOpcodeExtension_X0(tile_bundle_bits num)
569 const unsigned int n = (unsigned int)num;
570 return (((n >> 20)) & 0x7f);
573 static __inline unsigned int
574 get_ImmOpcodeExtension_X1(tile_bundle_bits n)
576 return (((unsigned int)(n >> 51)) & 0x7f);
579 static __inline unsigned int
580 get_ImmRROpcodeExtension_SN(tile_bundle_bits num)
582 const unsigned int n = (unsigned int)num;
583 return (((n >> 8)) & 0x3);
586 static __inline unsigned int
587 get_JOffLong_X1(tile_bundle_bits n)
589 return (((unsigned int)(n >> 43)) & 0x00007fff) |
590 (((unsigned int)(n >> 20)) & 0x00018000) |
591 (((unsigned int)(n >> 14)) & 0x001e0000) |
592 (((unsigned int)(n >> 16)) & 0x07e00000) |
593 (((unsigned int)(n >> 31)) & 0x18000000);
596 static __inline unsigned int
597 get_JOff_X1(tile_bundle_bits n)
599 return (((unsigned int)(n >> 43)) & 0x00007fff) |
600 (((unsigned int)(n >> 20)) & 0x00018000) |
601 (((unsigned int)(n >> 14)) & 0x001e0000) |
602 (((unsigned int)(n >> 16)) & 0x07e00000) |
603 (((unsigned int)(n >> 31)) & 0x08000000);
606 static __inline unsigned int
607 get_MF_Imm15_X1(tile_bundle_bits n)
609 return (((unsigned int)(n >> 37)) & 0x00003fff) |
610 (((unsigned int)(n >> 44)) & 0x00004000);
613 static __inline unsigned int
614 get_MMEnd_X0(tile_bundle_bits num)
616 const unsigned int n = (unsigned int)num;
617 return (((n >> 18)) & 0x1f);
620 static __inline unsigned int
621 get_MMEnd_X1(tile_bundle_bits n)
623 return (((unsigned int)(n >> 49)) & 0x1f);
626 static __inline unsigned int
627 get_MMStart_X0(tile_bundle_bits num)
629 const unsigned int n = (unsigned int)num;
630 return (((n >> 23)) & 0x1f);
633 static __inline unsigned int
634 get_MMStart_X1(tile_bundle_bits n)
636 return (((unsigned int)(n >> 54)) & 0x1f);
639 static __inline unsigned int
640 get_MT_Imm15_X1(tile_bundle_bits n)
642 return (((unsigned int)(n >> 31)) & 0x0000003f) |
643 (((unsigned int)(n >> 37)) & 0x00003fc0) |
644 (((unsigned int)(n >> 44)) & 0x00004000);
647 static __inline unsigned int
648 get_Mode(tile_bundle_bits n)
650 return (((unsigned int)(n >> 63)) & 0x1);
653 static __inline unsigned int
654 get_NoRegOpcodeExtension_SN(tile_bundle_bits num)
656 const unsigned int n = (unsigned int)num;
657 return (((n >> 0)) & 0xf);
660 static __inline unsigned int
661 get_Opcode_SN(tile_bundle_bits num)
663 const unsigned int n = (unsigned int)num;
664 return (((n >> 10)) & 0x3f);
667 static __inline unsigned int
668 get_Opcode_X0(tile_bundle_bits num)
670 const unsigned int n = (unsigned int)num;
671 return (((n >> 28)) & 0x7);
674 static __inline unsigned int
675 get_Opcode_X1(tile_bundle_bits n)
677 return (((unsigned int)(n >> 59)) & 0xf);
680 static __inline unsigned int
681 get_Opcode_Y0(tile_bundle_bits num)
683 const unsigned int n = (unsigned int)num;
684 return (((n >> 27)) & 0xf);
687 static __inline unsigned int
688 get_Opcode_Y1(tile_bundle_bits n)
690 return (((unsigned int)(n >> 59)) & 0xf);
693 static __inline unsigned int
694 get_Opcode_Y2(tile_bundle_bits n)
696 return (((unsigned int)(n >> 56)) & 0x7);
699 static __inline unsigned int
700 get_RROpcodeExtension_SN(tile_bundle_bits num)
702 const unsigned int n = (unsigned int)num;
703 return (((n >> 4)) & 0xf);
706 static __inline unsigned int
707 get_RRROpcodeExtension_X0(tile_bundle_bits num)
709 const unsigned int n = (unsigned int)num;
710 return (((n >> 18)) & 0x1ff);
713 static __inline unsigned int
714 get_RRROpcodeExtension_X1(tile_bundle_bits n)
716 return (((unsigned int)(n >> 49)) & 0x1ff);
719 static __inline unsigned int
720 get_RRROpcodeExtension_Y0(tile_bundle_bits num)
722 const unsigned int n = (unsigned int)num;
723 return (((n >> 18)) & 0x3);
726 static __inline unsigned int
727 get_RRROpcodeExtension_Y1(tile_bundle_bits n)
729 return (((unsigned int)(n >> 49)) & 0x3);
732 static __inline unsigned int
733 get_RouteOpcodeExtension_SN(tile_bundle_bits num)
735 const unsigned int n = (unsigned int)num;
736 return (((n >> 0)) & 0x3ff);
739 static __inline unsigned int
740 get_S_X0(tile_bundle_bits num)
742 const unsigned int n = (unsigned int)num;
743 return (((n >> 27)) & 0x1);
746 static __inline unsigned int
747 get_S_X1(tile_bundle_bits n)
749 return (((unsigned int)(n >> 58)) & 0x1);
752 static __inline unsigned int
753 get_ShAmt_X0(tile_bundle_bits num)
755 const unsigned int n = (unsigned int)num;
756 return (((n >> 12)) & 0x1f);
759 static __inline unsigned int
760 get_ShAmt_X1(tile_bundle_bits n)
762 return (((unsigned int)(n >> 43)) & 0x1f);
765 static __inline unsigned int
766 get_ShAmt_Y0(tile_bundle_bits num)
768 const unsigned int n = (unsigned int)num;
769 return (((n >> 12)) & 0x1f);
772 static __inline unsigned int
773 get_ShAmt_Y1(tile_bundle_bits n)
775 return (((unsigned int)(n >> 43)) & 0x1f);
778 static __inline unsigned int
779 get_SrcA_X0(tile_bundle_bits num)
781 const unsigned int n = (unsigned int)num;
782 return (((n >> 6)) & 0x3f);
785 static __inline unsigned int
786 get_SrcA_X1(tile_bundle_bits n)
788 return (((unsigned int)(n >> 37)) & 0x3f);
791 static __inline unsigned int
792 get_SrcA_Y0(tile_bundle_bits num)
794 const unsigned int n = (unsigned int)num;
795 return (((n >> 6)) & 0x3f);
798 static __inline unsigned int
799 get_SrcA_Y1(tile_bundle_bits n)
801 return (((unsigned int)(n >> 37)) & 0x3f);
804 static __inline unsigned int
805 get_SrcA_Y2(tile_bundle_bits n)
807 return (((n >> 26)) & 0x00000001) |
808 (((unsigned int)(n >> 50)) & 0x0000003e);
811 static __inline unsigned int
812 get_SrcBDest_Y2(tile_bundle_bits num)
814 const unsigned int n = (unsigned int)num;
815 return (((n >> 20)) & 0x3f);
818 static __inline unsigned int
819 get_SrcB_X0(tile_bundle_bits num)
821 const unsigned int n = (unsigned int)num;
822 return (((n >> 12)) & 0x3f);
825 static __inline unsigned int
826 get_SrcB_X1(tile_bundle_bits n)
828 return (((unsigned int)(n >> 43)) & 0x3f);
831 static __inline unsigned int
832 get_SrcB_Y0(tile_bundle_bits num)
834 const unsigned int n = (unsigned int)num;
835 return (((n >> 12)) & 0x3f);
838 static __inline unsigned int
839 get_SrcB_Y1(tile_bundle_bits n)
841 return (((unsigned int)(n >> 43)) & 0x3f);
844 static __inline unsigned int
845 get_Src_SN(tile_bundle_bits num)
847 const unsigned int n = (unsigned int)num;
848 return (((n >> 0)) & 0x3);
851 static __inline unsigned int
852 get_UnOpcodeExtension_X0(tile_bundle_bits num)
854 const unsigned int n = (unsigned int)num;
855 return (((n >> 12)) & 0x1f);
858 static __inline unsigned int
859 get_UnOpcodeExtension_X1(tile_bundle_bits n)
861 return (((unsigned int)(n >> 43)) & 0x1f);
864 static __inline unsigned int
865 get_UnOpcodeExtension_Y0(tile_bundle_bits num)
867 const unsigned int n = (unsigned int)num;
868 return (((n >> 12)) & 0x1f);
871 static __inline unsigned int
872 get_UnOpcodeExtension_Y1(tile_bundle_bits n)
874 return (((unsigned int)(n >> 43)) & 0x1f);
877 static __inline unsigned int
878 get_UnShOpcodeExtension_X0(tile_bundle_bits num)
880 const unsigned int n = (unsigned int)num;
881 return (((n >> 17)) & 0x3ff);
884 static __inline unsigned int
885 get_UnShOpcodeExtension_X1(tile_bundle_bits n)
887 return (((unsigned int)(n >> 48)) & 0x3ff);
890 static __inline unsigned int
891 get_UnShOpcodeExtension_Y0(tile_bundle_bits num)
893 const unsigned int n = (unsigned int)num;
894 return (((n >> 17)) & 0x7);
897 static __inline unsigned int
898 get_UnShOpcodeExtension_Y1(tile_bundle_bits n)
900 return (((unsigned int)(n >> 48)) & 0x7);
905 sign_extend(int n, int num_bits)
907 int shift = (int)(sizeof(int) * 8 - num_bits);
908 return (n << shift) >> shift;
913 static __inline tile_bundle_bits
914 create_BrOff_SN(int num)
916 const unsigned int n = (unsigned int)num;
917 return ((n & 0x3ff) << 0);
920 static __inline tile_bundle_bits
921 create_BrOff_X1(int num)
923 const unsigned int n = (unsigned int)num;
924 return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
925 (((tile_bundle_bits)(n & 0x00018000)) << 20);
928 static __inline tile_bundle_bits
929 create_BrType_X1(int num)
931 const unsigned int n = (unsigned int)num;
932 return (((tile_bundle_bits)(n & 0xf)) << 31);
935 static __inline tile_bundle_bits
936 create_Dest_Imm8_X1(int num)
938 const unsigned int n = (unsigned int)num;
939 return (((tile_bundle_bits)(n & 0x0000003f)) << 31) |
940 (((tile_bundle_bits)(n & 0x000000c0)) << 43);
943 static __inline tile_bundle_bits
944 create_Dest_SN(int num)
946 const unsigned int n = (unsigned int)num;
947 return ((n & 0x3) << 2);
950 static __inline tile_bundle_bits
951 create_Dest_X0(int num)
953 const unsigned int n = (unsigned int)num;
954 return ((n & 0x3f) << 0);
957 static __inline tile_bundle_bits
958 create_Dest_X1(int num)
960 const unsigned int n = (unsigned int)num;
961 return (((tile_bundle_bits)(n & 0x3f)) << 31);
964 static __inline tile_bundle_bits
965 create_Dest_Y0(int num)
967 const unsigned int n = (unsigned int)num;
968 return ((n & 0x3f) << 0);
971 static __inline tile_bundle_bits
972 create_Dest_Y1(int num)
974 const unsigned int n = (unsigned int)num;
975 return (((tile_bundle_bits)(n & 0x3f)) << 31);
978 static __inline tile_bundle_bits
979 create_Imm16_X0(int num)
981 const unsigned int n = (unsigned int)num;
982 return ((n & 0xffff) << 12);
985 static __inline tile_bundle_bits
986 create_Imm16_X1(int num)
988 const unsigned int n = (unsigned int)num;
989 return (((tile_bundle_bits)(n & 0xffff)) << 43);
992 static __inline tile_bundle_bits
993 create_Imm8_SN(int num)
995 const unsigned int n = (unsigned int)num;
996 return ((n & 0xff) << 0);
999 static __inline tile_bundle_bits
1000 create_Imm8_X0(int num)
1002 const unsigned int n = (unsigned int)num;
1003 return ((n & 0xff) << 12);
1006 static __inline tile_bundle_bits
1007 create_Imm8_X1(int num)
1009 const unsigned int n = (unsigned int)num;
1010 return (((tile_bundle_bits)(n & 0xff)) << 43);
1013 static __inline tile_bundle_bits
1014 create_Imm8_Y0(int num)
1016 const unsigned int n = (unsigned int)num;
1017 return ((n & 0xff) << 12);
1020 static __inline tile_bundle_bits
1021 create_Imm8_Y1(int num)
1023 const unsigned int n = (unsigned int)num;
1024 return (((tile_bundle_bits)(n & 0xff)) << 43);
1027 static __inline tile_bundle_bits
1028 create_ImmOpcodeExtension_X0(int num)
1030 const unsigned int n = (unsigned int)num;
1031 return ((n & 0x7f) << 20);
1034 static __inline tile_bundle_bits
1035 create_ImmOpcodeExtension_X1(int num)
1037 const unsigned int n = (unsigned int)num;
1038 return (((tile_bundle_bits)(n & 0x7f)) << 51);
1041 static __inline tile_bundle_bits
1042 create_ImmRROpcodeExtension_SN(int num)
1044 const unsigned int n = (unsigned int)num;
1045 return ((n & 0x3) << 8);
1048 static __inline tile_bundle_bits
1049 create_JOffLong_X1(int num)
1051 const unsigned int n = (unsigned int)num;
1052 return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
1053 (((tile_bundle_bits)(n & 0x00018000)) << 20) |
1054 (((tile_bundle_bits)(n & 0x001e0000)) << 14) |
1055 (((tile_bundle_bits)(n & 0x07e00000)) << 16) |
1056 (((tile_bundle_bits)(n & 0x18000000)) << 31);
1059 static __inline tile_bundle_bits
1060 create_JOff_X1(int num)
1062 const unsigned int n = (unsigned int)num;
1063 return (((tile_bundle_bits)(n & 0x00007fff)) << 43) |
1064 (((tile_bundle_bits)(n & 0x00018000)) << 20) |
1065 (((tile_bundle_bits)(n & 0x001e0000)) << 14) |
1066 (((tile_bundle_bits)(n & 0x07e00000)) << 16) |
1067 (((tile_bundle_bits)(n & 0x08000000)) << 31);
1070 static __inline tile_bundle_bits
1071 create_MF_Imm15_X1(int num)
1073 const unsigned int n = (unsigned int)num;
1074 return (((tile_bundle_bits)(n & 0x00003fff)) << 37) |
1075 (((tile_bundle_bits)(n & 0x00004000)) << 44);
1078 static __inline tile_bundle_bits
1079 create_MMEnd_X0(int num)
1081 const unsigned int n = (unsigned int)num;
1082 return ((n & 0x1f) << 18);
1085 static __inline tile_bundle_bits
1086 create_MMEnd_X1(int num)
1088 const unsigned int n = (unsigned int)num;
1089 return (((tile_bundle_bits)(n & 0x1f)) << 49);
1092 static __inline tile_bundle_bits
1093 create_MMStart_X0(int num)
1095 const unsigned int n = (unsigned int)num;
1096 return ((n & 0x1f) << 23);
1099 static __inline tile_bundle_bits
1100 create_MMStart_X1(int num)
1102 const unsigned int n = (unsigned int)num;
1103 return (((tile_bundle_bits)(n & 0x1f)) << 54);
1106 static __inline tile_bundle_bits
1107 create_MT_Imm15_X1(int num)
1109 const unsigned int n = (unsigned int)num;
1110 return (((tile_bundle_bits)(n & 0x0000003f)) << 31) |
1111 (((tile_bundle_bits)(n & 0x00003fc0)) << 37) |
1112 (((tile_bundle_bits)(n & 0x00004000)) << 44);
1115 static __inline tile_bundle_bits
1116 create_Mode(int num)
1118 const unsigned int n = (unsigned int)num;
1119 return (((tile_bundle_bits)(n & 0x1)) << 63);
1122 static __inline tile_bundle_bits
1123 create_NoRegOpcodeExtension_SN(int num)
1125 const unsigned int n = (unsigned int)num;
1126 return ((n & 0xf) << 0);
1129 static __inline tile_bundle_bits
1130 create_Opcode_SN(int num)
1132 const unsigned int n = (unsigned int)num;
1133 return ((n & 0x3f) << 10);
1136 static __inline tile_bundle_bits
1137 create_Opcode_X0(int num)
1139 const unsigned int n = (unsigned int)num;
1140 return ((n & 0x7) << 28);
1143 static __inline tile_bundle_bits
1144 create_Opcode_X1(int num)
1146 const unsigned int n = (unsigned int)num;
1147 return (((tile_bundle_bits)(n & 0xf)) << 59);
1150 static __inline tile_bundle_bits
1151 create_Opcode_Y0(int num)
1153 const unsigned int n = (unsigned int)num;
1154 return ((n & 0xf) << 27);
1157 static __inline tile_bundle_bits
1158 create_Opcode_Y1(int num)
1160 const unsigned int n = (unsigned int)num;
1161 return (((tile_bundle_bits)(n & 0xf)) << 59);
1164 static __inline tile_bundle_bits
1165 create_Opcode_Y2(int num)
1167 const unsigned int n = (unsigned int)num;
1168 return (((tile_bundle_bits)(n & 0x7)) << 56);
1171 static __inline tile_bundle_bits
1172 create_RROpcodeExtension_SN(int num)
1174 const unsigned int n = (unsigned int)num;
1175 return ((n & 0xf) << 4);
1178 static __inline tile_bundle_bits
1179 create_RRROpcodeExtension_X0(int num)
1181 const unsigned int n = (unsigned int)num;
1182 return ((n & 0x1ff) << 18);
1185 static __inline tile_bundle_bits
1186 create_RRROpcodeExtension_X1(int num)
1188 const unsigned int n = (unsigned int)num;
1189 return (((tile_bundle_bits)(n & 0x1ff)) << 49);
1192 static __inline tile_bundle_bits
1193 create_RRROpcodeExtension_Y0(int num)
1195 const unsigned int n = (unsigned int)num;
1196 return ((n & 0x3) << 18);
1199 static __inline tile_bundle_bits
1200 create_RRROpcodeExtension_Y1(int num)
1202 const unsigned int n = (unsigned int)num;
1203 return (((tile_bundle_bits)(n & 0x3)) << 49);
1206 static __inline tile_bundle_bits
1207 create_RouteOpcodeExtension_SN(int num)
1209 const unsigned int n = (unsigned int)num;
1210 return ((n & 0x3ff) << 0);
1213 static __inline tile_bundle_bits
1214 create_S_X0(int num)
1216 const unsigned int n = (unsigned int)num;
1217 return ((n & 0x1) << 27);
1220 static __inline tile_bundle_bits
1221 create_S_X1(int num)
1223 const unsigned int n = (unsigned int)num;
1224 return (((tile_bundle_bits)(n & 0x1)) << 58);
1227 static __inline tile_bundle_bits
1228 create_ShAmt_X0(int num)
1230 const unsigned int n = (unsigned int)num;
1231 return ((n & 0x1f) << 12);
1234 static __inline tile_bundle_bits
1235 create_ShAmt_X1(int num)
1237 const unsigned int n = (unsigned int)num;
1238 return (((tile_bundle_bits)(n & 0x1f)) << 43);
1241 static __inline tile_bundle_bits
1242 create_ShAmt_Y0(int num)
1244 const unsigned int n = (unsigned int)num;
1245 return ((n & 0x1f) << 12);
1248 static __inline tile_bundle_bits
1249 create_ShAmt_Y1(int num)
1251 const unsigned int n = (unsigned int)num;
1252 return (((tile_bundle_bits)(n & 0x1f)) << 43);
1255 static __inline tile_bundle_bits
1256 create_SrcA_X0(int num)
1258 const unsigned int n = (unsigned int)num;
1259 return ((n & 0x3f) << 6);
1262 static __inline tile_bundle_bits
1263 create_SrcA_X1(int num)
1265 const unsigned int n = (unsigned int)num;
1266 return (((tile_bundle_bits)(n & 0x3f)) << 37);
1269 static __inline tile_bundle_bits
1270 create_SrcA_Y0(int num)
1272 const unsigned int n = (unsigned int)num;
1273 return ((n & 0x3f) << 6);
1276 static __inline tile_bundle_bits
1277 create_SrcA_Y1(int num)
1279 const unsigned int n = (unsigned int)num;
1280 return (((tile_bundle_bits)(n & 0x3f)) << 37);
1283 static __inline tile_bundle_bits
1284 create_SrcA_Y2(int num)
1286 const unsigned int n = (unsigned int)num;
1287 return ((n & 0x00000001) << 26) |
1288 (((tile_bundle_bits)(n & 0x0000003e)) << 50);
1291 static __inline tile_bundle_bits
1292 create_SrcBDest_Y2(int num)
1294 const unsigned int n = (unsigned int)num;
1295 return ((n & 0x3f) << 20);
1298 static __inline tile_bundle_bits
1299 create_SrcB_X0(int num)
1301 const unsigned int n = (unsigned int)num;
1302 return ((n & 0x3f) << 12);
1305 static __inline tile_bundle_bits
1306 create_SrcB_X1(int num)
1308 const unsigned int n = (unsigned int)num;
1309 return (((tile_bundle_bits)(n & 0x3f)) << 43);
1312 static __inline tile_bundle_bits
1313 create_SrcB_Y0(int num)
1315 const unsigned int n = (unsigned int)num;
1316 return ((n & 0x3f) << 12);
1319 static __inline tile_bundle_bits
1320 create_SrcB_Y1(int num)
1322 const unsigned int n = (unsigned int)num;
1323 return (((tile_bundle_bits)(n & 0x3f)) << 43);
1326 static __inline tile_bundle_bits
1327 create_Src_SN(int num)
1329 const unsigned int n = (unsigned int)num;
1330 return ((n & 0x3) << 0);
1333 static __inline tile_bundle_bits
1334 create_UnOpcodeExtension_X0(int num)
1336 const unsigned int n = (unsigned int)num;
1337 return ((n & 0x1f) << 12);
1340 static __inline tile_bundle_bits
1341 create_UnOpcodeExtension_X1(int num)
1343 const unsigned int n = (unsigned int)num;
1344 return (((tile_bundle_bits)(n & 0x1f)) << 43);
1347 static __inline tile_bundle_bits
1348 create_UnOpcodeExtension_Y0(int num)
1350 const unsigned int n = (unsigned int)num;
1351 return ((n & 0x1f) << 12);
1354 static __inline tile_bundle_bits
1355 create_UnOpcodeExtension_Y1(int num)
1357 const unsigned int n = (unsigned int)num;
1358 return (((tile_bundle_bits)(n & 0x1f)) << 43);
1361 static __inline tile_bundle_bits
1362 create_UnShOpcodeExtension_X0(int num)
1364 const unsigned int n = (unsigned int)num;
1365 return ((n & 0x3ff) << 17);
1368 static __inline tile_bundle_bits
1369 create_UnShOpcodeExtension_X1(int num)
1371 const unsigned int n = (unsigned int)num;
1372 return (((tile_bundle_bits)(n & 0x3ff)) << 48);
1375 static __inline tile_bundle_bits
1376 create_UnShOpcodeExtension_Y0(int num)
1378 const unsigned int n = (unsigned int)num;
1379 return ((n & 0x7) << 17);
1382 static __inline tile_bundle_bits
1383 create_UnShOpcodeExtension_Y1(int num)
1385 const unsigned int n = (unsigned int)num;
1386 return (((tile_bundle_bits)(n & 0x7)) << 48);
1390 typedef unsigned short tile_sn_instruction_bits;
1402 #define tile_is_x_pipeline(p) ((int)(p) <= (int)TILE_PIPELINE_X1)
1406 TILE_OP_TYPE_REGISTER,
1407 TILE_OP_TYPE_IMMEDIATE,
1408 TILE_OP_TYPE_ADDRESS,
1410 } tile_operand_type;
1412 /* This is the bit that determines if a bundle is in the Y encoding. */
1413 #define TILE_BUNDLE_Y_ENCODING_MASK ((tile_bundle_bits)1 << 63)
1417 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1418 TILE_MAX_INSTRUCTIONS_PER_BUNDLE = 3,
1420 /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1421 TILE_NUM_PIPELINE_ENCODINGS = 5,
1423 /* Log base 2 of TILE_BUNDLE_SIZE_IN_BYTES. */
1424 TILE_LOG2_BUNDLE_SIZE_IN_BYTES = 3,
1426 /* Instructions take this many bytes. */
1427 TILE_BUNDLE_SIZE_IN_BYTES = 1 << TILE_LOG2_BUNDLE_SIZE_IN_BYTES,
1429 /* Log base 2 of TILE_BUNDLE_ALIGNMENT_IN_BYTES. */
1430 TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES = 3,
1432 /* Bundles should be aligned modulo this number of bytes. */
1433 TILE_BUNDLE_ALIGNMENT_IN_BYTES =
1434 (1 << TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES),
1436 /* Log base 2 of TILE_SN_INSTRUCTION_SIZE_IN_BYTES. */
1437 TILE_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES = 1,
1439 /* Static network instructions take this many bytes. */
1440 TILE_SN_INSTRUCTION_SIZE_IN_BYTES =
1441 (1 << TILE_LOG2_SN_INSTRUCTION_SIZE_IN_BYTES),
1443 /* Number of registers (some are magic, such as network I/O). */
1444 TILE_NUM_REGISTERS = 64,
1446 /* Number of static network registers. */
1447 TILE_NUM_SN_REGISTERS = 4
1453 /* Is this operand a register, immediate or address? */
1454 tile_operand_type type;
1456 /* The default relocation type for this operand. */
1457 signed int default_reloc : 16;
1459 /* How many bits is this value? (used for range checking) */
1460 unsigned int num_bits : 5;
1462 /* Is the value signed? (used for range checking) */
1463 unsigned int is_signed : 1;
1465 /* Is this operand a source register? */
1466 unsigned int is_src_reg : 1;
1468 /* Is this operand written? (i.e. is it a destination register) */
1469 unsigned int is_dest_reg : 1;
1471 /* Is this operand PC-relative? */
1472 unsigned int is_pc_relative : 1;
1474 /* By how many bits do we right shift the value before inserting? */
1475 unsigned int rightshift : 2;
1477 /* Return the bits for this operand to be ORed into an existing bundle. */
1478 tile_bundle_bits (*insert) (int op);
1480 /* Extract this operand and return it. */
1481 unsigned int (*extract) (tile_bundle_bits bundle);
1485 extern const struct tile_operand tile_operands[];
1487 /* One finite-state machine per pipe for rapid instruction decoding. */
1488 extern const unsigned short * const
1489 tile_bundle_decoder_fsms[TILE_NUM_PIPELINE_ENCODINGS];
1494 /* The opcode mnemonic, e.g. "add" */
1497 /* The enum value for this mnemonic. */
1498 tile_mnemonic mnemonic;
1500 /* A bit mask of which of the five pipes this instruction
1507 unsigned char pipes;
1509 /* How many operands are there? */
1510 unsigned char num_operands;
1512 /* Which register does this write implicitly, or TREG_ZERO if none? */
1513 unsigned char implicitly_written_register;
1515 /* Can this be bundled with other instructions (almost always true). */
1516 unsigned char can_bundle;
1518 /* The description of the operands. Each of these is an
1519 * index into the tile_operands[] table. */
1520 unsigned char operands[TILE_NUM_PIPELINE_ENCODINGS][TILE_MAX_OPERANDS];
1522 /* A mask of which bits have predefined values for each pipeline.
1523 * This is useful for disassembly. */
1524 tile_bundle_bits fixed_bit_masks[TILE_NUM_PIPELINE_ENCODINGS];
1526 /* For each bit set in fixed_bit_masks, what the value is for this
1528 tile_bundle_bits fixed_bit_values[TILE_NUM_PIPELINE_ENCODINGS];
1531 extern const struct tile_opcode tile_opcodes[];
1533 struct tile_sn_opcode
1535 /* The opcode mnemonic, e.g. "add" */
1538 /* The enum value for this mnemonic. */
1539 tile_sn_mnemonic mnemonic;
1541 /* How many operands are there? */
1542 unsigned char num_operands;
1544 /* The description of the operands. Each of these is an
1545 * index into the tile_operands[] table. */
1546 unsigned char operands[TILE_SN_MAX_OPERANDS];
1548 /* A mask of which bits have predefined values.
1549 * This is useful for disassembly. */
1550 tile_sn_instruction_bits fixed_bit_mask;
1552 /* For each bit set in fixed_bit_masks, what its value is. */
1553 tile_sn_instruction_bits fixed_bit_values;
1556 extern const struct tile_sn_opcode tile_sn_opcodes[];
1558 /* Used for non-textual disassembly into structs. */
1559 struct tile_decoded_instruction
1561 const struct tile_opcode *opcode;
1562 const struct tile_operand *operands[TILE_MAX_OPERANDS];
1563 int operand_values[TILE_MAX_OPERANDS];
1567 /* Disassemble a bundle into a struct for machine processing. */
1568 extern int parse_insn_tile(tile_bundle_bits bits,
1570 struct tile_decoded_instruction
1571 decoded[TILE_MAX_INSTRUCTIONS_PER_BUNDLE]);
1574 /* Canonical names of all the registers. */
1575 /* ISSUE: This table lives in "tile-dis.c" */
1576 extern const char * const tile_register_names[];
1578 /* Descriptor for a special-purpose register. */
1588 /* List of all the SPRs; ordered by increasing number. */
1589 extern const struct tile_spr tile_sprs[];
1591 /* Number of special-purpose registers. */
1592 extern const int tile_num_sprs;
1595 get_tile_spr_name (int num);
1597 #endif /* opcode_tile_h */