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