deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / src / compiler / machine-operator-reducer.h
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_MACHINE_OPERATOR_REDUCER_H_
6 #define V8_COMPILER_MACHINE_OPERATOR_REDUCER_H_
7
8 #include "src/compiler/graph-reducer.h"
9 #include "src/compiler/machine-operator.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14
15 // Forward declarations.
16 class CommonOperatorBuilder;
17 class JSGraph;
18
19
20 // Performs constant folding and strength reduction on nodes that have
21 // machine operators.
22 class MachineOperatorReducer FINAL : public Reducer {
23  public:
24   explicit MachineOperatorReducer(JSGraph* jsgraph);
25   ~MachineOperatorReducer();
26
27   Reduction Reduce(Node* node) OVERRIDE;
28
29  private:
30   Node* Float32Constant(volatile float value);
31   Node* Float64Constant(volatile double value);
32   Node* Int32Constant(int32_t value);
33   Node* Int64Constant(int64_t value);
34   Node* Uint32Constant(uint32_t value) {
35     return Int32Constant(bit_cast<uint32_t>(value));
36   }
37   Node* Word32And(Node* lhs, Node* rhs);
38   Node* Word32And(Node* lhs, uint32_t rhs) {
39     return Word32And(lhs, Uint32Constant(rhs));
40   }
41   Node* Word32Sar(Node* lhs, uint32_t rhs);
42   Node* Word32Shr(Node* lhs, uint32_t rhs);
43   Node* Word32Equal(Node* lhs, Node* rhs);
44   Node* Int32Add(Node* lhs, Node* rhs);
45   Node* Int32Sub(Node* lhs, Node* rhs);
46   Node* Int32Mul(Node* lhs, Node* rhs);
47   Node* Int32Div(Node* dividend, int32_t divisor);
48   Node* Uint32Div(Node* dividend, uint32_t divisor);
49
50   Reduction ReplaceBool(bool value) { return ReplaceInt32(value ? 1 : 0); }
51   Reduction ReplaceFloat32(volatile float value) {
52     return Replace(Float32Constant(value));
53   }
54   Reduction ReplaceFloat64(volatile double value) {
55     return Replace(Float64Constant(value));
56   }
57   Reduction ReplaceInt32(int32_t value) {
58     return Replace(Int32Constant(value));
59   }
60   Reduction ReplaceUint32(uint32_t value) {
61     return Replace(Uint32Constant(value));
62   }
63   Reduction ReplaceInt64(int64_t value) {
64     return Replace(Int64Constant(value));
65   }
66
67   Reduction ReduceInt32Add(Node* node);
68   Reduction ReduceInt32Sub(Node* node);
69   Reduction ReduceInt32Div(Node* node);
70   Reduction ReduceUint32Div(Node* node);
71   Reduction ReduceInt32Mod(Node* node);
72   Reduction ReduceUint32Mod(Node* node);
73   Reduction ReduceTruncateFloat64ToInt32(Node* node);
74   Reduction ReduceStore(Node* node);
75   Reduction ReduceProjection(size_t index, Node* node);
76   Reduction ReduceWord32Shifts(Node* node);
77   Reduction ReduceWord32Shl(Node* node);
78   Reduction ReduceWord32Sar(Node* node);
79   Reduction ReduceWord32And(Node* node);
80   Reduction ReduceWord32Or(Node* node);
81   Reduction ReduceFloat64InsertLowWord32(Node* node);
82   Reduction ReduceFloat64InsertHighWord32(Node* node);
83
84   Graph* graph() const;
85   JSGraph* jsgraph() const { return jsgraph_; }
86   CommonOperatorBuilder* common() const;
87   MachineOperatorBuilder* machine() const;
88
89   JSGraph* jsgraph_;
90 };
91
92 }  // namespace compiler
93 }  // namespace internal
94 }  // namespace v8
95
96 #endif  // V8_COMPILER_MACHINE_OPERATOR_REDUCER_H_