OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/compiler/machine-operator-reducer.h" | 6 #include "src/compiler/machine-operator-reducer.h" |
7 #include "test/compiler-unittests/graph-unittest.h" | 7 #include "test/compiler-unittests/graph-unittest.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 namespace compiler { | 11 namespace compiler { |
12 | 12 |
13 class MachineOperatorReducerTest : public GraphTest { | 13 class MachineOperatorReducerTest : public GraphTest { |
14 public: | 14 public: |
15 explicit MachineOperatorReducerTest(int num_parameters = 2) | 15 explicit MachineOperatorReducerTest(int num_parameters = 2) |
16 : GraphTest(num_parameters), machine_(zone()) {} | 16 : GraphTest(num_parameters), machine_(zone()) {} |
17 virtual ~MachineOperatorReducerTest() {} | 17 virtual ~MachineOperatorReducerTest() {} |
18 | 18 |
19 protected: | 19 protected: |
20 Node* Parameter(int32_t index) { | |
21 return graph()->NewNode(common()->Parameter(index), graph()->start()); | |
22 } | |
23 Node* Int32Constant(int32_t value) { | |
24 return graph()->NewNode(common()->Int32Constant(value)); | |
25 } | |
26 | |
27 Reduction Reduce(Node* node) { | 20 Reduction Reduce(Node* node) { |
28 MachineOperatorReducer reducer(graph()); | 21 MachineOperatorReducer reducer(graph()); |
29 return reducer.Reduce(node); | 22 return reducer.Reduce(node); |
30 } | 23 } |
31 | 24 |
32 MachineOperatorBuilder* machine() { return &machine_; } | 25 MachineOperatorBuilder* machine() { return &machine_; } |
33 | 26 |
34 private: | 27 private: |
35 MachineOperatorBuilder machine_; | 28 MachineOperatorBuilder machine_; |
36 }; | 29 }; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_TRUE(reduction.Changed()); | 114 EXPECT_TRUE(reduction.Changed()); |
122 EXPECT_THAT(reduction.replacement(), | 115 EXPECT_THAT(reduction.replacement(), |
123 IsInt32Constant(base::bits::RotateRight32(x, y))); | 116 IsInt32Constant(base::bits::RotateRight32(x, y))); |
124 } | 117 } |
125 } | 118 } |
126 } | 119 } |
127 | 120 |
128 } // namespace compiler | 121 } // namespace compiler |
129 } // namespace internal | 122 } // namespace internal |
130 } // namespace v8 | 123 } // namespace v8 |
OLD | NEW |