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_OPERATOR_REDUCER_H_ 6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_ 7 8 #include "src/base/compiler-specific.h" 9 #include "src/common/globals.h" 10 #include "src/compiler/common-operator.h" 11 #include "src/compiler/graph-reducer.h" 12 13 namespace v8 { 14 namespace internal { 15 16 // Forward declarations. 17 class Factory; 18 class Isolate; 19 20 namespace compiler { 21 22 // Forward declarations. 23 class JSGraph; 24 class MachineOperatorBuilder; 25 class SimplifiedOperatorBuilder; 26 27 class V8_EXPORT_PRIVATE SimplifiedOperatorReducer final NON_EXPORTED_BASE(AdvancedReducer)28 : public NON_EXPORTED_BASE(AdvancedReducer) { 29 public: 30 SimplifiedOperatorReducer(Editor* editor, JSGraph* jsgraph, 31 JSHeapBroker* broker, 32 BranchSemantics branch_semantics); 33 ~SimplifiedOperatorReducer() final; 34 SimplifiedOperatorReducer(const SimplifiedOperatorReducer&) = delete; 35 SimplifiedOperatorReducer& operator=(const SimplifiedOperatorReducer&) = 36 delete; 37 38 const char* reducer_name() const override { 39 return "SimplifiedOperatorReducer"; 40 } 41 42 Reduction Reduce(Node* node) final; 43 44 private: 45 Reduction Change(Node* node, const Operator* op, Node* a); 46 Reduction ReplaceBoolean(bool value); 47 Reduction ReplaceFloat64(double value); 48 Reduction ReplaceInt32(int32_t value); 49 Reduction ReplaceUint32(uint32_t value) { 50 return ReplaceInt32(bit_cast<int32_t>(value)); 51 } 52 Reduction ReplaceNumber(double value); 53 Reduction ReplaceNumber(int32_t value); 54 55 Factory* factory() const; 56 Graph* graph() const; 57 MachineOperatorBuilder* machine() const; 58 SimplifiedOperatorBuilder* simplified() const; 59 60 JSGraph* jsgraph() const { return jsgraph_; } 61 JSHeapBroker* broker() const { return broker_; } 62 63 JSGraph* const jsgraph_; 64 JSHeapBroker* const broker_; 65 BranchSemantics branch_semantics_; 66 }; 67 68 } // namespace compiler 69 } // namespace internal 70 } // namespace v8 71 72 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_ 73