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 "test/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
6 | 6 |
7 #include "src/base/utils/random-number-generator.h" | 7 #include "src/base/utils/random-number-generator.h" |
8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/machine-operator-reducer.h" | 9 #include "src/compiler/machine-operator-reducer.h" |
10 #include "test/cctest/compiler/value-helper.h" | 10 #include "test/cctest/compiler/value-helper.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 template <> | 24 template <> |
25 Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, | 25 Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, |
26 volatile double value) { | 26 volatile double value) { |
27 return common->Float64Constant(value); | 27 return common->Float64Constant(value); |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 class ReducerTester : public HandleAndZoneScope { | 31 class ReducerTester : public HandleAndZoneScope { |
32 public: | 32 public: |
33 ReducerTester() | 33 explicit ReducerTester(int num_parameters = 0) |
34 : isolate(main_isolate()), | 34 : isolate(main_isolate()), |
35 binop(NULL), | 35 binop(NULL), |
36 unop(NULL), | 36 unop(NULL), |
37 machine(main_zone()), | 37 machine(main_zone()), |
38 common(main_zone()), | 38 common(main_zone()), |
39 graph(main_zone()), | 39 graph(main_zone()), |
40 maxuint32(Constant<int32_t>(kMaxUInt32)) {} | 40 maxuint32(Constant<int32_t>(kMaxUInt32)) { |
| 41 Node* s = graph.NewNode(common.Start(num_parameters)); |
| 42 graph.SetStart(s); |
| 43 } |
41 | 44 |
42 Isolate* isolate; | 45 Isolate* isolate; |
43 Operator* binop; | 46 Operator* binop; |
44 Operator* unop; | 47 Operator* unop; |
45 MachineOperatorBuilder machine; | 48 MachineOperatorBuilder machine; |
46 CommonOperatorBuilder common; | 49 CommonOperatorBuilder common; |
47 Graph graph; | 50 Graph graph; |
48 Node* maxuint32; | 51 Node* maxuint32; |
49 | 52 |
50 template <typename T> | 53 template <typename T> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Node* k = Constant<T>(constant); | 164 Node* k = Constant<T>(constant); |
162 Node* n = graph.NewNode(binop, k, p); | 165 Node* n = graph.NewNode(binop, k, p); |
163 MachineOperatorReducer reducer(&graph); | 166 MachineOperatorReducer reducer(&graph); |
164 Reduction reduction = reducer.Reduce(n); | 167 Reduction reduction = reducer.Reduce(n); |
165 CHECK(!reduction.Changed()); | 168 CHECK(!reduction.Changed()); |
166 CHECK_EQ(k, n->InputAt(0)); | 169 CHECK_EQ(k, n->InputAt(0)); |
167 CHECK_EQ(p, n->InputAt(1)); | 170 CHECK_EQ(p, n->InputAt(1)); |
168 } | 171 } |
169 | 172 |
170 Node* Parameter(int32_t index = 0) { | 173 Node* Parameter(int32_t index = 0) { |
171 return graph.NewNode(common.Parameter(index)); | 174 return graph.NewNode(common.Parameter(index), graph.start()); |
172 } | 175 } |
173 }; | 176 }; |
174 | 177 |
175 | 178 |
176 TEST(ReduceWord32And) { | 179 TEST(ReduceWord32And) { |
177 ReducerTester R; | 180 ReducerTester R; |
178 R.binop = R.machine.Word32And(); | 181 R.binop = R.machine.Word32And(); |
179 | 182 |
180 FOR_INT32_INPUTS(pl) { | 183 FOR_INT32_INPUTS(pl) { |
181 FOR_INT32_INPUTS(pr) { | 184 FOR_INT32_INPUTS(pr) { |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // TODO(titzer): test MachineOperatorReducer for Int64Mul | 770 // TODO(titzer): test MachineOperatorReducer for Int64Mul |
768 // TODO(titzer): test MachineOperatorReducer for Int64UMul | 771 // TODO(titzer): test MachineOperatorReducer for Int64UMul |
769 // TODO(titzer): test MachineOperatorReducer for Int64Div | 772 // TODO(titzer): test MachineOperatorReducer for Int64Div |
770 // TODO(titzer): test MachineOperatorReducer for Int64UDiv | 773 // TODO(titzer): test MachineOperatorReducer for Int64UDiv |
771 // TODO(titzer): test MachineOperatorReducer for Int64Mod | 774 // TODO(titzer): test MachineOperatorReducer for Int64Mod |
772 // TODO(titzer): test MachineOperatorReducer for Int64UMod | 775 // TODO(titzer): test MachineOperatorReducer for Int64UMod |
773 // TODO(titzer): test MachineOperatorReducer for Int64Neg | 776 // TODO(titzer): test MachineOperatorReducer for Int64Neg |
774 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 | 777 // TODO(titzer): test MachineOperatorReducer for ChangeInt32ToFloat64 |
775 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 | 778 // TODO(titzer): test MachineOperatorReducer for ChangeFloat64ToInt32 |
776 // TODO(titzer): test MachineOperatorReducer for Float64Compare | 779 // TODO(titzer): test MachineOperatorReducer for Float64Compare |
OLD | NEW |