| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return ne; | 255 return ne; |
| 256 case kNotOverflow: | 256 case kNotOverflow: |
| 257 return eq; | 257 return eq; |
| 258 default: | 258 default: |
| 259 break; | 259 break; |
| 260 } | 260 } |
| 261 UNREACHABLE(); | 261 UNREACHABLE(); |
| 262 return kNoCondition; | 262 return kNoCondition; |
| 263 } | 263 } |
| 264 | 264 |
| 265 |
| 266 FPUCondition FlagsConditionToConditionCmpD(bool& predicate, |
| 267 FlagsCondition condition) { |
| 268 switch (condition) { |
| 269 case kEqual: |
| 270 predicate = true; |
| 271 return EQ; |
| 272 case kNotEqual: |
| 273 predicate = false; |
| 274 return EQ; |
| 275 case kUnsignedLessThan: |
| 276 predicate = true; |
| 277 return OLT; |
| 278 case kUnsignedGreaterThanOrEqual: |
| 279 predicate = false; |
| 280 return ULT; |
| 281 case kUnsignedLessThanOrEqual: |
| 282 predicate = true; |
| 283 return OLE; |
| 284 case kUnsignedGreaterThan: |
| 285 predicate = false; |
| 286 return ULE; |
| 287 case kUnorderedEqual: |
| 288 case kUnorderedNotEqual: |
| 289 predicate = true; |
| 290 break; |
| 291 default: |
| 292 predicate = true; |
| 293 break; |
| 294 } |
| 295 UNREACHABLE(); |
| 296 return kNoFPUCondition; |
| 297 } |
| 298 |
| 265 } // namespace | 299 } // namespace |
| 266 | 300 |
| 267 | 301 |
| 268 #define ASSEMBLE_CHECKED_LOAD_FLOAT(width, asm_instr) \ | 302 #define ASSEMBLE_CHECKED_LOAD_FLOAT(width, asm_instr) \ |
| 269 do { \ | 303 do { \ |
| 270 auto result = i.Output##width##Register(); \ | 304 auto result = i.Output##width##Register(); \ |
| 271 auto ool = new (zone()) OutOfLineLoad##width(this, result); \ | 305 auto ool = new (zone()) OutOfLineLoad##width(this, result); \ |
| 272 if (instr->InputAt(0)->IsRegister()) { \ | 306 if (instr->InputAt(0)->IsRegister()) { \ |
| 273 auto offset = i.InputRegister(0); \ | 307 auto offset = i.InputRegister(0); \ |
| 274 __ Branch(USE_DELAY_SLOT, ool->entry(), hs, offset, i.InputOperand(1)); \ | 308 __ Branch(USE_DELAY_SLOT, ool->entry(), hs, offset, i.InputOperand(1)); \ |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 break; | 995 break; |
| 962 default: | 996 default: |
| 963 UNSUPPORTED_COND(kMips64Cmp32, condition); | 997 UNSUPPORTED_COND(kMips64Cmp32, condition); |
| 964 break; | 998 break; |
| 965 } | 999 } |
| 966 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); | 1000 __ Branch(USE_DELAY_SLOT, &done, cc, left, right); |
| 967 __ li(result, Operand(1)); // In delay slot. | 1001 __ li(result, Operand(1)); // In delay slot. |
| 968 } else if (instr->arch_opcode() == kMips64CmpD) { | 1002 } else if (instr->arch_opcode() == kMips64CmpD) { |
| 969 FPURegister left = i.InputDoubleRegister(0); | 1003 FPURegister left = i.InputDoubleRegister(0); |
| 970 FPURegister right = i.InputDoubleRegister(1); | 1004 FPURegister right = i.InputDoubleRegister(1); |
| 971 // TODO(plind): Provide NaN-testing macro-asm function without need for | 1005 |
| 972 // BranchF. | 1006 bool predicate; |
| 973 FPURegister dummy1 = f0; | 1007 FPUCondition cc = FlagsConditionToConditionCmpD(predicate, condition); |
| 974 FPURegister dummy2 = f2; | 1008 if (kArchVariant != kMips64r6) { |
| 975 switch (condition) { | 1009 __ li(result, Operand(1)); |
| 976 case kEqual: | 1010 __ c(cc, D, left, right); |
| 977 // TODO(plind): improve the NaN testing throughout this function. | 1011 if (predicate) { |
| 978 __ BranchF(NULL, &false_value, kNoCondition, dummy1, dummy2); | 1012 __ Movf(result, zero_reg); |
| 979 cc = eq; | 1013 } else { |
| 980 break; | 1014 __ Movt(result, zero_reg); |
| 981 case kNotEqual: | 1015 } |
| 982 __ BranchF(USE_DELAY_SLOT, NULL, &done, kNoCondition, dummy1, dummy2); | 1016 } else { |
| 983 __ li(result, Operand(1)); // In delay slot - returns 1 on NaN. | 1017 __ cmp(cc, L, kDoubleCompareReg, left, right); |
| 984 cc = ne; | 1018 __ dmfc1(at, kDoubleCompareReg); |
| 985 break; | 1019 __ dsrl32(result, at, 31); // Cmp returns all 1s for true. |
| 986 case kUnsignedLessThan: | 1020 if (!predicate) // Toggle result for not equal. |
| 987 __ BranchF(NULL, &false_value, kNoCondition, dummy1, dummy2); | 1021 __ xori(result, result, 1); |
| 988 cc = lt; | |
| 989 break; | |
| 990 case kUnsignedGreaterThanOrEqual: | |
| 991 __ BranchF(USE_DELAY_SLOT, NULL, &done, kNoCondition, dummy1, dummy2); | |
| 992 __ li(result, Operand(1)); // In delay slot - returns 1 on NaN. | |
| 993 cc = ge; | |
| 994 break; | |
| 995 case kUnsignedLessThanOrEqual: | |
| 996 __ BranchF(NULL, &false_value, kNoCondition, dummy1, dummy2); | |
| 997 cc = le; | |
| 998 break; | |
| 999 case kUnsignedGreaterThan: | |
| 1000 __ BranchF(USE_DELAY_SLOT, NULL, &done, kNoCondition, dummy1, dummy2); | |
| 1001 __ li(result, Operand(1)); // In delay slot - returns 1 on NaN. | |
| 1002 cc = gt; | |
| 1003 break; | |
| 1004 default: | |
| 1005 UNSUPPORTED_COND(kMips64Cmp, condition); | |
| 1006 break; | |
| 1007 } | 1022 } |
| 1008 __ BranchF(USE_DELAY_SLOT, &done, NULL, cc, left, right); | 1023 return; |
| 1009 __ li(result, Operand(1)); // In delay slot - branch taken returns 1. | |
| 1010 // Fall-thru (branch not taken) returns 0. | |
| 1011 | |
| 1012 } else { | 1024 } else { |
| 1013 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", | 1025 PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", |
| 1014 instr->arch_opcode()); | 1026 instr->arch_opcode()); |
| 1015 TRACE_UNIMPL(); | 1027 TRACE_UNIMPL(); |
| 1016 UNIMPLEMENTED(); | 1028 UNIMPLEMENTED(); |
| 1017 } | 1029 } |
| 1018 // Fallthru case is the false materialization. | 1030 // Fallthru case is the false materialization. |
| 1019 __ bind(&false_value); | 1031 __ bind(&false_value); |
| 1020 __ li(result, Operand(static_cast<int64_t>(0))); | 1032 __ li(result, Operand(static_cast<int64_t>(0))); |
| 1021 __ bind(&done); | 1033 __ bind(&done); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 } | 1325 } |
| 1314 } | 1326 } |
| 1315 MarkLazyDeoptSite(); | 1327 MarkLazyDeoptSite(); |
| 1316 } | 1328 } |
| 1317 | 1329 |
| 1318 #undef __ | 1330 #undef __ |
| 1319 | 1331 |
| 1320 } // namespace compiler | 1332 } // namespace compiler |
| 1321 } // namespace internal | 1333 } // namespace internal |
| 1322 } // namespace v8 | 1334 } // namespace v8 |
| OLD | NEW |