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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 break; | 822 break; |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 | 826 |
827 #define UNSUPPORTED_COND(opcode, condition) \ | 827 #define UNSUPPORTED_COND(opcode, condition) \ |
828 OFStream out(stdout); \ | 828 OFStream out(stdout); \ |
829 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ | 829 out << "Unsupported " << #opcode << " condition: \"" << condition << "\""; \ |
830 UNIMPLEMENTED(); | 830 UNIMPLEMENTED(); |
831 | 831 |
832 static bool convertCondition(FlagsCondition condition, Condition& cc, | 832 static bool convertCondition(FlagsCondition condition, Condition& cc) { |
833 bool& acceptNaN) { | |
834 acceptNaN = false; | |
835 switch (condition) { | 833 switch (condition) { |
836 case kEqual: | 834 case kEqual: |
837 cc = eq; | 835 cc = eq; |
838 return true; | 836 return true; |
839 case kNotEqual: | 837 case kNotEqual: |
840 cc = ne; | 838 cc = ne; |
841 acceptNaN = true; | |
842 return true; | 839 return true; |
843 case kUnsignedLessThan: | 840 case kUnsignedLessThan: |
844 cc = lt; | 841 cc = lt; |
845 return true; | 842 return true; |
846 case kUnsignedGreaterThanOrEqual: | 843 case kUnsignedGreaterThanOrEqual: |
847 cc = ge; | 844 cc = uge; |
848 acceptNaN = true; | |
849 return true; | 845 return true; |
850 case kUnsignedLessThanOrEqual: | 846 case kUnsignedLessThanOrEqual: |
851 cc = le; | 847 cc = le; |
852 return true; | 848 return true; |
853 case kUnsignedGreaterThan: | 849 case kUnsignedGreaterThan: |
854 cc = gt; | 850 cc = ugt; |
855 acceptNaN = true; | |
856 return true; | 851 return true; |
857 default: | 852 default: |
858 break; | 853 break; |
859 } | 854 } |
860 return false; | 855 return false; |
861 } | 856 } |
862 | 857 |
863 | 858 |
864 // Assembles branches after an instruction. | 859 // Assembles branches after an instruction. |
865 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { | 860 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
(...skipping 22 matching lines...) Expand all Loading... |
888 cc = FlagsConditionToConditionOvf(branch->condition); | 883 cc = FlagsConditionToConditionOvf(branch->condition); |
889 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); | 884 __ Branch(tlabel, cc, kCompareReg, Operand(zero_reg)); |
890 | 885 |
891 } else if (instr->arch_opcode() == kMipsCmp) { | 886 } else if (instr->arch_opcode() == kMipsCmp) { |
892 cc = FlagsConditionToConditionCmp(branch->condition); | 887 cc = FlagsConditionToConditionCmp(branch->condition); |
893 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); | 888 __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); |
894 | 889 |
895 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 890 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
896 | 891 |
897 } else if (instr->arch_opcode() == kMipsCmpS) { | 892 } else if (instr->arch_opcode() == kMipsCmpS) { |
898 // TODO(dusmil) optimize unordered checks to use fewer instructions | 893 if (!convertCondition(branch->condition, cc)) { |
899 // even if we have to unfold BranchF macro. | |
900 bool acceptNaN = false; | |
901 if (!convertCondition(branch->condition, cc, acceptNaN)) { | |
902 UNSUPPORTED_COND(kMips64CmpS, branch->condition); | 894 UNSUPPORTED_COND(kMips64CmpS, branch->condition); |
903 } | 895 } |
904 Label* nan = acceptNaN ? tlabel : flabel; | 896 __ BranchF32(tlabel, NULL, cc, i.InputSingleRegister(0), |
905 __ BranchF32(tlabel, nan, cc, i.InputSingleRegister(0), | |
906 i.InputSingleRegister(1)); | 897 i.InputSingleRegister(1)); |
907 | 898 |
908 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 899 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
909 | 900 |
910 } else if (instr->arch_opcode() == kMipsCmpD) { | 901 } else if (instr->arch_opcode() == kMipsCmpD) { |
911 // TODO(dusmil) optimize unordered checks to use fewer instructions | 902 if (!convertCondition(branch->condition, cc)) { |
912 // even if we have to unfold BranchF macro. | |
913 bool acceptNaN = false; | |
914 if (!convertCondition(branch->condition, cc, acceptNaN)) { | |
915 UNSUPPORTED_COND(kMips64CmpD, branch->condition); | 903 UNSUPPORTED_COND(kMips64CmpD, branch->condition); |
916 } | 904 } |
917 Label* nan = acceptNaN ? tlabel : flabel; | 905 __ BranchF64(tlabel, NULL, cc, i.InputDoubleRegister(0), |
918 __ BranchF64(tlabel, nan, cc, i.InputDoubleRegister(0), | |
919 i.InputDoubleRegister(1)); | 906 i.InputDoubleRegister(1)); |
920 | 907 |
921 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. | 908 if (!branch->fallthru) __ Branch(flabel); // no fallthru to flabel. |
922 | 909 |
923 } else { | 910 } else { |
924 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", | 911 PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", |
925 instr->arch_opcode()); | 912 instr->arch_opcode()); |
926 UNIMPLEMENTED(); | 913 UNIMPLEMENTED(); |
927 } | 914 } |
928 } | 915 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 } | 1323 } |
1337 } | 1324 } |
1338 MarkLazyDeoptSite(); | 1325 MarkLazyDeoptSite(); |
1339 } | 1326 } |
1340 | 1327 |
1341 #undef __ | 1328 #undef __ |
1342 | 1329 |
1343 } // namespace compiler | 1330 } // namespace compiler |
1344 } // namespace internal | 1331 } // namespace internal |
1345 } // namespace v8 | 1332 } // namespace v8 |
OLD | NEW |