1 /* TILE-Gx 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,
24 typedef unsigned long long tilegx_bundle_bits
;
29 TILEGX_MAX_OPERANDS
= 4 /* bfexts */
41 TILEGX_OPC_PREFETCH_ADD_L1
,
42 TILEGX_OPC_PREFETCH_ADD_L1_FAULT
,
43 TILEGX_OPC_PREFETCH_ADD_L2
,
44 TILEGX_OPC_PREFETCH_ADD_L2_FAULT
,
45 TILEGX_OPC_PREFETCH_ADD_L3
,
46 TILEGX_OPC_PREFETCH_ADD_L3_FAULT
,
47 TILEGX_OPC_PREFETCH_L1
,
48 TILEGX_OPC_PREFETCH_L1_FAULT
,
49 TILEGX_OPC_PREFETCH_L2
,
50 TILEGX_OPC_PREFETCH_L2_FAULT
,
51 TILEGX_OPC_PREFETCH_L3
,
52 TILEGX_OPC_PREFETCH_L3_FAULT
,
107 TILEGX_OPC_DBLALIGN2
,
108 TILEGX_OPC_DBLALIGN4
,
109 TILEGX_OPC_DBLALIGN6
,
114 TILEGX_OPC_FDOUBLE_ADD_FLAGS
,
115 TILEGX_OPC_FDOUBLE_ADDSUB
,
116 TILEGX_OPC_FDOUBLE_MUL_FLAGS
,
117 TILEGX_OPC_FDOUBLE_PACK1
,
118 TILEGX_OPC_FDOUBLE_PACK2
,
119 TILEGX_OPC_FDOUBLE_SUB_FLAGS
,
120 TILEGX_OPC_FDOUBLE_UNPACK_MAX
,
121 TILEGX_OPC_FDOUBLE_UNPACK_MIN
,
123 TILEGX_OPC_FETCHADD4
,
124 TILEGX_OPC_FETCHADDGEZ
,
125 TILEGX_OPC_FETCHADDGEZ4
,
127 TILEGX_OPC_FETCHAND4
,
134 TILEGX_OPC_FSINGLE_ADD1
,
135 TILEGX_OPC_FSINGLE_ADDSUB2
,
136 TILEGX_OPC_FSINGLE_MUL1
,
137 TILEGX_OPC_FSINGLE_MUL2
,
138 TILEGX_OPC_FSINGLE_PACK1
,
139 TILEGX_OPC_FSINGLE_PACK2
,
140 TILEGX_OPC_FSINGLE_SUB1
,
169 TILEGX_OPC_LDNT1S_ADD
,
171 TILEGX_OPC_LDNT1U_ADD
,
173 TILEGX_OPC_LDNT2S_ADD
,
175 TILEGX_OPC_LDNT2U_ADD
,
177 TILEGX_OPC_LDNT4S_ADD
,
179 TILEGX_OPC_LDNT4U_ADD
,
187 TILEGX_OPC_MUL_HS_HS
,
188 TILEGX_OPC_MUL_HS_HU
,
189 TILEGX_OPC_MUL_HS_LS
,
190 TILEGX_OPC_MUL_HS_LU
,
191 TILEGX_OPC_MUL_HU_HU
,
192 TILEGX_OPC_MUL_HU_LS
,
193 TILEGX_OPC_MUL_HU_LU
,
194 TILEGX_OPC_MUL_LS_LS
,
195 TILEGX_OPC_MUL_LS_LU
,
196 TILEGX_OPC_MUL_LU_LU
,
197 TILEGX_OPC_MULA_HS_HS
,
198 TILEGX_OPC_MULA_HS_HU
,
199 TILEGX_OPC_MULA_HS_LS
,
200 TILEGX_OPC_MULA_HS_LU
,
201 TILEGX_OPC_MULA_HU_HU
,
202 TILEGX_OPC_MULA_HU_LS
,
203 TILEGX_OPC_MULA_HU_LU
,
204 TILEGX_OPC_MULA_LS_LS
,
205 TILEGX_OPC_MULA_LS_LU
,
206 TILEGX_OPC_MULA_LU_LU
,
221 TILEGX_OPC_SHL16INSLI
,
237 TILEGX_OPC_SHUFFLEBYTES
,
248 TILEGX_OPC_STNT1_ADD
,
250 TILEGX_OPC_STNT2_ADD
,
252 TILEGX_OPC_STNT4_ADD
,
275 TILEGX_OPC_V1CMPLTSI
,
277 TILEGX_OPC_V1CMPLTUI
,
280 TILEGX_OPC_V1DDOTPUA
,
281 TILEGX_OPC_V1DDOTPUS
,
282 TILEGX_OPC_V1DDOTPUSA
,
288 TILEGX_OPC_V1DOTPUSA
,
320 TILEGX_OPC_V2CMPLTSI
,
322 TILEGX_OPC_V2CMPLTUI
,
370 /* 64-bit pattern for a { bpt ; nop } bundle. */
371 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
375 static __inline
unsigned int
376 get_BFEnd_X0(tilegx_bundle_bits num
)
378 const unsigned int n
= (unsigned int)num
;
379 return (((n
>> 12)) & 0x3f);
382 static __inline
unsigned int
383 get_BFOpcodeExtension_X0(tilegx_bundle_bits num
)
385 const unsigned int n
= (unsigned int)num
;
386 return (((n
>> 24)) & 0xf);
389 static __inline
unsigned int
390 get_BFStart_X0(tilegx_bundle_bits num
)
392 const unsigned int n
= (unsigned int)num
;
393 return (((n
>> 18)) & 0x3f);
396 static __inline
unsigned int
397 get_BrOff_X1(tilegx_bundle_bits n
)
399 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
400 (((unsigned int)(n
>> 37)) & 0x0001ffc0);
403 static __inline
unsigned int
404 get_BrType_X1(tilegx_bundle_bits n
)
406 return (((unsigned int)(n
>> 54)) & 0x1f);
409 static __inline
unsigned int
410 get_Dest_Imm8_X1(tilegx_bundle_bits n
)
412 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
413 (((unsigned int)(n
>> 43)) & 0x000000c0);
416 static __inline
unsigned int
417 get_Dest_X0(tilegx_bundle_bits num
)
419 const unsigned int n
= (unsigned int)num
;
420 return (((n
>> 0)) & 0x3f);
423 static __inline
unsigned int
424 get_Dest_X1(tilegx_bundle_bits n
)
426 return (((unsigned int)(n
>> 31)) & 0x3f);
429 static __inline
unsigned int
430 get_Dest_Y0(tilegx_bundle_bits num
)
432 const unsigned int n
= (unsigned int)num
;
433 return (((n
>> 0)) & 0x3f);
436 static __inline
unsigned int
437 get_Dest_Y1(tilegx_bundle_bits n
)
439 return (((unsigned int)(n
>> 31)) & 0x3f);
442 static __inline
unsigned int
443 get_Imm16_X0(tilegx_bundle_bits num
)
445 const unsigned int n
= (unsigned int)num
;
446 return (((n
>> 12)) & 0xffff);
449 static __inline
unsigned int
450 get_Imm16_X1(tilegx_bundle_bits n
)
452 return (((unsigned int)(n
>> 43)) & 0xffff);
455 static __inline
unsigned int
456 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num
)
458 const unsigned int n
= (unsigned int)num
;
459 return (((n
>> 20)) & 0xff);
462 static __inline
unsigned int
463 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n
)
465 return (((unsigned int)(n
>> 51)) & 0xff);
468 static __inline
unsigned int
469 get_Imm8_X0(tilegx_bundle_bits num
)
471 const unsigned int n
= (unsigned int)num
;
472 return (((n
>> 12)) & 0xff);
475 static __inline
unsigned int
476 get_Imm8_X1(tilegx_bundle_bits n
)
478 return (((unsigned int)(n
>> 43)) & 0xff);
481 static __inline
unsigned int
482 get_Imm8_Y0(tilegx_bundle_bits num
)
484 const unsigned int n
= (unsigned int)num
;
485 return (((n
>> 12)) & 0xff);
488 static __inline
unsigned int
489 get_Imm8_Y1(tilegx_bundle_bits n
)
491 return (((unsigned int)(n
>> 43)) & 0xff);
494 static __inline
unsigned int
495 get_JumpOff_X1(tilegx_bundle_bits n
)
497 return (((unsigned int)(n
>> 31)) & 0x7ffffff);
500 static __inline
unsigned int
501 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n
)
503 return (((unsigned int)(n
>> 58)) & 0x1);
506 static __inline
unsigned int
507 get_MF_Imm14_X1(tilegx_bundle_bits n
)
509 return (((unsigned int)(n
>> 37)) & 0x3fff);
512 static __inline
unsigned int
513 get_MT_Imm14_X1(tilegx_bundle_bits n
)
515 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
516 (((unsigned int)(n
>> 37)) & 0x00003fc0);
519 static __inline
unsigned int
520 get_Mode(tilegx_bundle_bits n
)
522 return (((unsigned int)(n
>> 62)) & 0x3);
525 static __inline
unsigned int
526 get_Opcode_X0(tilegx_bundle_bits num
)
528 const unsigned int n
= (unsigned int)num
;
529 return (((n
>> 28)) & 0x7);
532 static __inline
unsigned int
533 get_Opcode_X1(tilegx_bundle_bits n
)
535 return (((unsigned int)(n
>> 59)) & 0x7);
538 static __inline
unsigned int
539 get_Opcode_Y0(tilegx_bundle_bits num
)
541 const unsigned int n
= (unsigned int)num
;
542 return (((n
>> 27)) & 0xf);
545 static __inline
unsigned int
546 get_Opcode_Y1(tilegx_bundle_bits n
)
548 return (((unsigned int)(n
>> 58)) & 0xf);
551 static __inline
unsigned int
552 get_Opcode_Y2(tilegx_bundle_bits n
)
554 return (((n
>> 26)) & 0x00000001) |
555 (((unsigned int)(n
>> 56)) & 0x00000002);
558 static __inline
unsigned int
559 get_RRROpcodeExtension_X0(tilegx_bundle_bits num
)
561 const unsigned int n
= (unsigned int)num
;
562 return (((n
>> 18)) & 0x3ff);
565 static __inline
unsigned int
566 get_RRROpcodeExtension_X1(tilegx_bundle_bits n
)
568 return (((unsigned int)(n
>> 49)) & 0x3ff);
571 static __inline
unsigned int
572 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num
)
574 const unsigned int n
= (unsigned int)num
;
575 return (((n
>> 18)) & 0x3);
578 static __inline
unsigned int
579 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n
)
581 return (((unsigned int)(n
>> 49)) & 0x3);
584 static __inline
unsigned int
585 get_ShAmt_X0(tilegx_bundle_bits num
)
587 const unsigned int n
= (unsigned int)num
;
588 return (((n
>> 12)) & 0x3f);
591 static __inline
unsigned int
592 get_ShAmt_X1(tilegx_bundle_bits n
)
594 return (((unsigned int)(n
>> 43)) & 0x3f);
597 static __inline
unsigned int
598 get_ShAmt_Y0(tilegx_bundle_bits num
)
600 const unsigned int n
= (unsigned int)num
;
601 return (((n
>> 12)) & 0x3f);
604 static __inline
unsigned int
605 get_ShAmt_Y1(tilegx_bundle_bits n
)
607 return (((unsigned int)(n
>> 43)) & 0x3f);
610 static __inline
unsigned int
611 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num
)
613 const unsigned int n
= (unsigned int)num
;
614 return (((n
>> 18)) & 0x3ff);
617 static __inline
unsigned int
618 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n
)
620 return (((unsigned int)(n
>> 49)) & 0x3ff);
623 static __inline
unsigned int
624 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num
)
626 const unsigned int n
= (unsigned int)num
;
627 return (((n
>> 18)) & 0x3);
630 static __inline
unsigned int
631 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n
)
633 return (((unsigned int)(n
>> 49)) & 0x3);
636 static __inline
unsigned int
637 get_SrcA_X0(tilegx_bundle_bits num
)
639 const unsigned int n
= (unsigned int)num
;
640 return (((n
>> 6)) & 0x3f);
643 static __inline
unsigned int
644 get_SrcA_X1(tilegx_bundle_bits n
)
646 return (((unsigned int)(n
>> 37)) & 0x3f);
649 static __inline
unsigned int
650 get_SrcA_Y0(tilegx_bundle_bits num
)
652 const unsigned int n
= (unsigned int)num
;
653 return (((n
>> 6)) & 0x3f);
656 static __inline
unsigned int
657 get_SrcA_Y1(tilegx_bundle_bits n
)
659 return (((unsigned int)(n
>> 37)) & 0x3f);
662 static __inline
unsigned int
663 get_SrcA_Y2(tilegx_bundle_bits num
)
665 const unsigned int n
= (unsigned int)num
;
666 return (((n
>> 20)) & 0x3f);
669 static __inline
unsigned int
670 get_SrcBDest_Y2(tilegx_bundle_bits n
)
672 return (((unsigned int)(n
>> 51)) & 0x3f);
675 static __inline
unsigned int
676 get_SrcB_X0(tilegx_bundle_bits num
)
678 const unsigned int n
= (unsigned int)num
;
679 return (((n
>> 12)) & 0x3f);
682 static __inline
unsigned int
683 get_SrcB_X1(tilegx_bundle_bits n
)
685 return (((unsigned int)(n
>> 43)) & 0x3f);
688 static __inline
unsigned int
689 get_SrcB_Y0(tilegx_bundle_bits num
)
691 const unsigned int n
= (unsigned int)num
;
692 return (((n
>> 12)) & 0x3f);
695 static __inline
unsigned int
696 get_SrcB_Y1(tilegx_bundle_bits n
)
698 return (((unsigned int)(n
>> 43)) & 0x3f);
701 static __inline
unsigned int
702 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num
)
704 const unsigned int n
= (unsigned int)num
;
705 return (((n
>> 12)) & 0x3f);
708 static __inline
unsigned int
709 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n
)
711 return (((unsigned int)(n
>> 43)) & 0x3f);
714 static __inline
unsigned int
715 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num
)
717 const unsigned int n
= (unsigned int)num
;
718 return (((n
>> 12)) & 0x3f);
721 static __inline
unsigned int
722 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n
)
724 return (((unsigned int)(n
>> 43)) & 0x3f);
729 sign_extend(int n
, int num_bits
)
731 int shift
= (int)(sizeof(int) * 8 - num_bits
);
732 return (n
<< shift
) >> shift
;
737 static __inline tilegx_bundle_bits
738 create_BFEnd_X0(int num
)
740 const unsigned int n
= (unsigned int)num
;
741 return ((n
& 0x3f) << 12);
744 static __inline tilegx_bundle_bits
745 create_BFOpcodeExtension_X0(int num
)
747 const unsigned int n
= (unsigned int)num
;
748 return ((n
& 0xf) << 24);
751 static __inline tilegx_bundle_bits
752 create_BFStart_X0(int num
)
754 const unsigned int n
= (unsigned int)num
;
755 return ((n
& 0x3f) << 18);
758 static __inline tilegx_bundle_bits
759 create_BrOff_X1(int num
)
761 const unsigned int n
= (unsigned int)num
;
762 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
763 (((tilegx_bundle_bits
)(n
& 0x0001ffc0)) << 37);
766 static __inline tilegx_bundle_bits
767 create_BrType_X1(int num
)
769 const unsigned int n
= (unsigned int)num
;
770 return (((tilegx_bundle_bits
)(n
& 0x1f)) << 54);
773 static __inline tilegx_bundle_bits
774 create_Dest_Imm8_X1(int num
)
776 const unsigned int n
= (unsigned int)num
;
777 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
778 (((tilegx_bundle_bits
)(n
& 0x000000c0)) << 43);
781 static __inline tilegx_bundle_bits
782 create_Dest_X0(int num
)
784 const unsigned int n
= (unsigned int)num
;
785 return ((n
& 0x3f) << 0);
788 static __inline tilegx_bundle_bits
789 create_Dest_X1(int num
)
791 const unsigned int n
= (unsigned int)num
;
792 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
795 static __inline tilegx_bundle_bits
796 create_Dest_Y0(int num
)
798 const unsigned int n
= (unsigned int)num
;
799 return ((n
& 0x3f) << 0);
802 static __inline tilegx_bundle_bits
803 create_Dest_Y1(int num
)
805 const unsigned int n
= (unsigned int)num
;
806 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
809 static __inline tilegx_bundle_bits
810 create_Imm16_X0(int num
)
812 const unsigned int n
= (unsigned int)num
;
813 return ((n
& 0xffff) << 12);
816 static __inline tilegx_bundle_bits
817 create_Imm16_X1(int num
)
819 const unsigned int n
= (unsigned int)num
;
820 return (((tilegx_bundle_bits
)(n
& 0xffff)) << 43);
823 static __inline tilegx_bundle_bits
824 create_Imm8OpcodeExtension_X0(int num
)
826 const unsigned int n
= (unsigned int)num
;
827 return ((n
& 0xff) << 20);
830 static __inline tilegx_bundle_bits
831 create_Imm8OpcodeExtension_X1(int num
)
833 const unsigned int n
= (unsigned int)num
;
834 return (((tilegx_bundle_bits
)(n
& 0xff)) << 51);
837 static __inline tilegx_bundle_bits
838 create_Imm8_X0(int num
)
840 const unsigned int n
= (unsigned int)num
;
841 return ((n
& 0xff) << 12);
844 static __inline tilegx_bundle_bits
845 create_Imm8_X1(int num
)
847 const unsigned int n
= (unsigned int)num
;
848 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
851 static __inline tilegx_bundle_bits
852 create_Imm8_Y0(int num
)
854 const unsigned int n
= (unsigned int)num
;
855 return ((n
& 0xff) << 12);
858 static __inline tilegx_bundle_bits
859 create_Imm8_Y1(int num
)
861 const unsigned int n
= (unsigned int)num
;
862 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
865 static __inline tilegx_bundle_bits
866 create_JumpOff_X1(int num
)
868 const unsigned int n
= (unsigned int)num
;
869 return (((tilegx_bundle_bits
)(n
& 0x7ffffff)) << 31);
872 static __inline tilegx_bundle_bits
873 create_JumpOpcodeExtension_X1(int num
)
875 const unsigned int n
= (unsigned int)num
;
876 return (((tilegx_bundle_bits
)(n
& 0x1)) << 58);
879 static __inline tilegx_bundle_bits
880 create_MF_Imm14_X1(int num
)
882 const unsigned int n
= (unsigned int)num
;
883 return (((tilegx_bundle_bits
)(n
& 0x3fff)) << 37);
886 static __inline tilegx_bundle_bits
887 create_MT_Imm14_X1(int num
)
889 const unsigned int n
= (unsigned int)num
;
890 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
891 (((tilegx_bundle_bits
)(n
& 0x00003fc0)) << 37);
894 static __inline tilegx_bundle_bits
897 const unsigned int n
= (unsigned int)num
;
898 return (((tilegx_bundle_bits
)(n
& 0x3)) << 62);
901 static __inline tilegx_bundle_bits
902 create_Opcode_X0(int num
)
904 const unsigned int n
= (unsigned int)num
;
905 return ((n
& 0x7) << 28);
908 static __inline tilegx_bundle_bits
909 create_Opcode_X1(int num
)
911 const unsigned int n
= (unsigned int)num
;
912 return (((tilegx_bundle_bits
)(n
& 0x7)) << 59);
915 static __inline tilegx_bundle_bits
916 create_Opcode_Y0(int num
)
918 const unsigned int n
= (unsigned int)num
;
919 return ((n
& 0xf) << 27);
922 static __inline tilegx_bundle_bits
923 create_Opcode_Y1(int num
)
925 const unsigned int n
= (unsigned int)num
;
926 return (((tilegx_bundle_bits
)(n
& 0xf)) << 58);
929 static __inline tilegx_bundle_bits
930 create_Opcode_Y2(int num
)
932 const unsigned int n
= (unsigned int)num
;
933 return ((n
& 0x00000001) << 26) |
934 (((tilegx_bundle_bits
)(n
& 0x00000002)) << 56);
937 static __inline tilegx_bundle_bits
938 create_RRROpcodeExtension_X0(int num
)
940 const unsigned int n
= (unsigned int)num
;
941 return ((n
& 0x3ff) << 18);
944 static __inline tilegx_bundle_bits
945 create_RRROpcodeExtension_X1(int num
)
947 const unsigned int n
= (unsigned int)num
;
948 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
951 static __inline tilegx_bundle_bits
952 create_RRROpcodeExtension_Y0(int num
)
954 const unsigned int n
= (unsigned int)num
;
955 return ((n
& 0x3) << 18);
958 static __inline tilegx_bundle_bits
959 create_RRROpcodeExtension_Y1(int num
)
961 const unsigned int n
= (unsigned int)num
;
962 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
965 static __inline tilegx_bundle_bits
966 create_ShAmt_X0(int num
)
968 const unsigned int n
= (unsigned int)num
;
969 return ((n
& 0x3f) << 12);
972 static __inline tilegx_bundle_bits
973 create_ShAmt_X1(int num
)
975 const unsigned int n
= (unsigned int)num
;
976 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
979 static __inline tilegx_bundle_bits
980 create_ShAmt_Y0(int num
)
982 const unsigned int n
= (unsigned int)num
;
983 return ((n
& 0x3f) << 12);
986 static __inline tilegx_bundle_bits
987 create_ShAmt_Y1(int num
)
989 const unsigned int n
= (unsigned int)num
;
990 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
993 static __inline tilegx_bundle_bits
994 create_ShiftOpcodeExtension_X0(int num
)
996 const unsigned int n
= (unsigned int)num
;
997 return ((n
& 0x3ff) << 18);
1000 static __inline tilegx_bundle_bits
1001 create_ShiftOpcodeExtension_X1(int num
)
1003 const unsigned int n
= (unsigned int)num
;
1004 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
1007 static __inline tilegx_bundle_bits
1008 create_ShiftOpcodeExtension_Y0(int num
)
1010 const unsigned int n
= (unsigned int)num
;
1011 return ((n
& 0x3) << 18);
1014 static __inline tilegx_bundle_bits
1015 create_ShiftOpcodeExtension_Y1(int num
)
1017 const unsigned int n
= (unsigned int)num
;
1018 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
1021 static __inline tilegx_bundle_bits
1022 create_SrcA_X0(int num
)
1024 const unsigned int n
= (unsigned int)num
;
1025 return ((n
& 0x3f) << 6);
1028 static __inline tilegx_bundle_bits
1029 create_SrcA_X1(int num
)
1031 const unsigned int n
= (unsigned int)num
;
1032 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1035 static __inline tilegx_bundle_bits
1036 create_SrcA_Y0(int num
)
1038 const unsigned int n
= (unsigned int)num
;
1039 return ((n
& 0x3f) << 6);
1042 static __inline tilegx_bundle_bits
1043 create_SrcA_Y1(int num
)
1045 const unsigned int n
= (unsigned int)num
;
1046 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1049 static __inline tilegx_bundle_bits
1050 create_SrcA_Y2(int num
)
1052 const unsigned int n
= (unsigned int)num
;
1053 return ((n
& 0x3f) << 20);
1056 static __inline tilegx_bundle_bits
1057 create_SrcBDest_Y2(int num
)
1059 const unsigned int n
= (unsigned int)num
;
1060 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 51);
1063 static __inline tilegx_bundle_bits
1064 create_SrcB_X0(int num
)
1066 const unsigned int n
= (unsigned int)num
;
1067 return ((n
& 0x3f) << 12);
1070 static __inline tilegx_bundle_bits
1071 create_SrcB_X1(int num
)
1073 const unsigned int n
= (unsigned int)num
;
1074 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1077 static __inline tilegx_bundle_bits
1078 create_SrcB_Y0(int num
)
1080 const unsigned int n
= (unsigned int)num
;
1081 return ((n
& 0x3f) << 12);
1084 static __inline tilegx_bundle_bits
1085 create_SrcB_Y1(int num
)
1087 const unsigned int n
= (unsigned int)num
;
1088 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1091 static __inline tilegx_bundle_bits
1092 create_UnaryOpcodeExtension_X0(int num
)
1094 const unsigned int n
= (unsigned int)num
;
1095 return ((n
& 0x3f) << 12);
1098 static __inline tilegx_bundle_bits
1099 create_UnaryOpcodeExtension_X1(int num
)
1101 const unsigned int n
= (unsigned int)num
;
1102 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1105 static __inline tilegx_bundle_bits
1106 create_UnaryOpcodeExtension_Y0(int num
)
1108 const unsigned int n
= (unsigned int)num
;
1109 return ((n
& 0x3f) << 12);
1112 static __inline tilegx_bundle_bits
1113 create_UnaryOpcodeExtension_Y1(int num
)
1115 const unsigned int n
= (unsigned int)num
;
1116 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1129 #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1133 TILEGX_OP_TYPE_REGISTER
,
1134 TILEGX_OP_TYPE_IMMEDIATE
,
1135 TILEGX_OP_TYPE_ADDRESS
,
1137 } tilegx_operand_type
;
1139 /* These are the bits that determine if a bundle is in the X encoding. */
1140 #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
1144 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1145 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1147 /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1148 TILEGX_NUM_PIPELINE_ENCODINGS
= 5,
1150 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1151 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
= 3,
1153 /* Instructions take this many bytes. */
1154 TILEGX_BUNDLE_SIZE_IN_BYTES
= 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
,
1156 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1157 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
= 3,
1159 /* Bundles should be aligned modulo this number of bytes. */
1160 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
=
1161 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
),
1163 /* Number of registers (some are magic, such as network I/O). */
1164 TILEGX_NUM_REGISTERS
= 64,
1168 struct tilegx_operand
1170 /* Is this operand a register, immediate or address? */
1171 tilegx_operand_type type
;
1173 /* The default relocation type for this operand. */
1174 signed int default_reloc
: 16;
1176 /* How many bits is this value? (used for range checking) */
1177 unsigned int num_bits
: 5;
1179 /* Is the value signed? (used for range checking) */
1180 unsigned int is_signed
: 1;
1182 /* Is this operand a source register? */
1183 unsigned int is_src_reg
: 1;
1185 /* Is this operand written? (i.e. is it a destination register) */
1186 unsigned int is_dest_reg
: 1;
1188 /* Is this operand PC-relative? */
1189 unsigned int is_pc_relative
: 1;
1191 /* By how many bits do we right shift the value before inserting? */
1192 unsigned int rightshift
: 2;
1194 /* Return the bits for this operand to be ORed into an existing bundle. */
1195 tilegx_bundle_bits (*insert
) (int op
);
1197 /* Extract this operand and return it. */
1198 unsigned int (*extract
) (tilegx_bundle_bits bundle
);
1202 extern const struct tilegx_operand tilegx_operands
[];
1204 /* One finite-state machine per pipe for rapid instruction decoding. */
1205 extern const unsigned short * const
1206 tilegx_bundle_decoder_fsms
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1209 struct tilegx_opcode
1211 /* The opcode mnemonic, e.g. "add" */
1214 /* The enum value for this mnemonic. */
1215 tilegx_mnemonic mnemonic
;
1217 /* A bit mask of which of the five pipes this instruction
1224 unsigned char pipes
;
1226 /* How many operands are there? */
1227 unsigned char num_operands
;
1229 /* Which register does this write implicitly, or TREG_ZERO if none? */
1230 unsigned char implicitly_written_register
;
1232 /* Can this be bundled with other instructions (almost always true). */
1233 unsigned char can_bundle
;
1235 /* The description of the operands. Each of these is an
1236 * index into the tilegx_operands[] table. */
1237 unsigned char operands
[TILEGX_NUM_PIPELINE_ENCODINGS
][TILEGX_MAX_OPERANDS
];
1239 #if !defined(__KERNEL__) && !defined(_LIBC)
1240 /* A mask of which bits have predefined values for each pipeline.
1241 * This is useful for disassembly. */
1242 tilegx_bundle_bits fixed_bit_masks
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1244 /* For each bit set in fixed_bit_masks, what the value is for this
1246 tilegx_bundle_bits fixed_bit_values
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1250 extern const struct tilegx_opcode tilegx_opcodes
[];
1252 /* Used for non-textual disassembly into structs. */
1253 struct tilegx_decoded_instruction
1255 const struct tilegx_opcode
*opcode
;
1256 const struct tilegx_operand
*operands
[TILEGX_MAX_OPERANDS
];
1257 long long operand_values
[TILEGX_MAX_OPERANDS
];
1261 /* Disassemble a bundle into a struct for machine processing. */
1262 extern int parse_insn_tilegx(tilegx_bundle_bits bits
,
1263 unsigned long long pc
,
1264 struct tilegx_decoded_instruction
1265 decoded
[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
]);
1268 #if !defined(__KERNEL__) && !defined(_LIBC)
1269 /* Canonical names of all the registers. */
1270 /* ISSUE: This table lives in "tile-dis.c" */
1271 extern const char * const tilegx_register_names
[];
1273 /* Descriptor for a special-purpose register. */
1283 /* List of all the SPRs; ordered by increasing number. */
1284 extern const struct tilegx_spr tilegx_sprs
[];
1286 /* Number of special-purpose registers. */
1287 extern const int tilegx_num_sprs
;
1290 get_tilegx_spr_name (int num
);
1291 #endif /* !__KERNEL__ && !_LIBC */
1293 /* Make a few "tile_" variables to simply common code between
1296 typedef tilegx_bundle_bits tile_bundle_bits
;
1297 #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
1298 #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
1299 #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1300 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1302 #endif /* opcode_tilegx_h */