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/compiler/graph-reducer.h" 10 #include "src/globals.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* js_heap_broker); 31 ~SimplifiedOperatorReducer() final; 32 33 const char* reducer_name() const override { 34 return "SimplifiedOperatorReducer"; 35 } 36 37 Reduction Reduce(Node* node) final; 38 39 private: 40 Reduction ReduceReferenceEqual(Node* node); 41 42 Reduction Change(Node* node, const Operator* op, Node* a); 43 Reduction ReplaceBoolean(bool value); 44 Reduction ReplaceFloat64(double value); 45 Reduction ReplaceInt32(int32_t value); 46 Reduction ReplaceUint32(uint32_t value) { 47 return ReplaceInt32(bit_cast<int32_t>(value)); 48 } 49 Reduction ReplaceNumber(double value); 50 Reduction ReplaceNumber(int32_t value); 51 52 Factory* factory() const; 53 Graph* graph() const; 54 Isolate* isolate() const; 55 MachineOperatorBuilder* machine() const; 56 SimplifiedOperatorBuilder* simplified() const; 57 58 JSGraph* jsgraph() const { return jsgraph_; } 59 JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } 60 61 JSGraph* const jsgraph_; 62 JSHeapBroker* const js_heap_broker_; 63 64 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer); 65 }; 66 67 } // namespace compiler 68 } // namespace internal 69 } // namespace v8 70 71 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_ 72