OLD | NEW |
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/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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 VisitRO(this, node, kSSEFloat32Sqrt); | 864 VisitRO(this, node, kSSEFloat32Sqrt); |
865 } | 865 } |
866 | 866 |
867 | 867 |
868 void InstructionSelector::VisitFloat64Sqrt(Node* node) { | 868 void InstructionSelector::VisitFloat64Sqrt(Node* node) { |
869 VisitRO(this, node, kSSEFloat64Sqrt); | 869 VisitRO(this, node, kSSEFloat64Sqrt); |
870 } | 870 } |
871 | 871 |
872 | 872 |
873 void InstructionSelector::VisitFloat32RoundDown(Node* node) { | 873 void InstructionSelector::VisitFloat32RoundDown(Node* node) { |
874 if (CpuFeatures::IsSupported(SSE4_1)) { | 874 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown)); |
875 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown)); | |
876 } else { | |
877 IA32OperandGenerator g(this); | |
878 InstructionOperand temps[] = {g.TempRegister()}; | |
879 Emit(kSSEFloat32Round | MiscField::encode(kRoundDown), | |
880 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
881 } | |
882 } | 875 } |
883 | 876 |
884 | 877 |
885 void InstructionSelector::VisitFloat64RoundDown(Node* node) { | 878 void InstructionSelector::VisitFloat64RoundDown(Node* node) { |
886 if (CpuFeatures::IsSupported(SSE4_1)) { | 879 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown)); |
887 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown)); | |
888 } else { | |
889 IA32OperandGenerator g(this); | |
890 InstructionOperand temps[] = {g.TempRegister()}; | |
891 Emit(kSSEFloat64Round | MiscField::encode(kRoundDown), | |
892 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
893 } | |
894 } | 880 } |
895 | 881 |
896 | 882 |
897 void InstructionSelector::VisitFloat32RoundUp(Node* node) { | 883 void InstructionSelector::VisitFloat32RoundUp(Node* node) { |
898 if (CpuFeatures::IsSupported(SSE4_1)) { | 884 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp)); |
899 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp)); | |
900 } else { | |
901 IA32OperandGenerator g(this); | |
902 InstructionOperand temps[] = {g.TempRegister()}; | |
903 Emit(kSSEFloat32Round | MiscField::encode(kRoundUp), | |
904 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
905 } | |
906 } | 885 } |
907 | 886 |
908 | 887 |
909 void InstructionSelector::VisitFloat64RoundUp(Node* node) { | 888 void InstructionSelector::VisitFloat64RoundUp(Node* node) { |
910 if (CpuFeatures::IsSupported(SSE4_1)) { | 889 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp)); |
911 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp)); | |
912 } else { | |
913 IA32OperandGenerator g(this); | |
914 InstructionOperand temps[] = {g.TempRegister()}; | |
915 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp), | |
916 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
917 } | |
918 } | 890 } |
919 | 891 |
920 | 892 |
921 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { | 893 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { |
922 if (CpuFeatures::IsSupported(SSE4_1)) { | 894 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero)); |
923 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero)); | |
924 } else { | |
925 IA32OperandGenerator g(this); | |
926 InstructionOperand temps[] = {g.TempRegister()}; | |
927 Emit(kSSEFloat32Round | MiscField::encode(kRoundToZero), | |
928 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
929 } | |
930 } | 895 } |
931 | 896 |
932 | 897 |
933 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { | 898 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { |
934 if (CpuFeatures::IsSupported(SSE4_1)) { | 899 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero)); |
935 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero)); | |
936 } else { | |
937 IA32OperandGenerator g(this); | |
938 InstructionOperand temps[] = {g.TempRegister()}; | |
939 Emit(kSSEFloat64Round | MiscField::encode(kRoundToZero), | |
940 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
941 } | |
942 } | 900 } |
943 | 901 |
944 | 902 |
945 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { | 903 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { |
946 UNREACHABLE(); | 904 UNREACHABLE(); |
947 } | 905 } |
948 | 906 |
949 | 907 |
950 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { | 908 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { |
951 if (CpuFeatures::IsSupported(SSE4_1)) { | 909 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest)); |
952 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest)); | |
953 } else { | |
954 IA32OperandGenerator g(this); | |
955 InstructionOperand temps[] = {g.TempRegister()}; | |
956 Emit(kSSEFloat32Round | MiscField::encode(kRoundToNearest), | |
957 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
958 } | |
959 } | 910 } |
960 | 911 |
961 | 912 |
962 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { | 913 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { |
963 if (CpuFeatures::IsSupported(SSE4_1)) { | 914 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest)); |
964 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest)); | |
965 } else { | |
966 IA32OperandGenerator g(this); | |
967 InstructionOperand temps[] = {g.TempRegister()}; | |
968 Emit(kSSEFloat64Round | MiscField::encode(kRoundToNearest), | |
969 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps); | |
970 } | |
971 } | 915 } |
972 | 916 |
973 | 917 |
974 void InstructionSelector::EmitPrepareArguments( | 918 void InstructionSelector::EmitPrepareArguments( |
975 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor, | 919 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor, |
976 Node* node) { | 920 Node* node) { |
977 IA32OperandGenerator g(this); | 921 IA32OperandGenerator g(this); |
978 | 922 |
979 // Prepare for C function call. | 923 // Prepare for C function call. |
980 if (descriptor->IsCFunctionCall()) { | 924 if (descriptor->IsCFunctionCall()) { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 | 1316 |
1373 // static | 1317 // static |
1374 MachineOperatorBuilder::Flags | 1318 MachineOperatorBuilder::Flags |
1375 InstructionSelector::SupportedMachineOperatorFlags() { | 1319 InstructionSelector::SupportedMachineOperatorFlags() { |
1376 MachineOperatorBuilder::Flags flags = | 1320 MachineOperatorBuilder::Flags flags = |
1377 MachineOperatorBuilder::kFloat32Max | | 1321 MachineOperatorBuilder::kFloat32Max | |
1378 MachineOperatorBuilder::kFloat32Min | | 1322 MachineOperatorBuilder::kFloat32Min | |
1379 MachineOperatorBuilder::kFloat64Max | | 1323 MachineOperatorBuilder::kFloat64Max | |
1380 MachineOperatorBuilder::kFloat64Min | | 1324 MachineOperatorBuilder::kFloat64Min | |
1381 MachineOperatorBuilder::kWord32ShiftIsSafe | | 1325 MachineOperatorBuilder::kWord32ShiftIsSafe | |
1382 MachineOperatorBuilder::kWord32Ctz | | 1326 MachineOperatorBuilder::kWord32Ctz; |
1383 MachineOperatorBuilder::kFloat32RoundDown | | |
1384 MachineOperatorBuilder::kFloat32RoundUp | | |
1385 MachineOperatorBuilder::kFloat32RoundTruncate | | |
1386 MachineOperatorBuilder::kFloat32RoundTiesEven | | |
1387 MachineOperatorBuilder::kFloat64RoundDown | | |
1388 MachineOperatorBuilder::kFloat64RoundUp | | |
1389 MachineOperatorBuilder::kFloat64RoundTruncate | | |
1390 MachineOperatorBuilder::kFloat64RoundTiesEven; | |
1391 | |
1392 if (CpuFeatures::IsSupported(POPCNT)) { | 1327 if (CpuFeatures::IsSupported(POPCNT)) { |
1393 flags |= MachineOperatorBuilder::kWord32Popcnt; | 1328 flags |= MachineOperatorBuilder::kWord32Popcnt; |
1394 } | 1329 } |
| 1330 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 1331 flags |= MachineOperatorBuilder::kFloat32RoundDown | |
| 1332 MachineOperatorBuilder::kFloat64RoundDown | |
| 1333 MachineOperatorBuilder::kFloat32RoundUp | |
| 1334 MachineOperatorBuilder::kFloat64RoundUp | |
| 1335 MachineOperatorBuilder::kFloat32RoundTruncate | |
| 1336 MachineOperatorBuilder::kFloat64RoundTruncate | |
| 1337 MachineOperatorBuilder::kFloat32RoundTiesEven | |
| 1338 MachineOperatorBuilder::kFloat64RoundTiesEven; |
| 1339 } |
1395 return flags; | 1340 return flags; |
1396 } | 1341 } |
1397 | 1342 |
1398 } // namespace compiler | 1343 } // namespace compiler |
1399 } // namespace internal | 1344 } // namespace internal |
1400 } // namespace v8 | 1345 } // namespace v8 |
OLD | NEW |