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 */
43 TILEGX_OPC_PREFETCH_ADD_L1
,
44 TILEGX_OPC_PREFETCH_ADD_L1_FAULT
,
45 TILEGX_OPC_PREFETCH_ADD_L2
,
46 TILEGX_OPC_PREFETCH_ADD_L2_FAULT
,
47 TILEGX_OPC_PREFETCH_ADD_L3
,
48 TILEGX_OPC_PREFETCH_ADD_L3_FAULT
,
49 TILEGX_OPC_PREFETCH_L1
,
50 TILEGX_OPC_PREFETCH_L1_FAULT
,
51 TILEGX_OPC_PREFETCH_L2
,
52 TILEGX_OPC_PREFETCH_L2_FAULT
,
53 TILEGX_OPC_PREFETCH_L3
,
54 TILEGX_OPC_PREFETCH_L3_FAULT
,
109 TILEGX_OPC_DBLALIGN2
,
110 TILEGX_OPC_DBLALIGN4
,
111 TILEGX_OPC_DBLALIGN6
,
116 TILEGX_OPC_FDOUBLE_ADD_FLAGS
,
117 TILEGX_OPC_FDOUBLE_ADDSUB
,
118 TILEGX_OPC_FDOUBLE_MUL_FLAGS
,
119 TILEGX_OPC_FDOUBLE_PACK1
,
120 TILEGX_OPC_FDOUBLE_PACK2
,
121 TILEGX_OPC_FDOUBLE_SUB_FLAGS
,
122 TILEGX_OPC_FDOUBLE_UNPACK_MAX
,
123 TILEGX_OPC_FDOUBLE_UNPACK_MIN
,
125 TILEGX_OPC_FETCHADD4
,
126 TILEGX_OPC_FETCHADDGEZ
,
127 TILEGX_OPC_FETCHADDGEZ4
,
129 TILEGX_OPC_FETCHAND4
,
136 TILEGX_OPC_FSINGLE_ADD1
,
137 TILEGX_OPC_FSINGLE_ADDSUB2
,
138 TILEGX_OPC_FSINGLE_MUL1
,
139 TILEGX_OPC_FSINGLE_MUL2
,
140 TILEGX_OPC_FSINGLE_PACK1
,
141 TILEGX_OPC_FSINGLE_PACK2
,
142 TILEGX_OPC_FSINGLE_SUB1
,
171 TILEGX_OPC_LDNT1S_ADD
,
173 TILEGX_OPC_LDNT1U_ADD
,
175 TILEGX_OPC_LDNT2S_ADD
,
177 TILEGX_OPC_LDNT2U_ADD
,
179 TILEGX_OPC_LDNT4S_ADD
,
181 TILEGX_OPC_LDNT4U_ADD
,
189 TILEGX_OPC_MUL_HS_HS
,
190 TILEGX_OPC_MUL_HS_HU
,
191 TILEGX_OPC_MUL_HS_LS
,
192 TILEGX_OPC_MUL_HS_LU
,
193 TILEGX_OPC_MUL_HU_HU
,
194 TILEGX_OPC_MUL_HU_LS
,
195 TILEGX_OPC_MUL_HU_LU
,
196 TILEGX_OPC_MUL_LS_LS
,
197 TILEGX_OPC_MUL_LS_LU
,
198 TILEGX_OPC_MUL_LU_LU
,
199 TILEGX_OPC_MULA_HS_HS
,
200 TILEGX_OPC_MULA_HS_HU
,
201 TILEGX_OPC_MULA_HS_LS
,
202 TILEGX_OPC_MULA_HS_LU
,
203 TILEGX_OPC_MULA_HU_HU
,
204 TILEGX_OPC_MULA_HU_LS
,
205 TILEGX_OPC_MULA_HU_LU
,
206 TILEGX_OPC_MULA_LS_LS
,
207 TILEGX_OPC_MULA_LS_LU
,
208 TILEGX_OPC_MULA_LU_LU
,
223 TILEGX_OPC_SHL16INSLI
,
239 TILEGX_OPC_SHUFFLEBYTES
,
250 TILEGX_OPC_STNT1_ADD
,
252 TILEGX_OPC_STNT2_ADD
,
254 TILEGX_OPC_STNT4_ADD
,
277 TILEGX_OPC_V1CMPLTSI
,
279 TILEGX_OPC_V1CMPLTUI
,
282 TILEGX_OPC_V1DDOTPUA
,
283 TILEGX_OPC_V1DDOTPUS
,
284 TILEGX_OPC_V1DDOTPUSA
,
290 TILEGX_OPC_V1DOTPUSA
,
322 TILEGX_OPC_V2CMPLTSI
,
324 TILEGX_OPC_V2CMPLTUI
,
372 /* 64-bit pattern for a { bpt ; nop } bundle. */
373 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
377 static __inline
unsigned int
378 get_BFEnd_X0(tilegx_bundle_bits num
)
380 const unsigned int n
= (unsigned int)num
;
381 return (((n
>> 12)) & 0x3f);
384 static __inline
unsigned int
385 get_BFOpcodeExtension_X0(tilegx_bundle_bits num
)
387 const unsigned int n
= (unsigned int)num
;
388 return (((n
>> 24)) & 0xf);
391 static __inline
unsigned int
392 get_BFStart_X0(tilegx_bundle_bits num
)
394 const unsigned int n
= (unsigned int)num
;
395 return (((n
>> 18)) & 0x3f);
398 static __inline
unsigned int
399 get_BrOff_X1(tilegx_bundle_bits n
)
401 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
402 (((unsigned int)(n
>> 37)) & 0x0001ffc0);
405 static __inline
unsigned int
406 get_BrType_X1(tilegx_bundle_bits n
)
408 return (((unsigned int)(n
>> 54)) & 0x1f);
411 static __inline
unsigned int
412 get_Dest_Imm8_X1(tilegx_bundle_bits n
)
414 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
415 (((unsigned int)(n
>> 43)) & 0x000000c0);
418 static __inline
unsigned int
419 get_Dest_X0(tilegx_bundle_bits num
)
421 const unsigned int n
= (unsigned int)num
;
422 return (((n
>> 0)) & 0x3f);
425 static __inline
unsigned int
426 get_Dest_X1(tilegx_bundle_bits n
)
428 return (((unsigned int)(n
>> 31)) & 0x3f);
431 static __inline
unsigned int
432 get_Dest_Y0(tilegx_bundle_bits num
)
434 const unsigned int n
= (unsigned int)num
;
435 return (((n
>> 0)) & 0x3f);
438 static __inline
unsigned int
439 get_Dest_Y1(tilegx_bundle_bits n
)
441 return (((unsigned int)(n
>> 31)) & 0x3f);
444 static __inline
unsigned int
445 get_Imm16_X0(tilegx_bundle_bits num
)
447 const unsigned int n
= (unsigned int)num
;
448 return (((n
>> 12)) & 0xffff);
451 static __inline
unsigned int
452 get_Imm16_X1(tilegx_bundle_bits n
)
454 return (((unsigned int)(n
>> 43)) & 0xffff);
457 static __inline
unsigned int
458 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num
)
460 const unsigned int n
= (unsigned int)num
;
461 return (((n
>> 20)) & 0xff);
464 static __inline
unsigned int
465 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n
)
467 return (((unsigned int)(n
>> 51)) & 0xff);
470 static __inline
unsigned int
471 get_Imm8_X0(tilegx_bundle_bits num
)
473 const unsigned int n
= (unsigned int)num
;
474 return (((n
>> 12)) & 0xff);
477 static __inline
unsigned int
478 get_Imm8_X1(tilegx_bundle_bits n
)
480 return (((unsigned int)(n
>> 43)) & 0xff);
483 static __inline
unsigned int
484 get_Imm8_Y0(tilegx_bundle_bits num
)
486 const unsigned int n
= (unsigned int)num
;
487 return (((n
>> 12)) & 0xff);
490 static __inline
unsigned int
491 get_Imm8_Y1(tilegx_bundle_bits n
)
493 return (((unsigned int)(n
>> 43)) & 0xff);
496 static __inline
unsigned int
497 get_JumpOff_X1(tilegx_bundle_bits n
)
499 return (((unsigned int)(n
>> 31)) & 0x7ffffff);
502 static __inline
unsigned int
503 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n
)
505 return (((unsigned int)(n
>> 58)) & 0x1);
508 static __inline
unsigned int
509 get_MF_Imm14_X1(tilegx_bundle_bits n
)
511 return (((unsigned int)(n
>> 37)) & 0x3fff);
514 static __inline
unsigned int
515 get_MT_Imm14_X1(tilegx_bundle_bits n
)
517 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
518 (((unsigned int)(n
>> 37)) & 0x00003fc0);
521 static __inline
unsigned int
522 get_Mode(tilegx_bundle_bits n
)
524 return (((unsigned int)(n
>> 62)) & 0x3);
527 static __inline
unsigned int
528 get_Opcode_X0(tilegx_bundle_bits num
)
530 const unsigned int n
= (unsigned int)num
;
531 return (((n
>> 28)) & 0x7);
534 static __inline
unsigned int
535 get_Opcode_X1(tilegx_bundle_bits n
)
537 return (((unsigned int)(n
>> 59)) & 0x7);
540 static __inline
unsigned int
541 get_Opcode_Y0(tilegx_bundle_bits num
)
543 const unsigned int n
= (unsigned int)num
;
544 return (((n
>> 27)) & 0xf);
547 static __inline
unsigned int
548 get_Opcode_Y1(tilegx_bundle_bits n
)
550 return (((unsigned int)(n
>> 58)) & 0xf);
553 static __inline
unsigned int
554 get_Opcode_Y2(tilegx_bundle_bits n
)
556 return (((n
>> 26)) & 0x00000001) |
557 (((unsigned int)(n
>> 56)) & 0x00000002);
560 static __inline
unsigned int
561 get_RRROpcodeExtension_X0(tilegx_bundle_bits num
)
563 const unsigned int n
= (unsigned int)num
;
564 return (((n
>> 18)) & 0x3ff);
567 static __inline
unsigned int
568 get_RRROpcodeExtension_X1(tilegx_bundle_bits n
)
570 return (((unsigned int)(n
>> 49)) & 0x3ff);
573 static __inline
unsigned int
574 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num
)
576 const unsigned int n
= (unsigned int)num
;
577 return (((n
>> 18)) & 0x3);
580 static __inline
unsigned int
581 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n
)
583 return (((unsigned int)(n
>> 49)) & 0x3);
586 static __inline
unsigned int
587 get_ShAmt_X0(tilegx_bundle_bits num
)
589 const unsigned int n
= (unsigned int)num
;
590 return (((n
>> 12)) & 0x3f);
593 static __inline
unsigned int
594 get_ShAmt_X1(tilegx_bundle_bits n
)
596 return (((unsigned int)(n
>> 43)) & 0x3f);
599 static __inline
unsigned int
600 get_ShAmt_Y0(tilegx_bundle_bits num
)
602 const unsigned int n
= (unsigned int)num
;
603 return (((n
>> 12)) & 0x3f);
606 static __inline
unsigned int
607 get_ShAmt_Y1(tilegx_bundle_bits n
)
609 return (((unsigned int)(n
>> 43)) & 0x3f);
612 static __inline
unsigned int
613 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num
)
615 const unsigned int n
= (unsigned int)num
;
616 return (((n
>> 18)) & 0x3ff);
619 static __inline
unsigned int
620 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n
)
622 return (((unsigned int)(n
>> 49)) & 0x3ff);
625 static __inline
unsigned int
626 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num
)
628 const unsigned int n
= (unsigned int)num
;
629 return (((n
>> 18)) & 0x3);
632 static __inline
unsigned int
633 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n
)
635 return (((unsigned int)(n
>> 49)) & 0x3);
638 static __inline
unsigned int
639 get_SrcA_X0(tilegx_bundle_bits num
)
641 const unsigned int n
= (unsigned int)num
;
642 return (((n
>> 6)) & 0x3f);
645 static __inline
unsigned int
646 get_SrcA_X1(tilegx_bundle_bits n
)
648 return (((unsigned int)(n
>> 37)) & 0x3f);
651 static __inline
unsigned int
652 get_SrcA_Y0(tilegx_bundle_bits num
)
654 const unsigned int n
= (unsigned int)num
;
655 return (((n
>> 6)) & 0x3f);
658 static __inline
unsigned int
659 get_SrcA_Y1(tilegx_bundle_bits n
)
661 return (((unsigned int)(n
>> 37)) & 0x3f);
664 static __inline
unsigned int
665 get_SrcA_Y2(tilegx_bundle_bits num
)
667 const unsigned int n
= (unsigned int)num
;
668 return (((n
>> 20)) & 0x3f);
671 static __inline
unsigned int
672 get_SrcBDest_Y2(tilegx_bundle_bits n
)
674 return (((unsigned int)(n
>> 51)) & 0x3f);
677 static __inline
unsigned int
678 get_SrcB_X0(tilegx_bundle_bits num
)
680 const unsigned int n
= (unsigned int)num
;
681 return (((n
>> 12)) & 0x3f);
684 static __inline
unsigned int
685 get_SrcB_X1(tilegx_bundle_bits n
)
687 return (((unsigned int)(n
>> 43)) & 0x3f);
690 static __inline
unsigned int
691 get_SrcB_Y0(tilegx_bundle_bits num
)
693 const unsigned int n
= (unsigned int)num
;
694 return (((n
>> 12)) & 0x3f);
697 static __inline
unsigned int
698 get_SrcB_Y1(tilegx_bundle_bits n
)
700 return (((unsigned int)(n
>> 43)) & 0x3f);
703 static __inline
unsigned int
704 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num
)
706 const unsigned int n
= (unsigned int)num
;
707 return (((n
>> 12)) & 0x3f);
710 static __inline
unsigned int
711 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n
)
713 return (((unsigned int)(n
>> 43)) & 0x3f);
716 static __inline
unsigned int
717 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num
)
719 const unsigned int n
= (unsigned int)num
;
720 return (((n
>> 12)) & 0x3f);
723 static __inline
unsigned int
724 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n
)
726 return (((unsigned int)(n
>> 43)) & 0x3f);
731 sign_extend(int n
, int num_bits
)
733 int shift
= (int)(sizeof(int) * 8 - num_bits
);
734 return (n
<< shift
) >> shift
;
739 static __inline tilegx_bundle_bits
740 create_BFEnd_X0(int num
)
742 const unsigned int n
= (unsigned int)num
;
743 return ((n
& 0x3f) << 12);
746 static __inline tilegx_bundle_bits
747 create_BFOpcodeExtension_X0(int num
)
749 const unsigned int n
= (unsigned int)num
;
750 return ((n
& 0xf) << 24);
753 static __inline tilegx_bundle_bits
754 create_BFStart_X0(int num
)
756 const unsigned int n
= (unsigned int)num
;
757 return ((n
& 0x3f) << 18);
760 static __inline tilegx_bundle_bits
761 create_BrOff_X1(int num
)
763 const unsigned int n
= (unsigned int)num
;
764 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
765 (((tilegx_bundle_bits
)(n
& 0x0001ffc0)) << 37);
768 static __inline tilegx_bundle_bits
769 create_BrType_X1(int num
)
771 const unsigned int n
= (unsigned int)num
;
772 return (((tilegx_bundle_bits
)(n
& 0x1f)) << 54);
775 static __inline tilegx_bundle_bits
776 create_Dest_Imm8_X1(int num
)
778 const unsigned int n
= (unsigned int)num
;
779 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
780 (((tilegx_bundle_bits
)(n
& 0x000000c0)) << 43);
783 static __inline tilegx_bundle_bits
784 create_Dest_X0(int num
)
786 const unsigned int n
= (unsigned int)num
;
787 return ((n
& 0x3f) << 0);
790 static __inline tilegx_bundle_bits
791 create_Dest_X1(int num
)
793 const unsigned int n
= (unsigned int)num
;
794 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
797 static __inline tilegx_bundle_bits
798 create_Dest_Y0(int num
)
800 const unsigned int n
= (unsigned int)num
;
801 return ((n
& 0x3f) << 0);
804 static __inline tilegx_bundle_bits
805 create_Dest_Y1(int num
)
807 const unsigned int n
= (unsigned int)num
;
808 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
811 static __inline tilegx_bundle_bits
812 create_Imm16_X0(int num
)
814 const unsigned int n
= (unsigned int)num
;
815 return ((n
& 0xffff) << 12);
818 static __inline tilegx_bundle_bits
819 create_Imm16_X1(int num
)
821 const unsigned int n
= (unsigned int)num
;
822 return (((tilegx_bundle_bits
)(n
& 0xffff)) << 43);
825 static __inline tilegx_bundle_bits
826 create_Imm8OpcodeExtension_X0(int num
)
828 const unsigned int n
= (unsigned int)num
;
829 return ((n
& 0xff) << 20);
832 static __inline tilegx_bundle_bits
833 create_Imm8OpcodeExtension_X1(int num
)
835 const unsigned int n
= (unsigned int)num
;
836 return (((tilegx_bundle_bits
)(n
& 0xff)) << 51);
839 static __inline tilegx_bundle_bits
840 create_Imm8_X0(int num
)
842 const unsigned int n
= (unsigned int)num
;
843 return ((n
& 0xff) << 12);
846 static __inline tilegx_bundle_bits
847 create_Imm8_X1(int num
)
849 const unsigned int n
= (unsigned int)num
;
850 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
853 static __inline tilegx_bundle_bits
854 create_Imm8_Y0(int num
)
856 const unsigned int n
= (unsigned int)num
;
857 return ((n
& 0xff) << 12);
860 static __inline tilegx_bundle_bits
861 create_Imm8_Y1(int num
)
863 const unsigned int n
= (unsigned int)num
;
864 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
867 static __inline tilegx_bundle_bits
868 create_JumpOff_X1(int num
)
870 const unsigned int n
= (unsigned int)num
;
871 return (((tilegx_bundle_bits
)(n
& 0x7ffffff)) << 31);
874 static __inline tilegx_bundle_bits
875 create_JumpOpcodeExtension_X1(int num
)
877 const unsigned int n
= (unsigned int)num
;
878 return (((tilegx_bundle_bits
)(n
& 0x1)) << 58);
881 static __inline tilegx_bundle_bits
882 create_MF_Imm14_X1(int num
)
884 const unsigned int n
= (unsigned int)num
;
885 return (((tilegx_bundle_bits
)(n
& 0x3fff)) << 37);
888 static __inline tilegx_bundle_bits
889 create_MT_Imm14_X1(int num
)
891 const unsigned int n
= (unsigned int)num
;
892 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
893 (((tilegx_bundle_bits
)(n
& 0x00003fc0)) << 37);
896 static __inline tilegx_bundle_bits
899 const unsigned int n
= (unsigned int)num
;
900 return (((tilegx_bundle_bits
)(n
& 0x3)) << 62);
903 static __inline tilegx_bundle_bits
904 create_Opcode_X0(int num
)
906 const unsigned int n
= (unsigned int)num
;
907 return ((n
& 0x7) << 28);
910 static __inline tilegx_bundle_bits
911 create_Opcode_X1(int num
)
913 const unsigned int n
= (unsigned int)num
;
914 return (((tilegx_bundle_bits
)(n
& 0x7)) << 59);
917 static __inline tilegx_bundle_bits
918 create_Opcode_Y0(int num
)
920 const unsigned int n
= (unsigned int)num
;
921 return ((n
& 0xf) << 27);
924 static __inline tilegx_bundle_bits
925 create_Opcode_Y1(int num
)
927 const unsigned int n
= (unsigned int)num
;
928 return (((tilegx_bundle_bits
)(n
& 0xf)) << 58);
931 static __inline tilegx_bundle_bits
932 create_Opcode_Y2(int num
)
934 const unsigned int n
= (unsigned int)num
;
935 return ((n
& 0x00000001) << 26) |
936 (((tilegx_bundle_bits
)(n
& 0x00000002)) << 56);
939 static __inline tilegx_bundle_bits
940 create_RRROpcodeExtension_X0(int num
)
942 const unsigned int n
= (unsigned int)num
;
943 return ((n
& 0x3ff) << 18);
946 static __inline tilegx_bundle_bits
947 create_RRROpcodeExtension_X1(int num
)
949 const unsigned int n
= (unsigned int)num
;
950 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
953 static __inline tilegx_bundle_bits
954 create_RRROpcodeExtension_Y0(int num
)
956 const unsigned int n
= (unsigned int)num
;
957 return ((n
& 0x3) << 18);
960 static __inline tilegx_bundle_bits
961 create_RRROpcodeExtension_Y1(int num
)
963 const unsigned int n
= (unsigned int)num
;
964 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
967 static __inline tilegx_bundle_bits
968 create_ShAmt_X0(int num
)
970 const unsigned int n
= (unsigned int)num
;
971 return ((n
& 0x3f) << 12);
974 static __inline tilegx_bundle_bits
975 create_ShAmt_X1(int num
)
977 const unsigned int n
= (unsigned int)num
;
978 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
981 static __inline tilegx_bundle_bits
982 create_ShAmt_Y0(int num
)
984 const unsigned int n
= (unsigned int)num
;
985 return ((n
& 0x3f) << 12);
988 static __inline tilegx_bundle_bits
989 create_ShAmt_Y1(int num
)
991 const unsigned int n
= (unsigned int)num
;
992 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
995 static __inline tilegx_bundle_bits
996 create_ShiftOpcodeExtension_X0(int num
)
998 const unsigned int n
= (unsigned int)num
;
999 return ((n
& 0x3ff) << 18);
1002 static __inline tilegx_bundle_bits
1003 create_ShiftOpcodeExtension_X1(int num
)
1005 const unsigned int n
= (unsigned int)num
;
1006 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
1009 static __inline tilegx_bundle_bits
1010 create_ShiftOpcodeExtension_Y0(int num
)
1012 const unsigned int n
= (unsigned int)num
;
1013 return ((n
& 0x3) << 18);
1016 static __inline tilegx_bundle_bits
1017 create_ShiftOpcodeExtension_Y1(int num
)
1019 const unsigned int n
= (unsigned int)num
;
1020 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
1023 static __inline tilegx_bundle_bits
1024 create_SrcA_X0(int num
)
1026 const unsigned int n
= (unsigned int)num
;
1027 return ((n
& 0x3f) << 6);
1030 static __inline tilegx_bundle_bits
1031 create_SrcA_X1(int num
)
1033 const unsigned int n
= (unsigned int)num
;
1034 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1037 static __inline tilegx_bundle_bits
1038 create_SrcA_Y0(int num
)
1040 const unsigned int n
= (unsigned int)num
;
1041 return ((n
& 0x3f) << 6);
1044 static __inline tilegx_bundle_bits
1045 create_SrcA_Y1(int num
)
1047 const unsigned int n
= (unsigned int)num
;
1048 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1051 static __inline tilegx_bundle_bits
1052 create_SrcA_Y2(int num
)
1054 const unsigned int n
= (unsigned int)num
;
1055 return ((n
& 0x3f) << 20);
1058 static __inline tilegx_bundle_bits
1059 create_SrcBDest_Y2(int num
)
1061 const unsigned int n
= (unsigned int)num
;
1062 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 51);
1065 static __inline tilegx_bundle_bits
1066 create_SrcB_X0(int num
)
1068 const unsigned int n
= (unsigned int)num
;
1069 return ((n
& 0x3f) << 12);
1072 static __inline tilegx_bundle_bits
1073 create_SrcB_X1(int num
)
1075 const unsigned int n
= (unsigned int)num
;
1076 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1079 static __inline tilegx_bundle_bits
1080 create_SrcB_Y0(int num
)
1082 const unsigned int n
= (unsigned int)num
;
1083 return ((n
& 0x3f) << 12);
1086 static __inline tilegx_bundle_bits
1087 create_SrcB_Y1(int num
)
1089 const unsigned int n
= (unsigned int)num
;
1090 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1093 static __inline tilegx_bundle_bits
1094 create_UnaryOpcodeExtension_X0(int num
)
1096 const unsigned int n
= (unsigned int)num
;
1097 return ((n
& 0x3f) << 12);
1100 static __inline tilegx_bundle_bits
1101 create_UnaryOpcodeExtension_X1(int num
)
1103 const unsigned int n
= (unsigned int)num
;
1104 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1107 static __inline tilegx_bundle_bits
1108 create_UnaryOpcodeExtension_Y0(int num
)
1110 const unsigned int n
= (unsigned int)num
;
1111 return ((n
& 0x3f) << 12);
1114 static __inline tilegx_bundle_bits
1115 create_UnaryOpcodeExtension_Y1(int num
)
1117 const unsigned int n
= (unsigned int)num
;
1118 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1131 #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1135 TILEGX_OP_TYPE_REGISTER
,
1136 TILEGX_OP_TYPE_IMMEDIATE
,
1137 TILEGX_OP_TYPE_ADDRESS
,
1139 } tilegx_operand_type
;
1141 /* These are the bits that determine if a bundle is in the X encoding. */
1142 #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
1146 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1147 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1149 /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1150 TILEGX_NUM_PIPELINE_ENCODINGS
= 5,
1152 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1153 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
= 3,
1155 /* Instructions take this many bytes. */
1156 TILEGX_BUNDLE_SIZE_IN_BYTES
= 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
,
1158 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1159 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
= 3,
1161 /* Bundles should be aligned modulo this number of bytes. */
1162 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
=
1163 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
),
1165 /* Number of registers (some are magic, such as network I/O). */
1166 TILEGX_NUM_REGISTERS
= 64,
1170 struct tilegx_operand
1172 /* Is this operand a register, immediate or address? */
1173 tilegx_operand_type type
;
1175 /* The default relocation type for this operand. */
1176 signed int default_reloc
: 16;
1178 /* How many bits is this value? (used for range checking) */
1179 unsigned int num_bits
: 5;
1181 /* Is the value signed? (used for range checking) */
1182 unsigned int is_signed
: 1;
1184 /* Is this operand a source register? */
1185 unsigned int is_src_reg
: 1;
1187 /* Is this operand written? (i.e. is it a destination register) */
1188 unsigned int is_dest_reg
: 1;
1190 /* Is this operand PC-relative? */
1191 unsigned int is_pc_relative
: 1;
1193 /* By how many bits do we right shift the value before inserting? */
1194 unsigned int rightshift
: 2;
1196 /* Return the bits for this operand to be ORed into an existing bundle. */
1197 tilegx_bundle_bits (*insert
) (int op
);
1199 /* Extract this operand and return it. */
1200 unsigned int (*extract
) (tilegx_bundle_bits bundle
);
1204 extern const struct tilegx_operand tilegx_operands
[];
1206 /* One finite-state machine per pipe for rapid instruction decoding. */
1207 extern const unsigned short * const
1208 tilegx_bundle_decoder_fsms
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1211 struct tilegx_opcode
1213 /* The opcode mnemonic, e.g. "add" */
1216 /* The enum value for this mnemonic. */
1217 tilegx_mnemonic mnemonic
;
1219 /* A bit mask of which of the five pipes this instruction
1226 unsigned char pipes
;
1228 /* How many operands are there? */
1229 unsigned char num_operands
;
1231 /* Which register does this write implicitly, or TREG_ZERO if none? */
1232 unsigned char implicitly_written_register
;
1234 /* Can this be bundled with other instructions (almost always true). */
1235 unsigned char can_bundle
;
1237 /* The description of the operands. Each of these is an
1238 * index into the tilegx_operands[] table. */
1239 unsigned char operands
[TILEGX_NUM_PIPELINE_ENCODINGS
][TILEGX_MAX_OPERANDS
];
1241 #if !defined(__KERNEL__) && !defined(_LIBC)
1242 /* A mask of which bits have predefined values for each pipeline.
1243 * This is useful for disassembly. */
1244 tilegx_bundle_bits fixed_bit_masks
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1246 /* For each bit set in fixed_bit_masks, what the value is for this
1248 tilegx_bundle_bits fixed_bit_values
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1252 extern const struct tilegx_opcode tilegx_opcodes
[];
1254 /* Used for non-textual disassembly into structs. */
1255 struct tilegx_decoded_instruction
1257 const struct tilegx_opcode
*opcode
;
1258 const struct tilegx_operand
*operands
[TILEGX_MAX_OPERANDS
];
1259 long long operand_values
[TILEGX_MAX_OPERANDS
];
1263 /* Disassemble a bundle into a struct for machine processing. */
1264 extern int parse_insn_tilegx(tilegx_bundle_bits bits
,
1265 unsigned long long pc
,
1266 struct tilegx_decoded_instruction
1267 decoded
[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
]);
1270 #if !defined(__KERNEL__) && !defined(_LIBC)
1271 /* Canonical names of all the registers. */
1272 /* ISSUE: This table lives in "tile-dis.c" */
1273 extern const char * const tilegx_register_names
[];
1275 /* Descriptor for a special-purpose register. */
1285 /* List of all the SPRs; ordered by increasing number. */
1286 extern const struct tilegx_spr tilegx_sprs
[];
1288 /* Number of special-purpose registers. */
1289 extern const int tilegx_num_sprs
;
1292 get_tilegx_spr_name (int num
);
1293 #endif /* !__KERNEL__ && !_LIBC */
1295 /* Make a few "tile_" variables to simply common code between
1298 typedef tilegx_bundle_bits tile_bundle_bits
;
1299 #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
1300 #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
1301 #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1302 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1304 #endif /* opcode_tilegx_h */