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

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

Issue 1779713009: Implement optional turbofan UnalignedLoad and UnalignedStore operators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix failures in cctest/test-run-wasm-64/Run_Wasm_LoadStoreI64_sx due to missing implementation of U… Created 4 years, 9 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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 885 }
886 } 886 }
887 } 887 }
888 } 888 }
889 889
890 890
891 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } 891 bool InstructionSelector::IsTailCallAddressImmediate() { return false; }
892 892
893 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } 893 int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; }
894 894
895 void InstructionSelector::VisitUnalignedLoad(Node* node) {
896 UnalignedLoadRepresentation load_rep =
897 UnalignedLoadRepresentationOf(node->op());
898 MipsOperandGenerator g(this);
899 Node* base = node->InputAt(0);
900 Node* index = node->InputAt(1);
901
902 ArchOpcode opcode = kArchNop;
903 switch (load_rep.representation()) {
904 case MachineRepresentation::kBit: // Fall through.
905 case MachineRepresentation::kWord8:
906 opcode = load_rep.IsUnsigned() ? kMipsLbu : kMipsLb;
907 break;
908 case MachineRepresentation::kWord16:
909 opcode = load_rep.IsUnsigned() ? kMipsUlhu : kMipsUlh;
910 break;
911 case MachineRepresentation::kTagged: // Fall through.
912 case MachineRepresentation::kWord32:
913 opcode = kMipsUlw;
914 break;
915 case MachineRepresentation::kFloat32:
916 opcode = kMipsUlwc1;
917 break;
918 case MachineRepresentation::kFloat64:
919 opcode = kMipsUldc1;
920 break;
921 case MachineRepresentation::kWord64: // Fall through.
922 case MachineRepresentation::kSimd128: // Fall through.
923 case MachineRepresentation::kNone:
924 UNREACHABLE();
925 return;
926 }
927
928 if (g.CanBeImmediate(index, opcode)) {
929 Emit(opcode | AddressingModeField::encode(kMode_MRI),
930 g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index));
931 } else {
932 InstructionOperand addr_reg = g.TempRegister();
933 Emit(kMipsAdd | AddressingModeField::encode(kMode_None), addr_reg,
934 g.UseRegister(index), g.UseRegister(base));
935 // Emit desired load opcode, using temp addr_reg.
936 Emit(opcode | AddressingModeField::encode(kMode_MRI),
937 g.DefineAsRegister(node), addr_reg, g.TempImmediate(0));
938 }
939 }
940
941 void InstructionSelector::VisitUnalignedStore(Node* node) {
942 MipsOperandGenerator g(this);
943 Node* base = node->InputAt(0);
944 Node* index = node->InputAt(1);
945 Node* value = node->InputAt(2);
946
947 UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op());
948
949 // TODO(mips): I guess this could be done in a better way.
950 ArchOpcode opcode = kArchNop;
951 switch (rep) {
952 case MachineRepresentation::kFloat32:
953 opcode = kMipsUswc1;
954 break;
955 case MachineRepresentation::kFloat64:
956 opcode = kMipsUsdc1;
957 break;
958 case MachineRepresentation::kBit: // Fall through.
959 case MachineRepresentation::kWord8:
960 opcode = kMipsSb;
961 break;
962 case MachineRepresentation::kWord16:
963 opcode = kMipsUsh;
964 break;
965 case MachineRepresentation::kTagged: // Fall through.
966 case MachineRepresentation::kWord32:
967 opcode = kMipsUsw;
968 break;
969 case MachineRepresentation::kWord64: // Fall through.
970 case MachineRepresentation::kSimd128: // Fall through.
971 case MachineRepresentation::kNone:
972 UNREACHABLE();
973 return;
974 }
975
976 if (g.CanBeImmediate(index, opcode)) {
977 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(),
978 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value));
979 } else {
980 InstructionOperand addr_reg = g.TempRegister();
981 Emit(kMipsAdd | AddressingModeField::encode(kMode_None), addr_reg,
982 g.UseRegister(index), g.UseRegister(base));
983 // Emit desired store opcode, using temp addr_reg.
984 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(),
985 addr_reg, g.TempImmediate(0), g.UseRegister(value));
986 }
987 }
988
895 void InstructionSelector::VisitCheckedLoad(Node* node) { 989 void InstructionSelector::VisitCheckedLoad(Node* node) {
896 CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); 990 CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op());
897 MipsOperandGenerator g(this); 991 MipsOperandGenerator g(this);
898 Node* const buffer = node->InputAt(0); 992 Node* const buffer = node->InputAt(0);
899 Node* const offset = node->InputAt(1); 993 Node* const offset = node->InputAt(1);
900 Node* const length = node->InputAt(2); 994 Node* const length = node->InputAt(2);
901 ArchOpcode opcode = kArchNop; 995 ArchOpcode opcode = kArchNop;
902 switch (load_rep.representation()) { 996 switch (load_rep.representation()) {
903 case MachineRepresentation::kWord8: 997 case MachineRepresentation::kWord8:
904 opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; 998 opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 MachineOperatorBuilder::Flags 1472 MachineOperatorBuilder::Flags
1379 InstructionSelector::SupportedMachineOperatorFlags() { 1473 InstructionSelector::SupportedMachineOperatorFlags() {
1380 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; 1474 MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags;
1381 if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) && 1475 if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) &&
1382 IsFp64Mode()) { 1476 IsFp64Mode()) {
1383 flags |= MachineOperatorBuilder::kFloat64RoundDown | 1477 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1384 MachineOperatorBuilder::kFloat64RoundUp | 1478 MachineOperatorBuilder::kFloat64RoundUp |
1385 MachineOperatorBuilder::kFloat64RoundTruncate | 1479 MachineOperatorBuilder::kFloat64RoundTruncate |
1386 MachineOperatorBuilder::kFloat64RoundTiesEven; 1480 MachineOperatorBuilder::kFloat64RoundTiesEven;
1387 } 1481 }
1482
1483 if ((IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r1)) ||
1484 IsMipsArchVariant(kLoongson)) {
1485 flags |= MachineOperatorBuilder::kUnalignedLoad |
1486 MachineOperatorBuilder::kUnalignedStore;
1487 }
1488
1388 return flags | MachineOperatorBuilder::kWord32Ctz | 1489 return flags | MachineOperatorBuilder::kWord32Ctz |
1389 MachineOperatorBuilder::kWord32Popcnt | 1490 MachineOperatorBuilder::kWord32Popcnt |
1390 MachineOperatorBuilder::kInt32DivIsSafe | 1491 MachineOperatorBuilder::kInt32DivIsSafe |
1391 MachineOperatorBuilder::kUint32DivIsSafe | 1492 MachineOperatorBuilder::kUint32DivIsSafe |
1392 MachineOperatorBuilder::kWord32ShiftIsSafe | 1493 MachineOperatorBuilder::kWord32ShiftIsSafe |
1393 MachineOperatorBuilder::kFloat64Min | 1494 MachineOperatorBuilder::kFloat64Min |
1394 MachineOperatorBuilder::kFloat64Max | 1495 MachineOperatorBuilder::kFloat64Max |
1395 MachineOperatorBuilder::kFloat32Min | 1496 MachineOperatorBuilder::kFloat32Min |
1396 MachineOperatorBuilder::kFloat32Max | 1497 MachineOperatorBuilder::kFloat32Max |
1397 MachineOperatorBuilder::kFloat32RoundDown | 1498 MachineOperatorBuilder::kFloat32RoundDown |
1398 MachineOperatorBuilder::kFloat32RoundUp | 1499 MachineOperatorBuilder::kFloat32RoundUp |
1399 MachineOperatorBuilder::kFloat32RoundTruncate | 1500 MachineOperatorBuilder::kFloat32RoundTruncate |
1400 MachineOperatorBuilder::kFloat32RoundTiesEven; 1501 MachineOperatorBuilder::kFloat32RoundTiesEven;
1401 } 1502 }
1402 1503
1403 } // namespace compiler 1504 } // namespace compiler
1404 } // namespace internal 1505 } // namespace internal
1405 } // namespace v8 1506 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698