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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/mips/macro-assembler-mips.h" | 9 #include "src/mips/macro-assembler-mips.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 break; | 890 break; |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 | 894 |
895 #define UNSUPPORTED_COND(opcode, condition) \ | 895 #define UNSUPPORTED_COND(opcode, condition) \ |
896 OFStream out(stdout); \ | 896 OFStream out(stdout); \ |
897 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ | 897 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ |
898 UNIMPLEMENTED(); | 898 UNIMPLEMENTED(); |
899 | 899 |
900 static bool convertCondition(FlagsCondition condition, Condition& cc, | 900 static bool convertCondition(FlagsCondition condition, Condition& cc) { |
901 bool& acceptNaN) { | |
902 acceptNaN = false; | |
903 switch (condition) { | 901 switch (condition) { |
904 case kEqual: | 902 case kEqual: |
905 cc = eq; | 903 cc = eq; |
906 return true; | 904 return true; |
907 case kNotEqual: | 905 case kNotEqual: |
908 cc = ne; | 906 cc = ne; |
909 acceptNaN = true; | |
910 return true; | 907 return true; |
911 case kUnsignedLessThan: | 908 case kUnsignedLessThan: |
912 cc = lt; | 909 cc = lt; |
913 return true; | 910 return true; |
914 case kUnsignedGreaterThanOrEqual: | 911 case kUnsignedGreaterThanOrEqual: |
915 cc = ge; | 912 cc = uge; |
916 acceptNaN = true; | |
917 return true; | 913 return true; |
918 case kUnsignedLessThanOrEqual: | 914 case kUnsignedLessThanOrEqual: |
919 cc = le; | 915 cc = le; |
920 return true; | 916 return true; |
921 case kUnsignedGreaterThan: | 917 case kUnsignedGreaterThan: |
922 cc = gt; | 918 cc = ugt; |
923 acceptNaN = true; | |
924 return true; | 919 return true; |
925 default: | 920 default: |
926 break; | 921 break; |
927 } | 922 } |
928 return false; | 923 return false; |
929 } | 924 } |
930 | 925 |
931 | 926 |
932 // Assembles branches after an instruction. | 927 // Assembles branches after an instruction. |
933 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 928 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
(...skipping 19 matching lines...) Expand all Loading... |
953 | 948 |
954 __ dsra32(kScratchReg, i.OutputRegister(), 0); | 949 __ dsra32(kScratchReg, i.OutputRegister(), 0); |
955 __ sra(at, i.OutputRegister(), 31); | 950 __ sra(at, i.OutputRegister(), 31); |
956 __ Branch(tlabel, cc, at, Operand(kScratchReg)); | 951 __ Branch(tlabel, cc, at, Operand(kScratchReg)); |
957 } else if (instr->arch_opcode() == kMips64Cmp) { | 952 } else if (instr->arch_opcode() == kMips64Cmp) { |
958 cc = FlagsConditionToConditionCmp(branch->condition); | 953 cc = FlagsConditionToConditionCmp(branch->condition); |
959 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); | 954 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); |
960 | 955 |
961 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 956 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
962 } else if (instr->arch_opcode() == kMips64CmpS) { | 957 } else if (instr->arch_opcode() == kMips64CmpS) { |
963 // TODO(dusmil) optimize unordered checks to use fewer instructions | 958 if (!convertCondition(branch->condition, cc)) { |
964 // even if we have to unfold BranchF macro. | |
965 bool acceptNaN = false; | |
966 if (!convertCondition(branch->condition, cc, acceptNaN)) { | |
967 UNSUPPORTED_COND(kMips64CmpS, branch->condition); | 959 UNSUPPORTED_COND(kMips64CmpS, branch->condition); |
968 } | 960 } |
969 Label* nan = acceptNaN ? tlabel : flabel; | 961 __ BranchF32(tlabel, NULL, cc, i.InputSingleRegister(0), |
970 __ BranchF32(tlabel, nan, cc, i.InputSingleRegister(0), | |
971 i.InputSingleRegister(1)); | 962 i.InputSingleRegister(1)); |
972 | 963 |
973 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 964 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
974 | 965 |
975 } else if (instr->arch_opcode() == kMips64CmpD) { | 966 } else if (instr->arch_opcode() == kMips64CmpD) { |
976 // TODO(dusmil) optimize unordered checks to use less instructions | 967 if (!convertCondition(branch->condition, cc)) { |
977 // even if we have to unfold BranchF macro. | |
978 bool acceptNaN = false; | |
979 if (!convertCondition(branch->condition, cc, acceptNaN)) { | |
980 UNSUPPORTED_COND(kMips64CmpD, branch->condition); | 968 UNSUPPORTED_COND(kMips64CmpD, branch->condition); |
981 } | 969 } |
982 Label* nan = acceptNaN ? tlabel : flabel; | 970 __ BranchF64(tlabel, NULL, cc, i.InputDoubleRegister(0), |
983 __ BranchF64(tlabel, nan, cc, i.InputDoubleRegister(0), | |
984 i.InputDoubleRegister(1)); | 971 i.InputDoubleRegister(1)); |
985 | 972 |
986 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 973 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
987 } else { | 974 } else { |
988 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", | 975 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", |
989 instr->arch_opcode()); | 976 instr->arch_opcode()); |
990 UNIMPLEMENTED(); | 977 UNIMPLEMENTED(); |
991 } | 978 } |
992 } | 979 } |
993 | 980 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 } | 1389 } |
1403 } | 1390 } |
1404 MarkLazyDeoptSite(); | 1391 MarkLazyDeoptSite(); |
1405 } | 1392 } |
1406 | 1393 |
1407 #undef __ | 1394 #undef __ |
1408 | 1395 |
1409 } // namespace compiler | 1396 } // namespace compiler |
1410 } // namespace internal | 1397 } // namespace internal |
1411 } // namespace v8 | 1398 } // namespace v8 |
OLD | NEW |