OLD | NEW |
---|---|
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 #include "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 #include "src/compiler/code-generator.h" | 6 #include "src/compiler/code-generator.h" |
7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/osr.h" | 10 #include "src/compiler/osr.h" |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 } | 823 } |
824 break; | 824 break; |
825 case kMipsSar: | 825 case kMipsSar: |
826 if (instr->InputAt(1)->IsRegister()) { | 826 if (instr->InputAt(1)->IsRegister()) { |
827 __ srav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); | 827 __ srav(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); |
828 } else { | 828 } else { |
829 int32_t imm = i.InputOperand(1).immediate(); | 829 int32_t imm = i.InputOperand(1).immediate(); |
830 __ sra(i.OutputRegister(), i.InputRegister(0), imm); | 830 __ sra(i.OutputRegister(), i.InputRegister(0), imm); |
831 } | 831 } |
832 break; | 832 break; |
833 case kMipsShlPair: { | |
834 if (instr->InputAt(2)->IsRegister()) { | |
akos.palfi.imgtec
2016/03/24 12:10:19
Please move this code into the macro-assembler.
F
Marija Antic
2016/03/24 15:40:34
Done.
| |
835 Label less_than_32; | |
836 Label zero_shift; | |
837 Label word_shift; | |
838 Label done; | |
839 __ Branch(&less_than_32, lt, i.InputRegister(2), Operand(32)); | |
840 | |
841 __ Branch(&word_shift, eq, i.InputRegister(2), Operand(32)); | |
842 | |
843 // Shift more than 32 | |
844 __ li(kScratchReg, 0x20); | |
balazs.kilvady
2016/03/24 11:52:46
Using Operand(32) in the above 2 Branches causes 2
Marija Antic
2016/03/24 15:40:34
Done.
| |
845 __ Subu(kScratchReg, i.InputRegister(2), kScratchReg); | |
846 __ mov(i.OutputRegister(0), zero_reg); | |
847 __ sllv(i.OutputRegister(1), i.InputRegister(0), kScratchReg); | |
848 __ Branch(&done); | |
849 | |
850 // Word shift | |
851 __ bind(&word_shift); | |
852 __ mov(i.OutputRegister(0), zero_reg); | |
853 __ mov(i.OutputRegister(1), i.InputRegister(0)); | |
854 __ Branch(&done); | |
855 | |
856 __ bind(&less_than_32); | |
857 | |
858 // Check if zero shift | |
859 __ Branch(&zero_shift, eq, i.InputRegister(2), Operand(zero_reg)); | |
860 | |
861 // Shift less than 32 | |
862 __ li(kScratchReg, 0x20); | |
863 __ Subu(kScratchReg, kScratchReg, i.InputRegister(2)); | |
864 __ sllv(i.OutputRegister(1), i.InputRegister(1), i.InputRegister(2)); | |
865 __ sllv(i.OutputRegister(0), i.InputRegister(0), i.InputRegister(2)); | |
866 __ srlv(kScratchReg, i.InputRegister(0), kScratchReg); | |
867 __ Or(i.OutputRegister(1), i.OutputRegister(1), kScratchReg); | |
868 __ Branch(&done); | |
869 | |
870 // Zero shift | |
871 __ bind(&zero_shift); | |
872 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
873 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
874 __ bind(&done); | |
875 } else { | |
876 int32_t imm = i.InputOperand(2).immediate(); | |
877 if (imm < 32) { | |
878 if (imm == 0) { | |
879 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
880 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
881 } else { | |
882 __ sll(i.OutputRegister(1), i.InputRegister(1), imm); | |
883 __ sll(i.OutputRegister(0), i.InputRegister(0), imm); | |
884 imm = 32 - imm; | |
885 __ srl(kScratchReg, i.InputRegister(0), imm); | |
886 __ Or(i.OutputRegister(1), i.OutputRegister(1), kScratchReg); | |
887 } | |
888 } else { | |
889 if (imm == 32) { | |
890 __ mov(i.OutputRegister(0), zero_reg); | |
891 __ mov(i.OutputRegister(1), i.InputRegister(0)); | |
892 } else { | |
893 imm = imm - 32; | |
894 __ mov(i.OutputRegister(0), zero_reg); | |
895 __ sll(i.OutputRegister(1), i.InputRegister(0), imm); | |
896 } | |
897 } | |
898 } | |
899 } break; | |
900 case kMipsShrPair: { | |
901 if (instr->InputAt(2)->IsRegister()) { | |
akos.palfi.imgtec
2016/03/24 12:10:19
Same here, please move to the macro-asm.
Marija Antic
2016/03/24 15:40:34
Done.
| |
902 Label less_than_32; | |
903 Label zero_shift; | |
904 Label word_shift; | |
905 Label done; | |
906 __ Branch(&less_than_32, lt, i.InputRegister(2), Operand(32)); | |
907 | |
908 __ Branch(&word_shift, eq, i.InputRegister(2), Operand(32)); | |
909 | |
910 // Shift more than 32 | |
911 __ li(kScratchReg, 0x20); | |
912 __ Subu(kScratchReg, i.InputRegister(2), kScratchReg); | |
913 __ mov(i.OutputRegister(1), zero_reg); | |
914 __ srlv(i.OutputRegister(0), i.InputRegister(1), kScratchReg); | |
915 __ Branch(&done); | |
916 | |
917 // Word shift | |
918 __ bind(&word_shift); | |
919 __ mov(i.OutputRegister(1), zero_reg); | |
920 __ mov(i.OutputRegister(0), i.InputRegister(1)); | |
921 __ Branch(&done); | |
922 | |
923 __ bind(&less_than_32); | |
924 | |
925 // Check if zero shift | |
926 __ Branch(&zero_shift, eq, i.InputRegister(2), Operand(zero_reg)); | |
927 | |
928 // Shift less than 32 | |
929 __ li(kScratchReg, 0x20); | |
930 __ Subu(kScratchReg, kScratchReg, i.InputRegister(2)); | |
931 __ srlv(i.OutputRegister(1), i.InputRegister(1), i.InputRegister(2)); | |
932 __ srlv(i.OutputRegister(0), i.InputRegister(0), i.InputRegister(2)); | |
933 __ sllv(kScratchReg, i.InputRegister(1), kScratchReg); | |
934 __ Or(i.OutputRegister(0), i.OutputRegister(0), kScratchReg); | |
935 __ Branch(&done); | |
936 | |
937 // Zero shift | |
938 __ bind(&zero_shift); | |
939 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
940 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
941 | |
942 __ bind(&done); | |
943 } else { | |
944 int32_t imm = i.InputOperand(2).immediate(); | |
945 if (imm < 32) { | |
946 if (imm == 0) { | |
947 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
948 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
949 } else { | |
950 __ srl(i.OutputRegister(1), i.InputRegister(1), imm); | |
951 __ srl(i.OutputRegister(0), i.InputRegister(0), imm); | |
952 imm = 32 - imm; | |
953 __ sll(kScratchReg, i.InputRegister(1), imm); | |
954 __ Or(i.OutputRegister(0), i.OutputRegister(0), kScratchReg); | |
955 } | |
956 } else { | |
957 if (imm == 32) { | |
958 __ mov(i.OutputRegister(1), zero_reg); | |
959 __ mov(i.OutputRegister(0), i.InputRegister(1)); | |
960 } else { | |
961 imm = imm - 32; | |
962 __ mov(i.OutputRegister(1), zero_reg); | |
963 __ srl(i.OutputRegister(0), i.InputRegister(1), imm); | |
964 } | |
965 } | |
966 } | |
967 } break; | |
968 case kMipsSarPair: { | |
969 if (instr->InputAt(2)->IsRegister()) { | |
akos.palfi.imgtec
2016/03/24 12:10:19
Same here, please move to the macro-asm.
Marija Antic
2016/03/24 15:40:34
Done.
| |
970 Label less_than_32; | |
971 Label zero_shift; | |
972 Label word_shift; | |
973 Label done; | |
974 __ Branch(&less_than_32, lt, i.InputRegister(2), Operand(32)); | |
975 | |
976 __ Branch(&word_shift, eq, i.InputRegister(2), Operand(32)); | |
977 | |
978 // Shift more than 32 | |
979 __ li(kScratchReg, 0x20); | |
980 __ li(kScratchReg2, 0x1F); | |
981 __ Subu(kScratchReg, i.InputRegister(2), kScratchReg); | |
982 __ srav(i.OutputRegister(1), i.InputRegister(1), kScratchReg2); | |
983 __ srav(i.OutputRegister(0), i.InputRegister(1), kScratchReg); | |
984 __ Branch(&done); | |
985 | |
986 // Word shift | |
987 __ bind(&word_shift); | |
988 __ li(kScratchReg2, 0x1F); | |
989 __ srav(i.OutputRegister(1), i.InputRegister(1), kScratchReg2); | |
990 __ mov(i.OutputRegister(0), i.InputRegister(1)); | |
991 __ Branch(&done); | |
992 | |
993 __ bind(&less_than_32); | |
994 // Check if zero shift | |
995 __ Branch(&zero_shift, eq, i.InputRegister(2), Operand(zero_reg)); | |
996 | |
997 // Shift less than 32 | |
998 __ li(kScratchReg, 0x20); | |
999 __ Subu(kScratchReg, kScratchReg, i.InputRegister(2)); | |
1000 __ srav(i.OutputRegister(1), i.InputRegister(1), i.InputRegister(2)); | |
1001 __ srlv(i.OutputRegister(0), i.InputRegister(0), i.InputRegister(2)); | |
1002 __ sllv(kScratchReg, i.InputRegister(1), kScratchReg); | |
1003 __ Or(i.OutputRegister(0), i.OutputRegister(0), kScratchReg); | |
1004 __ Branch(&done); | |
1005 | |
1006 // Zero shift | |
1007 __ bind(&zero_shift); | |
1008 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
1009 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
1010 | |
1011 __ bind(&done); | |
1012 } else { | |
1013 int32_t imm = i.InputOperand(2).immediate(); | |
1014 if (imm < 32) { | |
1015 if (imm == 0) { | |
1016 __ mov(i.OutputRegister(0), i.InputRegister(0)); | |
1017 __ mov(i.OutputRegister(1), i.InputRegister(1)); | |
1018 } else { | |
1019 __ sra(i.OutputRegister(1), i.InputRegister(1), imm); | |
1020 __ srl(i.OutputRegister(0), i.InputRegister(0), imm); | |
1021 imm = 32 - imm; | |
1022 __ sll(kScratchReg, i.InputRegister(1), imm); | |
1023 __ Or(i.OutputRegister(0), i.OutputRegister(0), kScratchReg); | |
1024 } | |
1025 } else { | |
1026 if (imm == 32) { | |
1027 __ sra(i.OutputRegister(1), i.InputRegister(1), 31); | |
1028 __ mov(i.OutputRegister(0), i.InputRegister(1)); | |
1029 } else { | |
1030 imm = imm - 32; | |
1031 __ sra(i.OutputRegister(1), i.InputRegister(1), 31); | |
1032 __ sra(i.OutputRegister(0), i.InputRegister(1), imm); | |
1033 } | |
1034 } | |
1035 } | |
1036 } break; | |
833 case kMipsExt: | 1037 case kMipsExt: |
834 __ Ext(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), | 1038 __ Ext(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), |
835 i.InputInt8(2)); | 1039 i.InputInt8(2)); |
836 break; | 1040 break; |
837 case kMipsIns: | 1041 case kMipsIns: |
838 if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { | 1042 if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { |
839 __ Ins(i.OutputRegister(), zero_reg, i.InputInt8(1), i.InputInt8(2)); | 1043 __ Ins(i.OutputRegister(), zero_reg, i.InputInt8(1), i.InputInt8(2)); |
840 } else { | 1044 } else { |
841 __ Ins(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), | 1045 __ Ins(i.OutputRegister(), i.InputRegister(0), i.InputInt8(1), |
842 i.InputInt8(2)); | 1046 i.InputInt8(2)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 __ max_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), | 1111 __ max_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), |
908 i.InputDoubleRegister(1)); | 1112 i.InputDoubleRegister(1)); |
909 break; | 1113 break; |
910 case kMipsMinS: | 1114 case kMipsMinS: |
911 __ min_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), | 1115 __ min_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), |
912 i.InputDoubleRegister(1)); | 1116 i.InputDoubleRegister(1)); |
913 break; | 1117 break; |
914 case kMipsCmpD: | 1118 case kMipsCmpD: |
915 // Psuedo-instruction used for FP cmp/branch. No opcode emitted here. | 1119 // Psuedo-instruction used for FP cmp/branch. No opcode emitted here. |
916 break; | 1120 break; |
1121 case kMipsAddPair: { | |
1122 Label no_overflow; | |
1123 // Add lower word | |
1124 __ Addu(i.OutputRegister(0), i.InputRegister(0), i.InputRegister(2)); | |
1125 __ Addu(i.OutputRegister(1), i.InputRegister(1), i.InputRegister(3)); | |
1126 // Check for lower word overflow | |
akos.palfi.imgtec
2016/03/24 12:10:19
Instead of manual overflow checking here, can you
Marija Antic
2016/03/25 11:17:58
Simple switching to AddBranchOvf() causes test fai
| |
1127 __ Sltu(kScratchReg, i.OutputRegister(0), i.InputRegister(0)); | |
1128 __ Sltu(kScratchReg2, i.OutputRegister(0), i.InputRegister(2)); | |
1129 __ Or(kScratchReg, kScratchReg2, kScratchReg); | |
1130 __ Branch(&no_overflow, eq, kScratchReg, Operand(zero_reg)); | |
1131 // Increment higher word if there was overflow | |
1132 __ Addu(i.OutputRegister(1), i.OutputRegister(1), 0x1); | |
1133 __ bind(&no_overflow); | |
1134 } break; | |
1135 case kMipsSubPair: { | |
1136 Label no_overflow; | |
1137 // Subtract lower word | |
1138 __ Subu(i.OutputRegister(0), i.InputRegister(0), i.InputRegister(2)); | |
1139 __ Subu(i.OutputRegister(1), i.InputRegister(1), i.InputRegister(3)); | |
1140 // Check for lower word underflow | |
akos.palfi.imgtec
2016/03/24 12:10:19
Same question here with SubBranchOvf().
| |
1141 __ Sltu(kScratchReg, i.InputRegister(0), i.OutputRegister(0)); | |
1142 __ Branch(&no_overflow, eq, kScratchReg, Operand(zero_reg)); | |
1143 // Decrement higher word if there was underflow | |
1144 __ Subu(i.OutputRegister(1), i.OutputRegister(1), 0x1); | |
1145 __ bind(&no_overflow); | |
1146 } break; | |
917 case kMipsAddD: | 1147 case kMipsAddD: |
918 // TODO(plind): add special case: combine mult & add. | 1148 // TODO(plind): add special case: combine mult & add. |
919 __ add_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), | 1149 __ add_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), |
920 i.InputDoubleRegister(1)); | 1150 i.InputDoubleRegister(1)); |
921 break; | 1151 break; |
922 case kMipsSubD: | 1152 case kMipsSubD: |
923 __ sub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), | 1153 __ sub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), |
924 i.InputDoubleRegister(1)); | 1154 i.InputDoubleRegister(1)); |
925 break; | 1155 break; |
926 case kMipsMulD: | 1156 case kMipsMulD: |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1865 padding_size -= v8::internal::Assembler::kInstrSize; | 2095 padding_size -= v8::internal::Assembler::kInstrSize; |
1866 } | 2096 } |
1867 } | 2097 } |
1868 } | 2098 } |
1869 | 2099 |
1870 #undef __ | 2100 #undef __ |
1871 | 2101 |
1872 } // namespace compiler | 2102 } // namespace compiler |
1873 } // namespace internal | 2103 } // namespace internal |
1874 } // namespace v8 | 2104 } // namespace v8 |
OLD | NEW |