| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_MIPS64 | 9 #if V8_TARGET_ARCH_MIPS64 |
| 10 | 10 |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 right_op = UseRegister(right); | 1520 right_op = UseRegister(right); |
| 1521 } | 1521 } |
| 1522 } else { | 1522 } else { |
| 1523 if (bailout_on_minus_zero) { | 1523 if (bailout_on_minus_zero) { |
| 1524 left_op = UseRegister(left); | 1524 left_op = UseRegister(left); |
| 1525 } else { | 1525 } else { |
| 1526 left_op = UseRegisterAtStart(left); | 1526 left_op = UseRegisterAtStart(left); |
| 1527 } | 1527 } |
| 1528 right_op = UseRegister(right); | 1528 right_op = UseRegister(right); |
| 1529 } | 1529 } |
| 1530 LMulI* mul = new(zone()) LMulI(left_op, right_op); | 1530 LInstruction* result = |
| 1531 instr->representation().IsSmi() |
| 1532 ? DefineAsRegister(new (zone()) LMulS(left_op, right_op)) |
| 1533 : DefineAsRegister(new (zone()) LMulI(left_op, right_op)); |
| 1531 if (right_op->IsConstantOperand() | 1534 if (right_op->IsConstantOperand() |
| 1532 ? ((can_overflow && constant_value == -1) || | 1535 ? ((can_overflow && constant_value == -1) || |
| 1533 (bailout_on_minus_zero && constant_value <= 0)) | 1536 (bailout_on_minus_zero && constant_value <= 0)) |
| 1534 : (can_overflow || bailout_on_minus_zero)) { | 1537 : (can_overflow || bailout_on_minus_zero)) { |
| 1535 AssignEnvironment(mul); | 1538 AssignEnvironment(result); |
| 1536 } | 1539 } |
| 1537 return DefineAsRegister(mul); | 1540 return result; |
| 1538 | 1541 |
| 1539 } else if (instr->representation().IsDouble()) { | 1542 } else if (instr->representation().IsDouble()) { |
| 1540 if (kArchVariant == kMips64r2) { | 1543 if (kArchVariant == kMips64r2) { |
| 1541 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) { | 1544 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) { |
| 1542 HAdd* add = HAdd::cast(instr->uses().value()); | 1545 HAdd* add = HAdd::cast(instr->uses().value()); |
| 1543 if (instr == add->left()) { | 1546 if (instr == add->left()) { |
| 1544 // This mul is the lhs of an add. The add and mul will be folded | 1547 // This mul is the lhs of an add. The add and mul will be folded |
| 1545 // into a multiply-add. | 1548 // into a multiply-add. |
| 1546 return NULL; | 1549 return NULL; |
| 1547 } | 1550 } |
| 1548 if (instr == add->right() && !add->left()->IsMul()) { | 1551 if (instr == add->right() && !add->left()->IsMul()) { |
| 1549 // This mul is the rhs of an add, where the lhs is not another mul. | 1552 // This mul is the rhs of an add, where the lhs is not another mul. |
| 1550 // The add and mul will be folded into a multiply-add. | 1553 // The add and mul will be folded into a multiply-add. |
| 1551 return NULL; | 1554 return NULL; |
| 1552 } | 1555 } |
| 1553 } | 1556 } |
| 1554 } | 1557 } |
| 1555 return DoArithmeticD(Token::MUL, instr); | 1558 return DoArithmeticD(Token::MUL, instr); |
| 1556 } else { | 1559 } else { |
| 1557 return DoArithmeticT(Token::MUL, instr); | 1560 return DoArithmeticT(Token::MUL, instr); |
| 1558 } | 1561 } |
| 1559 } | 1562 } |
| 1560 | 1563 |
| 1561 | 1564 |
| 1562 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | 1565 LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| 1563 if (instr->representation().IsSmiOrInteger32()) { | 1566 if (instr->representation().IsSmiOrInteger32()) { |
| 1564 DCHECK(instr->left()->representation().Equals(instr->representation())); | 1567 DCHECK(instr->left()->representation().Equals(instr->representation())); |
| 1565 DCHECK(instr->right()->representation().Equals(instr->representation())); | 1568 DCHECK(instr->right()->representation().Equals(instr->representation())); |
| 1566 LOperand* left = UseRegisterAtStart(instr->left()); | 1569 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1567 LOperand* right = UseOrConstantAtStart(instr->right()); | 1570 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); |
| 1568 LSubI* sub = new(zone()) LSubI(left, right); | 1571 LInstruction* result = |
| 1569 LInstruction* result = DefineAsRegister(sub); | 1572 instr->representation().IsSmi() |
| 1573 ? DefineAsRegister(new (zone()) LSubS(left, right)) |
| 1574 : DefineAsRegister(new (zone()) LSubI(left, right)); |
| 1570 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1575 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1571 result = AssignEnvironment(result); | 1576 result = AssignEnvironment(result); |
| 1572 } | 1577 } |
| 1573 return result; | 1578 return result; |
| 1574 } else if (instr->representation().IsDouble()) { | 1579 } else if (instr->representation().IsDouble()) { |
| 1575 return DoArithmeticD(Token::SUB, instr); | 1580 return DoArithmeticD(Token::SUB, instr); |
| 1576 } else { | 1581 } else { |
| 1577 return DoArithmeticT(Token::SUB, instr); | 1582 return DoArithmeticT(Token::SUB, instr); |
| 1578 } | 1583 } |
| 1579 } | 1584 } |
| 1580 | 1585 |
| 1581 | 1586 |
| 1582 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { | 1587 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { |
| 1583 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); | 1588 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); |
| 1584 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); | 1589 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); |
| 1585 LOperand* addend_op = UseRegisterAtStart(addend); | 1590 LOperand* addend_op = UseRegisterAtStart(addend); |
| 1586 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, | 1591 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, |
| 1587 multiplicand_op)); | 1592 multiplicand_op)); |
| 1588 } | 1593 } |
| 1589 | 1594 |
| 1590 | 1595 |
| 1591 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | 1596 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| 1592 if (instr->representation().IsSmiOrInteger32()) { | 1597 if (instr->representation().IsSmiOrInteger32()) { |
| 1593 DCHECK(instr->left()->representation().Equals(instr->representation())); | 1598 DCHECK(instr->left()->representation().Equals(instr->representation())); |
| 1594 DCHECK(instr->right()->representation().Equals(instr->representation())); | 1599 DCHECK(instr->right()->representation().Equals(instr->representation())); |
| 1595 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1600 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1596 LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand()); | 1601 LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand()); |
| 1597 LAddI* add = new(zone()) LAddI(left, right); | 1602 LInstruction* result = |
| 1598 LInstruction* result = DefineAsRegister(add); | 1603 instr->representation().IsSmi() |
| 1604 ? DefineAsRegister(new (zone()) LAddS(left, right)) |
| 1605 : DefineAsRegister(new (zone()) LAddI(left, right)); |
| 1599 if (instr->CheckFlag(HValue::kCanOverflow)) { | 1606 if (instr->CheckFlag(HValue::kCanOverflow)) { |
| 1600 result = AssignEnvironment(result); | 1607 result = AssignEnvironment(result); |
| 1601 } | 1608 } |
| 1602 return result; | 1609 return result; |
| 1603 } else if (instr->representation().IsExternal()) { | 1610 } else if (instr->representation().IsExternal()) { |
| 1604 DCHECK(instr->left()->representation().IsExternal()); | 1611 DCHECK(instr->left()->representation().IsExternal()); |
| 1605 DCHECK(instr->right()->representation().IsInteger32()); | 1612 DCHECK(instr->right()->representation().IsInteger32()); |
| 1606 DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); | 1613 DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); |
| 1607 LOperand* left = UseRegisterAtStart(instr->left()); | 1614 LOperand* left = UseRegisterAtStart(instr->left()); |
| 1608 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | 1615 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2615 LAllocateBlockContext* result = | 2622 LAllocateBlockContext* result = |
| 2616 new(zone()) LAllocateBlockContext(context, function); | 2623 new(zone()) LAllocateBlockContext(context, function); |
| 2617 return MarkAsCall(DefineFixed(result, cp), instr); | 2624 return MarkAsCall(DefineFixed(result, cp), instr); |
| 2618 } | 2625 } |
| 2619 | 2626 |
| 2620 | 2627 |
| 2621 } // namespace internal | 2628 } // namespace internal |
| 2622 } // namespace v8 | 2629 } // namespace v8 |
| 2623 | 2630 |
| 2624 #endif // V8_TARGET_ARCH_MIPS64 | 2631 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |