Index: src/compiler/ia32/instruction-selector-ia32.cc |
diff --git a/src/compiler/ia32/instruction-selector-ia32.cc b/src/compiler/ia32/instruction-selector-ia32.cc |
index aad734cfb214ae61cd69605f7901f8a095b461ab..6fd1ad56564e8f976705909f4105ab5d702875ea 100644 |
--- a/src/compiler/ia32/instruction-selector-ia32.cc |
+++ b/src/compiler/ia32/instruction-selector-ia32.cc |
@@ -1724,7 +1724,11 @@ void InstructionSelector::VisitAtomicStore(Node* node) { |
AddressingMode addressing_mode; |
InstructionOperand inputs[4]; |
size_t input_count = 0; |
- inputs[input_count++] = g.UseUniqueRegister(value); |
+ if (rep == MachineRepresentation::kWord8) { |
+ inputs[input_count++] = g.UseByteRegister(value); |
+ } else { |
+ inputs[input_count++] = g.UseUniqueRegister(value); |
+ } |
inputs[input_count++] = g.UseUniqueRegister(base); |
if (g.CanBeImmediate(index)) { |
inputs[input_count++] = g.UseImmediate(index); |
@@ -1743,7 +1747,7 @@ void InstructionSelector::VisitAtomicExchange(Node* node) { |
Node* index = node->InputAt(1); |
Node* value = node->InputAt(2); |
- MachineType type = AtomicExchangeRepresentationOf(node->op()); |
+ MachineType type = AtomicOpRepresentationOf(node->op()); |
ArchOpcode opcode = kArchNop; |
if (type == MachineType::Int8()) { |
opcode = kAtomicExchangeInt8; |
@@ -1761,9 +1765,13 @@ void InstructionSelector::VisitAtomicExchange(Node* node) { |
} |
InstructionOperand outputs[1]; |
AddressingMode addressing_mode; |
- InstructionOperand inputs[4]; |
+ InstructionOperand inputs[3]; |
size_t input_count = 0; |
- inputs[input_count++] = g.UseUniqueRegister(value); |
+ if (type == MachineType::Int8() || type == MachineType::Uint8()) { |
+ inputs[input_count++] = g.UseFixed(value, edx); |
+ } else { |
+ inputs[input_count++] = g.UseUniqueRegister(value); |
+ } |
inputs[input_count++] = g.UseUniqueRegister(base); |
if (g.CanBeImmediate(index)) { |
inputs[input_count++] = g.UseImmediate(index); |
@@ -1772,7 +1780,12 @@ void InstructionSelector::VisitAtomicExchange(Node* node) { |
inputs[input_count++] = g.UseUniqueRegister(index); |
addressing_mode = kMode_MR1; |
} |
- outputs[0] = g.DefineSameAsFirst(node); |
+ if (type == MachineType::Int8() || type == MachineType::Uint8()) { |
+ // Using DefineSameAsFirst requires the register to be unallocated. |
+ outputs[0] = g.DefineAsFixed(node, edx); |
+ } else { |
+ outputs[0] = g.DefineSameAsFirst(node); |
+ } |
InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
Emit(code, 1, outputs, input_count, inputs); |
} |
@@ -1784,7 +1797,7 @@ void InstructionSelector::VisitAtomicCompareExchange(Node* node) { |
Node* old_value = node->InputAt(2); |
Node* new_value = node->InputAt(3); |
- MachineType type = AtomicCompareExchangeRepresentationOf(node->op()); |
+ MachineType type = AtomicOpRepresentationOf(node->op()); |
ArchOpcode opcode = kArchNop; |
if (type == MachineType::Int8()) { |
opcode = kAtomicCompareExchangeInt8; |
@@ -1805,7 +1818,11 @@ void InstructionSelector::VisitAtomicCompareExchange(Node* node) { |
InstructionOperand inputs[4]; |
size_t input_count = 0; |
inputs[input_count++] = g.UseFixed(old_value, eax); |
- inputs[input_count++] = g.UseUniqueRegister(new_value); |
+ if (type == MachineType::Int8() || type == MachineType::Uint8()) { |
+ inputs[input_count++] = g.UseByteRegister(new_value); |
+ } else { |
+ inputs[input_count++] = g.UseUniqueRegister(new_value); |
+ } |
inputs[input_count++] = g.UseUniqueRegister(base); |
if (g.CanBeImmediate(index)) { |
inputs[input_count++] = g.UseImmediate(index); |
@@ -1819,6 +1836,67 @@ void InstructionSelector::VisitAtomicCompareExchange(Node* node) { |
Emit(code, 1, outputs, input_count, inputs); |
} |
+void InstructionSelector::VisitAtomicBinaryOperation( |
+ Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op, |
+ ArchOpcode uint16_op, ArchOpcode word32_op) { |
+ IA32OperandGenerator g(this); |
+ Node* base = node->InputAt(0); |
+ Node* index = node->InputAt(1); |
+ Node* value = node->InputAt(2); |
+ |
+ MachineType type = AtomicOpRepresentationOf(node->op()); |
+ ArchOpcode opcode = kArchNop; |
+ if (type == MachineType::Int8()) { |
+ opcode = int8_op; |
+ } else if (type == MachineType::Uint8()) { |
+ opcode = uint8_op; |
+ } else if (type == MachineType::Int16()) { |
+ opcode = int16_op; |
+ } else if (type == MachineType::Uint16()) { |
+ opcode = uint16_op; |
+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { |
+ opcode = word32_op; |
+ } else { |
+ UNREACHABLE(); |
+ return; |
+ } |
+ InstructionOperand outputs[1]; |
+ AddressingMode addressing_mode; |
+ InstructionOperand inputs[3]; |
+ size_t input_count = 0; |
+ if (type == MachineType::Int8() || type == MachineType::Uint8()) { |
+ inputs[input_count++] = g.UseByteRegister(value); |
+ } else { |
+ inputs[input_count++] = g.UseUniqueRegister(value); |
+ } |
+ inputs[input_count++] = g.UseUniqueRegister(base); |
+ if (g.CanBeImmediate(index)) { |
+ inputs[input_count++] = g.UseImmediate(index); |
+ addressing_mode = kMode_MRI; |
+ } else { |
+ inputs[input_count++] = g.UseUniqueRegister(index); |
+ addressing_mode = kMode_MR1; |
+ } |
+ outputs[0] = g.DefineAsFixed(node, eax); |
+ InstructionOperand temp[1]; |
+ temp[0] = g.TempRegister(); |
+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); |
+ Emit(code, 1, outputs, input_count, inputs, 1, temp); |
+} |
+ |
+#define VISIT_ATOMIC_BINOP(op) \ |
+ void InstructionSelector::VisitAtomic##op(Node* node) { \ |
+ VisitAtomicBinaryOperation(node, kAtomic##op##Int8, kAtomic##op##Uint8, \ |
+ kAtomic##op##Int16, kAtomic##op##Uint16, \ |
+ kAtomic##op##Word32); \ |
+ } |
+VISIT_ATOMIC_BINOP(Add) |
+VISIT_ATOMIC_BINOP(Sub) |
+VISIT_ATOMIC_BINOP(And) |
+VISIT_ATOMIC_BINOP(Or) |
+VISIT_ATOMIC_BINOP(Xor) |
+#undef VISIT_ATOMIC_BINOP |
+ |
void InstructionSelector::VisitI32x4Splat(Node* node) { |
VisitRO(this, node, kIA32I32x4Splat); |
} |