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

Side by Side Diff: src/compiler/arm64/instruction-selector-arm64.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/assembler-inl.h" 5 #include "src/assembler-inl.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 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 InstructionOperand temps[] = {g.TempRegister()}; 2707 InstructionOperand temps[] = {g.TempRegister()};
2708 Emit(code, 0, nullptr, input_count, inputs, arraysize(temps), temps); 2708 Emit(code, 0, nullptr, input_count, inputs, arraysize(temps), temps);
2709 } 2709 }
2710 2710
2711 void InstructionSelector::VisitAtomicExchange(Node* node) { 2711 void InstructionSelector::VisitAtomicExchange(Node* node) {
2712 Arm64OperandGenerator g(this); 2712 Arm64OperandGenerator g(this);
2713 Node* base = node->InputAt(0); 2713 Node* base = node->InputAt(0);
2714 Node* index = node->InputAt(1); 2714 Node* index = node->InputAt(1);
2715 Node* value = node->InputAt(2); 2715 Node* value = node->InputAt(2);
2716 ArchOpcode opcode = kArchNop; 2716 ArchOpcode opcode = kArchNop;
2717 MachineType type = AtomicExchangeRepresentationOf(node->op()); 2717 MachineType type = AtomicOpRepresentationOf(node->op());
2718 if (type == MachineType::Int8()) { 2718 if (type == MachineType::Int8()) {
2719 opcode = kAtomicExchangeInt8; 2719 opcode = kAtomicExchangeInt8;
2720 } else if (type == MachineType::Uint8()) { 2720 } else if (type == MachineType::Uint8()) {
2721 opcode = kAtomicExchangeUint8; 2721 opcode = kAtomicExchangeUint8;
2722 } else if (type == MachineType::Int16()) { 2722 } else if (type == MachineType::Int16()) {
2723 opcode = kAtomicExchangeInt16; 2723 opcode = kAtomicExchangeInt16;
2724 } else if (type == MachineType::Uint16()) { 2724 } else if (type == MachineType::Uint16()) {
2725 opcode = kAtomicExchangeUint16; 2725 opcode = kAtomicExchangeUint16;
2726 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { 2726 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
2727 opcode = kAtomicExchangeWord32; 2727 opcode = kAtomicExchangeWord32;
(...skipping 15 matching lines...) Expand all
2743 Emit(code, 1, outputs, input_count, inputs, arraysize(temps), temps); 2743 Emit(code, 1, outputs, input_count, inputs, arraysize(temps), temps);
2744 } 2744 }
2745 2745
2746 void InstructionSelector::VisitAtomicCompareExchange(Node* node) { 2746 void InstructionSelector::VisitAtomicCompareExchange(Node* node) {
2747 Arm64OperandGenerator g(this); 2747 Arm64OperandGenerator g(this);
2748 Node* base = node->InputAt(0); 2748 Node* base = node->InputAt(0);
2749 Node* index = node->InputAt(1); 2749 Node* index = node->InputAt(1);
2750 Node* old_value = node->InputAt(2); 2750 Node* old_value = node->InputAt(2);
2751 Node* new_value = node->InputAt(3); 2751 Node* new_value = node->InputAt(3);
2752 ArchOpcode opcode = kArchNop; 2752 ArchOpcode opcode = kArchNop;
2753 MachineType type = AtomicCompareExchangeRepresentationOf(node->op()); 2753 MachineType type = AtomicOpRepresentationOf(node->op());
2754 if (type == MachineType::Int8()) { 2754 if (type == MachineType::Int8()) {
2755 opcode = kAtomicCompareExchangeInt8; 2755 opcode = kAtomicCompareExchangeInt8;
2756 } else if (type == MachineType::Uint8()) { 2756 } else if (type == MachineType::Uint8()) {
2757 opcode = kAtomicCompareExchangeUint8; 2757 opcode = kAtomicCompareExchangeUint8;
2758 } else if (type == MachineType::Int16()) { 2758 } else if (type == MachineType::Int16()) {
2759 opcode = kAtomicCompareExchangeInt16; 2759 opcode = kAtomicCompareExchangeInt16;
2760 } else if (type == MachineType::Uint16()) { 2760 } else if (type == MachineType::Uint16()) {
2761 opcode = kAtomicCompareExchangeUint16; 2761 opcode = kAtomicCompareExchangeUint16;
2762 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { 2762 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
2763 opcode = kAtomicCompareExchangeWord32; 2763 opcode = kAtomicCompareExchangeWord32;
(...skipping 11 matching lines...) Expand all
2775 inputs[input_count++] = g.UseUniqueRegister(new_value); 2775 inputs[input_count++] = g.UseUniqueRegister(new_value);
2776 InstructionOperand outputs[1]; 2776 InstructionOperand outputs[1];
2777 outputs[0] = g.UseUniqueRegister(node); 2777 outputs[0] = g.UseUniqueRegister(node);
2778 InstructionOperand temp[2]; 2778 InstructionOperand temp[2];
2779 temp[0] = g.TempRegister(); 2779 temp[0] = g.TempRegister();
2780 temp[1] = g.TempRegister(); 2780 temp[1] = g.TempRegister();
2781 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); 2781 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2782 Emit(code, 1, outputs, input_count, inputs, 2, temp); 2782 Emit(code, 1, outputs, input_count, inputs, 2, temp);
2783 } 2783 }
2784 2784
2785 void InstructionSelector::VisitAtomicBinaryOperation(
2786 Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op,
2787 ArchOpcode uint16_op, ArchOpcode word32_op) {
2788 Arm64OperandGenerator g(this);
2789 Node* base = node->InputAt(0);
2790 Node* index = node->InputAt(1);
2791 Node* value = node->InputAt(2);
2792 ArchOpcode opcode = kArchNop;
2793 MachineType type = AtomicOpRepresentationOf(node->op());
2794 if (type == MachineType::Int8()) {
2795 opcode = int8_op;
2796 } else if (type == MachineType::Uint8()) {
2797 opcode = uint8_op;
2798 } else if (type == MachineType::Int16()) {
2799 opcode = int16_op;
2800 } else if (type == MachineType::Uint16()) {
2801 opcode = uint16_op;
2802 } else if (type == MachineType::Int32() || type == MachineType::Uint32()) {
2803 opcode = word32_op;
2804 } else {
2805 UNREACHABLE();
2806 return;
2807 }
2808
2809 AddressingMode addressing_mode = kMode_MRR;
2810 InstructionOperand inputs[3];
2811 size_t input_count = 0;
2812 inputs[input_count++] = g.UseUniqueRegister(base);
2813 inputs[input_count++] = g.UseUniqueRegister(index);
2814 inputs[input_count++] = g.UseUniqueRegister(value);
2815 InstructionOperand outputs[1];
2816 outputs[0] = g.UseUniqueRegister(node);
2817 InstructionOperand temps[2];
2818 temps[0] = g.TempRegister();
2819 temps[1] = g.TempRegister();
2820 InstructionCode code = opcode | AddressingModeField::encode(addressing_mode);
2821 Emit(code, 1, outputs, input_count, inputs, 2, temps);
2822 }
2823
2824 #define VISIT_ATOMIC_BINOP(op) \
2825 void InstructionSelector::VisitAtomic##op(Node* node) { \
2826 VisitAtomicBinaryOperation(node, kAtomic##op##Int8, kAtomic##op##Uint8, \
2827 kAtomic##op##Int16, kAtomic##op##Uint16, \
2828 kAtomic##op##Word32); \
2829 }
2830 VISIT_ATOMIC_BINOP(Add)
2831 VISIT_ATOMIC_BINOP(Sub)
2832 VISIT_ATOMIC_BINOP(And)
2833 VISIT_ATOMIC_BINOP(Or)
2834 VISIT_ATOMIC_BINOP(Xor)
2835 #undef VISIT_ATOMIC_BINOP
2836
2785 void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) { 2837 void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) {
2786 UNREACHABLE(); 2838 UNREACHABLE();
2787 } 2839 }
2788 2840
2789 void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { 2841 void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) {
2790 UNREACHABLE(); 2842 UNREACHABLE();
2791 } 2843 }
2792 2844
2793 // static 2845 // static
2794 MachineOperatorBuilder::Flags 2846 MachineOperatorBuilder::Flags
(...skipping 17 matching lines...) Expand all
2812 // static 2864 // static
2813 MachineOperatorBuilder::AlignmentRequirements 2865 MachineOperatorBuilder::AlignmentRequirements
2814 InstructionSelector::AlignmentRequirements() { 2866 InstructionSelector::AlignmentRequirements() {
2815 return MachineOperatorBuilder::AlignmentRequirements:: 2867 return MachineOperatorBuilder::AlignmentRequirements::
2816 FullUnalignedAccessSupport(); 2868 FullUnalignedAccessSupport();
2817 } 2869 }
2818 2870
2819 } // namespace compiler 2871 } // namespace compiler
2820 } // namespace internal 2872 } // namespace internal
2821 } // namespace v8 2873 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698