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

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

Issue 1584663007: [turbofan] Implement rounding of floats on x64 and ia32 without sse4.1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 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/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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 VisitRO(this, node, kSSEFloat32Sqrt); 854 VisitRO(this, node, kSSEFloat32Sqrt);
855 } 855 }
856 856
857 857
858 void InstructionSelector::VisitFloat64Sqrt(Node* node) { 858 void InstructionSelector::VisitFloat64Sqrt(Node* node) {
859 VisitRO(this, node, kSSEFloat64Sqrt); 859 VisitRO(this, node, kSSEFloat64Sqrt);
860 } 860 }
861 861
862 862
863 void InstructionSelector::VisitFloat32RoundDown(Node* node) { 863 void InstructionSelector::VisitFloat32RoundDown(Node* node) {
864 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown)); 864 if (CpuFeatures::IsSupported(SSE4_1)) {
865 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown));
866 } else {
867 IA32OperandGenerator g(this);
868 InstructionOperand temps[] = {g.TempRegister()};
869 Emit(kSSEFloat32Round | MiscField::encode(kRoundDown),
870 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
871 }
865 } 872 }
866 873
867 874
868 void InstructionSelector::VisitFloat64RoundDown(Node* node) { 875 void InstructionSelector::VisitFloat64RoundDown(Node* node) {
869 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown)); 876 if (CpuFeatures::IsSupported(SSE4_1)) {
877 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown));
878 } else {
879 IA32OperandGenerator g(this);
880 InstructionOperand temps[] = {g.TempRegister()};
881 Emit(kSSEFloat64Round | MiscField::encode(kRoundDown),
882 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
883 }
870 } 884 }
871 885
872 886
873 void InstructionSelector::VisitFloat32RoundUp(Node* node) { 887 void InstructionSelector::VisitFloat32RoundUp(Node* node) {
874 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp)); 888 if (CpuFeatures::IsSupported(SSE4_1)) {
889 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp));
890 } else {
891 IA32OperandGenerator g(this);
892 InstructionOperand temps[] = {g.TempRegister()};
893 Emit(kSSEFloat32Round | MiscField::encode(kRoundUp),
894 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
895 }
875 } 896 }
876 897
877 898
878 void InstructionSelector::VisitFloat64RoundUp(Node* node) { 899 void InstructionSelector::VisitFloat64RoundUp(Node* node) {
879 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp)); 900 if (CpuFeatures::IsSupported(SSE4_1)) {
901 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp));
902 } else {
903 IA32OperandGenerator g(this);
904 InstructionOperand temps[] = {g.TempRegister()};
905 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp),
906 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
907 }
880 } 908 }
881 909
882 910
883 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { 911 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) {
884 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero)); 912 if (CpuFeatures::IsSupported(SSE4_1)) {
913 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero));
914 } else {
915 IA32OperandGenerator g(this);
916 InstructionOperand temps[] = {g.TempRegister()};
917 Emit(kSSEFloat32Round | MiscField::encode(kRoundToZero),
918 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
919 }
885 } 920 }
886 921
887 922
888 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { 923 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) {
889 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero)); 924 if (CpuFeatures::IsSupported(SSE4_1)) {
925 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero));
926 } else {
927 IA32OperandGenerator g(this);
928 InstructionOperand temps[] = {g.TempRegister()};
929 Emit(kSSEFloat64Round | MiscField::encode(kRoundToZero),
930 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
931 }
890 } 932 }
891 933
892 934
893 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { 935 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) {
894 UNREACHABLE(); 936 UNREACHABLE();
895 } 937 }
896 938
897 939
898 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { 940 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) {
899 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest)); 941 if (CpuFeatures::IsSupported(SSE4_1)) {
942 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest));
943 } else {
944 IA32OperandGenerator g(this);
945 InstructionOperand temps[] = {g.TempRegister()};
946 Emit(kSSEFloat32Round | MiscField::encode(kRoundToNearest),
947 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
948 }
900 } 949 }
901 950
902 951
903 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { 952 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) {
904 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest)); 953 if (CpuFeatures::IsSupported(SSE4_1)) {
954 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest));
955 } else {
956 IA32OperandGenerator g(this);
957 InstructionOperand temps[] = {g.TempRegister()};
958 Emit(kSSEFloat64Round | MiscField::encode(kRoundToNearest),
959 g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 1, temps);
960 }
905 } 961 }
906 962
907 963
908 void InstructionSelector::EmitPrepareArguments( 964 void InstructionSelector::EmitPrepareArguments(
909 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor, 965 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor,
910 Node* node) { 966 Node* node) {
911 IA32OperandGenerator g(this); 967 IA32OperandGenerator g(this);
912 968
913 // Prepare for C function call. 969 // Prepare for C function call.
914 if (descriptor->IsCFunctionCall()) { 970 if (descriptor->IsCFunctionCall()) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1362
1307 // static 1363 // static
1308 MachineOperatorBuilder::Flags 1364 MachineOperatorBuilder::Flags
1309 InstructionSelector::SupportedMachineOperatorFlags() { 1365 InstructionSelector::SupportedMachineOperatorFlags() {
1310 MachineOperatorBuilder::Flags flags = 1366 MachineOperatorBuilder::Flags flags =
1311 MachineOperatorBuilder::kFloat32Max | 1367 MachineOperatorBuilder::kFloat32Max |
1312 MachineOperatorBuilder::kFloat32Min | 1368 MachineOperatorBuilder::kFloat32Min |
1313 MachineOperatorBuilder::kFloat64Max | 1369 MachineOperatorBuilder::kFloat64Max |
1314 MachineOperatorBuilder::kFloat64Min | 1370 MachineOperatorBuilder::kFloat64Min |
1315 MachineOperatorBuilder::kWord32ShiftIsSafe | 1371 MachineOperatorBuilder::kWord32ShiftIsSafe |
1316 MachineOperatorBuilder::kWord32Ctz; 1372 MachineOperatorBuilder::kWord32Ctz |
1373 MachineOperatorBuilder::kFloat32RoundDown |
1374 MachineOperatorBuilder::kFloat32RoundUp |
1375 MachineOperatorBuilder::kFloat32RoundTruncate |
1376 MachineOperatorBuilder::kFloat32RoundTiesEven |
1377 MachineOperatorBuilder::kFloat64RoundDown |
1378 MachineOperatorBuilder::kFloat64RoundUp |
1379 MachineOperatorBuilder::kFloat64RoundTruncate |
1380 MachineOperatorBuilder::kFloat64RoundTiesEven;
1381
1317 if (CpuFeatures::IsSupported(POPCNT)) { 1382 if (CpuFeatures::IsSupported(POPCNT)) {
1318 flags |= MachineOperatorBuilder::kWord32Popcnt; 1383 flags |= MachineOperatorBuilder::kWord32Popcnt;
1319 } 1384 }
1320 if (CpuFeatures::IsSupported(SSE4_1)) {
1321 flags |= MachineOperatorBuilder::kFloat32RoundDown |
1322 MachineOperatorBuilder::kFloat64RoundDown |
1323 MachineOperatorBuilder::kFloat32RoundUp |
1324 MachineOperatorBuilder::kFloat64RoundUp |
1325 MachineOperatorBuilder::kFloat32RoundTruncate |
1326 MachineOperatorBuilder::kFloat64RoundTruncate |
1327 MachineOperatorBuilder::kFloat32RoundTiesEven |
1328 MachineOperatorBuilder::kFloat64RoundTiesEven;
1329 }
1330 return flags; 1385 return flags;
1331 } 1386 }
1332 1387
1333 } // namespace compiler 1388 } // namespace compiler
1334 } // namespace internal 1389 } // namespace internal
1335 } // namespace v8 1390 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698