Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: test/unittests/compiler/move-optimizer-unittest.cc

Issue 1087793002: [turbofan] add MachineType to AllocatedOperand (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: no flag Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/move-optimizer.h" 5 #include "src/compiler/move-optimizer.h"
6 #include "test/unittests/compiler/instruction-sequence-unittest.h" 6 #include "test/unittests/compiler/instruction-sequence-unittest.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
(...skipping 15 matching lines...) Expand all
26 i++; 26 i++;
27 } 27 }
28 return i; 28 return i;
29 } 29 }
30 30
31 bool Contains(ParallelMove* moves, TestOperand from_op, TestOperand to_op) { 31 bool Contains(ParallelMove* moves, TestOperand from_op, TestOperand to_op) {
32 auto from = ConvertMoveArg(from_op); 32 auto from = ConvertMoveArg(from_op);
33 auto to = ConvertMoveArg(to_op); 33 auto to = ConvertMoveArg(to_op);
34 for (auto move : *moves) { 34 for (auto move : *moves) {
35 if (move->IsRedundant()) continue; 35 if (move->IsRedundant()) continue;
36 if (move->source() == from && move->destination() == to) { 36 if (move->source().Equals(from) && move->destination().Equals(to)) {
37 return true; 37 return true;
38 } 38 }
39 } 39 }
40 return false; 40 return false;
41 } 41 }
42 42
43 // TODO(dcarney): add a verifier. 43 // TODO(dcarney): add a verifier.
44 void Optimize() { 44 void Optimize() {
45 WireBlocks(); 45 WireBlocks();
46 if (FLAG_trace_turbo) { 46 if (FLAG_trace_turbo) {
(...skipping 13 matching lines...) Expand all
60 } 60 }
61 61
62 private: 62 private:
63 InstructionOperand ConvertMoveArg(TestOperand op) { 63 InstructionOperand ConvertMoveArg(TestOperand op) {
64 CHECK_EQ(kNoValue, op.vreg_.value_); 64 CHECK_EQ(kNoValue, op.vreg_.value_);
65 CHECK_NE(kNoValue, op.value_); 65 CHECK_NE(kNoValue, op.value_);
66 switch (op.type_) { 66 switch (op.type_) {
67 case kConstant: 67 case kConstant:
68 return ConstantOperand(op.value_); 68 return ConstantOperand(op.value_);
69 case kFixedSlot: 69 case kFixedSlot:
70 return StackSlotOperand(op.value_); 70 return StackSlotOperand(kRepWord32, op.value_);
71 case kFixedRegister: 71 case kFixedRegister:
72 CHECK(0 <= op.value_ && op.value_ < num_general_registers()); 72 CHECK(0 <= op.value_ && op.value_ < num_general_registers());
73 return RegisterOperand(op.value_); 73 return RegisterOperand(kRepWord32, op.value_);
74 default: 74 default:
75 break; 75 break;
76 } 76 }
77 CHECK(false); 77 CHECK(false);
78 return InstructionOperand(); 78 return InstructionOperand();
79 } 79 }
80 }; 80 };
81 81
82 82
83 TEST_F(MoveOptimizerTest, RemovesRedundant) { 83 TEST_F(MoveOptimizerTest, RemovesRedundant) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 CHECK(gap_1->AreMovesRedundant()); 169 CHECK(gap_1->AreMovesRedundant());
170 auto move = LastInstruction()->parallel_moves()[0]; 170 auto move = LastInstruction()->parallel_moves()[0];
171 CHECK_EQ(2, NonRedundantSize(move)); 171 CHECK_EQ(2, NonRedundantSize(move));
172 CHECK(Contains(move, Reg(0), Reg(1))); 172 CHECK(Contains(move, Reg(0), Reg(1)));
173 CHECK(Contains(move, Reg(1), Reg(0))); 173 CHECK(Contains(move, Reg(1), Reg(0)));
174 } 174 }
175 175
176 } // namespace compiler 176 } // namespace compiler
177 } // namespace internal 177 } // namespace internal
178 } // namespace v8 178 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/instruction-selector-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698