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/machine-type.h" | 9 #include "src/machine-type.h" |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 kPointerWriteBarrier, | 55 kPointerWriteBarrier, |
56 kFullWriteBarrier | 56 kFullWriteBarrier |
57 }; | 57 }; |
58 | 58 |
59 std::ostream& operator<<(std::ostream& os, WriteBarrierKind); | 59 std::ostream& operator<<(std::ostream& os, WriteBarrierKind); |
60 | 60 |
61 | 61 |
62 // A Load needs a MachineType. | 62 // A Load needs a MachineType. |
63 typedef MachineType LoadRepresentation; | 63 typedef MachineType LoadRepresentation; |
64 | 64 |
| 65 LoadRepresentation LoadRepresentationOf(Operator const*); |
65 | 66 |
66 // A Store needs a MachineType and a WriteBarrierKind in order to emit the | 67 // A Store needs a MachineType and a WriteBarrierKind in order to emit the |
67 // correct write barrier. | 68 // correct write barrier. |
68 class StoreRepresentation final { | 69 class StoreRepresentation final { |
69 public: | 70 public: |
70 StoreRepresentation(MachineType machine_type, | 71 StoreRepresentation(MachineType machine_type, |
71 WriteBarrierKind write_barrier_kind) | 72 WriteBarrierKind write_barrier_kind) |
72 : machine_type_(machine_type), write_barrier_kind_(write_barrier_kind) {} | 73 : machine_type_(machine_type), write_barrier_kind_(write_barrier_kind) {} |
73 | 74 |
74 MachineType machine_type() const { return machine_type_; } | 75 MachineType machine_type() const { return machine_type_; } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 kWord64Popcnt = 1u << 19, | 135 kWord64Popcnt = 1u << 19, |
135 kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | | 136 kAllOptionalOps = kFloat32Max | kFloat32Min | kFloat64Max | kFloat64Min | |
136 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | | 137 kFloat32RoundDown | kFloat64RoundDown | kFloat32RoundUp | |
137 kFloat64RoundUp | kFloat32RoundTruncate | | 138 kFloat64RoundUp | kFloat32RoundTruncate | |
138 kFloat64RoundTruncate | kFloat64RoundTiesAway | | 139 kFloat64RoundTruncate | kFloat64RoundTiesAway | |
139 kFloat32RoundTiesEven | kFloat64RoundTiesEven | | 140 kFloat32RoundTiesEven | kFloat64RoundTiesEven | |
140 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt | 141 kWord32Ctz | kWord64Ctz | kWord32Popcnt | kWord64Popcnt |
141 }; | 142 }; |
142 typedef base::Flags<Flag, unsigned> Flags; | 143 typedef base::Flags<Flag, unsigned> Flags; |
143 | 144 |
144 explicit MachineOperatorBuilder(Zone* zone, MachineType word = kMachPtr, | 145 explicit MachineOperatorBuilder( |
145 Flags supportedOperators = kNoFlags); | 146 Zone* zone, |
| 147 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 148 Flags supportedOperators = kNoFlags); |
146 | 149 |
147 const Operator* Word32And(); | 150 const Operator* Word32And(); |
148 const Operator* Word32Or(); | 151 const Operator* Word32Or(); |
149 const Operator* Word32Xor(); | 152 const Operator* Word32Xor(); |
150 const Operator* Word32Shl(); | 153 const Operator* Word32Shl(); |
151 const Operator* Word32Shr(); | 154 const Operator* Word32Shr(); |
152 const Operator* Word32Sar(); | 155 const Operator* Word32Sar(); |
153 const Operator* Word32Ror(); | 156 const Operator* Word32Ror(); |
154 const Operator* Word32Equal(); | 157 const Operator* Word32Equal(); |
155 const Operator* Word32Clz(); | 158 const Operator* Word32Clz(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // Access to the machine stack. | 303 // Access to the machine stack. |
301 const Operator* LoadStackPointer(); | 304 const Operator* LoadStackPointer(); |
302 const Operator* LoadFramePointer(); | 305 const Operator* LoadFramePointer(); |
303 | 306 |
304 // checked-load heap, index, length | 307 // checked-load heap, index, length |
305 const Operator* CheckedLoad(CheckedLoadRepresentation); | 308 const Operator* CheckedLoad(CheckedLoadRepresentation); |
306 // checked-store heap, index, length, value | 309 // checked-store heap, index, length, value |
307 const Operator* CheckedStore(CheckedStoreRepresentation); | 310 const Operator* CheckedStore(CheckedStoreRepresentation); |
308 | 311 |
309 // Target machine word-size assumed by this builder. | 312 // Target machine word-size assumed by this builder. |
310 bool Is32() const { return word() == kRepWord32; } | 313 bool Is32() const { return word() == MachineRepresentation::kWord32; } |
311 bool Is64() const { return word() == kRepWord64; } | 314 bool Is64() const { return word() == MachineRepresentation::kWord64; } |
312 MachineType word() const { return word_; } | 315 MachineRepresentation word() const { return word_; } |
313 | 316 |
314 // Pseudo operators that translate to 32/64-bit operators depending on the | 317 // Pseudo operators that translate to 32/64-bit operators depending on the |
315 // word-size of the target machine assumed by this builder. | 318 // word-size of the target machine assumed by this builder. |
316 #define PSEUDO_OP_LIST(V) \ | 319 #define PSEUDO_OP_LIST(V) \ |
317 V(Word, And) \ | 320 V(Word, And) \ |
318 V(Word, Or) \ | 321 V(Word, Or) \ |
319 V(Word, Xor) \ | 322 V(Word, Xor) \ |
320 V(Word, Shl) \ | 323 V(Word, Shl) \ |
321 V(Word, Shr) \ | 324 V(Word, Shr) \ |
322 V(Word, Sar) \ | 325 V(Word, Sar) \ |
(...skipping 12 matching lines...) Expand all Loading... |
335 #define PSEUDO_OP(Prefix, Suffix) \ | 338 #define PSEUDO_OP(Prefix, Suffix) \ |
336 const Operator* Prefix##Suffix() { \ | 339 const Operator* Prefix##Suffix() { \ |
337 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 340 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
338 } | 341 } |
339 PSEUDO_OP_LIST(PSEUDO_OP) | 342 PSEUDO_OP_LIST(PSEUDO_OP) |
340 #undef PSEUDO_OP | 343 #undef PSEUDO_OP |
341 #undef PSEUDO_OP_LIST | 344 #undef PSEUDO_OP_LIST |
342 | 345 |
343 private: | 346 private: |
344 MachineOperatorGlobalCache const& cache_; | 347 MachineOperatorGlobalCache const& cache_; |
345 MachineType const word_; | 348 MachineRepresentation const word_; |
346 Flags const flags_; | 349 Flags const flags_; |
347 | 350 |
348 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); | 351 DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder); |
349 }; | 352 }; |
350 | 353 |
351 | 354 |
352 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 355 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
353 | 356 |
354 } // namespace compiler | 357 } // namespace compiler |
355 } // namespace internal | 358 } // namespace internal |
356 } // namespace v8 | 359 } // namespace v8 |
357 | 360 |
358 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 361 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |