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 | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 24 | class RepresentationSelector; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 25 | class SourcePositionTable; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 26 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 27 | class SimplifiedLowering final { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 28 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 29 | SimplifiedLowering(JSGraph* jsgraph, Zone* zone, |
| 30 | SourcePositionTable* source_positions); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 31 | ~SimplifiedLowering() {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 32 | |
| 33 | void LowerAllNodes(); |
| 34 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 35 | void DoJSToNumberTruncatesToFloat64(Node* node, |
| 36 | RepresentationSelector* selector); |
| 37 | void DoJSToNumberTruncatesToWord32(Node* node, |
| 38 | RepresentationSelector* selector); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 39 | // TODO(turbofan): The representation can be removed once the result of the |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 40 | // representation analysis is stored in the node bounds. |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 41 | void DoLoadBuffer(Node* node, MachineRepresentation rep, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 42 | RepresentationChanger* changer); |
| 43 | void DoStoreBuffer(Node* node); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 44 | void DoShift(Node* node, Operator const* op, Type* rhs_type); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 50 | SetOncePointer<Node> to_number_code_; |
| 51 | SetOncePointer<Operator const> to_number_operator_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 52 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 53 | // TODO(danno): SimplifiedLowering shouldn't know anything about the source |
| 54 | // positions table, but must for now since there currently is no other way to |
| 55 | // pass down source position information to nodes created during |
| 56 | // lowering. Once this phase becomes a vanilla reducer, it should get source |
| 57 | // position information via the SourcePositionWrapper like all other reducers. |
| 58 | SourcePositionTable* source_positions_; |
| 59 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 60 | Node* Float64Ceil(Node* const node); |
| 61 | Node* Float64Floor(Node* const node); |
| 62 | Node* Float64Round(Node* const node); |
| 63 | Node* Float64Trunc(Node* const node); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 64 | Node* Int32Div(Node* const node); |
| 65 | Node* Int32Mod(Node* const node); |
| 66 | Node* Uint32Div(Node* const node); |
| 67 | Node* Uint32Mod(Node* const node); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 68 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 69 | Node* ToNumberCode(); |
| 70 | Operator const* ToNumberOperator(); |
| 71 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 72 | friend class RepresentationSelector; |
| 73 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 74 | Isolate* isolate() { return jsgraph_->isolate(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 75 | Zone* zone() { return jsgraph_->zone(); } |
| 76 | JSGraph* jsgraph() { return jsgraph_; } |
| 77 | Graph* graph() { return jsgraph()->graph(); } |
| 78 | CommonOperatorBuilder* common() { return jsgraph()->common(); } |
| 79 | MachineOperatorBuilder* machine() { return jsgraph()->machine(); } |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame^] | 80 | SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace compiler |
| 84 | } // namespace internal |
| 85 | } // namespace v8 |
| 86 | |
| 87 | #endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_ |