OLD | NEW |
---|---|
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 // For operators that are not supported on all platforms. | |
20 class OptionalOperator { | |
21 public: | |
22 explicit OptionalOperator(const Operator* op) : op_(op) {} | |
23 | |
24 bool supported() const { return op_ != nullptr; } | |
Benedikt Meurer
2015/05/07 04:48:38
Nit: Can we rename this to Supported() or IsSuppor
titzer
2015/05/11 11:55:29
Done.
| |
25 const Operator* op() const { | |
26 DCHECK_NOT_NULL(op_); | |
27 return op_; | |
28 } | |
29 | |
30 private: | |
31 const Operator* op_; | |
32 }; | |
19 | 33 |
20 // Supported write barrier modes. | 34 // Supported write barrier modes. |
21 enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier }; | 35 enum WriteBarrierKind { kNoWriteBarrier, kFullWriteBarrier }; |
22 | 36 |
23 std::ostream& operator<<(std::ostream& os, WriteBarrierKind); | 37 std::ostream& operator<<(std::ostream& os, WriteBarrierKind); |
24 | 38 |
25 | 39 |
26 // A Load needs a MachineType. | 40 // A Load needs a MachineType. |
27 typedef MachineType LoadRepresentation; | 41 typedef MachineType LoadRepresentation; |
28 | 42 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 kFloat32Max = 1u << 1, | 92 kFloat32Max = 1u << 1, |
79 kFloat32Min = 1u << 2, | 93 kFloat32Min = 1u << 2, |
80 kFloat64Abs = 1u << 3, | 94 kFloat64Abs = 1u << 3, |
81 kFloat64Max = 1u << 4, | 95 kFloat64Max = 1u << 4, |
82 kFloat64Min = 1u << 5, | 96 kFloat64Min = 1u << 5, |
83 kFloat64RoundDown = 1u << 6, | 97 kFloat64RoundDown = 1u << 6, |
84 kFloat64RoundTruncate = 1u << 7, | 98 kFloat64RoundTruncate = 1u << 7, |
85 kFloat64RoundTiesAway = 1u << 8, | 99 kFloat64RoundTiesAway = 1u << 8, |
86 kInt32DivIsSafe = 1u << 9, | 100 kInt32DivIsSafe = 1u << 9, |
87 kUint32DivIsSafe = 1u << 10, | 101 kUint32DivIsSafe = 1u << 10, |
88 kWord32ShiftIsSafe = 1u << 11 | 102 kWord32ShiftIsSafe = 1u << 11, |
103 kAllOptionalOps = kFloat32Abs | kFloat32Max | kFloat32Min | kFloat64Abs | | |
104 kFloat64Max | kFloat64Min | kFloat64RoundDown | | |
105 kFloat64RoundTruncate | kFloat64RoundTiesAway | |
89 }; | 106 }; |
90 typedef base::Flags<Flag, unsigned> Flags; | 107 typedef base::Flags<Flag, unsigned> Flags; |
91 | 108 |
92 explicit MachineOperatorBuilder(Zone* zone, MachineType word = kMachPtr, | 109 explicit MachineOperatorBuilder(Zone* zone, MachineType word = kMachPtr, |
93 Flags supportedOperators = kNoFlags); | 110 Flags supportedOperators = kNoFlags); |
94 | 111 |
95 const Operator* Word32And(); | 112 const Operator* Word32And(); |
96 const Operator* Word32Or(); | 113 const Operator* Word32Or(); |
97 const Operator* Word32Xor(); | 114 const Operator* Word32Xor(); |
98 const Operator* Word32Shl(); | 115 const Operator* Word32Shl(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 const Operator* Float32Equal(); | 198 const Operator* Float32Equal(); |
182 const Operator* Float32LessThan(); | 199 const Operator* Float32LessThan(); |
183 const Operator* Float32LessThanOrEqual(); | 200 const Operator* Float32LessThanOrEqual(); |
184 | 201 |
185 // Floating point comparisons complying to IEEE 754 (double-precision). | 202 // Floating point comparisons complying to IEEE 754 (double-precision). |
186 const Operator* Float64Equal(); | 203 const Operator* Float64Equal(); |
187 const Operator* Float64LessThan(); | 204 const Operator* Float64LessThan(); |
188 const Operator* Float64LessThanOrEqual(); | 205 const Operator* Float64LessThanOrEqual(); |
189 | 206 |
190 // Floating point min/max complying to IEEE 754 (single-precision). | 207 // Floating point min/max complying to IEEE 754 (single-precision). |
191 const Operator* Float32Max(); | 208 const OptionalOperator Float32Max(); |
192 const Operator* Float32Min(); | 209 const OptionalOperator Float32Min(); |
193 bool HasFloat32Max() { return flags_ & kFloat32Max; } | |
194 bool HasFloat32Min() { return flags_ & kFloat32Min; } | |
195 | 210 |
196 // Floating point min/max complying to IEEE 754 (double-precision). | 211 // Floating point min/max complying to IEEE 754 (double-precision). |
197 const Operator* Float64Max(); | 212 const OptionalOperator Float64Max(); |
198 const Operator* Float64Min(); | 213 const OptionalOperator Float64Min(); |
199 bool HasFloat64Max() { return flags_ & kFloat64Max; } | |
200 bool HasFloat64Min() { return flags_ & kFloat64Min; } | |
201 | 214 |
202 // Floating point abs complying to IEEE 754 (single-precision). | 215 // Floating point abs complying to IEEE 754 (single-precision). |
203 const Operator* Float32Abs(); | 216 const OptionalOperator Float32Abs(); |
204 bool HasFloat32Abs() const { return flags_ & kFloat32Abs; } | |
205 | 217 |
206 // Floating point abs complying to IEEE 754 (double-precision). | 218 // Floating point abs complying to IEEE 754 (double-precision). |
207 const Operator* Float64Abs(); | 219 const OptionalOperator Float64Abs(); |
208 bool HasFloat64Abs() const { return flags_ & kFloat64Abs; } | |
209 | 220 |
210 // Floating point rounding. | 221 // Floating point rounding. |
211 const Operator* Float64RoundDown(); | 222 const OptionalOperator Float64RoundDown(); |
212 const Operator* Float64RoundTruncate(); | 223 const OptionalOperator Float64RoundTruncate(); |
213 const Operator* Float64RoundTiesAway(); | 224 const OptionalOperator Float64RoundTiesAway(); |
214 bool HasFloat64RoundDown() { return flags_ & kFloat64RoundDown; } | |
215 bool HasFloat64RoundTruncate() { return flags_ & kFloat64RoundTruncate; } | |
216 bool HasFloat64RoundTiesAway() { return flags_ & kFloat64RoundTiesAway; } | |
217 | 225 |
218 // Floating point bit representation. | 226 // Floating point bit representation. |
219 const Operator* Float64ExtractLowWord32(); | 227 const Operator* Float64ExtractLowWord32(); |
220 const Operator* Float64ExtractHighWord32(); | 228 const Operator* Float64ExtractHighWord32(); |
221 const Operator* Float64InsertLowWord32(); | 229 const Operator* Float64InsertLowWord32(); |
222 const Operator* Float64InsertHighWord32(); | 230 const Operator* Float64InsertHighWord32(); |
223 | 231 |
224 // load [base + index] | 232 // load [base + index] |
225 const Operator* Load(LoadRepresentation rep); | 233 const Operator* Load(LoadRepresentation rep); |
226 | 234 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 }; | 287 }; |
280 | 288 |
281 | 289 |
282 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 290 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
283 | 291 |
284 } // namespace compiler | 292 } // namespace compiler |
285 } // namespace internal | 293 } // namespace internal |
286 } // namespace v8 | 294 } // namespace v8 |
287 | 295 |
288 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 296 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |