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/compiler/graph-reducer.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 // Forward declarations.
14 class Heap;
15 
16 namespace compiler {
17 
18 // Forward declarations.
19 class JSGraph;
20 class MachineOperatorBuilder;
21 
22 class SimplifiedOperatorReducer FINAL : public Reducer {
23  public:
SimplifiedOperatorReducer(JSGraph * jsgraph)24   explicit SimplifiedOperatorReducer(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
25   virtual ~SimplifiedOperatorReducer();
26 
27   virtual Reduction Reduce(Node* node) OVERRIDE;
28 
29  private:
30   Reduction Change(Node* node, const Operator* op, Node* a);
31   Reduction ReplaceFloat64(double value);
32   Reduction ReplaceInt32(int32_t value);
ReplaceUint32(uint32_t value)33   Reduction ReplaceUint32(uint32_t value) {
34     return ReplaceInt32(bit_cast<int32_t>(value));
35   }
36   Reduction ReplaceNumber(double value);
37   Reduction ReplaceNumber(int32_t value);
38 
39   Graph* graph() const;
40   Factory* factory() const;
jsgraph()41   JSGraph* jsgraph() const { return jsgraph_; }
42   MachineOperatorBuilder* machine() const;
43 
44   JSGraph* jsgraph_;
45 
46   DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorReducer);
47 };
48 
49 }  // namespace compiler
50 }  // namespace internal
51 }  // namespace v8
52 
53 #endif  // V8_COMPILER_SIMPLIFIED_OPERATOR_REDUCER_H_
54