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

Unified Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/x64/instruction-selector-x64.cc
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc
index 4094f46267f1e0fbd722b0396fc14df83df8164d..85f5e5c29387c8696f87182eccc34a9bcccb29cd 100644
--- a/src/compiler/x64/instruction-selector-x64.cc
+++ b/src/compiler/x64/instruction-selector-x64.cc
@@ -2390,6 +2390,42 @@ void InstructionSelector::VisitAtomicStore(Node* node) {
Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs);
}
+void InstructionSelector::VisitAtomicExchange(Node* node) {
+ X64OperandGenerator g(this);
+ Node* base = node->InputAt(0);
+ Node* index = node->InputAt(1);
+ Node* value = node->InputAt(2);
+
+ MachineType type = AtomicExchangeRepresentationOf(node->op());
+ ArchOpcode opcode = kArchNop;
+ if (type == MachineType::Uint8() || type == MachineType::Int8()) {
binji 2017/01/13 00:08:50 Looks like it is more common to do a switch on the
aseemgarg 2017/01/14 01:48:19 Changed a little. We can't use MachineRepresentati
binji 2017/01/17 21:45:50 Take a look at GetLoadOpcode/VisitCheckedLoad/Visi
+ opcode = kX64Xchgb;
+ } else if (type == MachineType::Uint16() || type == MachineType::Int16()) {
+ opcode = kX64Xchgw;
+ } else if (type == MachineType::Uint32() || type == MachineType::Int32()) {
+ opcode = kX64Xchgl;
+ } else {
+ UNREACHABLE();
+ return;
+ }
+ InstructionOperand outputs[1];
+ outputs[0] = g.DefineAsRegister(node);
+ 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, 1, outputs, input_count, inputs);
+}
+
void InstructionSelector::VisitCreateInt32x4(Node* node) {
X64OperandGenerator g(this);
Emit(kX64Int32x4Create, g.DefineAsRegister(node), g.Use(node->InputAt(0)));

Powered by Google App Engine
This is Rietveld 408576698