X87: [Atomics] Make Atomics.store a builtin using TF.

port 81cb841170 (r35993)

  original commit message:

BUG=

Review-Url: https://codereview.chromium.org/1947833002
Cr-Commit-Position: refs/heads/master@{#36049}
This commit is contained in:
zhengxing.li 2016-05-04 20:21:52 -07:00 committed by Commit bot
parent 8d77d42e9d
commit 7a07e9cae4
5 changed files with 77 additions and 1 deletions

View File

@ -1698,6 +1698,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
break;
}
case kX87Xchgb: {
size_t index = 0;
Operand operand = i.MemoryOperand(&index);
__ xchg_b(i.InputRegister(index), operand);
break;
}
case kX87Xchgw: {
size_t index = 0;
Operand operand = i.MemoryOperand(&index);
__ xchg_w(i.InputRegister(index), operand);
break;
}
case kX87Xchgl: {
size_t index = 0;
Operand operand = i.MemoryOperand(&index);
__ xchg(i.InputRegister(index), operand);
break;
}
case kX87PushFloat32:
__ lea(esp, Operand(esp, -kFloatSize));
if (instr->InputAt(0)->IsDoubleStackSlot()) {
@ -1771,6 +1789,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kAtomicLoadInt16:
case kAtomicLoadUint16:
case kAtomicLoadWord32:
case kAtomicStoreWord8:
case kAtomicStoreWord16:
case kAtomicStoreWord32:
UNREACHABLE(); // Won't be generated by instruction selector.
break;
}

View File

@ -96,7 +96,10 @@ namespace compiler {
V(X87PushFloat64) \
V(X87PushFloat32) \
V(X87Poke) \
V(X87StackCheck)
V(X87StackCheck) \
V(X87Xchgb) \
V(X87Xchgw) \
V(X87Xchgl)
// Addressing modes represent the "shape" of inputs to an instruction.
// Many instructions support multiple addressing modes. Addressing modes

View File

@ -1598,6 +1598,44 @@ void InstructionSelector::VisitAtomicLoad(Node* node) {
VisitLoad(node);
}
void InstructionSelector::VisitAtomicStore(Node* node) {
X87OperandGenerator g(this);
Node* base = node->InputAt(0);
Node* index = node->InputAt(1);
Node* value = node->InputAt(2);
MachineRepresentation rep = AtomicStoreRepresentationOf(node->op());
ArchOpcode opcode = kArchNop;
switch (rep) {
case MachineRepresentation::kWord8:
opcode = kX87Xchgb;
break;
case MachineRepresentation::kWord16:
opcode = kX87Xchgw;
break;
case MachineRepresentation::kWord32:
opcode = kX87Xchgl;
break;
default:
UNREACHABLE();
break;
}
AddressingMode addressing_mode;
InstructionOperand inputs[4];
size_t input_count = 0;
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;
}
inputs[input_count++] = g.UseUniqueRegister(value);
InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
Emit(code, 0, nullptr, input_count, inputs);
}
// static
MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() {

View File

@ -552,6 +552,18 @@ void Assembler::xchg(Register dst, const Operand& src) {
emit_operand(dst, src);
}
void Assembler::xchg_b(Register reg, const Operand& op) {
EnsureSpace ensure_space(this);
EMIT(0x86);
emit_operand(reg, op);
}
void Assembler::xchg_w(Register reg, const Operand& op) {
EnsureSpace ensure_space(this);
EMIT(0x66);
EMIT(0x87);
emit_operand(reg, op);
}
void Assembler::adc(Register dst, int32_t imm32) {
EnsureSpace ensure_space(this);

View File

@ -648,6 +648,8 @@ class Assembler : public AssemblerBase {
// Exchange
void xchg(Register dst, Register src);
void xchg(Register dst, const Operand& src);
void xchg_b(Register reg, const Operand& op);
void xchg_w(Register reg, const Operand& op);
// Arithmetics
void adc(Register dst, int32_t imm32);