| 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
| 7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 void InstructionSelector::VisitAtomicStore(Node* node) { | 1681 void InstructionSelector::VisitAtomicStore(Node* node) { |
| 1682 IA32OperandGenerator g(this); | 1682 IA32OperandGenerator g(this); |
| 1683 Node* base = node->InputAt(0); | 1683 Node* base = node->InputAt(0); |
| 1684 Node* index = node->InputAt(1); | 1684 Node* index = node->InputAt(1); |
| 1685 Node* value = node->InputAt(2); | 1685 Node* value = node->InputAt(2); |
| 1686 | 1686 |
| 1687 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); | 1687 MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); |
| 1688 ArchOpcode opcode = kArchNop; | 1688 ArchOpcode opcode = kArchNop; |
| 1689 switch (rep) { | 1689 switch (rep) { |
| 1690 case MachineRepresentation::kWord8: | 1690 case MachineRepresentation::kWord8: |
| 1691 opcode = kIA32Xchgb; | 1691 opcode = kAtomicExchangeInt8; |
| 1692 break; | 1692 break; |
| 1693 case MachineRepresentation::kWord16: | 1693 case MachineRepresentation::kWord16: |
| 1694 opcode = kIA32Xchgw; | 1694 opcode = kAtomicExchangeInt16; |
| 1695 break; | 1695 break; |
| 1696 case MachineRepresentation::kWord32: | 1696 case MachineRepresentation::kWord32: |
| 1697 opcode = kIA32Xchgl; | 1697 opcode = kAtomicExchangeWord32; |
| 1698 break; | 1698 break; |
| 1699 default: | 1699 default: |
| 1700 UNREACHABLE(); | 1700 UNREACHABLE(); |
| 1701 break; | 1701 break; |
| 1702 } | 1702 } |
| 1703 AddressingMode addressing_mode; | 1703 AddressingMode addressing_mode; |
| 1704 InstructionOperand inputs[4]; | 1704 InstructionOperand inputs[4]; |
| 1705 size_t input_count = 0; | 1705 size_t input_count = 0; |
| 1706 inputs[input_count++] = g.UseUniqueRegister(value); |
| 1706 inputs[input_count++] = g.UseUniqueRegister(base); | 1707 inputs[input_count++] = g.UseUniqueRegister(base); |
| 1707 if (g.CanBeImmediate(index)) { | 1708 if (g.CanBeImmediate(index)) { |
| 1708 inputs[input_count++] = g.UseImmediate(index); | 1709 inputs[input_count++] = g.UseImmediate(index); |
| 1709 addressing_mode = kMode_MRI; | 1710 addressing_mode = kMode_MRI; |
| 1710 } else { | 1711 } else { |
| 1711 inputs[input_count++] = g.UseUniqueRegister(index); | 1712 inputs[input_count++] = g.UseUniqueRegister(index); |
| 1712 addressing_mode = kMode_MR1; | 1713 addressing_mode = kMode_MR1; |
| 1713 } | 1714 } |
| 1714 inputs[input_count++] = g.UseUniqueRegister(value); | |
| 1715 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); | 1715 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
| 1716 Emit(code, 0, nullptr, input_count, inputs); | 1716 Emit(code, 0, nullptr, input_count, inputs); |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 void InstructionSelector::VisitAtomicExchange(Node* node) { |
| 1720 IA32OperandGenerator g(this); |
| 1721 Node* base = node->InputAt(0); |
| 1722 Node* index = node->InputAt(1); |
| 1723 Node* value = node->InputAt(2); |
| 1724 |
| 1725 MachineType type = AtomicExchangeRepresentationOf(node->op()); |
| 1726 ArchOpcode opcode = kArchNop; |
| 1727 if (type == MachineType::Int8()) { |
| 1728 opcode = kAtomicExchangeInt8; |
| 1729 } else if (type == MachineType::Uint8()) { |
| 1730 opcode = kAtomicExchangeUint8; |
| 1731 } else if (type == MachineType::Int16()) { |
| 1732 opcode = kAtomicExchangeInt16; |
| 1733 } else if (type == MachineType::Uint16()) { |
| 1734 opcode = kAtomicExchangeUint16; |
| 1735 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { |
| 1736 opcode = kAtomicExchangeWord32; |
| 1737 } else { |
| 1738 UNREACHABLE(); |
| 1739 return; |
| 1740 } |
| 1741 InstructionOperand outputs[1]; |
| 1742 AddressingMode addressing_mode; |
| 1743 InstructionOperand inputs[4]; |
| 1744 size_t input_count = 0; |
| 1745 inputs[input_count++] = g.UseUniqueRegister(value); |
| 1746 inputs[input_count++] = g.UseUniqueRegister(base); |
| 1747 if (g.CanBeImmediate(index)) { |
| 1748 inputs[input_count++] = g.UseImmediate(index); |
| 1749 addressing_mode = kMode_MRI; |
| 1750 } else { |
| 1751 inputs[input_count++] = g.UseUniqueRegister(index); |
| 1752 addressing_mode = kMode_MR1; |
| 1753 } |
| 1754 outputs[0] = g.DefineSameAsFirst(node); |
| 1755 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
| 1756 Emit(code, 1, outputs, input_count, inputs); |
| 1757 } |
| 1758 |
| 1719 // static | 1759 // static |
| 1720 MachineOperatorBuilder::Flags | 1760 MachineOperatorBuilder::Flags |
| 1721 InstructionSelector::SupportedMachineOperatorFlags() { | 1761 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1722 MachineOperatorBuilder::Flags flags = | 1762 MachineOperatorBuilder::Flags flags = |
| 1723 MachineOperatorBuilder::kWord32ShiftIsSafe | | 1763 MachineOperatorBuilder::kWord32ShiftIsSafe | |
| 1724 MachineOperatorBuilder::kWord32Ctz; | 1764 MachineOperatorBuilder::kWord32Ctz; |
| 1725 if (CpuFeatures::IsSupported(POPCNT)) { | 1765 if (CpuFeatures::IsSupported(POPCNT)) { |
| 1726 flags |= MachineOperatorBuilder::kWord32Popcnt; | 1766 flags |= MachineOperatorBuilder::kWord32Popcnt; |
| 1727 } | 1767 } |
| 1728 if (CpuFeatures::IsSupported(SSE4_1)) { | 1768 if (CpuFeatures::IsSupported(SSE4_1)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1741 // static | 1781 // static |
| 1742 MachineOperatorBuilder::AlignmentRequirements | 1782 MachineOperatorBuilder::AlignmentRequirements |
| 1743 InstructionSelector::AlignmentRequirements() { | 1783 InstructionSelector::AlignmentRequirements() { |
| 1744 return MachineOperatorBuilder::AlignmentRequirements:: | 1784 return MachineOperatorBuilder::AlignmentRequirements:: |
| 1745 FullUnalignedAccessSupport(); | 1785 FullUnalignedAccessSupport(); |
| 1746 } | 1786 } |
| 1747 | 1787 |
| 1748 } // namespace compiler | 1788 } // namespace compiler |
| 1749 } // namespace internal | 1789 } // namespace internal |
| 1750 } // namespace v8 | 1790 } // namespace v8 |
| OLD | NEW |