Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: src/ppc/disasm-ppc.cc

Issue 901083004: Contribution of PowerPC port (continuation of 422063005) - PPC dir update (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Contribution of PowerPC port (continuation of 422063005) - PPC dir update -comments and rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ppc/deoptimizer-ppc.cc ('k') | src/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A Disassembler object is used to disassemble a block of code instruction by 5 // A Disassembler object is used to disassemble a block of code instruction by
6 // instruction. The default implementation of the NameConverter object can be 6 // instruction. The default implementation of the NameConverter object can be
7 // overriden to modify register names or to do symbol lookup on addresses. 7 // overriden to modify register names or to do symbol lookup on addresses.
8 // 8 //
9 // The example below will disassemble a block of code and print it to stdout. 9 // The example below will disassemble a block of code and print it to stdout.
10 // 10 //
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void PrintDRegister(int reg); 70 void PrintDRegister(int reg);
71 int FormatFPRegister(Instruction* instr, const char* format); 71 int FormatFPRegister(Instruction* instr, const char* format);
72 void PrintSoftwareInterrupt(SoftwareInterruptCodes svc); 72 void PrintSoftwareInterrupt(SoftwareInterruptCodes svc);
73 73
74 // Handle formatting of instructions and their options. 74 // Handle formatting of instructions and their options.
75 int FormatRegister(Instruction* instr, const char* option); 75 int FormatRegister(Instruction* instr, const char* option);
76 int FormatOption(Instruction* instr, const char* option); 76 int FormatOption(Instruction* instr, const char* option);
77 void Format(Instruction* instr, const char* format); 77 void Format(Instruction* instr, const char* format);
78 void Unknown(Instruction* instr); 78 void Unknown(Instruction* instr);
79 void UnknownFormat(Instruction* instr, const char* opcname); 79 void UnknownFormat(Instruction* instr, const char* opcname);
80 void MarkerFormat(Instruction* instr, const char* opcname, int id);
81 80
82 void DecodeExt1(Instruction* instr); 81 void DecodeExt1(Instruction* instr);
83 void DecodeExt2(Instruction* instr); 82 void DecodeExt2(Instruction* instr);
84 void DecodeExt4(Instruction* instr); 83 void DecodeExt4(Instruction* instr);
85 void DecodeExt5(Instruction* instr); 84 void DecodeExt5(Instruction* instr);
86 85
87 const disasm::NameConverter& converter_; 86 const disasm::NameConverter& converter_;
88 Vector<char> out_buffer_; 87 Vector<char> out_buffer_;
89 int out_buffer_pos_; 88 int out_buffer_pos_;
90 89
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // For currently unimplemented decodings the disassembler calls 352 // For currently unimplemented decodings the disassembler calls
354 // UnknownFormat(instr) which will just print opcode name of the 353 // UnknownFormat(instr) which will just print opcode name of the
355 // instruction bits. 354 // instruction bits.
356 void Decoder::UnknownFormat(Instruction* instr, const char* name) { 355 void Decoder::UnknownFormat(Instruction* instr, const char* name) {
357 char buffer[100]; 356 char buffer[100];
358 snprintf(buffer, sizeof(buffer), "%s (unknown-format)", name); 357 snprintf(buffer, sizeof(buffer), "%s (unknown-format)", name);
359 Format(instr, buffer); 358 Format(instr, buffer);
360 } 359 }
361 360
362 361
363 void Decoder::MarkerFormat(Instruction* instr, const char* name, int id) {
364 char buffer[100];
365 snprintf(buffer, sizeof(buffer), "%s %d", name, id);
366 Format(instr, buffer);
367 }
368
369
370 void Decoder::DecodeExt1(Instruction* instr) { 362 void Decoder::DecodeExt1(Instruction* instr) {
371 switch (instr->Bits(10, 1) << 1) { 363 switch (instr->Bits(10, 1) << 1) {
372 case MCRF: { 364 case MCRF: {
373 UnknownFormat(instr, "mcrf"); // not used by V8 365 UnknownFormat(instr, "mcrf"); // not used by V8
374 break; 366 break;
375 } 367 }
376 case BCLRX: { 368 case BCLRX: {
377 switch (instr->Bits(25, 21) << 21) { 369 switch (instr->Bits(25, 21) << 21) {
378 case DCBNZF: { 370 case DCBNZF: {
379 UnknownFormat(instr, "bclrx-dcbnzf"); 371 UnknownFormat(instr, "bclrx-dcbnzf");
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 case CMP: { 590 case CMP: {
599 #if V8_TARGET_ARCH_PPC64 591 #if V8_TARGET_ARCH_PPC64
600 if (instr->Bit(21)) { 592 if (instr->Bit(21)) {
601 #endif 593 #endif
602 Format(instr, "cmp 'ra, 'rb"); 594 Format(instr, "cmp 'ra, 'rb");
603 #if V8_TARGET_ARCH_PPC64 595 #if V8_TARGET_ARCH_PPC64
604 } else { 596 } else {
605 Format(instr, "cmpw 'ra, 'rb"); 597 Format(instr, "cmpw 'ra, 'rb");
606 } 598 }
607 #endif 599 #endif
608 break; 600 return;
609 } 601 }
610 case SLWX: { 602 case SLWX: {
611 Format(instr, "slw'. 'ra, 'rs, 'rb"); 603 Format(instr, "slw'. 'ra, 'rs, 'rb");
612 break; 604 return;
613 } 605 }
614 #if V8_TARGET_ARCH_PPC64 606 #if V8_TARGET_ARCH_PPC64
615 case SLDX: { 607 case SLDX: {
616 Format(instr, "sld'. 'ra, 'rs, 'rb"); 608 Format(instr, "sld'. 'ra, 'rs, 'rb");
617 break; 609 return;
618 } 610 }
619 #endif 611 #endif
620 case SUBFCX: { 612 case SUBFCX: {
621 Format(instr, "subfc'. 'rt, 'ra, 'rb"); 613 Format(instr, "subfc'. 'rt, 'ra, 'rb");
622 break; 614 return;
623 } 615 }
624 case ADDCX: { 616 case ADDCX: {
625 Format(instr, "addc'. 'rt, 'ra, 'rb"); 617 Format(instr, "addc'. 'rt, 'ra, 'rb");
626 break; 618 return;
627 } 619 }
628 case CNTLZWX: { 620 case CNTLZWX: {
629 Format(instr, "cntlzw'. 'ra, 'rs"); 621 Format(instr, "cntlzw'. 'ra, 'rs");
630 break; 622 return;
631 } 623 }
632 #if V8_TARGET_ARCH_PPC64 624 #if V8_TARGET_ARCH_PPC64
633 case CNTLZDX: { 625 case CNTLZDX: {
634 Format(instr, "cntlzd'. 'ra, 'rs"); 626 Format(instr, "cntlzd'. 'ra, 'rs");
635 break; 627 return;
636 } 628 }
637 #endif 629 #endif
638 case ANDX: { 630 case ANDX: {
639 Format(instr, "and'. 'ra, 'rs, 'rb"); 631 Format(instr, "and'. 'ra, 'rs, 'rb");
640 break; 632 return;
641 } 633 }
642 case ANDCX: { 634 case ANDCX: {
643 Format(instr, "andc'. 'ra, 'rs, 'rb"); 635 Format(instr, "andc'. 'ra, 'rs, 'rb");
644 break; 636 return;
645 } 637 }
646 case CMPL: { 638 case CMPL: {
647 #if V8_TARGET_ARCH_PPC64 639 #if V8_TARGET_ARCH_PPC64
648 if (instr->Bit(21)) { 640 if (instr->Bit(21)) {
649 #endif 641 #endif
650 Format(instr, "cmpl 'ra, 'rb"); 642 Format(instr, "cmpl 'ra, 'rb");
651 #if V8_TARGET_ARCH_PPC64 643 #if V8_TARGET_ARCH_PPC64
652 } else { 644 } else {
653 Format(instr, "cmplw 'ra, 'rb"); 645 Format(instr, "cmplw 'ra, 'rb");
654 } 646 }
655 #endif 647 #endif
656 break; 648 return;
657 } 649 }
658 case NEGX: { 650 case NEGX: {
659 Format(instr, "neg'. 'rt, 'ra"); 651 Format(instr, "neg'. 'rt, 'ra");
660 break; 652 return;
661 } 653 }
662 case NORX: { 654 case NORX: {
663 Format(instr, "nor'. 'rt, 'ra, 'rb"); 655 Format(instr, "nor'. 'rt, 'ra, 'rb");
664 break; 656 return;
665 } 657 }
666 case SUBFX: { 658 case SUBFX: {
667 Format(instr, "subf'. 'rt, 'ra, 'rb"); 659 Format(instr, "subf'. 'rt, 'ra, 'rb");
668 break; 660 return;
669 } 661 }
670 case MULHWX: { 662 case MULHWX: {
671 Format(instr, "mulhw'o'. 'rt, 'ra, 'rb"); 663 Format(instr, "mulhw'o'. 'rt, 'ra, 'rb");
672 break; 664 return;
673 } 665 }
674 case ADDZEX: { 666 case ADDZEX: {
675 Format(instr, "addze'. 'rt, 'ra"); 667 Format(instr, "addze'. 'rt, 'ra");
676 break; 668 return;
677 } 669 }
678 case MULLW: { 670 case MULLW: {
679 Format(instr, "mullw'o'. 'rt, 'ra, 'rb"); 671 Format(instr, "mullw'o'. 'rt, 'ra, 'rb");
680 break; 672 return;
681 } 673 }
682 #if V8_TARGET_ARCH_PPC64 674 #if V8_TARGET_ARCH_PPC64
683 case MULLD: { 675 case MULLD: {
684 Format(instr, "mulld'o'. 'rt, 'ra, 'rb"); 676 Format(instr, "mulld'o'. 'rt, 'ra, 'rb");
685 break; 677 return;
686 } 678 }
687 #endif 679 #endif
688 case DIVW: { 680 case DIVW: {
689 Format(instr, "divw'o'. 'rt, 'ra, 'rb"); 681 Format(instr, "divw'o'. 'rt, 'ra, 'rb");
690 break; 682 return;
683 }
684 case DIVWU: {
685 Format(instr, "divwu'o'. 'rt, 'ra, 'rb");
686 return;
691 } 687 }
692 #if V8_TARGET_ARCH_PPC64 688 #if V8_TARGET_ARCH_PPC64
693 case DIVD: { 689 case DIVD: {
694 Format(instr, "divd'o'. 'rt, 'ra, 'rb"); 690 Format(instr, "divd'o'. 'rt, 'ra, 'rb");
695 break; 691 return;
696 } 692 }
697 #endif 693 #endif
698 case ADDX: { 694 case ADDX: {
699 Format(instr, "add'o 'rt, 'ra, 'rb"); 695 Format(instr, "add'o 'rt, 'ra, 'rb");
700 break; 696 return;
701 } 697 }
702 case XORX: { 698 case XORX: {
703 Format(instr, "xor'. 'ra, 'rs, 'rb"); 699 Format(instr, "xor'. 'ra, 'rs, 'rb");
704 break; 700 return;
705 } 701 }
706 case ORX: { 702 case ORX: {
707 if (instr->RTValue() == instr->RBValue()) { 703 if (instr->RTValue() == instr->RBValue()) {
708 Format(instr, "mr 'ra, 'rb"); 704 Format(instr, "mr 'ra, 'rb");
709 } else { 705 } else {
710 Format(instr, "or 'ra, 'rs, 'rb"); 706 Format(instr, "or 'ra, 'rs, 'rb");
711 } 707 }
712 break; 708 return;
713 } 709 }
714 case MFSPR: { 710 case MFSPR: {
715 int spr = instr->Bits(20, 11); 711 int spr = instr->Bits(20, 11);
716 if (256 == spr) { 712 if (256 == spr) {
717 Format(instr, "mflr 'rt"); 713 Format(instr, "mflr 'rt");
718 } else { 714 } else {
719 Format(instr, "mfspr 'rt ??"); 715 Format(instr, "mfspr 'rt ??");
720 } 716 }
721 break; 717 return;
722 } 718 }
723 case MTSPR: { 719 case MTSPR: {
724 int spr = instr->Bits(20, 11); 720 int spr = instr->Bits(20, 11);
725 if (256 == spr) { 721 if (256 == spr) {
726 Format(instr, "mtlr 'rt"); 722 Format(instr, "mtlr 'rt");
727 } else if (288 == spr) { 723 } else if (288 == spr) {
728 Format(instr, "mtctr 'rt"); 724 Format(instr, "mtctr 'rt");
729 } else { 725 } else {
730 Format(instr, "mtspr 'rt ??"); 726 Format(instr, "mtspr 'rt ??");
731 } 727 }
732 break; 728 return;
733 } 729 }
734 case MFCR: { 730 case MFCR: {
735 Format(instr, "mfcr 'rt"); 731 Format(instr, "mfcr 'rt");
736 break; 732 return;
737 } 733 }
738 case STWX: { 734 case STWX: {
739 Format(instr, "stwx 'rs, 'ra, 'rb"); 735 Format(instr, "stwx 'rs, 'ra, 'rb");
740 break; 736 return;
741 } 737 }
742 case STWUX: { 738 case STWUX: {
743 Format(instr, "stwux 'rs, 'ra, 'rb"); 739 Format(instr, "stwux 'rs, 'ra, 'rb");
744 break; 740 return;
745 } 741 }
746 case STBX: { 742 case STBX: {
747 Format(instr, "stbx 'rs, 'ra, 'rb"); 743 Format(instr, "stbx 'rs, 'ra, 'rb");
748 break; 744 return;
749 } 745 }
750 case STBUX: { 746 case STBUX: {
751 Format(instr, "stbux 'rs, 'ra, 'rb"); 747 Format(instr, "stbux 'rs, 'ra, 'rb");
752 break; 748 return;
753 } 749 }
754 case STHX: { 750 case STHX: {
755 Format(instr, "sthx 'rs, 'ra, 'rb"); 751 Format(instr, "sthx 'rs, 'ra, 'rb");
756 break; 752 return;
757 } 753 }
758 case STHUX: { 754 case STHUX: {
759 Format(instr, "sthux 'rs, 'ra, 'rb"); 755 Format(instr, "sthux 'rs, 'ra, 'rb");
760 break; 756 return;
761 } 757 }
762 case LWZX: { 758 case LWZX: {
763 Format(instr, "lwzx 'rt, 'ra, 'rb"); 759 Format(instr, "lwzx 'rt, 'ra, 'rb");
764 break; 760 return;
765 } 761 }
766 case LWZUX: { 762 case LWZUX: {
767 Format(instr, "lwzux 'rt, 'ra, 'rb"); 763 Format(instr, "lwzux 'rt, 'ra, 'rb");
768 break; 764 return;
765 }
766 case LWAX: {
767 Format(instr, "lwax 'rt, 'ra, 'rb");
768 return;
769 } 769 }
770 case LBZX: { 770 case LBZX: {
771 Format(instr, "lbzx 'rt, 'ra, 'rb"); 771 Format(instr, "lbzx 'rt, 'ra, 'rb");
772 break; 772 return;
773 } 773 }
774 case LBZUX: { 774 case LBZUX: {
775 Format(instr, "lbzux 'rt, 'ra, 'rb"); 775 Format(instr, "lbzux 'rt, 'ra, 'rb");
776 break; 776 return;
777 } 777 }
778 case LHZX: { 778 case LHZX: {
779 Format(instr, "lhzx 'rt, 'ra, 'rb"); 779 Format(instr, "lhzx 'rt, 'ra, 'rb");
780 break; 780 return;
781 } 781 }
782 case LHZUX: { 782 case LHZUX: {
783 Format(instr, "lhzux 'rt, 'ra, 'rb"); 783 Format(instr, "lhzux 'rt, 'ra, 'rb");
784 break; 784 return;
785 }
786 case LHAX: {
787 Format(instr, "lhax 'rt, 'ra, 'rb");
788 return;
785 } 789 }
786 #if V8_TARGET_ARCH_PPC64 790 #if V8_TARGET_ARCH_PPC64
787 case LDX: { 791 case LDX: {
788 Format(instr, "ldx 'rt, 'ra, 'rb"); 792 Format(instr, "ldx 'rt, 'ra, 'rb");
789 break; 793 return;
790 } 794 }
791 case LDUX: { 795 case LDUX: {
792 Format(instr, "ldux 'rt, 'ra, 'rb"); 796 Format(instr, "ldux 'rt, 'ra, 'rb");
793 break; 797 return;
794 } 798 }
795 case STDX: { 799 case STDX: {
796 Format(instr, "stdx 'rt, 'ra, 'rb"); 800 Format(instr, "stdx 'rt, 'ra, 'rb");
797 break; 801 return;
798 } 802 }
799 case STDUX: { 803 case STDUX: {
800 Format(instr, "stdux 'rt, 'ra, 'rb"); 804 Format(instr, "stdux 'rt, 'ra, 'rb");
801 break; 805 return;
802 } 806 }
803 case MFVSRD: { 807 case MFVSRD: {
804 Format(instr, "mffprd 'ra, 'Dt"); 808 Format(instr, "mffprd 'ra, 'Dt");
805 break; 809 return;
806 } 810 }
807 case MFVSRWZ: { 811 case MFVSRWZ: {
808 Format(instr, "mffprwz 'ra, 'Dt"); 812 Format(instr, "mffprwz 'ra, 'Dt");
809 break; 813 return;
810 } 814 }
811 case MTVSRD: { 815 case MTVSRD: {
812 Format(instr, "mtfprd 'Dt, 'ra"); 816 Format(instr, "mtfprd 'Dt, 'ra");
813 break; 817 return;
814 } 818 }
815 case MTVSRWA: { 819 case MTVSRWA: {
816 Format(instr, "mtfprwa 'Dt, 'ra"); 820 Format(instr, "mtfprwa 'Dt, 'ra");
817 break; 821 return;
818 } 822 }
819 case MTVSRWZ: { 823 case MTVSRWZ: {
820 Format(instr, "mtfprwz 'Dt, 'ra"); 824 Format(instr, "mtfprwz 'Dt, 'ra");
821 break; 825 return;
822 } 826 }
823 #endif 827 #endif
828 }
829
830 switch (instr->Bits(5, 1) << 1) {
831 case ISEL: {
832 Format(instr, "isel 'rt, 'ra, 'rb");
833 return;
834 }
824 default: { 835 default: {
825 Unknown(instr); // not used by V8 836 Unknown(instr); // not used by V8
826 } 837 }
827 } 838 }
828 } 839 }
829 840
830 841
831 void Decoder::DecodeExt4(Instruction* instr) { 842 void Decoder::DecodeExt4(Instruction* instr) {
832 switch (instr->Bits(5, 1) << 1) { 843 switch (instr->Bits(5, 1) << 1) {
833 case FDIV: { 844 case FDIV: {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 break; 917 break;
907 } 918 }
908 case MTFSF: { 919 case MTFSF: {
909 Format(instr, "mtfsf'. 'Db ?,?,?"); 920 Format(instr, "mtfsf'. 'Db ?,?,?");
910 break; 921 break;
911 } 922 }
912 case FABS: { 923 case FABS: {
913 Format(instr, "fabs'. 'Dt, 'Db"); 924 Format(instr, "fabs'. 'Dt, 'Db");
914 break; 925 break;
915 } 926 }
927 case FRIN: {
928 Format(instr, "frin. 'Dt, 'Db");
929 break;
930 }
931 case FRIZ: {
932 Format(instr, "friz. 'Dt, 'Db");
933 break;
934 }
935 case FRIP: {
936 Format(instr, "frip. 'Dt, 'Db");
937 break;
938 }
916 case FRIM: { 939 case FRIM: {
917 Format(instr, "frim 'Dt, 'Db"); 940 Format(instr, "frim. 'Dt, 'Db");
918 break; 941 break;
919 } 942 }
920 case FNEG: { 943 case FNEG: {
921 Format(instr, "fneg'. 'Dt, 'Db"); 944 Format(instr, "fneg'. 'Dt, 'Db");
922 break; 945 break;
923 } 946 }
924 default: { 947 default: {
925 Unknown(instr); // not used by V8 948 Unknown(instr); // not used by V8
926 } 949 }
927 } 950 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 } 1268 }
1246 case STD: { // could be STD or STDU 1269 case STD: { // could be STD or STDU
1247 if (instr->Bit(0) == 0) { 1270 if (instr->Bit(0) == 0) {
1248 Format(instr, "std 'rs, 'd('ra)"); 1271 Format(instr, "std 'rs, 'd('ra)");
1249 } else { 1272 } else {
1250 Format(instr, "stdu 'rs, 'd('ra)"); 1273 Format(instr, "stdu 'rs, 'd('ra)");
1251 } 1274 }
1252 break; 1275 break;
1253 } 1276 }
1254 #endif 1277 #endif
1255
1256 case FAKE_OPCODE: {
1257 if (instr->Bits(MARKER_SUBOPCODE_BIT, MARKER_SUBOPCODE_BIT) == 1) {
1258 int marker_code = instr->Bits(STUB_MARKER_HIGH_BIT, 0);
1259 DCHECK(marker_code < F_NEXT_AVAILABLE_STUB_MARKER);
1260 MarkerFormat(instr, "stub-marker ", marker_code);
1261 } else {
1262 int fake_opcode = instr->Bits(FAKE_OPCODE_HIGH_BIT, 0);
1263 MarkerFormat(instr, "faker-opcode ", fake_opcode);
1264 }
1265 break;
1266 }
1267 default: { 1278 default: {
1268 Unknown(instr); 1279 Unknown(instr);
1269 break; 1280 break;
1270 } 1281 }
1271 } 1282 }
1272 1283
1273 return Instruction::kInstrSize; 1284 return Instruction::kInstrSize;
1274 } 1285 }
1275 } 1286 }
1276 } // namespace v8::internal 1287 } // namespace v8::internal
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 pc += d.InstructionDecode(buffer, pc); 1355 pc += d.InstructionDecode(buffer, pc);
1345 v8::internal::PrintF(f, "%p %08x %s\n", prev_pc, 1356 v8::internal::PrintF(f, "%p %08x %s\n", prev_pc,
1346 *reinterpret_cast<int32_t*>(prev_pc), buffer.start()); 1357 *reinterpret_cast<int32_t*>(prev_pc), buffer.start());
1347 } 1358 }
1348 } 1359 }
1349 1360
1350 1361
1351 } // namespace disasm 1362 } // namespace disasm
1352 1363
1353 #endif // V8_TARGET_ARCH_PPC 1364 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/deoptimizer-ppc.cc ('k') | src/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698