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

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

Issue 2045943002: [compiler] [wasm] Introduce Word32/64ReverseBytes as TF Optional Opcode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update on store and some optimization on load Created 4 years, 6 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/s390/frames-s390.h" 9 #include "src/s390/frames-s390.h"
10 10
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; 258 InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()};
259 size_t const temp_count = arraysize(temps); 259 size_t const temp_count = arraysize(temps);
260 InstructionCode code = kArchStoreWithWriteBarrier; 260 InstructionCode code = kArchStoreWithWriteBarrier;
261 code |= AddressingModeField::encode(addressing_mode); 261 code |= AddressingModeField::encode(addressing_mode);
262 code |= MiscField::encode(static_cast<int>(record_write_mode)); 262 code |= MiscField::encode(static_cast<int>(record_write_mode));
263 Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); 263 Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
264 } else { 264 } else {
265 ArchOpcode opcode = kArchNop; 265 ArchOpcode opcode = kArchNop;
266 ImmediateMode mode = kInt16Imm; 266 ImmediateMode mode = kInt16Imm;
267 NodeMatcher m(value);
267 switch (rep) { 268 switch (rep) {
268 case MachineRepresentation::kFloat32: 269 case MachineRepresentation::kFloat32:
269 opcode = kS390_StoreFloat32; 270 opcode = kS390_StoreFloat32;
270 break; 271 break;
271 case MachineRepresentation::kFloat64: 272 case MachineRepresentation::kFloat64:
272 opcode = kS390_StoreDouble; 273 opcode = kS390_StoreDouble;
273 break; 274 break;
274 case MachineRepresentation::kBit: // Fall through. 275 case MachineRepresentation::kBit: // Fall through.
275 case MachineRepresentation::kWord8: 276 case MachineRepresentation::kWord8:
276 opcode = kS390_StoreWord8; 277 opcode = kS390_StoreWord8;
277 break; 278 break;
278 case MachineRepresentation::kWord16: 279 case MachineRepresentation::kWord16:
279 opcode = kS390_StoreWord16; 280 opcode = kS390_StoreWord16;
281 if (m.IsWord16ReverseBytes()) {
282 opcode = kS390_StoreReverse16;
283 value = value->InputAt(0);
284 }
280 break; 285 break;
281 #if !V8_TARGET_ARCH_S390X 286 #if !V8_TARGET_ARCH_S390X
282 case MachineRepresentation::kTagged: // Fall through. 287 case MachineRepresentation::kTagged: // Fall through.
283 #endif 288 #endif
284 case MachineRepresentation::kWord32: 289 case MachineRepresentation::kWord32:
285 opcode = kS390_StoreWord32; 290 opcode = kS390_StoreWord32;
291 if (m.IsWord32ReverseBytes()) {
292 opcode = kS390_StoreReverse32;
293 value = value->InputAt(0);
294 }
286 break; 295 break;
287 #if V8_TARGET_ARCH_S390X 296 #if V8_TARGET_ARCH_S390X
288 case MachineRepresentation::kTagged: // Fall through. 297 case MachineRepresentation::kTagged: // Fall through.
289 case MachineRepresentation::kWord64: 298 case MachineRepresentation::kWord64:
290 opcode = kS390_StoreWord64; 299 opcode = kS390_StoreWord64;
291 mode = kInt16Imm_4ByteAligned; 300 mode = kInt16Imm_4ByteAligned;
301 if (m.IsWord64ReverseBytes()) {
302 opcode = kS390_StoreReverse64;
303 value = value->InputAt(0);
304 }
292 break; 305 break;
293 #else 306 #else
294 case MachineRepresentation::kWord64: // Fall through. 307 case MachineRepresentation::kWord64: // Fall through.
295 #endif 308 #endif
296 case MachineRepresentation::kSimd128: // Fall through. 309 case MachineRepresentation::kSimd128: // Fall through.
297 case MachineRepresentation::kNone: 310 case MachineRepresentation::kNone:
298 UNREACHABLE(); 311 UNREACHABLE();
299 return; 312 return;
300 } 313 }
301 if (g.CanBeImmediate(offset, mode)) { 314 if (g.CanBeImmediate(offset, mode)) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 #if V8_TARGET_ARCH_S390X 886 #if V8_TARGET_ARCH_S390X
874 void InstructionSelector::VisitWord64Ctz(Node* node) { UNREACHABLE(); } 887 void InstructionSelector::VisitWord64Ctz(Node* node) { UNREACHABLE(); }
875 #endif 888 #endif
876 889
877 void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); } 890 void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); }
878 891
879 #if V8_TARGET_ARCH_S390X 892 #if V8_TARGET_ARCH_S390X
880 void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); } 893 void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); }
881 #endif 894 #endif
882 895
896 void InstructionSelector::VisitWord64ReverseBytes(Node* node) {
897 UNREACHABLE();
898 S390OperandGenerator g(this);
899 Emit(kS390_LoadReverse64RR, g.DefineAsRegister(node),
900 g.UseRegister(node->InputAt(0)));
901 }
902
903 void InstructionSelector::VisitWord32ReverseBytes(Node* node) {
904 S390OperandGenerator g(this);
905 NodeMatcher input(node->InputAt(0));
906 if (CanCover(node, input.node()) && input.IsLoad()) {
907 LoadRepresentation load_rep = LoadRepresentationOf(input.node()->op());
908 if (load_rep.representation() == MachineRepresentation::kWord32) {
909 Node* base = input.node()->InputAt(0);
910 Node* offset = input.node()->InputAt(1);
911 Emit(kS390_LoadReverse32 | AddressingModeField::encode(kMode_MRR),
912 // TODO(john.yan): one of the base and offset can be imm.
913 g.DefineAsRegister(node), g.UseRegister(base),
914 g.UseRegister(offset));
915 return;
916 }
917 }
918 Emit(kS390_LoadReverse32RR, g.DefineAsRegister(node),
919 g.UseRegister(node->InputAt(0)));
920 }
921
922 void InstructionSelector::VisitWord16ReverseBytes(Node* node) {
923 S390OperandGenerator g(this);
924 NodeMatcher input(node->InputAt(0));
925 if (CanCover(node, input.node()) && input.IsLoad()) {
926 LoadRepresentation load_rep = LoadRepresentationOf(input.node()->op());
927 if (load_rep.representation() == MachineRepresentation::kWord16) {
928 Node* base = input.node()->InputAt(0);
929 Node* offset = input.node()->InputAt(1);
930 Emit(kS390_LoadReverse16 | AddressingModeField::encode(kMode_MRR),
931 // TODO(john.yan): one of the base and offset can be imm.
932 g.DefineAsRegister(node), g.UseRegister(base),
933 g.UseRegister(offset));
934 return;
935 }
936 }
937 Emit(kS390_LoadReverse16RR, g.DefineAsRegister(node),
938 g.UseRegister(node->InputAt(0)));
939 }
940
883 void InstructionSelector::VisitInt32Add(Node* node) { 941 void InstructionSelector::VisitInt32Add(Node* node) {
884 VisitBinop<Int32BinopMatcher>(this, node, kS390_Add, kInt16Imm); 942 VisitBinop<Int32BinopMatcher>(this, node, kS390_Add, kInt16Imm);
885 } 943 }
886 944
887 #if V8_TARGET_ARCH_S390X 945 #if V8_TARGET_ARCH_S390X
888 void InstructionSelector::VisitInt64Add(Node* node) { 946 void InstructionSelector::VisitInt64Add(Node* node) {
889 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add, kInt16Imm); 947 VisitBinop<Int64BinopMatcher>(this, node, kS390_Add, kInt16Imm);
890 } 948 }
891 #endif 949 #endif
892 950
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 MachineOperatorBuilder::Flags 1881 MachineOperatorBuilder::Flags
1824 InstructionSelector::SupportedMachineOperatorFlags() { 1882 InstructionSelector::SupportedMachineOperatorFlags() {
1825 return MachineOperatorBuilder::kFloat32RoundDown | 1883 return MachineOperatorBuilder::kFloat32RoundDown |
1826 MachineOperatorBuilder::kFloat64RoundDown | 1884 MachineOperatorBuilder::kFloat64RoundDown |
1827 MachineOperatorBuilder::kFloat32RoundUp | 1885 MachineOperatorBuilder::kFloat32RoundUp |
1828 MachineOperatorBuilder::kFloat64RoundUp | 1886 MachineOperatorBuilder::kFloat64RoundUp |
1829 MachineOperatorBuilder::kFloat32RoundTruncate | 1887 MachineOperatorBuilder::kFloat32RoundTruncate |
1830 MachineOperatorBuilder::kFloat64RoundTruncate | 1888 MachineOperatorBuilder::kFloat64RoundTruncate |
1831 MachineOperatorBuilder::kFloat64RoundTiesAway | 1889 MachineOperatorBuilder::kFloat64RoundTiesAway |
1832 MachineOperatorBuilder::kWord32Popcnt | 1890 MachineOperatorBuilder::kWord32Popcnt |
1891 MachineOperatorBuilder::kWord16ReverseBytes |
1892 MachineOperatorBuilder::kWord32ReverseBytes |
1893 MachineOperatorBuilder::kWord64ReverseBytes |
1833 MachineOperatorBuilder::kWord64Popcnt; 1894 MachineOperatorBuilder::kWord64Popcnt;
1834 } 1895 }
1835 1896
1836 // static 1897 // static
1837 MachineOperatorBuilder::AlignmentRequirements 1898 MachineOperatorBuilder::AlignmentRequirements
1838 InstructionSelector::AlignmentRequirements() { 1899 InstructionSelector::AlignmentRequirements() {
1839 return MachineOperatorBuilder::AlignmentRequirements:: 1900 return MachineOperatorBuilder::AlignmentRequirements::
1840 FullUnalignedAccessSupport(); 1901 FullUnalignedAccessSupport();
1841 } 1902 }
1842 1903
1843 } // namespace compiler 1904 } // namespace compiler
1844 } // namespace internal 1905 } // namespace internal
1845 } // namespace v8 1906 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698