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

Side by Side Diff: src/compiler/ia32/instruction-selector-ia32.cc

Issue 2799863002: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor (Closed)
Patch Set: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor Created 3 years, 8 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
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/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 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 1736 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1737 Emit(code, 0, nullptr, input_count, inputs); 1737 Emit(code, 0, nullptr, input_count, inputs);
1738 } 1738 }
1739 1739
1740 void InstructionSelector::VisitAtomicExchange(Node* node) { 1740 void InstructionSelector::VisitAtomicExchange(Node* node) {
1741 IA32OperandGenerator g(this); 1741 IA32OperandGenerator g(this);
1742 Node* base = node->InputAt(0); 1742 Node* base = node->InputAt(0);
1743 Node* index = node->InputAt(1); 1743 Node* index = node->InputAt(1);
1744 Node* value = node->InputAt(2); 1744 Node* value = node->InputAt(2);
1745 1745
1746 MachineType type = AtomicExchangeRepresentationOf(node->op()); 1746 MachineType type = AtomicOpRepresentationOf(node->op());
1747 ArchOpcode opcode = kArchNop; 1747 ArchOpcode opcode = kArchNop;
1748 if (type == MachineType::Int8()) { 1748 if (type == MachineType::Int8()) {
1749 opcode = kAtomicExchangeInt8; 1749 opcode = kAtomicExchangeInt8;
1750 } else if (type == MachineType::Uint8()) { 1750 } else if (type == MachineType::Uint8()) {
1751 opcode = kAtomicExchangeUint8; 1751 opcode = kAtomicExchangeUint8;
1752 } else if (type == MachineType::Int16()) { 1752 } else if (type == MachineType::Int16()) {
1753 opcode = kAtomicExchangeInt16; 1753 opcode = kAtomicExchangeInt16;
1754 } else if (type == MachineType::Uint16()) { 1754 } else if (type == MachineType::Uint16()) {
1755 opcode = kAtomicExchangeUint16; 1755 opcode = kAtomicExchangeUint16;
1756 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { 1756 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
1757 opcode = kAtomicExchangeWord32; 1757 opcode = kAtomicExchangeWord32;
1758 } else { 1758 } else {
1759 UNREACHABLE(); 1759 UNREACHABLE();
1760 return; 1760 return;
1761 } 1761 }
1762 InstructionOperand outputs[1]; 1762 InstructionOperand outputs[1];
1763 AddressingMode addressing_mode; 1763 AddressingMode addressing_mode;
1764 InstructionOperand inputs[4]; 1764 InstructionOperand inputs[3];
1765 size_t input_count = 0; 1765 size_t input_count = 0;
1766 inputs[input_count++] = g.UseUniqueRegister(value); 1766 inputs[input_count++] = g.UseUniqueRegister(value);
1767 inputs[input_count++] = g.UseUniqueRegister(base); 1767 inputs[input_count++] = g.UseUniqueRegister(base);
1768 if (g.CanBeImmediate(index)) { 1768 if (g.CanBeImmediate(index)) {
1769 inputs[input_count++] = g.UseImmediate(index); 1769 inputs[input_count++] = g.UseImmediate(index);
1770 addressing_mode = kMode_MRI; 1770 addressing_mode = kMode_MRI;
1771 } else { 1771 } else {
1772 inputs[input_count++] = g.UseUniqueRegister(index); 1772 inputs[input_count++] = g.UseUniqueRegister(index);
1773 addressing_mode = kMode_MR1; 1773 addressing_mode = kMode_MR1;
1774 } 1774 }
1775 outputs[0] = g.DefineSameAsFirst(node); 1775 outputs[0] = g.DefineSameAsFirst(node);
1776 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 1776 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1777 Emit(code, 1, outputs, input_count, inputs); 1777 Emit(code, 1, outputs, input_count, inputs);
1778 } 1778 }
1779 1779
1780 void InstructionSelector::VisitAtomicCompareExchange(Node* node) { 1780 void InstructionSelector::VisitAtomicCompareExchange(Node* node) {
1781 IA32OperandGenerator g(this); 1781 IA32OperandGenerator g(this);
1782 Node* base = node->InputAt(0); 1782 Node* base = node->InputAt(0);
1783 Node* index = node->InputAt(1); 1783 Node* index = node->InputAt(1);
1784 Node* old_value = node->InputAt(2); 1784 Node* old_value = node->InputAt(2);
1785 Node* new_value = node->InputAt(3); 1785 Node* new_value = node->InputAt(3);
1786 1786
1787 MachineType type = AtomicCompareExchangeRepresentationOf(node->op()); 1787 MachineType type = AtomicOpRepresentationOf(node->op());
1788 ArchOpcode opcode = kArchNop; 1788 ArchOpcode opcode = kArchNop;
1789 if (type == MachineType::Int8()) { 1789 if (type == MachineType::Int8()) {
1790 opcode = kAtomicCompareExchangeInt8; 1790 opcode = kAtomicCompareExchangeInt8;
1791 } else if (type == MachineType::Uint8()) { 1791 } else if (type == MachineType::Uint8()) {
1792 opcode = kAtomicCompareExchangeUint8; 1792 opcode = kAtomicCompareExchangeUint8;
1793 } else if (type == MachineType::Int16()) { 1793 } else if (type == MachineType::Int16()) {
1794 opcode = kAtomicCompareExchangeInt16; 1794 opcode = kAtomicCompareExchangeInt16;
1795 } else if (type == MachineType::Uint16()) { 1795 } else if (type == MachineType::Uint16()) {
1796 opcode = kAtomicCompareExchangeUint16; 1796 opcode = kAtomicCompareExchangeUint16;
1797 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { 1797 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
(...skipping 14 matching lines...) Expand all
1812 addressing_mode = kMode_MRI; 1812 addressing_mode = kMode_MRI;
1813 } else { 1813 } else {
1814 inputs[input_count++] = g.UseUniqueRegister(index); 1814 inputs[input_count++] = g.UseUniqueRegister(index);
1815 addressing_mode = kMode_MR1; 1815 addressing_mode = kMode_MR1;
1816 } 1816 }
1817 outputs[0] = g.DefineAsFixed(node, eax); 1817 outputs[0] = g.DefineAsFixed(node, eax);
1818 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 1818 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1819 Emit(code, 1, outputs, input_count, inputs); 1819 Emit(code, 1, outputs, input_count, inputs);
1820 } 1820 }
1821 1821
1822 void InstructionSelector::VisitAtomicBinaryOperation(
1823 Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op,
1824 ArchOpcode uint16_op, ArchOpcode word32_op) {
1825 IA32OperandGenerator g(this);
1826 Node* base = node->InputAt(0);
1827 Node* index = node->InputAt(1);
1828 Node* value = node->InputAt(2);
1829
1830 MachineType type = AtomicOpRepresentationOf(node->op());
1831 ArchOpcode opcode = kArchNop;
1832 if (type == MachineType::Int8()) {
1833 opcode = int8_op;
1834 } else if (type == MachineType::Uint8()) {
1835 opcode = uint8_op;
1836 } else if (type == MachineType::Int16()) {
1837 opcode = int16_op;
1838 } else if (type == MachineType::Uint16()) {
1839 opcode = uint16_op;
1840 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
1841 opcode = word32_op;
1842 } else {
1843 UNREACHABLE();
1844 return;
1845 }
1846 InstructionOperand outputs[1];
1847 AddressingMode addressing_mode;
1848 InstructionOperand inputs[3];
1849 size_t input_count = 0;
1850 inputs[input_count++] = g.UseUniqueRegister(value);
1851 inputs[input_count++] = g.UseUniqueRegister(base);
1852 if (g.CanBeImmediate(index)) {
1853 inputs[input_count++] = g.UseImmediate(index);
1854 addressing_mode = kMode_MRI;
1855 } else {
1856 inputs[input_count++] = g.UseUniqueRegister(index);
1857 addressing_mode = kMode_MR1;
1858 }
1859 outputs[0] = g.DefineAsFixed(node, eax);
1860 InstructionOperand temp[1];
1861 temp[0] = g.TempRegister();
1862 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
1863 Emit(code, 1, outputs, input_count, inputs, 1, temp);
1864 }
1865
1866 #define VISIT_ATOMIC_BINOP(op) \
1867 void InstructionSelector::VisitAtomic##op(Node* node) { \
1868 VisitAtomicBinaryOperation(node, kAtomic##op##Int8, kAtomic##op##Uint8, \
1869 kAtomic##op##Int16, kAtomic##op##Uint16, \
1870 kAtomic##op##Word32); \
1871 }
1872 VISIT_ATOMIC_BINOP(Add)
1873 VISIT_ATOMIC_BINOP(Sub)
1874 VISIT_ATOMIC_BINOP(And)
1875 VISIT_ATOMIC_BINOP(Or)
1876 VISIT_ATOMIC_BINOP(Xor)
1877 #undef VISIT_ATOMIC_BINOP
1878
1822 void InstructionSelector::VisitI32x4Splat(Node* node) { 1879 void InstructionSelector::VisitI32x4Splat(Node* node) {
1823 VisitRO(this, node, kIA32I32x4Splat); 1880 VisitRO(this, node, kIA32I32x4Splat);
1824 } 1881 }
1825 1882
1826 void InstructionSelector::VisitI32x4ExtractLane(Node* node) { 1883 void InstructionSelector::VisitI32x4ExtractLane(Node* node) {
1827 IA32OperandGenerator g(this); 1884 IA32OperandGenerator g(this);
1828 int32_t lane = OpParameter<int32_t>(node); 1885 int32_t lane = OpParameter<int32_t>(node);
1829 Emit(kIA32I32x4ExtractLane, g.DefineAsRegister(node), 1886 Emit(kIA32I32x4ExtractLane, g.DefineAsRegister(node),
1830 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane)); 1887 g.UseRegister(node->InputAt(0)), g.UseImmediate(lane));
1831 } 1888 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 // static 1928 // static
1872 MachineOperatorBuilder::AlignmentRequirements 1929 MachineOperatorBuilder::AlignmentRequirements
1873 InstructionSelector::AlignmentRequirements() { 1930 InstructionSelector::AlignmentRequirements() {
1874 return MachineOperatorBuilder::AlignmentRequirements:: 1931 return MachineOperatorBuilder::AlignmentRequirements::
1875 FullUnalignedAccessSupport(); 1932 FullUnalignedAccessSupport();
1876 } 1933 }
1877 1934
1878 } // namespace compiler 1935 } // namespace compiler
1879 } // namespace internal 1936 } // namespace internal
1880 } // namespace v8 1937 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698