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

Side by Side Diff: src/compiler/machine-operator.cc

Issue 1225993002: [turbofan] Add TruncationMode for TruncateFloat64ToInt32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.cc » ('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 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/compiler/machine-operator.h" 5 #include "src/compiler/machine-operator.h"
6 6
7 #include "src/base/lazy-instance.h" 7 #include "src/base/lazy-instance.h"
8 #include "src/compiler/opcodes.h" 8 #include "src/compiler/opcodes.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 std::ostream& operator<<(std::ostream& os, TruncationMode mode) {
16 switch (mode) {
17 case TruncationMode::kJavaScript:
18 return os << "JavaScript";
19 case TruncationMode::kRoundToZero:
20 return os << "RoundToZero";
21 }
22 UNREACHABLE();
23 return os;
24 }
25
26
27 TruncationMode TruncationModeOf(Operator const* op) {
28 DCHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, op->opcode());
29 return OpParameter<TruncationMode>(op);
30 }
31
32
15 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { 33 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) {
16 switch (kind) { 34 switch (kind) {
17 case kNoWriteBarrier: 35 case kNoWriteBarrier:
18 return os << "NoWriteBarrier"; 36 return os << "NoWriteBarrier";
19 case kFullWriteBarrier: 37 case kFullWriteBarrier:
20 return os << "FullWriteBarrier"; 38 return os << "FullWriteBarrier";
21 } 39 }
22 UNREACHABLE(); 40 UNREACHABLE();
23 return os; 41 return os;
24 } 42 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \ 128 V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \
111 V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ 129 V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
112 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 130 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
113 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ 131 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
114 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \ 132 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
115 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 133 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
116 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \ 134 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \
117 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 135 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
118 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \ 136 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \
119 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 137 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
120 V(TruncateFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
121 V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \ 138 V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \
122 V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \ 139 V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \
123 V(Float32Add, Operator::kCommutative, 2, 0, 1) \ 140 V(Float32Add, Operator::kCommutative, 2, 0, 1) \
124 V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \ 141 V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \
125 V(Float32Mul, Operator::kCommutative, 2, 0, 1) \ 142 V(Float32Mul, Operator::kCommutative, 2, 0, 1) \
126 V(Float32Div, Operator::kNoProperties, 2, 0, 1) \ 143 V(Float32Div, Operator::kNoProperties, 2, 0, 1) \
127 V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \ 144 V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \
128 V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \ 145 V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \
129 V(Float64Add, Operator::kCommutative, 2, 0, 1) \ 146 V(Float64Add, Operator::kCommutative, 2, 0, 1) \
130 V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \ 147 V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 Name##Operator() \ 201 Name##Operator() \
185 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ 202 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
186 value_input_count, 0, control_input_count, output_count, 0, \ 203 value_input_count, 0, control_input_count, output_count, 0, \
187 0) {} \ 204 0) {} \
188 }; \ 205 }; \
189 Name##Operator k##Name; 206 Name##Operator k##Name;
190 PURE_OP_LIST(PURE) 207 PURE_OP_LIST(PURE)
191 PURE_OPTIONAL_OP_LIST(PURE) 208 PURE_OPTIONAL_OP_LIST(PURE)
192 #undef PURE 209 #undef PURE
193 210
211 template <TruncationMode kMode>
212 struct TruncateFloat64ToInt32Operator final
213 : public Operator1<TruncationMode> {
214 TruncateFloat64ToInt32Operator()
215 : Operator1<TruncationMode>(IrOpcode::kTruncateFloat64ToInt32,
216 Operator::kPure, "TruncateFloat64ToInt32",
217 1, 0, 0, 1, 0, 0, kMode) {}
218 };
219 TruncateFloat64ToInt32Operator<TruncationMode::kJavaScript>
220 kTruncateFloat64ToInt32JavaScript;
221 TruncateFloat64ToInt32Operator<TruncationMode::kRoundToZero>
222 kTruncateFloat64ToInt32RoundToZero;
223
194 #define LOAD(Type) \ 224 #define LOAD(Type) \
195 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ 225 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \
196 Load##Type##Operator() \ 226 Load##Type##Operator() \
197 : Operator1<LoadRepresentation>( \ 227 : Operator1<LoadRepresentation>( \
198 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ 228 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \
199 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \ 229 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \
200 }; \ 230 }; \
201 struct CheckedLoad##Type##Operator final \ 231 struct CheckedLoad##Type##Operator final \
202 : public Operator1<CheckedLoadRepresentation> { \ 232 : public Operator1<CheckedLoadRepresentation> { \
203 CheckedLoad##Type##Operator() \ 233 CheckedLoad##Type##Operator() \
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 #undef PURE 291 #undef PURE
262 292
263 #define PURE(Name, properties, value_input_count, control_input_count, \ 293 #define PURE(Name, properties, value_input_count, control_input_count, \
264 output_count) \ 294 output_count) \
265 const OptionalOperator MachineOperatorBuilder::Name() { \ 295 const OptionalOperator MachineOperatorBuilder::Name() { \
266 return OptionalOperator(flags_ & k##Name ? &cache_.k##Name : nullptr); \ 296 return OptionalOperator(flags_ & k##Name ? &cache_.k##Name : nullptr); \
267 } 297 }
268 PURE_OPTIONAL_OP_LIST(PURE) 298 PURE_OPTIONAL_OP_LIST(PURE)
269 #undef PURE 299 #undef PURE
270 300
301
302 const Operator* MachineOperatorBuilder::TruncateFloat64ToInt32(
303 TruncationMode mode) {
304 switch (mode) {
305 case TruncationMode::kJavaScript:
306 return &cache_.kTruncateFloat64ToInt32JavaScript;
307 case TruncationMode::kRoundToZero:
308 return &cache_.kTruncateFloat64ToInt32RoundToZero;
309 }
310 UNREACHABLE();
311 return nullptr;
312 }
313
314
271 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { 315 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
272 switch (rep) { 316 switch (rep) {
273 #define LOAD(Type) \ 317 #define LOAD(Type) \
274 case k##Type: \ 318 case k##Type: \
275 return &cache_.kLoad##Type; 319 return &cache_.kLoad##Type;
276 MACHINE_TYPE_LIST(LOAD) 320 MACHINE_TYPE_LIST(LOAD)
277 #undef LOAD 321 #undef LOAD
278 default: 322 default:
279 break; 323 break;
280 } 324 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 384 }
341 // Uncached. 385 // Uncached.
342 return new (zone_) Operator1<CheckedStoreRepresentation>( 386 return new (zone_) Operator1<CheckedStoreRepresentation>(
343 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, 387 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow,
344 "CheckedStore", 4, 1, 1, 0, 1, 0, rep); 388 "CheckedStore", 4, 1, 1, 0, 1, 0, rep);
345 } 389 }
346 390
347 } // namespace compiler 391 } // namespace compiler
348 } // namespace internal 392 } // namespace internal
349 } // namespace v8 393 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/machine-operator-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698