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