| 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/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
| 7 #include "test/unittests/compiler/graph-unittest.h" | 7 #include "test/unittests/compiler/graph-unittest.h" |
| 8 #include "test/unittests/compiler/node-test-utils.h" | 8 #include "test/unittests/compiler/node-test-utils.h" |
| 9 #include "testing/gmock-support.h" | 9 #include "testing/gmock-support.h" |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 EXPECT_THAT(d1.merge, IsMerge(d1.if_true, d1.if_false)); | 107 EXPECT_THAT(d1.merge, IsMerge(d1.if_true, d1.if_false)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 TEST_F(DiamondTest, DiamondPhis) { | 111 TEST_F(DiamondTest, DiamondPhis) { |
| 112 Node* p0 = Parameter(0); | 112 Node* p0 = Parameter(0); |
| 113 Node* p1 = Parameter(1); | 113 Node* p1 = Parameter(1); |
| 114 Node* p2 = Parameter(2); | 114 Node* p2 = Parameter(2); |
| 115 Diamond d(graph(), common(), p0); | 115 Diamond d(graph(), common(), p0); |
| 116 | 116 |
| 117 MachineType types[] = {kMachAnyTagged, kMachUint32, kMachInt32}; | 117 MachineRepresentation types[] = {MachineRepresentation::kTagged, |
| 118 MachineRepresentation::kWord32}; |
| 118 | 119 |
| 119 for (size_t i = 0; i < arraysize(types); i++) { | 120 for (size_t i = 0; i < arraysize(types); i++) { |
| 120 Node* phi = d.Phi(types[i], p1, p2); | 121 Node* phi = d.Phi(types[i], p1, p2); |
| 121 | 122 |
| 122 EXPECT_THAT(d.branch, IsBranch(p0, graph()->start())); | 123 EXPECT_THAT(d.branch, IsBranch(p0, graph()->start())); |
| 123 EXPECT_THAT(d.if_true, IsIfTrue(d.branch)); | 124 EXPECT_THAT(d.if_true, IsIfTrue(d.branch)); |
| 124 EXPECT_THAT(d.if_false, IsIfFalse(d.branch)); | 125 EXPECT_THAT(d.if_false, IsIfFalse(d.branch)); |
| 125 EXPECT_THAT(d.merge, IsMerge(d.if_true, d.if_false)); | 126 EXPECT_THAT(d.merge, IsMerge(d.if_true, d.if_false)); |
| 126 EXPECT_THAT(phi, IsPhi(types[i], p1, p2, d.merge)); | 127 EXPECT_THAT(phi, IsPhi(types[i], p1, p2, d.merge)); |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 | 130 |
| 130 | 131 |
| 131 TEST_F(DiamondTest, BranchHint) { | 132 TEST_F(DiamondTest, BranchHint) { |
| 132 Diamond dn(graph(), common(), Parameter(0)); | 133 Diamond dn(graph(), common(), Parameter(0)); |
| 133 CHECK(BranchHint::kNone == BranchHintOf(dn.branch->op())); | 134 CHECK(BranchHint::kNone == BranchHintOf(dn.branch->op())); |
| 134 | 135 |
| 135 Diamond dt(graph(), common(), Parameter(0), BranchHint::kTrue); | 136 Diamond dt(graph(), common(), Parameter(0), BranchHint::kTrue); |
| 136 CHECK(BranchHint::kTrue == BranchHintOf(dt.branch->op())); | 137 CHECK(BranchHint::kTrue == BranchHintOf(dt.branch->op())); |
| 137 | 138 |
| 138 Diamond df(graph(), common(), Parameter(0), BranchHint::kFalse); | 139 Diamond df(graph(), common(), Parameter(0), BranchHint::kFalse); |
| 139 CHECK(BranchHint::kFalse == BranchHintOf(df.branch->op())); | 140 CHECK(BranchHint::kFalse == BranchHintOf(df.branch->op())); |
| 140 } | 141 } |
| 141 | 142 |
| 142 | 143 |
| 143 } // namespace compiler | 144 } // namespace compiler |
| 144 } // namespace internal | 145 } // namespace internal |
| 145 } // namespace v8 | 146 } // namespace v8 |
| OLD | NEW |