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