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

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

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/instruction-selector.cc ('k') | src/compiler/machine-operator.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 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 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ 5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_H_ 6 #define V8_COMPILER_MACHINE_OPERATOR_H_
7 7
8 #include "src/base/flags.h" 8 #include "src/base/flags.h"
9 #include "src/compiler/machine-type.h" 9 #include "src/compiler/machine-type.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 struct MachineOperatorGlobalCache; 16 struct MachineOperatorGlobalCache;
17 class Operator; 17 class Operator;
18 18
19
19 // For operators that are not supported on all platforms. 20 // For operators that are not supported on all platforms.
20 class OptionalOperator { 21 class OptionalOperator final {
21 public: 22 public:
22 explicit OptionalOperator(const Operator* op) : op_(op) {} 23 explicit OptionalOperator(const Operator* op) : op_(op) {}
23 24
24 bool IsSupported() const { return op_ != nullptr; } 25 bool IsSupported() const { return op_ != nullptr; }
25 const Operator* op() const { 26 const Operator* op() const {
26 DCHECK_NOT_NULL(op_); 27 DCHECK_NOT_NULL(op_);
27 return op_; 28 return op_;
28 } 29 }
29 30
30 private: 31 private:
31 const Operator* op_; 32 const Operator* const op_;
32 }; 33 };
33 34
35
36 // Supported float64 to int32 truncation modes.
37 enum class TruncationMode : uint8_t {
38 kJavaScript, // ES6 section 7.1.5
39 kRoundToZero // Round towards zero. Implementation defined for NaN and ovf.
40 };
41
42 V8_INLINE size_t hash_value(TruncationMode mode) {
43 return static_cast<uint8_t>(mode);
44 }
45
46 std::ostream& operator<<(std::ostream&, TruncationMode);
47
48 TruncationMode TruncationModeOf(Operator const*);
49
50
34 // Supported write barrier modes. 51 // Supported write barrier modes.
35 enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier }; 52 enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier };
36 53
37 std::ostream& operator<<(std::ostream& os, WriteBarrierKind); 54 std::ostream& operator<<(std::ostream& os, WriteBarrierKind);
38 55
39 56
40 // A Load needs a MachineType. 57 // A Load needs a MachineType.
41 typedef MachineType LoadRepresentation; 58 typedef MachineType LoadRepresentation;
42 59
43 60
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const Operator* ChangeFloat64ToInt32(); // narrowing 185 const Operator* ChangeFloat64ToInt32(); // narrowing
169 const Operator* ChangeFloat64ToUint32(); // narrowing 186 const Operator* ChangeFloat64ToUint32(); // narrowing
170 const Operator* ChangeInt32ToFloat64(); 187 const Operator* ChangeInt32ToFloat64();
171 const Operator* ChangeInt32ToInt64(); 188 const Operator* ChangeInt32ToInt64();
172 const Operator* ChangeUint32ToFloat64(); 189 const Operator* ChangeUint32ToFloat64();
173 const Operator* ChangeUint32ToUint64(); 190 const Operator* ChangeUint32ToUint64();
174 191
175 // These operators truncate numbers, both changing the representation of 192 // These operators truncate numbers, both changing the representation of
176 // the number and mapping multiple input values onto the same output value. 193 // the number and mapping multiple input values onto the same output value.
177 const Operator* TruncateFloat64ToFloat32(); 194 const Operator* TruncateFloat64ToFloat32();
178 const Operator* TruncateFloat64ToInt32(); // JavaScript semantics. 195 const Operator* TruncateFloat64ToInt32(TruncationMode);
179 const Operator* TruncateInt64ToInt32(); 196 const Operator* TruncateInt64ToInt32();
180 197
181 // Floating point operators always operate with IEEE 754 round-to-nearest 198 // Floating point operators always operate with IEEE 754 round-to-nearest
182 // (single-precision). 199 // (single-precision).
183 const Operator* Float32Add(); 200 const Operator* Float32Add();
184 const Operator* Float32Sub(); 201 const Operator* Float32Sub();
185 const Operator* Float32Mul(); 202 const Operator* Float32Mul();
186 const Operator* Float32Div(); 203 const Operator* Float32Div();
187 const Operator* Float32Sqrt(); 204 const Operator* Float32Sqrt();
188 205
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }; 306 };
290 307
291 308
292 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) 309 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags)
293 310
294 } // namespace compiler 311 } // namespace compiler
295 } // namespace internal 312 } // namespace internal
296 } // namespace v8 313 } // namespace v8
297 314
298 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ 315 #endif // V8_COMPILER_MACHINE_OPERATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/machine-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698