| 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/base/division-by-constant.h" | 6 #include "src/base/division-by-constant.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
| 9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
| 10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
| 11 #include "testing/gmock-support.h" | 11 #include "testing/gmock-support.h" |
| 12 | 12 |
| 13 using testing::AllOf; | 13 using testing::AllOf; |
| 14 using testing::Capture; | 14 using testing::Capture; |
| 15 using testing::CaptureEq; | 15 using testing::CaptureEq; |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 namespace compiler { | 19 namespace compiler { |
| 20 | 20 |
| 21 class MachineOperatorReducerTest : public GraphTest { | 21 class MachineOperatorReducerTest : public TypedGraphTest { |
| 22 public: | 22 public: |
| 23 explicit MachineOperatorReducerTest(int num_parameters = 2) | 23 explicit MachineOperatorReducerTest(int num_parameters = 2) |
| 24 : GraphTest(num_parameters) {} | 24 : TypedGraphTest(num_parameters) {} |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 Reduction Reduce(Node* node) { | 27 Reduction Reduce(Node* node) { |
| 28 Typer typer(zone()); | |
| 29 JSOperatorBuilder javascript(zone()); | 28 JSOperatorBuilder javascript(zone()); |
| 30 JSGraph jsgraph(graph(), common(), &javascript, &typer, &machine_); | 29 JSGraph jsgraph(graph(), common(), &javascript, &machine_); |
| 31 MachineOperatorReducer reducer(&jsgraph); | 30 MachineOperatorReducer reducer(&jsgraph); |
| 32 return reducer.Reduce(node); | 31 return reducer.Reduce(node); |
| 33 } | 32 } |
| 34 | 33 |
| 35 Matcher<Node*> IsTruncatingDiv(const Matcher<Node*>& dividend_matcher, | 34 Matcher<Node*> IsTruncatingDiv(const Matcher<Node*>& dividend_matcher, |
| 36 const int32_t divisor) { | 35 const int32_t divisor) { |
| 37 base::MagicNumbersForDivision<uint32_t> const mag = | 36 base::MagicNumbersForDivision<uint32_t> const mag = |
| 38 base::SignedDivisionByConstant(bit_cast<uint32_t>(divisor)); | 37 base::SignedDivisionByConstant(bit_cast<uint32_t>(divisor)); |
| 39 int32_t const multiplier = bit_cast<int32_t>(mag.multiplier); | 38 int32_t const multiplier = bit_cast<int32_t>(mag.multiplier); |
| 40 int32_t const shift = bit_cast<int32_t>(mag.shift); | 39 int32_t const shift = bit_cast<int32_t>(mag.shift); |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 Reduction r = Reduce(node); | 915 Reduction r = Reduce(node); |
| 917 ASSERT_TRUE(r.Changed()); | 916 ASSERT_TRUE(r.Changed()); |
| 918 EXPECT_THAT(r.replacement(), | 917 EXPECT_THAT(r.replacement(), |
| 919 IsStore(rep, base, index, value, effect, control)); | 918 IsStore(rep, base, index, value, effect, control)); |
| 920 } | 919 } |
| 921 } | 920 } |
| 922 | 921 |
| 923 } // namespace compiler | 922 } // namespace compiler |
| 924 } // namespace internal | 923 } // namespace internal |
| 925 } // namespace v8 | 924 } // namespace v8 |
| OLD | NEW |