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

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

Issue 1919513002: [turbofan] Introduce TruncateTaggedToWord32 simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/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
33 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { 15 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) {
34 switch (kind) { 16 switch (kind) {
35 case kNoWriteBarrier: 17 case kNoWriteBarrier:
36 return os << "NoWriteBarrier"; 18 return os << "NoWriteBarrier";
37 case kMapWriteBarrier: 19 case kMapWriteBarrier:
38 return os << "MapWriteBarrier"; 20 return os << "MapWriteBarrier";
39 case kPointerWriteBarrier: 21 case kPointerWriteBarrier:
40 return os << "PointerWriteBarrier"; 22 return os << "PointerWriteBarrier";
41 case kFullWriteBarrier: 23 case kFullWriteBarrier:
42 return os << "FullWriteBarrier"; 24 return os << "FullWriteBarrier";
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \ 122 V(Int64Mul, Operator::kAssociative | Operator::kCommutative, 2, 0, 1) \
141 V(Int64Div, Operator::kNoProperties, 2, 1, 1) \ 123 V(Int64Div, Operator::kNoProperties, 2, 1, 1) \
142 V(Int64Mod, Operator::kNoProperties, 2, 1, 1) \ 124 V(Int64Mod, Operator::kNoProperties, 2, 1, 1) \
143 V(Int64LessThan, Operator::kNoProperties, 2, 0, 1) \ 125 V(Int64LessThan, Operator::kNoProperties, 2, 0, 1) \
144 V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ 126 V(Int64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
145 V(Uint64Div, Operator::kNoProperties, 2, 1, 1) \ 127 V(Uint64Div, Operator::kNoProperties, 2, 1, 1) \
146 V(Uint64Mod, Operator::kNoProperties, 2, 1, 1) \ 128 V(Uint64Mod, Operator::kNoProperties, 2, 1, 1) \
147 V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \ 129 V(Uint64LessThan, Operator::kNoProperties, 2, 0, 1) \
148 V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ 130 V(Uint64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \
149 V(BitcastWordToTagged, Operator::kNoProperties, 1, 0, 1) \ 131 V(BitcastWordToTagged, Operator::kNoProperties, 1, 0, 1) \
132 V(TruncateFloat64ToWord32, Operator::kNoProperties, 1, 0, 1) \
150 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 133 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
151 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ 134 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
152 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \ 135 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
153 V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \ 136 V(TruncateFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \
154 V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \ 137 V(TruncateFloat32ToInt32, Operator::kNoProperties, 1, 0, 1) \
155 V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1) \ 138 V(TruncateFloat32ToUint32, Operator::kNoProperties, 1, 0, 1) \
156 V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2) \ 139 V(TryTruncateFloat32ToInt64, Operator::kNoProperties, 1, 0, 2) \
157 V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2) \ 140 V(TryTruncateFloat64ToInt64, Operator::kNoProperties, 1, 0, 2) \
158 V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2) \ 141 V(TryTruncateFloat32ToUint64, Operator::kNoProperties, 1, 0, 2) \
159 V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2) \ 142 V(TryTruncateFloat64ToUint64, Operator::kNoProperties, 1, 0, 2) \
160 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 143 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
144 V(RoundFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \
161 V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 145 V(RoundInt32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
162 V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 146 V(RoundInt64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
163 V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 147 V(RoundInt64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
164 V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 148 V(RoundUint32ToFloat32, Operator::kNoProperties, 1, 0, 1) \
165 V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 149 V(RoundUint64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
166 V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 150 V(RoundUint64ToFloat64, Operator::kNoProperties, 1, 0, 1) \
167 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \ 151 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \
168 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ 152 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \
169 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \ 153 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \
170 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ 154 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 Name##Operator() \ 251 Name##Operator() \
268 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ 252 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
269 value_input_count, 0, control_input_count, output_count, 0, \ 253 value_input_count, 0, control_input_count, output_count, 0, \
270 0) {} \ 254 0) {} \
271 }; \ 255 }; \
272 Name##Operator k##Name; 256 Name##Operator k##Name;
273 PURE_OP_LIST(PURE) 257 PURE_OP_LIST(PURE)
274 PURE_OPTIONAL_OP_LIST(PURE) 258 PURE_OPTIONAL_OP_LIST(PURE)
275 #undef PURE 259 #undef PURE
276 260
277 template <TruncationMode kMode>
278 struct TruncateFloat64ToInt32Operator final
279 : public Operator1<TruncationMode> {
280 TruncateFloat64ToInt32Operator()
281 : Operator1<TruncationMode>(IrOpcode::kTruncateFloat64ToInt32,
282 Operator::kPure, "TruncateFloat64ToInt32",
283 1, 0, 0, 1, 0, 0, kMode) {}
284 };
285 TruncateFloat64ToInt32Operator<TruncationMode::kJavaScript>
286 kTruncateFloat64ToInt32JavaScript;
287 TruncateFloat64ToInt32Operator<TruncationMode::kRoundToZero>
288 kTruncateFloat64ToInt32RoundToZero;
289
290 #define LOAD(Type) \ 261 #define LOAD(Type) \
291 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ 262 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \
292 Load##Type##Operator() \ 263 Load##Type##Operator() \
293 : Operator1<LoadRepresentation>( \ 264 : Operator1<LoadRepresentation>( \
294 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ 265 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \
295 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \ 266 "Load", 2, 1, 1, 1, 1, 0, MachineType::Type()) {} \
296 }; \ 267 }; \
297 struct CheckedLoad##Type##Operator final \ 268 struct CheckedLoad##Type##Operator final \
298 : public Operator1<CheckedLoadRepresentation> { \ 269 : public Operator1<CheckedLoadRepresentation> { \
299 CheckedLoad##Type##Operator() \ 270 CheckedLoad##Type##Operator() \
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 370
400 #define PURE(Name, properties, value_input_count, control_input_count, \ 371 #define PURE(Name, properties, value_input_count, control_input_count, \
401 output_count) \ 372 output_count) \
402 const OptionalOperator MachineOperatorBuilder::Name() { \ 373 const OptionalOperator MachineOperatorBuilder::Name() { \
403 return OptionalOperator(flags_ & k##Name ? &cache_.k##Name : nullptr); \ 374 return OptionalOperator(flags_ & k##Name ? &cache_.k##Name : nullptr); \
404 } 375 }
405 PURE_OPTIONAL_OP_LIST(PURE) 376 PURE_OPTIONAL_OP_LIST(PURE)
406 #undef PURE 377 #undef PURE
407 378
408 379
409 const Operator* MachineOperatorBuilder::TruncateFloat64ToInt32(
410 TruncationMode mode) {
411 switch (mode) {
412 case TruncationMode::kJavaScript:
413 return &cache_.kTruncateFloat64ToInt32JavaScript;
414 case TruncationMode::kRoundToZero:
415 return &cache_.kTruncateFloat64ToInt32RoundToZero;
416 }
417 UNREACHABLE();
418 return nullptr;
419 }
420
421
422 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { 380 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) {
423 #define LOAD(Type) \ 381 #define LOAD(Type) \
424 if (rep == MachineType::Type()) { \ 382 if (rep == MachineType::Type()) { \
425 return &cache_.kLoad##Type; \ 383 return &cache_.kLoad##Type; \
426 } 384 }
427 MACHINE_TYPE_LIST(LOAD) 385 MACHINE_TYPE_LIST(LOAD)
428 #undef LOAD 386 #undef LOAD
429 UNREACHABLE(); 387 UNREACHABLE();
430 return nullptr; 388 return nullptr;
431 } 389 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 475 }
518 ATOMIC_TYPE_LIST(LOAD) 476 ATOMIC_TYPE_LIST(LOAD)
519 #undef LOAD 477 #undef LOAD
520 UNREACHABLE(); 478 UNREACHABLE();
521 return nullptr; 479 return nullptr;
522 } 480 }
523 481
524 } // namespace compiler 482 } // namespace compiler
525 } // namespace internal 483 } // namespace internal
526 } // namespace v8 484 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698