Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: src/compiler/ppc/code-generator-ppc.cc

Issue 2179503003: PPC/s390: [turbofan] Change Float64Max/Float64Min to JavaScript semantics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 __ PrepareCallCFunction(0, 2, kScratchReg); \ 463 __ PrepareCallCFunction(0, 2, kScratchReg); \
464 __ MovToFloatParameters(i.InputDoubleRegister(0), \ 464 __ MovToFloatParameters(i.InputDoubleRegister(0), \
465 i.InputDoubleRegister(1)); \ 465 i.InputDoubleRegister(1)); \
466 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ 466 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
467 0, 2); \ 467 0, 2); \
468 /* Move the result in the double result register. */ \ 468 /* Move the result in the double result register. */ \
469 __ MovFromFloatResult(i.OutputDoubleRegister()); \ 469 __ MovFromFloatResult(i.OutputDoubleRegister()); \
470 DCHECK_EQ(LeaveRC, i.OutputRCBit()); \ 470 DCHECK_EQ(LeaveRC, i.OutputRCBit()); \
471 } while (0) 471 } while (0)
472 472
473 #define ASSEMBLE_FLOAT_MAX(scratch_reg) \ 473 #define ASSEMBLE_FLOAT_MAX() \
474 do { \ 474 do { \
475 __ fsub(scratch_reg, i.InputDoubleRegister(0), i.InputDoubleRegister(1)); \ 475 DoubleRegister left_reg = i.InputDoubleRegister(0); \
476 __ fsel(i.OutputDoubleRegister(), scratch_reg, i.InputDoubleRegister(0), \ 476 DoubleRegister right_reg = i.InputDoubleRegister(1); \
477 i.InputDoubleRegister(1)); \ 477 DoubleRegister result_reg = i.OutputDoubleRegister(); \
478 Label check_nan_left, check_zero, return_left, return_right, done; \
479 __ fcmpu(left_reg, right_reg); \
480 __ bunordered(&check_nan_left); \
481 __ beq(&check_zero); \
482 __ bge(&return_left); \
483 __ b(&return_right); \
484 \
485 __ bind(&check_zero); \
486 __ fcmpu(left_reg, kDoubleRegZero); \
487 /* left == right != 0. */ \
488 __ bne(&return_left); \
489 /* At this point, both left and right are either 0 or -0. */ \
490 __ fadd(result_reg, left_reg, right_reg); \
491 __ b(&done); \
492 \
493 __ bind(&check_nan_left); \
494 __ fcmpu(left_reg, left_reg); \
495 /* left == NaN. */ \
496 __ bunordered(&return_left); \
497 __ bind(&return_right); \
498 if (!right_reg.is(result_reg)) { \
499 __ fmr(result_reg, right_reg); \
500 } \
501 __ b(&done); \
502 \
503 __ bind(&return_left); \
504 if (!left_reg.is(result_reg)) { \
505 __ fmr(result_reg, left_reg); \
506 } \
507 __ bind(&done); \
508 } while (0) \
509
510
511 #define ASSEMBLE_FLOAT_MIN() \
512 do { \
513 DoubleRegister left_reg = i.InputDoubleRegister(0); \
514 DoubleRegister right_reg = i.InputDoubleRegister(1); \
515 DoubleRegister result_reg = i.OutputDoubleRegister(); \
516 Label check_nan_left, check_zero, return_left, return_right, done; \
517 __ fcmpu(left_reg, right_reg); \
518 __ bunordered(&check_nan_left); \
519 __ beq(&check_zero); \
520 __ ble(&return_left); \
521 __ b(&return_right); \
522 \
523 __ bind(&check_zero); \
524 __ fcmpu(left_reg, kDoubleRegZero); \
525 /* left == right != 0. */ \
526 __ bne(&return_left); \
527 /* At this point, both left and right are either 0 or -0. */ \
528 /* Min: The algorithm is: -((-L) + (-R)), which in case of L and R being */\
529 /* different registers is most efficiently expressed as -((-L) - R). */ \
530 __ fneg(left_reg, left_reg); \
531 if (left_reg.is(right_reg)) { \
532 __ fadd(result_reg, left_reg, right_reg); \
533 } else { \
534 __ fsub(result_reg, left_reg, right_reg); \
535 } \
536 __ fneg(result_reg, result_reg); \
537 __ b(&done); \
538 \
539 __ bind(&check_nan_left); \
540 __ fcmpu(left_reg, left_reg); \
541 /* left == NaN. */ \
542 __ bunordered(&return_left); \
543 \
544 __ bind(&return_right); \
545 if (!right_reg.is(result_reg)) { \
546 __ fmr(result_reg, right_reg); \
547 } \
548 __ b(&done); \
549 \
550 __ bind(&return_left); \
551 if (!left_reg.is(result_reg)) { \
552 __ fmr(result_reg, left_reg); \
553 } \
554 __ bind(&done); \
478 } while (0) 555 } while (0)
479 556
480 557
481 #define ASSEMBLE_FLOAT_MIN(scratch_reg) \
482 do { \
483 __ fsub(scratch_reg, i.InputDoubleRegister(0), i.InputDoubleRegister(1)); \
484 __ fsel(i.OutputDoubleRegister(), scratch_reg, i.InputDoubleRegister(1), \
485 i.InputDoubleRegister(0)); \
486 } while (0)
487
488
489 #define ASSEMBLE_LOAD_FLOAT(asm_instr, asm_instrx) \ 558 #define ASSEMBLE_LOAD_FLOAT(asm_instr, asm_instrx) \
490 do { \ 559 do { \
491 DoubleRegister result = i.OutputDoubleRegister(); \ 560 DoubleRegister result = i.OutputDoubleRegister(); \
492 AddressingMode mode = kMode_None; \ 561 AddressingMode mode = kMode_None; \
493 MemOperand operand = i.MemoryOperand(&mode); \ 562 MemOperand operand = i.MemoryOperand(&mode); \
494 if (mode == kMode_MRI) { \ 563 if (mode == kMode_MRI) { \
495 __ asm_instr(result, operand); \ 564 __ asm_instr(result, operand); \
496 } else { \ 565 } else { \
497 __ asm_instrx(result, operand); \ 566 __ asm_instrx(result, operand); \
498 } \ 567 } \
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 case kIeee754Float64Pow: { 1510 case kIeee754Float64Pow: {
1442 MathPowStub stub(isolate(), MathPowStub::DOUBLE); 1511 MathPowStub stub(isolate(), MathPowStub::DOUBLE);
1443 __ CallStub(&stub); 1512 __ CallStub(&stub);
1444 __ Move(d1, d3); 1513 __ Move(d1, d3);
1445 break; 1514 break;
1446 } 1515 }
1447 case kPPC_Neg: 1516 case kPPC_Neg:
1448 __ neg(i.OutputRegister(), i.InputRegister(0), LeaveOE, i.OutputRCBit()); 1517 __ neg(i.OutputRegister(), i.InputRegister(0), LeaveOE, i.OutputRCBit());
1449 break; 1518 break;
1450 case kPPC_MaxDouble: 1519 case kPPC_MaxDouble:
1451 ASSEMBLE_FLOAT_MAX(kScratchDoubleReg); 1520 ASSEMBLE_FLOAT_MAX();
1452 break; 1521 break;
1453 case kPPC_MinDouble: 1522 case kPPC_MinDouble:
1454 ASSEMBLE_FLOAT_MIN(kScratchDoubleReg); 1523 ASSEMBLE_FLOAT_MIN();
1455 break; 1524 break;
1456 case kPPC_AbsDouble: 1525 case kPPC_AbsDouble:
1457 ASSEMBLE_FLOAT_UNOP_RC(fabs, 0); 1526 ASSEMBLE_FLOAT_UNOP_RC(fabs, 0);
1458 break; 1527 break;
1459 case kPPC_SqrtDouble: 1528 case kPPC_SqrtDouble:
1460 ASSEMBLE_FLOAT_UNOP_RC(fsqrt, MiscField::decode(instr->opcode())); 1529 ASSEMBLE_FLOAT_UNOP_RC(fsqrt, MiscField::decode(instr->opcode()));
1461 break; 1530 break;
1462 case kPPC_FloorDouble: 1531 case kPPC_FloorDouble:
1463 ASSEMBLE_FLOAT_UNOP_RC(frim, MiscField::decode(instr->opcode())); 1532 ASSEMBLE_FLOAT_UNOP_RC(frim, MiscField::decode(instr->opcode()));
1464 break; 1533 break;
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 padding_size -= v8::internal::Assembler::kInstrSize; 2439 padding_size -= v8::internal::Assembler::kInstrSize;
2371 } 2440 }
2372 } 2441 }
2373 } 2442 }
2374 2443
2375 #undef __ 2444 #undef __
2376 2445
2377 } // namespace compiler 2446 } // namespace compiler
2378 } // namespace internal 2447 } // namespace internal
2379 } // namespace v8 2448 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698