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

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 1479713003: [turbofan] Implemented the TruncateFloat32ToUint64 TurboFan operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/osr.h" 10 #include "src/compiler/osr.h"
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0)); 1050 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0));
1051 } 1051 }
1052 break; 1052 break;
1053 case kSSEFloat64ToInt64: 1053 case kSSEFloat64ToInt64:
1054 if (instr->InputAt(0)->IsDoubleRegister()) { 1054 if (instr->InputAt(0)->IsDoubleRegister()) {
1055 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); 1055 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0));
1056 } else { 1056 } else {
1057 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); 1057 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0));
1058 } 1058 }
1059 break; 1059 break;
1060 case kSSEFloat32ToUint64: {
1061 // There does not exist a Float32ToUint64 instruction, so we have to use
1062 // the Float32ToInt64 instruction.
1063 if (instr->InputAt(0)->IsDoubleRegister()) {
1064 __ Cvttss2siq(i.OutputRegister(), i.InputDoubleRegister(0));
1065 } else {
1066 __ Cvttss2siq(i.OutputRegister(), i.InputOperand(0));
1067 }
1068 // Check if the result of the Float32ToInt64 conversion is positive, we
1069 // are already done.
1070 __ testq(i.OutputRegister(), i.OutputRegister());
1071 Label done;
1072 __ j(positive, &done);
1073 // The result of the first conversion was negative, which means that the
1074 // input value was not within the positive int64 range. We subtract 2^64
1075 // and convert it again to see if it is within the uint64 range.
1076 __ Move(kScratchDoubleReg, -9223372036854775808.0f);
1077 if (instr->InputAt(0)->IsDoubleRegister()) {
1078 __ addss(kScratchDoubleReg, i.InputDoubleRegister(0));
1079 } else {
1080 __ addss(kScratchDoubleReg, i.InputOperand(0));
1081 }
1082 __ Cvttss2siq(i.OutputRegister(), kScratchDoubleReg);
1083 __ testq(i.OutputRegister(), i.OutputRegister());
1084 // The only possible negative value here is 0x80000000000000000, which is
1085 // used on x64 to indicate an integer overflow.
1086 __ j(negative, &done);
1087 // The input value is within uint64 range and the second conversion worked
1088 // successfully, but we still have to undo the subtraction we did
1089 // earlier.
1090 __ movq(kScratchRegister, Immediate(1));
1091 __ shlq(kScratchRegister, Immediate(63));
1092 __ orq(i.OutputRegister(), kScratchRegister);
1093 __ bind(&done);
1094 break;
1095 }
1060 case kSSEFloat64ToUint64: { 1096 case kSSEFloat64ToUint64: {
1061 // There does not exist a Float64ToUint64 instruction, so we have to use 1097 // There does not exist a Float64ToUint64 instruction, so we have to use
1062 // the Float64ToInt64 instruction. 1098 // the Float64ToInt64 instruction.
1063 if (instr->InputAt(0)->IsDoubleRegister()) { 1099 if (instr->InputAt(0)->IsDoubleRegister()) {
1064 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0)); 1100 __ Cvttsd2siq(i.OutputRegister(), i.InputDoubleRegister(0));
1065 } else { 1101 } else {
1066 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0)); 1102 __ Cvttsd2siq(i.OutputRegister(), i.InputOperand(0));
1067 } 1103 }
1068 // Check if the result of the Float64ToInt64 conversion is positive, we 1104 // Check if the result of the Float64ToInt64 conversion is positive, we
1069 // are already done. 1105 // are already done.
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2047 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2012 __ Nop(padding_size); 2048 __ Nop(padding_size);
2013 } 2049 }
2014 } 2050 }
2015 2051
2016 #undef __ 2052 #undef __
2017 2053
2018 } // namespace compiler 2054 } // namespace compiler
2019 } // namespace internal 2055 } // namespace internal
2020 } // namespace v8 2056 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698