1 /* TILE-Gx opcode information.
3 * Copyright (C) 2011-2022 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,
28 typedef unsigned long long tilegx_bundle_bits
;
33 TILEGX_MAX_OPERANDS
= 4 /* bfexts */
47 TILEGX_OPC_PREFETCH_ADD_L1
,
48 TILEGX_OPC_PREFETCH_ADD_L1_FAULT
,
49 TILEGX_OPC_PREFETCH_ADD_L2
,
50 TILEGX_OPC_PREFETCH_ADD_L2_FAULT
,
51 TILEGX_OPC_PREFETCH_ADD_L3
,
52 TILEGX_OPC_PREFETCH_ADD_L3_FAULT
,
53 TILEGX_OPC_PREFETCH_L1
,
54 TILEGX_OPC_PREFETCH_L1_FAULT
,
55 TILEGX_OPC_PREFETCH_L2
,
56 TILEGX_OPC_PREFETCH_L2_FAULT
,
57 TILEGX_OPC_PREFETCH_L3
,
58 TILEGX_OPC_PREFETCH_L3_FAULT
,
113 TILEGX_OPC_DBLALIGN2
,
114 TILEGX_OPC_DBLALIGN4
,
115 TILEGX_OPC_DBLALIGN6
,
120 TILEGX_OPC_FDOUBLE_ADD_FLAGS
,
121 TILEGX_OPC_FDOUBLE_ADDSUB
,
122 TILEGX_OPC_FDOUBLE_MUL_FLAGS
,
123 TILEGX_OPC_FDOUBLE_PACK1
,
124 TILEGX_OPC_FDOUBLE_PACK2
,
125 TILEGX_OPC_FDOUBLE_SUB_FLAGS
,
126 TILEGX_OPC_FDOUBLE_UNPACK_MAX
,
127 TILEGX_OPC_FDOUBLE_UNPACK_MIN
,
129 TILEGX_OPC_FETCHADD4
,
130 TILEGX_OPC_FETCHADDGEZ
,
131 TILEGX_OPC_FETCHADDGEZ4
,
133 TILEGX_OPC_FETCHAND4
,
140 TILEGX_OPC_FSINGLE_ADD1
,
141 TILEGX_OPC_FSINGLE_ADDSUB2
,
142 TILEGX_OPC_FSINGLE_MUL1
,
143 TILEGX_OPC_FSINGLE_MUL2
,
144 TILEGX_OPC_FSINGLE_PACK1
,
145 TILEGX_OPC_FSINGLE_PACK2
,
146 TILEGX_OPC_FSINGLE_SUB1
,
175 TILEGX_OPC_LDNT1S_ADD
,
177 TILEGX_OPC_LDNT1U_ADD
,
179 TILEGX_OPC_LDNT2S_ADD
,
181 TILEGX_OPC_LDNT2U_ADD
,
183 TILEGX_OPC_LDNT4S_ADD
,
185 TILEGX_OPC_LDNT4U_ADD
,
193 TILEGX_OPC_MUL_HS_HS
,
194 TILEGX_OPC_MUL_HS_HU
,
195 TILEGX_OPC_MUL_HS_LS
,
196 TILEGX_OPC_MUL_HS_LU
,
197 TILEGX_OPC_MUL_HU_HU
,
198 TILEGX_OPC_MUL_HU_LS
,
199 TILEGX_OPC_MUL_HU_LU
,
200 TILEGX_OPC_MUL_LS_LS
,
201 TILEGX_OPC_MUL_LS_LU
,
202 TILEGX_OPC_MUL_LU_LU
,
203 TILEGX_OPC_MULA_HS_HS
,
204 TILEGX_OPC_MULA_HS_HU
,
205 TILEGX_OPC_MULA_HS_LS
,
206 TILEGX_OPC_MULA_HS_LU
,
207 TILEGX_OPC_MULA_HU_HU
,
208 TILEGX_OPC_MULA_HU_LS
,
209 TILEGX_OPC_MULA_HU_LU
,
210 TILEGX_OPC_MULA_LS_LS
,
211 TILEGX_OPC_MULA_LS_LU
,
212 TILEGX_OPC_MULA_LU_LU
,
227 TILEGX_OPC_SHL16INSLI
,
243 TILEGX_OPC_SHUFFLEBYTES
,
254 TILEGX_OPC_STNT1_ADD
,
256 TILEGX_OPC_STNT2_ADD
,
258 TILEGX_OPC_STNT4_ADD
,
281 TILEGX_OPC_V1CMPLTSI
,
283 TILEGX_OPC_V1CMPLTUI
,
286 TILEGX_OPC_V1DDOTPUA
,
287 TILEGX_OPC_V1DDOTPUS
,
288 TILEGX_OPC_V1DDOTPUSA
,
294 TILEGX_OPC_V1DOTPUSA
,
326 TILEGX_OPC_V2CMPLTSI
,
328 TILEGX_OPC_V2CMPLTUI
,
376 /* 64-bit pattern for a { bpt ; nop } bundle. */
377 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
381 static __inline
unsigned int
382 get_BFEnd_X0(tilegx_bundle_bits num
)
384 const unsigned int n
= (unsigned int)num
;
385 return (((n
>> 12)) & 0x3f);
388 static __inline
unsigned int
389 get_BFOpcodeExtension_X0(tilegx_bundle_bits num
)
391 const unsigned int n
= (unsigned int)num
;
392 return (((n
>> 24)) & 0xf);
395 static __inline
unsigned int
396 get_BFStart_X0(tilegx_bundle_bits num
)
398 const unsigned int n
= (unsigned int)num
;
399 return (((n
>> 18)) & 0x3f);
402 static __inline
unsigned int
403 get_BrOff_X1(tilegx_bundle_bits n
)
405 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
406 (((unsigned int)(n
>> 37)) & 0x0001ffc0);
409 static __inline
unsigned int
410 get_BrType_X1(tilegx_bundle_bits n
)
412 return (((unsigned int)(n
>> 54)) & 0x1f);
415 static __inline
unsigned int
416 get_Dest_Imm8_X1(tilegx_bundle_bits n
)
418 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
419 (((unsigned int)(n
>> 43)) & 0x000000c0);
422 static __inline
unsigned int
423 get_Dest_X0(tilegx_bundle_bits num
)
425 const unsigned int n
= (unsigned int)num
;
426 return (((n
>> 0)) & 0x3f);
429 static __inline
unsigned int
430 get_Dest_X1(tilegx_bundle_bits n
)
432 return (((unsigned int)(n
>> 31)) & 0x3f);
435 static __inline
unsigned int
436 get_Dest_Y0(tilegx_bundle_bits num
)
438 const unsigned int n
= (unsigned int)num
;
439 return (((n
>> 0)) & 0x3f);
442 static __inline
unsigned int
443 get_Dest_Y1(tilegx_bundle_bits n
)
445 return (((unsigned int)(n
>> 31)) & 0x3f);
448 static __inline
unsigned int
449 get_Imm16_X0(tilegx_bundle_bits num
)
451 const unsigned int n
= (unsigned int)num
;
452 return (((n
>> 12)) & 0xffff);
455 static __inline
unsigned int
456 get_Imm16_X1(tilegx_bundle_bits n
)
458 return (((unsigned int)(n
>> 43)) & 0xffff);
461 static __inline
unsigned int
462 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num
)
464 const unsigned int n
= (unsigned int)num
;
465 return (((n
>> 20)) & 0xff);
468 static __inline
unsigned int
469 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n
)
471 return (((unsigned int)(n
>> 51)) & 0xff);
474 static __inline
unsigned int
475 get_Imm8_X0(tilegx_bundle_bits num
)
477 const unsigned int n
= (unsigned int)num
;
478 return (((n
>> 12)) & 0xff);
481 static __inline
unsigned int
482 get_Imm8_X1(tilegx_bundle_bits n
)
484 return (((unsigned int)(n
>> 43)) & 0xff);
487 static __inline
unsigned int
488 get_Imm8_Y0(tilegx_bundle_bits num
)
490 const unsigned int n
= (unsigned int)num
;
491 return (((n
>> 12)) & 0xff);
494 static __inline
unsigned int
495 get_Imm8_Y1(tilegx_bundle_bits n
)
497 return (((unsigned int)(n
>> 43)) & 0xff);
500 static __inline
unsigned int
501 get_JumpOff_X1(tilegx_bundle_bits n
)
503 return (((unsigned int)(n
>> 31)) & 0x7ffffff);
506 static __inline
unsigned int
507 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n
)
509 return (((unsigned int)(n
>> 58)) & 0x1);
512 static __inline
unsigned int
513 get_MF_Imm14_X1(tilegx_bundle_bits n
)
515 return (((unsigned int)(n
>> 37)) & 0x3fff);
518 static __inline
unsigned int
519 get_MT_Imm14_X1(tilegx_bundle_bits n
)
521 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
522 (((unsigned int)(n
>> 37)) & 0x00003fc0);
525 static __inline
unsigned int
526 get_Mode(tilegx_bundle_bits n
)
528 return (((unsigned int)(n
>> 62)) & 0x3);
531 static __inline
unsigned int
532 get_Opcode_X0(tilegx_bundle_bits num
)
534 const unsigned int n
= (unsigned int)num
;
535 return (((n
>> 28)) & 0x7);
538 static __inline
unsigned int
539 get_Opcode_X1(tilegx_bundle_bits n
)
541 return (((unsigned int)(n
>> 59)) & 0x7);
544 static __inline
unsigned int
545 get_Opcode_Y0(tilegx_bundle_bits num
)
547 const unsigned int n
= (unsigned int)num
;
548 return (((n
>> 27)) & 0xf);
551 static __inline
unsigned int
552 get_Opcode_Y1(tilegx_bundle_bits n
)
554 return (((unsigned int)(n
>> 58)) & 0xf);
557 static __inline
unsigned int
558 get_Opcode_Y2(tilegx_bundle_bits n
)
560 return (((n
>> 26)) & 0x00000001) |
561 (((unsigned int)(n
>> 56)) & 0x00000002);
564 static __inline
unsigned int
565 get_RRROpcodeExtension_X0(tilegx_bundle_bits num
)
567 const unsigned int n
= (unsigned int)num
;
568 return (((n
>> 18)) & 0x3ff);
571 static __inline
unsigned int
572 get_RRROpcodeExtension_X1(tilegx_bundle_bits n
)
574 return (((unsigned int)(n
>> 49)) & 0x3ff);
577 static __inline
unsigned int
578 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num
)
580 const unsigned int n
= (unsigned int)num
;
581 return (((n
>> 18)) & 0x3);
584 static __inline
unsigned int
585 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n
)
587 return (((unsigned int)(n
>> 49)) & 0x3);
590 static __inline
unsigned int
591 get_ShAmt_X0(tilegx_bundle_bits num
)
593 const unsigned int n
= (unsigned int)num
;
594 return (((n
>> 12)) & 0x3f);
597 static __inline
unsigned int
598 get_ShAmt_X1(tilegx_bundle_bits n
)
600 return (((unsigned int)(n
>> 43)) & 0x3f);
603 static __inline
unsigned int
604 get_ShAmt_Y0(tilegx_bundle_bits num
)
606 const unsigned int n
= (unsigned int)num
;
607 return (((n
>> 12)) & 0x3f);
610 static __inline
unsigned int
611 get_ShAmt_Y1(tilegx_bundle_bits n
)
613 return (((unsigned int)(n
>> 43)) & 0x3f);
616 static __inline
unsigned int
617 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num
)
619 const unsigned int n
= (unsigned int)num
;
620 return (((n
>> 18)) & 0x3ff);
623 static __inline
unsigned int
624 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n
)
626 return (((unsigned int)(n
>> 49)) & 0x3ff);
629 static __inline
unsigned int
630 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num
)
632 const unsigned int n
= (unsigned int)num
;
633 return (((n
>> 18)) & 0x3);
636 static __inline
unsigned int
637 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n
)
639 return (((unsigned int)(n
>> 49)) & 0x3);
642 static __inline
unsigned int
643 get_SrcA_X0(tilegx_bundle_bits num
)
645 const unsigned int n
= (unsigned int)num
;
646 return (((n
>> 6)) & 0x3f);
649 static __inline
unsigned int
650 get_SrcA_X1(tilegx_bundle_bits n
)
652 return (((unsigned int)(n
>> 37)) & 0x3f);
655 static __inline
unsigned int
656 get_SrcA_Y0(tilegx_bundle_bits num
)
658 const unsigned int n
= (unsigned int)num
;
659 return (((n
>> 6)) & 0x3f);
662 static __inline
unsigned int
663 get_SrcA_Y1(tilegx_bundle_bits n
)
665 return (((unsigned int)(n
>> 37)) & 0x3f);
668 static __inline
unsigned int
669 get_SrcA_Y2(tilegx_bundle_bits num
)
671 const unsigned int n
= (unsigned int)num
;
672 return (((n
>> 20)) & 0x3f);
675 static __inline
unsigned int
676 get_SrcBDest_Y2(tilegx_bundle_bits n
)
678 return (((unsigned int)(n
>> 51)) & 0x3f);
681 static __inline
unsigned int
682 get_SrcB_X0(tilegx_bundle_bits num
)
684 const unsigned int n
= (unsigned int)num
;
685 return (((n
>> 12)) & 0x3f);
688 static __inline
unsigned int
689 get_SrcB_X1(tilegx_bundle_bits n
)
691 return (((unsigned int)(n
>> 43)) & 0x3f);
694 static __inline
unsigned int
695 get_SrcB_Y0(tilegx_bundle_bits num
)
697 const unsigned int n
= (unsigned int)num
;
698 return (((n
>> 12)) & 0x3f);
701 static __inline
unsigned int
702 get_SrcB_Y1(tilegx_bundle_bits n
)
704 return (((unsigned int)(n
>> 43)) & 0x3f);
707 static __inline
unsigned int
708 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num
)
710 const unsigned int n
= (unsigned int)num
;
711 return (((n
>> 12)) & 0x3f);
714 static __inline
unsigned int
715 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n
)
717 return (((unsigned int)(n
>> 43)) & 0x3f);
720 static __inline
unsigned int
721 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num
)
723 const unsigned int n
= (unsigned int)num
;
724 return (((n
>> 12)) & 0x3f);
727 static __inline
unsigned int
728 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n
)
730 return (((unsigned int)(n
>> 43)) & 0x3f);
735 sign_extend(int n
, int num_bits
)
737 int shift
= (int)(sizeof(int) * 8 - num_bits
);
738 return (n
<< shift
) >> shift
;
743 static __inline tilegx_bundle_bits
744 create_BFEnd_X0(int num
)
746 const unsigned int n
= (unsigned int)num
;
747 return ((n
& 0x3f) << 12);
750 static __inline tilegx_bundle_bits
751 create_BFOpcodeExtension_X0(int num
)
753 const unsigned int n
= (unsigned int)num
;
754 return ((n
& 0xf) << 24);
757 static __inline tilegx_bundle_bits
758 create_BFStart_X0(int num
)
760 const unsigned int n
= (unsigned int)num
;
761 return ((n
& 0x3f) << 18);
764 static __inline tilegx_bundle_bits
765 create_BrOff_X1(int num
)
767 const unsigned int n
= (unsigned int)num
;
768 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
769 (((tilegx_bundle_bits
)(n
& 0x0001ffc0)) << 37);
772 static __inline tilegx_bundle_bits
773 create_BrType_X1(int num
)
775 const unsigned int n
= (unsigned int)num
;
776 return (((tilegx_bundle_bits
)(n
& 0x1f)) << 54);
779 static __inline tilegx_bundle_bits
780 create_Dest_Imm8_X1(int num
)
782 const unsigned int n
= (unsigned int)num
;
783 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
784 (((tilegx_bundle_bits
)(n
& 0x000000c0)) << 43);
787 static __inline tilegx_bundle_bits
788 create_Dest_X0(int num
)
790 const unsigned int n
= (unsigned int)num
;
791 return ((n
& 0x3f) << 0);
794 static __inline tilegx_bundle_bits
795 create_Dest_X1(int num
)
797 const unsigned int n
= (unsigned int)num
;
798 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
801 static __inline tilegx_bundle_bits
802 create_Dest_Y0(int num
)
804 const unsigned int n
= (unsigned int)num
;
805 return ((n
& 0x3f) << 0);
808 static __inline tilegx_bundle_bits
809 create_Dest_Y1(int num
)
811 const unsigned int n
= (unsigned int)num
;
812 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
815 static __inline tilegx_bundle_bits
816 create_Imm16_X0(int num
)
818 const unsigned int n
= (unsigned int)num
;
819 return ((n
& 0xffff) << 12);
822 static __inline tilegx_bundle_bits
823 create_Imm16_X1(int num
)
825 const unsigned int n
= (unsigned int)num
;
826 return (((tilegx_bundle_bits
)(n
& 0xffff)) << 43);
829 static __inline tilegx_bundle_bits
830 create_Imm8OpcodeExtension_X0(int num
)
832 const unsigned int n
= (unsigned int)num
;
833 return ((n
& 0xff) << 20);
836 static __inline tilegx_bundle_bits
837 create_Imm8OpcodeExtension_X1(int num
)
839 const unsigned int n
= (unsigned int)num
;
840 return (((tilegx_bundle_bits
)(n
& 0xff)) << 51);
843 static __inline tilegx_bundle_bits
844 create_Imm8_X0(int num
)
846 const unsigned int n
= (unsigned int)num
;
847 return ((n
& 0xff) << 12);
850 static __inline tilegx_bundle_bits
851 create_Imm8_X1(int num
)
853 const unsigned int n
= (unsigned int)num
;
854 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
857 static __inline tilegx_bundle_bits
858 create_Imm8_Y0(int num
)
860 const unsigned int n
= (unsigned int)num
;
861 return ((n
& 0xff) << 12);
864 static __inline tilegx_bundle_bits
865 create_Imm8_Y1(int num
)
867 const unsigned int n
= (unsigned int)num
;
868 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
871 static __inline tilegx_bundle_bits
872 create_JumpOff_X1(int num
)
874 const unsigned int n
= (unsigned int)num
;
875 return (((tilegx_bundle_bits
)(n
& 0x7ffffff)) << 31);
878 static __inline tilegx_bundle_bits
879 create_JumpOpcodeExtension_X1(int num
)
881 const unsigned int n
= (unsigned int)num
;
882 return (((tilegx_bundle_bits
)(n
& 0x1)) << 58);
885 static __inline tilegx_bundle_bits
886 create_MF_Imm14_X1(int num
)
888 const unsigned int n
= (unsigned int)num
;
889 return (((tilegx_bundle_bits
)(n
& 0x3fff)) << 37);
892 static __inline tilegx_bundle_bits
893 create_MT_Imm14_X1(int num
)
895 const unsigned int n
= (unsigned int)num
;
896 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
897 (((tilegx_bundle_bits
)(n
& 0x00003fc0)) << 37);
900 static __inline tilegx_bundle_bits
903 const unsigned int n
= (unsigned int)num
;
904 return (((tilegx_bundle_bits
)(n
& 0x3)) << 62);
907 static __inline tilegx_bundle_bits
908 create_Opcode_X0(int num
)
910 const unsigned int n
= (unsigned int)num
;
911 return ((n
& 0x7) << 28);
914 static __inline tilegx_bundle_bits
915 create_Opcode_X1(int num
)
917 const unsigned int n
= (unsigned int)num
;
918 return (((tilegx_bundle_bits
)(n
& 0x7)) << 59);
921 static __inline tilegx_bundle_bits
922 create_Opcode_Y0(int num
)
924 const unsigned int n
= (unsigned int)num
;
925 return ((n
& 0xf) << 27);
928 static __inline tilegx_bundle_bits
929 create_Opcode_Y1(int num
)
931 const unsigned int n
= (unsigned int)num
;
932 return (((tilegx_bundle_bits
)(n
& 0xf)) << 58);
935 static __inline tilegx_bundle_bits
936 create_Opcode_Y2(int num
)
938 const unsigned int n
= (unsigned int)num
;
939 return ((n
& 0x00000001) << 26) |
940 (((tilegx_bundle_bits
)(n
& 0x00000002)) << 56);
943 static __inline tilegx_bundle_bits
944 create_RRROpcodeExtension_X0(int num
)
946 const unsigned int n
= (unsigned int)num
;
947 return ((n
& 0x3ff) << 18);
950 static __inline tilegx_bundle_bits
951 create_RRROpcodeExtension_X1(int num
)
953 const unsigned int n
= (unsigned int)num
;
954 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
957 static __inline tilegx_bundle_bits
958 create_RRROpcodeExtension_Y0(int num
)
960 const unsigned int n
= (unsigned int)num
;
961 return ((n
& 0x3) << 18);
964 static __inline tilegx_bundle_bits
965 create_RRROpcodeExtension_Y1(int num
)
967 const unsigned int n
= (unsigned int)num
;
968 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
971 static __inline tilegx_bundle_bits
972 create_ShAmt_X0(int num
)
974 const unsigned int n
= (unsigned int)num
;
975 return ((n
& 0x3f) << 12);
978 static __inline tilegx_bundle_bits
979 create_ShAmt_X1(int num
)
981 const unsigned int n
= (unsigned int)num
;
982 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
985 static __inline tilegx_bundle_bits
986 create_ShAmt_Y0(int num
)
988 const unsigned int n
= (unsigned int)num
;
989 return ((n
& 0x3f) << 12);
992 static __inline tilegx_bundle_bits
993 create_ShAmt_Y1(int num
)
995 const unsigned int n
= (unsigned int)num
;
996 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
999 static __inline tilegx_bundle_bits
1000 create_ShiftOpcodeExtension_X0(int num
)
1002 const unsigned int n
= (unsigned int)num
;
1003 return ((n
& 0x3ff) << 18);
1006 static __inline tilegx_bundle_bits
1007 create_ShiftOpcodeExtension_X1(int num
)
1009 const unsigned int n
= (unsigned int)num
;
1010 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
1013 static __inline tilegx_bundle_bits
1014 create_ShiftOpcodeExtension_Y0(int num
)
1016 const unsigned int n
= (unsigned int)num
;
1017 return ((n
& 0x3) << 18);
1020 static __inline tilegx_bundle_bits
1021 create_ShiftOpcodeExtension_Y1(int num
)
1023 const unsigned int n
= (unsigned int)num
;
1024 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
1027 static __inline tilegx_bundle_bits
1028 create_SrcA_X0(int num
)
1030 const unsigned int n
= (unsigned int)num
;
1031 return ((n
& 0x3f) << 6);
1034 static __inline tilegx_bundle_bits
1035 create_SrcA_X1(int num
)
1037 const unsigned int n
= (unsigned int)num
;
1038 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1041 static __inline tilegx_bundle_bits
1042 create_SrcA_Y0(int num
)
1044 const unsigned int n
= (unsigned int)num
;
1045 return ((n
& 0x3f) << 6);
1048 static __inline tilegx_bundle_bits
1049 create_SrcA_Y1(int num
)
1051 const unsigned int n
= (unsigned int)num
;
1052 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1055 static __inline tilegx_bundle_bits
1056 create_SrcA_Y2(int num
)
1058 const unsigned int n
= (unsigned int)num
;
1059 return ((n
& 0x3f) << 20);
1062 static __inline tilegx_bundle_bits
1063 create_SrcBDest_Y2(int num
)
1065 const unsigned int n
= (unsigned int)num
;
1066 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 51);
1069 static __inline tilegx_bundle_bits
1070 create_SrcB_X0(int num
)
1072 const unsigned int n
= (unsigned int)num
;
1073 return ((n
& 0x3f) << 12);
1076 static __inline tilegx_bundle_bits
1077 create_SrcB_X1(int num
)
1079 const unsigned int n
= (unsigned int)num
;
1080 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1083 static __inline tilegx_bundle_bits
1084 create_SrcB_Y0(int num
)
1086 const unsigned int n
= (unsigned int)num
;
1087 return ((n
& 0x3f) << 12);
1090 static __inline tilegx_bundle_bits
1091 create_SrcB_Y1(int num
)
1093 const unsigned int n
= (unsigned int)num
;
1094 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1097 static __inline tilegx_bundle_bits
1098 create_UnaryOpcodeExtension_X0(int num
)
1100 const unsigned int n
= (unsigned int)num
;
1101 return ((n
& 0x3f) << 12);
1104 static __inline tilegx_bundle_bits
1105 create_UnaryOpcodeExtension_X1(int num
)
1107 const unsigned int n
= (unsigned int)num
;
1108 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1111 static __inline tilegx_bundle_bits
1112 create_UnaryOpcodeExtension_Y0(int num
)
1114 const unsigned int n
= (unsigned int)num
;
1115 return ((n
& 0x3f) << 12);
1118 static __inline tilegx_bundle_bits
1119 create_UnaryOpcodeExtension_Y1(int num
)
1121 const unsigned int n
= (unsigned int)num
;
1122 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1133 TILEGX_NUM_PIPELINE_ENCODINGS
= 5,
1136 #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1140 TILEGX_OP_TYPE_REGISTER
,
1141 TILEGX_OP_TYPE_IMMEDIATE
,
1142 TILEGX_OP_TYPE_ADDRESS
,
1144 } tilegx_operand_type
;
1146 /* These are the bits that determine if a bundle is in the X encoding. */
1147 #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
1151 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1152 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1154 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1155 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
= 3,
1157 /* Instructions take this many bytes. */
1158 TILEGX_BUNDLE_SIZE_IN_BYTES
= 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
,
1160 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1161 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
= 3,
1163 /* Bundles should be aligned modulo this number of bytes. */
1164 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
=
1165 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
),
1167 /* Number of registers (some are magic, such as network I/O). */
1168 TILEGX_NUM_REGISTERS
= 64,
1172 struct tilegx_operand
1174 /* Is this operand a register, immediate or address? */
1175 tilegx_operand_type type
;
1177 /* The default relocation type for this operand. */
1178 signed int default_reloc
: 16;
1180 /* How many bits is this value? (used for range checking) */
1181 unsigned int num_bits
: 5;
1183 /* Is the value signed? (used for range checking) */
1184 unsigned int is_signed
: 1;
1186 /* Is this operand a source register? */
1187 unsigned int is_src_reg
: 1;
1189 /* Is this operand written? (i.e. is it a destination register) */
1190 unsigned int is_dest_reg
: 1;
1192 /* Is this operand PC-relative? */
1193 unsigned int is_pc_relative
: 1;
1195 /* By how many bits do we right shift the value before inserting? */
1196 unsigned int rightshift
: 2;
1198 /* Return the bits for this operand to be ORed into an existing bundle. */
1199 tilegx_bundle_bits (*insert
) (int op
);
1201 /* Extract this operand and return it. */
1202 unsigned int (*extract
) (tilegx_bundle_bits bundle
);
1206 extern const struct tilegx_operand tilegx_operands
[];
1208 /* One finite-state machine per pipe for rapid instruction decoding. */
1209 extern const unsigned short * const
1210 tilegx_bundle_decoder_fsms
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1213 struct tilegx_opcode
1215 /* The opcode mnemonic, e.g. "add" */
1218 /* The enum value for this mnemonic. */
1219 tilegx_mnemonic mnemonic
;
1221 /* A bit mask of which of the five pipes this instruction
1228 unsigned char pipes
;
1230 /* How many operands are there? */
1231 unsigned char num_operands
;
1233 /* Which register does this write implicitly, or TREG_ZERO if none? */
1234 unsigned char implicitly_written_register
;
1236 /* Can this be bundled with other instructions (almost always true). */
1237 unsigned char can_bundle
;
1239 /* The description of the operands. Each of these is an
1240 * index into the tilegx_operands[] table. */
1241 unsigned char operands
[TILEGX_NUM_PIPELINE_ENCODINGS
][TILEGX_MAX_OPERANDS
];
1243 #if !defined(__KERNEL__) && !defined(_LIBC)
1244 /* A mask of which bits have predefined values for each pipeline.
1245 * This is useful for disassembly. */
1246 tilegx_bundle_bits fixed_bit_masks
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1248 /* For each bit set in fixed_bit_masks, what the value is for this
1250 tilegx_bundle_bits fixed_bit_values
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1254 extern const struct tilegx_opcode tilegx_opcodes
[];
1256 /* Used for non-textual disassembly into structs. */
1257 struct tilegx_decoded_instruction
1259 const struct tilegx_opcode
*opcode
;
1260 const struct tilegx_operand
*operands
[TILEGX_MAX_OPERANDS
];
1261 long long operand_values
[TILEGX_MAX_OPERANDS
];
1265 /* Disassemble a bundle into a struct for machine processing. */
1266 extern int parse_insn_tilegx(tilegx_bundle_bits bits
,
1267 unsigned long long pc
,
1268 struct tilegx_decoded_instruction
1269 decoded
[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
]);
1272 #if !defined(__KERNEL__) && !defined(_LIBC)
1273 /* Canonical names of all the registers. */
1274 /* ISSUE: This table lives in "tile-dis.c" */
1275 extern const char * const tilegx_register_names
[];
1277 /* Descriptor for a special-purpose register. */
1287 /* List of all the SPRs; ordered by increasing number. */
1288 extern const struct tilegx_spr tilegx_sprs
[];
1290 /* Number of special-purpose registers. */
1291 extern const int tilegx_num_sprs
;
1294 get_tilegx_spr_name (int num
);
1295 #endif /* !__KERNEL__ && !_LIBC */
1297 /* Make a few "tile_" variables to simply common code between
1300 typedef tilegx_bundle_bits tile_bundle_bits
;
1301 #define TILE_BUNDLE_SIZE_IN_BYTES TILEGX_BUNDLE_SIZE_IN_BYTES
1302 #define TILE_BUNDLE_ALIGNMENT_IN_BYTES TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
1303 #define TILE_LOG2_BUNDLE_ALIGNMENT_IN_BYTES \
1304 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
1310 #endif /* opcode_tilegx_h */