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 tilegx_bundle_bits
;
13 TILEGX_MAX_OPERANDS
= 4 /* bfexts */
25 TILEGX_OPC_PREFETCH_ADD_L1
,
26 TILEGX_OPC_PREFETCH_ADD_L1_FAULT
,
27 TILEGX_OPC_PREFETCH_ADD_L2
,
28 TILEGX_OPC_PREFETCH_ADD_L2_FAULT
,
29 TILEGX_OPC_PREFETCH_ADD_L3
,
30 TILEGX_OPC_PREFETCH_ADD_L3_FAULT
,
31 TILEGX_OPC_PREFETCH_L1
,
32 TILEGX_OPC_PREFETCH_L1_FAULT
,
33 TILEGX_OPC_PREFETCH_L2
,
34 TILEGX_OPC_PREFETCH_L2_FAULT
,
35 TILEGX_OPC_PREFETCH_L3
,
36 TILEGX_OPC_PREFETCH_L3_FAULT
,
98 TILEGX_OPC_FDOUBLE_ADD_FLAGS
,
99 TILEGX_OPC_FDOUBLE_ADDSUB
,
100 TILEGX_OPC_FDOUBLE_MUL_FLAGS
,
101 TILEGX_OPC_FDOUBLE_PACK1
,
102 TILEGX_OPC_FDOUBLE_PACK2
,
103 TILEGX_OPC_FDOUBLE_SUB_FLAGS
,
104 TILEGX_OPC_FDOUBLE_UNPACK_MAX
,
105 TILEGX_OPC_FDOUBLE_UNPACK_MIN
,
107 TILEGX_OPC_FETCHADD4
,
108 TILEGX_OPC_FETCHADDGEZ
,
109 TILEGX_OPC_FETCHADDGEZ4
,
111 TILEGX_OPC_FETCHAND4
,
118 TILEGX_OPC_FSINGLE_ADD1
,
119 TILEGX_OPC_FSINGLE_ADDSUB2
,
120 TILEGX_OPC_FSINGLE_MUL1
,
121 TILEGX_OPC_FSINGLE_MUL2
,
122 TILEGX_OPC_FSINGLE_PACK1
,
123 TILEGX_OPC_FSINGLE_PACK2
,
124 TILEGX_OPC_FSINGLE_SUB1
,
153 TILEGX_OPC_LDNT1S_ADD
,
155 TILEGX_OPC_LDNT1U_ADD
,
157 TILEGX_OPC_LDNT2S_ADD
,
159 TILEGX_OPC_LDNT2U_ADD
,
161 TILEGX_OPC_LDNT4S_ADD
,
163 TILEGX_OPC_LDNT4U_ADD
,
171 TILEGX_OPC_MUL_HS_HS
,
172 TILEGX_OPC_MUL_HS_HU
,
173 TILEGX_OPC_MUL_HS_LS
,
174 TILEGX_OPC_MUL_HS_LU
,
175 TILEGX_OPC_MUL_HU_HU
,
176 TILEGX_OPC_MUL_HU_LS
,
177 TILEGX_OPC_MUL_HU_LU
,
178 TILEGX_OPC_MUL_LS_LS
,
179 TILEGX_OPC_MUL_LS_LU
,
180 TILEGX_OPC_MUL_LU_LU
,
181 TILEGX_OPC_MULA_HS_HS
,
182 TILEGX_OPC_MULA_HS_HU
,
183 TILEGX_OPC_MULA_HS_LS
,
184 TILEGX_OPC_MULA_HS_LU
,
185 TILEGX_OPC_MULA_HU_HU
,
186 TILEGX_OPC_MULA_HU_LS
,
187 TILEGX_OPC_MULA_HU_LU
,
188 TILEGX_OPC_MULA_LS_LS
,
189 TILEGX_OPC_MULA_LS_LU
,
190 TILEGX_OPC_MULA_LU_LU
,
205 TILEGX_OPC_SHL16INSLI
,
221 TILEGX_OPC_SHUFFLEBYTES
,
232 TILEGX_OPC_STNT1_ADD
,
234 TILEGX_OPC_STNT2_ADD
,
236 TILEGX_OPC_STNT4_ADD
,
259 TILEGX_OPC_V1CMPLTSI
,
261 TILEGX_OPC_V1CMPLTUI
,
264 TILEGX_OPC_V1DDOTPUA
,
265 TILEGX_OPC_V1DDOTPUS
,
266 TILEGX_OPC_V1DDOTPUSA
,
272 TILEGX_OPC_V1DOTPUSA
,
304 TILEGX_OPC_V2CMPLTSI
,
306 TILEGX_OPC_V2CMPLTUI
,
354 /* 64-bit pattern for a { bpt ; nop } bundle. */
355 #define TILEGX_BPT_BUNDLE 0x286a44ae51485000ULL
358 #define TILE_ELF_MACHINE_CODE EM_TILE64
360 #define TILE_ELF_NAME "elf32-tile64"
363 static __inline
unsigned int
364 get_BFEnd_X0(tilegx_bundle_bits num
)
366 const unsigned int n
= (unsigned int)num
;
367 return (((n
>> 12)) & 0x3f);
370 static __inline
unsigned int
371 get_BFOpcodeExtension_X0(tilegx_bundle_bits num
)
373 const unsigned int n
= (unsigned int)num
;
374 return (((n
>> 24)) & 0xf);
377 static __inline
unsigned int
378 get_BFStart_X0(tilegx_bundle_bits num
)
380 const unsigned int n
= (unsigned int)num
;
381 return (((n
>> 18)) & 0x3f);
384 static __inline
unsigned int
385 get_BrOff_X1(tilegx_bundle_bits n
)
387 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
388 (((unsigned int)(n
>> 37)) & 0x0001ffc0);
391 static __inline
unsigned int
392 get_BrType_X1(tilegx_bundle_bits n
)
394 return (((unsigned int)(n
>> 54)) & 0x1f);
397 static __inline
unsigned int
398 get_Dest_Imm8_X1(tilegx_bundle_bits n
)
400 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
401 (((unsigned int)(n
>> 43)) & 0x000000c0);
404 static __inline
unsigned int
405 get_Dest_X0(tilegx_bundle_bits num
)
407 const unsigned int n
= (unsigned int)num
;
408 return (((n
>> 0)) & 0x3f);
411 static __inline
unsigned int
412 get_Dest_X1(tilegx_bundle_bits n
)
414 return (((unsigned int)(n
>> 31)) & 0x3f);
417 static __inline
unsigned int
418 get_Dest_Y0(tilegx_bundle_bits num
)
420 const unsigned int n
= (unsigned int)num
;
421 return (((n
>> 0)) & 0x3f);
424 static __inline
unsigned int
425 get_Dest_Y1(tilegx_bundle_bits n
)
427 return (((unsigned int)(n
>> 31)) & 0x3f);
430 static __inline
unsigned int
431 get_Imm16_X0(tilegx_bundle_bits num
)
433 const unsigned int n
= (unsigned int)num
;
434 return (((n
>> 12)) & 0xffff);
437 static __inline
unsigned int
438 get_Imm16_X1(tilegx_bundle_bits n
)
440 return (((unsigned int)(n
>> 43)) & 0xffff);
443 static __inline
unsigned int
444 get_Imm8OpcodeExtension_X0(tilegx_bundle_bits num
)
446 const unsigned int n
= (unsigned int)num
;
447 return (((n
>> 20)) & 0xff);
450 static __inline
unsigned int
451 get_Imm8OpcodeExtension_X1(tilegx_bundle_bits n
)
453 return (((unsigned int)(n
>> 51)) & 0xff);
456 static __inline
unsigned int
457 get_Imm8_X0(tilegx_bundle_bits num
)
459 const unsigned int n
= (unsigned int)num
;
460 return (((n
>> 12)) & 0xff);
463 static __inline
unsigned int
464 get_Imm8_X1(tilegx_bundle_bits n
)
466 return (((unsigned int)(n
>> 43)) & 0xff);
469 static __inline
unsigned int
470 get_Imm8_Y0(tilegx_bundle_bits num
)
472 const unsigned int n
= (unsigned int)num
;
473 return (((n
>> 12)) & 0xff);
476 static __inline
unsigned int
477 get_Imm8_Y1(tilegx_bundle_bits n
)
479 return (((unsigned int)(n
>> 43)) & 0xff);
482 static __inline
unsigned int
483 get_JumpOff_X1(tilegx_bundle_bits n
)
485 return (((unsigned int)(n
>> 31)) & 0x7ffffff);
488 static __inline
unsigned int
489 get_JumpOpcodeExtension_X1(tilegx_bundle_bits n
)
491 return (((unsigned int)(n
>> 58)) & 0x1);
494 static __inline
unsigned int
495 get_MF_Imm14_X1(tilegx_bundle_bits n
)
497 return (((unsigned int)(n
>> 37)) & 0x3fff);
500 static __inline
unsigned int
501 get_MT_Imm14_X1(tilegx_bundle_bits n
)
503 return (((unsigned int)(n
>> 31)) & 0x0000003f) |
504 (((unsigned int)(n
>> 37)) & 0x00003fc0);
507 static __inline
unsigned int
508 get_Mode(tilegx_bundle_bits n
)
510 return (((unsigned int)(n
>> 62)) & 0x3);
513 static __inline
unsigned int
514 get_Opcode_X0(tilegx_bundle_bits num
)
516 const unsigned int n
= (unsigned int)num
;
517 return (((n
>> 28)) & 0x7);
520 static __inline
unsigned int
521 get_Opcode_X1(tilegx_bundle_bits n
)
523 return (((unsigned int)(n
>> 59)) & 0x7);
526 static __inline
unsigned int
527 get_Opcode_Y0(tilegx_bundle_bits num
)
529 const unsigned int n
= (unsigned int)num
;
530 return (((n
>> 27)) & 0xf);
533 static __inline
unsigned int
534 get_Opcode_Y1(tilegx_bundle_bits n
)
536 return (((unsigned int)(n
>> 58)) & 0xf);
539 static __inline
unsigned int
540 get_Opcode_Y2(tilegx_bundle_bits n
)
542 return (((n
>> 26)) & 0x00000001) |
543 (((unsigned int)(n
>> 56)) & 0x00000002);
546 static __inline
unsigned int
547 get_RRROpcodeExtension_X0(tilegx_bundle_bits num
)
549 const unsigned int n
= (unsigned int)num
;
550 return (((n
>> 18)) & 0x3ff);
553 static __inline
unsigned int
554 get_RRROpcodeExtension_X1(tilegx_bundle_bits n
)
556 return (((unsigned int)(n
>> 49)) & 0x3ff);
559 static __inline
unsigned int
560 get_RRROpcodeExtension_Y0(tilegx_bundle_bits num
)
562 const unsigned int n
= (unsigned int)num
;
563 return (((n
>> 18)) & 0x3);
566 static __inline
unsigned int
567 get_RRROpcodeExtension_Y1(tilegx_bundle_bits n
)
569 return (((unsigned int)(n
>> 49)) & 0x3);
572 static __inline
unsigned int
573 get_ShAmt_X0(tilegx_bundle_bits num
)
575 const unsigned int n
= (unsigned int)num
;
576 return (((n
>> 12)) & 0x3f);
579 static __inline
unsigned int
580 get_ShAmt_X1(tilegx_bundle_bits n
)
582 return (((unsigned int)(n
>> 43)) & 0x3f);
585 static __inline
unsigned int
586 get_ShAmt_Y0(tilegx_bundle_bits num
)
588 const unsigned int n
= (unsigned int)num
;
589 return (((n
>> 12)) & 0x3f);
592 static __inline
unsigned int
593 get_ShAmt_Y1(tilegx_bundle_bits n
)
595 return (((unsigned int)(n
>> 43)) & 0x3f);
598 static __inline
unsigned int
599 get_ShiftOpcodeExtension_X0(tilegx_bundle_bits num
)
601 const unsigned int n
= (unsigned int)num
;
602 return (((n
>> 18)) & 0x3ff);
605 static __inline
unsigned int
606 get_ShiftOpcodeExtension_X1(tilegx_bundle_bits n
)
608 return (((unsigned int)(n
>> 49)) & 0x3ff);
611 static __inline
unsigned int
612 get_ShiftOpcodeExtension_Y0(tilegx_bundle_bits num
)
614 const unsigned int n
= (unsigned int)num
;
615 return (((n
>> 18)) & 0x3);
618 static __inline
unsigned int
619 get_ShiftOpcodeExtension_Y1(tilegx_bundle_bits n
)
621 return (((unsigned int)(n
>> 49)) & 0x3);
624 static __inline
unsigned int
625 get_SrcA_X0(tilegx_bundle_bits num
)
627 const unsigned int n
= (unsigned int)num
;
628 return (((n
>> 6)) & 0x3f);
631 static __inline
unsigned int
632 get_SrcA_X1(tilegx_bundle_bits n
)
634 return (((unsigned int)(n
>> 37)) & 0x3f);
637 static __inline
unsigned int
638 get_SrcA_Y0(tilegx_bundle_bits num
)
640 const unsigned int n
= (unsigned int)num
;
641 return (((n
>> 6)) & 0x3f);
644 static __inline
unsigned int
645 get_SrcA_Y1(tilegx_bundle_bits n
)
647 return (((unsigned int)(n
>> 37)) & 0x3f);
650 static __inline
unsigned int
651 get_SrcA_Y2(tilegx_bundle_bits num
)
653 const unsigned int n
= (unsigned int)num
;
654 return (((n
>> 20)) & 0x3f);
657 static __inline
unsigned int
658 get_SrcBDest_Y2(tilegx_bundle_bits n
)
660 return (((unsigned int)(n
>> 51)) & 0x3f);
663 static __inline
unsigned int
664 get_SrcB_X0(tilegx_bundle_bits num
)
666 const unsigned int n
= (unsigned int)num
;
667 return (((n
>> 12)) & 0x3f);
670 static __inline
unsigned int
671 get_SrcB_X1(tilegx_bundle_bits n
)
673 return (((unsigned int)(n
>> 43)) & 0x3f);
676 static __inline
unsigned int
677 get_SrcB_Y0(tilegx_bundle_bits num
)
679 const unsigned int n
= (unsigned int)num
;
680 return (((n
>> 12)) & 0x3f);
683 static __inline
unsigned int
684 get_SrcB_Y1(tilegx_bundle_bits n
)
686 return (((unsigned int)(n
>> 43)) & 0x3f);
689 static __inline
unsigned int
690 get_UnaryOpcodeExtension_X0(tilegx_bundle_bits num
)
692 const unsigned int n
= (unsigned int)num
;
693 return (((n
>> 12)) & 0x3f);
696 static __inline
unsigned int
697 get_UnaryOpcodeExtension_X1(tilegx_bundle_bits n
)
699 return (((unsigned int)(n
>> 43)) & 0x3f);
702 static __inline
unsigned int
703 get_UnaryOpcodeExtension_Y0(tilegx_bundle_bits num
)
705 const unsigned int n
= (unsigned int)num
;
706 return (((n
>> 12)) & 0x3f);
709 static __inline
unsigned int
710 get_UnaryOpcodeExtension_Y1(tilegx_bundle_bits n
)
712 return (((unsigned int)(n
>> 43)) & 0x3f);
717 sign_extend(int n
, int num_bits
)
719 int shift
= (int)(sizeof(int) * 8 - num_bits
);
720 return (n
<< shift
) >> shift
;
725 static __inline tilegx_bundle_bits
726 create_BFEnd_X0(int num
)
728 const unsigned int n
= (unsigned int)num
;
729 return ((n
& 0x3f) << 12);
732 static __inline tilegx_bundle_bits
733 create_BFOpcodeExtension_X0(int num
)
735 const unsigned int n
= (unsigned int)num
;
736 return ((n
& 0xf) << 24);
739 static __inline tilegx_bundle_bits
740 create_BFStart_X0(int num
)
742 const unsigned int n
= (unsigned int)num
;
743 return ((n
& 0x3f) << 18);
746 static __inline tilegx_bundle_bits
747 create_BrOff_X1(int num
)
749 const unsigned int n
= (unsigned int)num
;
750 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
751 (((tilegx_bundle_bits
)(n
& 0x0001ffc0)) << 37);
754 static __inline tilegx_bundle_bits
755 create_BrType_X1(int num
)
757 const unsigned int n
= (unsigned int)num
;
758 return (((tilegx_bundle_bits
)(n
& 0x1f)) << 54);
761 static __inline tilegx_bundle_bits
762 create_Dest_Imm8_X1(int num
)
764 const unsigned int n
= (unsigned int)num
;
765 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
766 (((tilegx_bundle_bits
)(n
& 0x000000c0)) << 43);
769 static __inline tilegx_bundle_bits
770 create_Dest_X0(int num
)
772 const unsigned int n
= (unsigned int)num
;
773 return ((n
& 0x3f) << 0);
776 static __inline tilegx_bundle_bits
777 create_Dest_X1(int num
)
779 const unsigned int n
= (unsigned int)num
;
780 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 31);
783 static __inline tilegx_bundle_bits
784 create_Dest_Y0(int num
)
786 const unsigned int n
= (unsigned int)num
;
787 return ((n
& 0x3f) << 0);
790 static __inline tilegx_bundle_bits
791 create_Dest_Y1(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_Imm16_X0(int num
)
800 const unsigned int n
= (unsigned int)num
;
801 return ((n
& 0xffff) << 12);
804 static __inline tilegx_bundle_bits
805 create_Imm16_X1(int num
)
807 const unsigned int n
= (unsigned int)num
;
808 return (((tilegx_bundle_bits
)(n
& 0xffff)) << 43);
811 static __inline tilegx_bundle_bits
812 create_Imm8OpcodeExtension_X0(int num
)
814 const unsigned int n
= (unsigned int)num
;
815 return ((n
& 0xff) << 20);
818 static __inline tilegx_bundle_bits
819 create_Imm8OpcodeExtension_X1(int num
)
821 const unsigned int n
= (unsigned int)num
;
822 return (((tilegx_bundle_bits
)(n
& 0xff)) << 51);
825 static __inline tilegx_bundle_bits
826 create_Imm8_X0(int num
)
828 const unsigned int n
= (unsigned int)num
;
829 return ((n
& 0xff) << 12);
832 static __inline tilegx_bundle_bits
833 create_Imm8_X1(int num
)
835 const unsigned int n
= (unsigned int)num
;
836 return (((tilegx_bundle_bits
)(n
& 0xff)) << 43);
839 static __inline tilegx_bundle_bits
840 create_Imm8_Y0(int num
)
842 const unsigned int n
= (unsigned int)num
;
843 return ((n
& 0xff) << 12);
846 static __inline tilegx_bundle_bits
847 create_Imm8_Y1(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_JumpOff_X1(int num
)
856 const unsigned int n
= (unsigned int)num
;
857 return (((tilegx_bundle_bits
)(n
& 0x7ffffff)) << 31);
860 static __inline tilegx_bundle_bits
861 create_JumpOpcodeExtension_X1(int num
)
863 const unsigned int n
= (unsigned int)num
;
864 return (((tilegx_bundle_bits
)(n
& 0x1)) << 58);
867 static __inline tilegx_bundle_bits
868 create_MF_Imm14_X1(int num
)
870 const unsigned int n
= (unsigned int)num
;
871 return (((tilegx_bundle_bits
)(n
& 0x3fff)) << 37);
874 static __inline tilegx_bundle_bits
875 create_MT_Imm14_X1(int num
)
877 const unsigned int n
= (unsigned int)num
;
878 return (((tilegx_bundle_bits
)(n
& 0x0000003f)) << 31) |
879 (((tilegx_bundle_bits
)(n
& 0x00003fc0)) << 37);
882 static __inline tilegx_bundle_bits
885 const unsigned int n
= (unsigned int)num
;
886 return (((tilegx_bundle_bits
)(n
& 0x3)) << 62);
889 static __inline tilegx_bundle_bits
890 create_Opcode_X0(int num
)
892 const unsigned int n
= (unsigned int)num
;
893 return ((n
& 0x7) << 28);
896 static __inline tilegx_bundle_bits
897 create_Opcode_X1(int num
)
899 const unsigned int n
= (unsigned int)num
;
900 return (((tilegx_bundle_bits
)(n
& 0x7)) << 59);
903 static __inline tilegx_bundle_bits
904 create_Opcode_Y0(int num
)
906 const unsigned int n
= (unsigned int)num
;
907 return ((n
& 0xf) << 27);
910 static __inline tilegx_bundle_bits
911 create_Opcode_Y1(int num
)
913 const unsigned int n
= (unsigned int)num
;
914 return (((tilegx_bundle_bits
)(n
& 0xf)) << 58);
917 static __inline tilegx_bundle_bits
918 create_Opcode_Y2(int num
)
920 const unsigned int n
= (unsigned int)num
;
921 return ((n
& 0x00000001) << 26) |
922 (((tilegx_bundle_bits
)(n
& 0x00000002)) << 56);
925 static __inline tilegx_bundle_bits
926 create_RRROpcodeExtension_X0(int num
)
928 const unsigned int n
= (unsigned int)num
;
929 return ((n
& 0x3ff) << 18);
932 static __inline tilegx_bundle_bits
933 create_RRROpcodeExtension_X1(int num
)
935 const unsigned int n
= (unsigned int)num
;
936 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
939 static __inline tilegx_bundle_bits
940 create_RRROpcodeExtension_Y0(int num
)
942 const unsigned int n
= (unsigned int)num
;
943 return ((n
& 0x3) << 18);
946 static __inline tilegx_bundle_bits
947 create_RRROpcodeExtension_Y1(int num
)
949 const unsigned int n
= (unsigned int)num
;
950 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
953 static __inline tilegx_bundle_bits
954 create_ShAmt_X0(int num
)
956 const unsigned int n
= (unsigned int)num
;
957 return ((n
& 0x3f) << 12);
960 static __inline tilegx_bundle_bits
961 create_ShAmt_X1(int num
)
963 const unsigned int n
= (unsigned int)num
;
964 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
967 static __inline tilegx_bundle_bits
968 create_ShAmt_Y0(int num
)
970 const unsigned int n
= (unsigned int)num
;
971 return ((n
& 0x3f) << 12);
974 static __inline tilegx_bundle_bits
975 create_ShAmt_Y1(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_ShiftOpcodeExtension_X0(int num
)
984 const unsigned int n
= (unsigned int)num
;
985 return ((n
& 0x3ff) << 18);
988 static __inline tilegx_bundle_bits
989 create_ShiftOpcodeExtension_X1(int num
)
991 const unsigned int n
= (unsigned int)num
;
992 return (((tilegx_bundle_bits
)(n
& 0x3ff)) << 49);
995 static __inline tilegx_bundle_bits
996 create_ShiftOpcodeExtension_Y0(int num
)
998 const unsigned int n
= (unsigned int)num
;
999 return ((n
& 0x3) << 18);
1002 static __inline tilegx_bundle_bits
1003 create_ShiftOpcodeExtension_Y1(int num
)
1005 const unsigned int n
= (unsigned int)num
;
1006 return (((tilegx_bundle_bits
)(n
& 0x3)) << 49);
1009 static __inline tilegx_bundle_bits
1010 create_SrcA_X0(int num
)
1012 const unsigned int n
= (unsigned int)num
;
1013 return ((n
& 0x3f) << 6);
1016 static __inline tilegx_bundle_bits
1017 create_SrcA_X1(int num
)
1019 const unsigned int n
= (unsigned int)num
;
1020 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 37);
1023 static __inline tilegx_bundle_bits
1024 create_SrcA_Y0(int num
)
1026 const unsigned int n
= (unsigned int)num
;
1027 return ((n
& 0x3f) << 6);
1030 static __inline tilegx_bundle_bits
1031 create_SrcA_Y1(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_Y2(int num
)
1040 const unsigned int n
= (unsigned int)num
;
1041 return ((n
& 0x3f) << 20);
1044 static __inline tilegx_bundle_bits
1045 create_SrcBDest_Y2(int num
)
1047 const unsigned int n
= (unsigned int)num
;
1048 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 51);
1051 static __inline tilegx_bundle_bits
1052 create_SrcB_X0(int num
)
1054 const unsigned int n
= (unsigned int)num
;
1055 return ((n
& 0x3f) << 12);
1058 static __inline tilegx_bundle_bits
1059 create_SrcB_X1(int num
)
1061 const unsigned int n
= (unsigned int)num
;
1062 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1065 static __inline tilegx_bundle_bits
1066 create_SrcB_Y0(int num
)
1068 const unsigned int n
= (unsigned int)num
;
1069 return ((n
& 0x3f) << 12);
1072 static __inline tilegx_bundle_bits
1073 create_SrcB_Y1(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_UnaryOpcodeExtension_X0(int num
)
1082 const unsigned int n
= (unsigned int)num
;
1083 return ((n
& 0x3f) << 12);
1086 static __inline tilegx_bundle_bits
1087 create_UnaryOpcodeExtension_X1(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_Y0(int num
)
1096 const unsigned int n
= (unsigned int)num
;
1097 return ((n
& 0x3f) << 12);
1100 static __inline tilegx_bundle_bits
1101 create_UnaryOpcodeExtension_Y1(int num
)
1103 const unsigned int n
= (unsigned int)num
;
1104 return (((tilegx_bundle_bits
)(n
& 0x3f)) << 43);
1117 #define tilegx_is_x_pipeline(p) ((int)(p) <= (int)TILEGX_PIPELINE_X1)
1121 TILEGX_OP_TYPE_REGISTER
,
1122 TILEGX_OP_TYPE_IMMEDIATE
,
1123 TILEGX_OP_TYPE_ADDRESS
,
1125 } tilegx_operand_type
;
1127 /* These are the bits that determine if a bundle is in the X encoding. */
1128 #define TILEGX_BUNDLE_MODE_MASK ((tilegx_bundle_bits)3 << 62)
1132 /* Maximum number of instructions in a bundle (2 for X, 3 for Y). */
1133 TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
= 3,
1135 /* How many different pipeline encodings are there? X0, X1, Y0, Y1, Y2. */
1136 TILEGX_NUM_PIPELINE_ENCODINGS
= 5,
1138 /* Log base 2 of TILEGX_BUNDLE_SIZE_IN_BYTES. */
1139 TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
= 3,
1141 /* Instructions take this many bytes. */
1142 TILEGX_BUNDLE_SIZE_IN_BYTES
= 1 << TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES
,
1144 /* Log base 2 of TILEGX_BUNDLE_ALIGNMENT_IN_BYTES. */
1145 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
= 3,
1147 /* Bundles should be aligned modulo this number of bytes. */
1148 TILEGX_BUNDLE_ALIGNMENT_IN_BYTES
=
1149 (1 << TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES
),
1151 /* Number of registers (some are magic, such as network I/O). */
1152 TILEGX_NUM_REGISTERS
= 64,
1156 struct tilegx_operand
1158 /* Is this operand a register, immediate or address? */
1159 tilegx_operand_type type
;
1161 /* The default relocation type for this operand. */
1162 signed int default_reloc
: 16;
1164 /* How many bits is this value? (used for range checking) */
1165 unsigned int num_bits
: 5;
1167 /* Is the value signed? (used for range checking) */
1168 unsigned int is_signed
: 1;
1170 /* Is this operand a source register? */
1171 unsigned int is_src_reg
: 1;
1173 /* Is this operand written? (i.e. is it a destination register) */
1174 unsigned int is_dest_reg
: 1;
1176 /* Is this operand PC-relative? */
1177 unsigned int is_pc_relative
: 1;
1179 /* By how many bits do we right shift the value before inserting? */
1180 unsigned int rightshift
: 2;
1182 /* Return the bits for this operand to be ORed into an existing bundle. */
1183 tilegx_bundle_bits (*insert
) (int op
);
1185 /* Extract this operand and return it. */
1186 unsigned int (*extract
) (tilegx_bundle_bits bundle
);
1190 extern const struct tilegx_operand tilegx_operands
[];
1192 /* One finite-state machine per pipe for rapid instruction decoding. */
1193 extern const unsigned short * const
1194 tilegx_bundle_decoder_fsms
[TILEGX_NUM_PIPELINE_ENCODINGS
];
1197 struct tilegx_opcode
1199 /* The opcode mnemonic, e.g. "add" */
1202 /* The enum value for this mnemonic. */
1203 tilegx_mnemonic mnemonic
;
1205 /* A bit mask of which of the five pipes this instruction
1212 unsigned char pipes
;
1214 /* How many operands are there? */
1215 unsigned char num_operands
;
1217 /* Which register does this write implicitly, or TREG_ZERO if none? */
1218 unsigned char implicitly_written_register
;
1220 /* Can this be bundled with other instructions (almost always true). */
1221 unsigned char can_bundle
;
1223 /* The description of the operands. Each of these is an
1224 * index into the tilegx_operands[] table. */
1225 unsigned char operands
[TILEGX_NUM_PIPELINE_ENCODINGS
][TILEGX_MAX_OPERANDS
];
1229 extern const struct tilegx_opcode tilegx_opcodes
[];
1231 /* Used for non-textual disassembly into structs. */
1232 struct tilegx_decoded_instruction
1234 const struct tilegx_opcode
*opcode
;
1235 const struct tilegx_operand
*operands
[TILEGX_MAX_OPERANDS
];
1236 long long operand_values
[TILEGX_MAX_OPERANDS
];
1240 /* Disassemble a bundle into a struct for machine processing. */
1241 extern int parse_insn_tilegx(tilegx_bundle_bits bits
,
1242 unsigned long long pc
,
1243 struct tilegx_decoded_instruction
1244 decoded
[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE
]);
1248 #endif /* opcode_tilegx_h */