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

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

Issue 1389373002: [turbofan] Create ExplicitOperands to specify operands without virtual registers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 5 years, 1 month 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-sequence-unittest.h ('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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(kRepWord32, op.value_); 70 return AllocatedOperand(LocationOperand::STACK_SLOT, kRepWord32,
71 op.value_);
71 case kFixedRegister: 72 case kFixedRegister:
72 CHECK(0 <= op.value_ && op.value_ < num_general_registers()); 73 CHECK(0 <= op.value_ && op.value_ < num_general_registers());
73 return RegisterOperand(kRepWord32, op.value_); 74 return AllocatedOperand(LocationOperand::REGISTER, kRepWord32,
75 op.value_);
76 case kExplicit:
77 CHECK(0 <= op.value_ && op.value_ < num_general_registers());
78 return ExplicitOperand(LocationOperand::REGISTER, kRepWord32,
79 op.value_);
74 default: 80 default:
75 break; 81 break;
76 } 82 }
77 CHECK(false); 83 CHECK(false);
78 return InstructionOperand(); 84 return InstructionOperand();
79 } 85 }
80 }; 86 };
81 87
82 88
83 TEST_F(MoveOptimizerTest, RemovesRedundant) { 89 TEST_F(MoveOptimizerTest, RemovesRedundant) {
84 StartBlock(); 90 StartBlock();
85 auto first_instr = EmitNop(); 91 auto first_instr = EmitNop();
86 AddMove(first_instr, Reg(0), Reg(1)); 92 AddMove(first_instr, Reg(0), Reg(1));
87 auto last_instr = EmitNop(); 93 auto last_instr = EmitNop();
88 AddMove(last_instr, Reg(1), Reg(0)); 94 AddMove(last_instr, Reg(1), Reg(0));
89 EndBlock(Last()); 95 EndBlock(Last());
90 96
91 Optimize(); 97 Optimize();
92 98
93 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0])); 99 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0]));
94 auto move = last_instr->parallel_moves()[0]; 100 auto move = last_instr->parallel_moves()[0];
95 CHECK_EQ(1, NonRedundantSize(move)); 101 CHECK_EQ(1, NonRedundantSize(move));
96 CHECK(Contains(move, Reg(0), Reg(1))); 102 CHECK(Contains(move, Reg(0), Reg(1)));
97 } 103 }
98 104
99 105
106 TEST_F(MoveOptimizerTest, RemovesRedundantExplicit) {
107 StartBlock();
108 auto first_instr = EmitNop();
109 AddMove(first_instr, Reg(0), ExplicitReg(1));
110 auto last_instr = EmitNop();
111 AddMove(last_instr, Reg(1), Reg(0));
112 EndBlock(Last());
113
114 Optimize();
115
116 CHECK_EQ(0, NonRedundantSize(first_instr->parallel_moves()[0]));
117 auto move = last_instr->parallel_moves()[0];
118 CHECK_EQ(1, NonRedundantSize(move));
119 CHECK(Contains(move, Reg(0), ExplicitReg(1)));
120 }
121
122
100 TEST_F(MoveOptimizerTest, SplitsConstants) { 123 TEST_F(MoveOptimizerTest, SplitsConstants) {
101 StartBlock(); 124 StartBlock();
102 EndBlock(Last()); 125 EndBlock(Last());
103 126
104 auto gap = LastInstruction(); 127 auto gap = LastInstruction();
105 AddMove(gap, Const(1), Slot(0)); 128 AddMove(gap, Const(1), Slot(0));
106 AddMove(gap, Const(1), Slot(1)); 129 AddMove(gap, Const(1), Slot(1));
107 AddMove(gap, Const(1), Reg(0)); 130 AddMove(gap, Const(1), Reg(0));
108 AddMove(gap, Const(1), Slot(2)); 131 AddMove(gap, Const(1), Slot(2));
109 132
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 CHECK(gap_1->AreMovesRedundant()); 196 CHECK(gap_1->AreMovesRedundant());
174 auto move = last->parallel_moves()[0]; 197 auto move = last->parallel_moves()[0];
175 CHECK_EQ(2, NonRedundantSize(move)); 198 CHECK_EQ(2, NonRedundantSize(move));
176 CHECK(Contains(move, Reg(0), Reg(1))); 199 CHECK(Contains(move, Reg(0), Reg(1)));
177 CHECK(Contains(move, Reg(1), Reg(0))); 200 CHECK(Contains(move, Reg(1), Reg(0)));
178 } 201 }
179 202
180 } // namespace compiler 203 } // namespace compiler
181 } // namespace internal 204 } // namespace internal
182 } // namespace v8 205 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/instruction-sequence-unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698