Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_COMPILER_SIMPLIFIED_LOWERING_H_ |
| 6 | #define V8_COMPILER_SIMPLIFIED_LOWERING_H_ |
| 7 | |
| 8 | #include "src/compiler/js-graph.h" |
| 9 | #include "src/compiler/machine-operator.h" |
| 10 | #include "src/compiler/node.h" |
| 11 | #include "src/compiler/simplified-operator.h" |
| 12 | |
| 13 | namespace v8 { |
| 14 | namespace internal { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 15 | |
| 16 | // Forward declarations. |
| 17 | class TypeCache; |
| 18 | |
| 19 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 20 | namespace compiler { |
| 21 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 22 | // Forward declarations. |
| 23 | class RepresentationChanger; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 24 | class SourcePositionTable; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 25 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 26 | class SimplifiedLowering final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 27 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 28 | SimplifiedLowering(JSGraph* jsgraph, Zone* zone, |
| 29 | SourcePositionTable* source_positions); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 30 | ~SimplifiedLowering() {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 31 | |
| 32 | void LowerAllNodes(); |
| 33 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 34 | // TODO(turbofan): The representation can be removed once the result of the |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 35 | // representation analysis is stored in the node bounds. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 36 | void DoLoadBuffer(Node* node, MachineRepresentation rep, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 37 | RepresentationChanger* changer); |
| 38 | void DoStoreBuffer(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 39 | void DoObjectIsNumber(Node* node); |
| 40 | void DoObjectIsSmi(Node* node); |
| 41 | void DoShift(Node* node, Operator const* op, Type* rhs_type); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 42 | void DoStringEqual(Node* node); |
| 43 | void DoStringLessThan(Node* node); |
| 44 | void DoStringLessThanOrEqual(Node* node); |
| 45 | |
| 46 | private: |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 47 | JSGraph* const jsgraph_; |
| 48 | Zone* const zone_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 49 | TypeCache const& type_cache_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 50 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 51 | // TODO(danno): SimplifiedLowering shouldn't know anything about the source |
| 52 | // positions table, but must for now since there currently is no other way to |
| 53 | // pass down source position information to nodes created during |
| 54 | // lowering. Once this phase becomes a vanilla reducer, it should get source |
| 55 | // position information via the SourcePositionWrapper like all other reducers. |
| 56 | SourcePositionTable* source_positions_; |
| 57 | |
| 58 | Node* StringComparison(Node* node); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 59 | Node* Int32Div(Node* const node); |
| 60 | Node* Int32Mod(Node* const node); |
| 61 | Node* Uint32Div(Node* const node); |
| 62 | Node* Uint32Mod(Node* const node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 63 | |
| 64 | friend class RepresentationSelector; |
| 65 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 66 | Isolate* isolate() { return jsgraph_->isolate(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 67 | Zone* zone() { return jsgraph_->zone(); } |
| 68 | JSGraph* jsgraph() { return jsgraph_; } |
| 69 | Graph* graph() { return jsgraph()->graph(); } |
| 70 | CommonOperatorBuilder* common() { return jsgraph()->common(); } |
| 71 | MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
| 72 | }; |
| 73 | |
| 74 | } // namespace compiler |
| 75 | } // namespace internal |
| 76 | } // namespace v8 |
| 77 | |
| 78 | #endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_ |