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 { 15 namespace compiler { 16 17 // Forward declarations. 18 class NodeOriginTable; 19 class RepresentationChanger; 20 class RepresentationSelector; 21 class SourcePositionTable; 22 class TypeCache; 23 24 class V8_EXPORT_PRIVATE SimplifiedLowering final { 25 public: 26 SimplifiedLowering(JSGraph* jsgraph, JSHeapBroker* js_heap_broker, Zone* zone, 27 SourcePositionTable* source_position, 28 NodeOriginTable* node_origins, 29 PoisoningMitigationLevel poisoning_level); ~SimplifiedLowering()30 ~SimplifiedLowering() {} 31 32 void LowerAllNodes(); 33 34 void DoMax(Node* node, Operator const* op, MachineRepresentation rep); 35 void DoMin(Node* node, Operator const* op, MachineRepresentation rep); 36 void DoJSToNumberOrNumericTruncatesToFloat64( 37 Node* node, RepresentationSelector* selector); 38 void DoJSToNumberOrNumericTruncatesToWord32(Node* node, 39 RepresentationSelector* selector); 40 void DoShift(Node* node, Operator const* op, Type rhs_type); 41 void DoIntegral32ToBit(Node* node); 42 void DoOrderedNumberToBit(Node* node); 43 void DoNumberToBit(Node* node); 44 void DoIntegerToUint8Clamped(Node* node); 45 void DoNumberToUint8Clamped(Node* node); 46 void DoSigned32ToUint8Clamped(Node* node); 47 void DoUnsigned32ToUint8Clamped(Node* node); 48 49 private: 50 JSGraph* const jsgraph_; 51 JSHeapBroker* js_heap_broker_; 52 Zone* const zone_; 53 TypeCache const& type_cache_; 54 SetOncePointer<Node> to_number_code_; 55 SetOncePointer<Node> to_number_convert_big_int_code_; 56 SetOncePointer<Node> to_numeric_code_; 57 SetOncePointer<Operator const> to_number_operator_; 58 SetOncePointer<Operator const> to_number_convert_big_int_operator_; 59 SetOncePointer<Operator const> to_numeric_operator_; 60 61 // TODO(danno): SimplifiedLowering shouldn't know anything about the source 62 // positions table, but must for now since there currently is no other way to 63 // pass down source position information to nodes created during 64 // lowering. Once this phase becomes a vanilla reducer, it should get source 65 // position information via the SourcePositionWrapper like all other reducers. 66 SourcePositionTable* source_positions_; 67 NodeOriginTable* node_origins_; 68 69 PoisoningMitigationLevel poisoning_level_; 70 71 Node* Float64Round(Node* const node); 72 Node* Float64Sign(Node* const node); 73 Node* Int32Abs(Node* const node); 74 Node* Int32Div(Node* const node); 75 Node* Int32Mod(Node* const node); 76 Node* Int32Sign(Node* const node); 77 Node* Uint32Div(Node* const node); 78 Node* Uint32Mod(Node* const node); 79 80 Node* ToNumberCode(); 81 Node* ToNumberConvertBigIntCode(); 82 Node* ToNumericCode(); 83 Operator const* ToNumberOperator(); 84 Operator const* ToNumberConvertBigIntOperator(); 85 Operator const* ToNumericOperator(); 86 87 friend class RepresentationSelector; 88 isolate()89 Isolate* isolate() { return jsgraph_->isolate(); } zone()90 Zone* zone() { return jsgraph_->zone(); } jsgraph()91 JSGraph* jsgraph() { return jsgraph_; } graph()92 Graph* graph() { return jsgraph()->graph(); } common()93 CommonOperatorBuilder* common() { return jsgraph()->common(); } machine()94 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } simplified()95 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } 96 }; 97 98 } // namespace compiler 99 } // namespace internal 100 } // namespace v8 101 102 #endif // V8_COMPILER_SIMPLIFIED_LOWERING_H_ 103