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

Side by Side Diff: test/cctest/compiler/test-instruction.cc

Issue 1041163002: [turbofan] smash GapInstruction into Instruction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: arm compile Created 5 years, 8 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
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/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/compiler/code-generator.h" 8 #include "src/compiler/code-generator.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 R.schedule.AddReturn(b0, R.Int32Constant(1)); 199 R.schedule.AddReturn(b0, R.Int32Constant(1));
200 200
201 R.allocCode(); 201 R.allocCode();
202 TestInstr* i0 = TestInstr::New(R.zone(), 100); 202 TestInstr* i0 = TestInstr::New(R.zone(), 100);
203 TestInstr* g = TestInstr::New(R.zone(), 103); 203 TestInstr* g = TestInstr::New(R.zone(), 103);
204 R.code->StartBlock(R.RpoFor(b0)); 204 R.code->StartBlock(R.RpoFor(b0));
205 R.code->AddInstruction(i0); 205 R.code->AddInstruction(i0);
206 R.code->AddInstruction(g); 206 R.code->AddInstruction(g);
207 R.code->EndBlock(R.RpoFor(b0)); 207 R.code->EndBlock(R.RpoFor(b0));
208 208
209 CHECK(R.code->instructions().size() == 4); 209 CHECK(R.code->instructions().size() == 2);
210 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
211 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
212 }
213 } 210 }
214 211
215 212
216 TEST(InstructionIsGapAt2) { 213 TEST(InstructionIsGapAt2) {
217 InstructionTester R; 214 InstructionTester R;
218 215
219 BasicBlock* b0 = R.schedule.start(); 216 BasicBlock* b0 = R.schedule.start();
220 BasicBlock* b1 = R.schedule.end(); 217 BasicBlock* b1 = R.schedule.end();
221 R.schedule.AddGoto(b0, b1); 218 R.schedule.AddGoto(b0, b1);
222 R.schedule.AddReturn(b1, R.Int32Constant(1)); 219 R.schedule.AddReturn(b1, R.Int32Constant(1));
223 220
224 R.allocCode(); 221 R.allocCode();
225 TestInstr* i0 = TestInstr::New(R.zone(), 100); 222 TestInstr* i0 = TestInstr::New(R.zone(), 100);
226 TestInstr* g = TestInstr::New(R.zone(), 103); 223 TestInstr* g = TestInstr::New(R.zone(), 103);
227 R.code->StartBlock(R.RpoFor(b0)); 224 R.code->StartBlock(R.RpoFor(b0));
228 R.code->AddInstruction(i0); 225 R.code->AddInstruction(i0);
229 R.code->AddInstruction(g); 226 R.code->AddInstruction(g);
230 R.code->EndBlock(R.RpoFor(b0)); 227 R.code->EndBlock(R.RpoFor(b0));
231 228
232 TestInstr* i1 = TestInstr::New(R.zone(), 102); 229 TestInstr* i1 = TestInstr::New(R.zone(), 102);
233 TestInstr* g1 = TestInstr::New(R.zone(), 104); 230 TestInstr* g1 = TestInstr::New(R.zone(), 104);
234 R.code->StartBlock(R.RpoFor(b1)); 231 R.code->StartBlock(R.RpoFor(b1));
235 R.code->AddInstruction(i1); 232 R.code->AddInstruction(i1);
236 R.code->AddInstruction(g1); 233 R.code->AddInstruction(g1);
237 R.code->EndBlock(R.RpoFor(b1)); 234 R.code->EndBlock(R.RpoFor(b1));
238 235
239 CHECK(R.code->instructions().size() == 8); 236 CHECK(R.code->instructions().size() == 4);
240 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
241 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
242 }
243 } 237 }
244 238
245 239
246 TEST(InstructionAddGapMove) { 240 TEST(InstructionAddGapMove) {
247 InstructionTester R; 241 InstructionTester R;
248 242
249 BasicBlock* b0 = R.schedule.start(); 243 BasicBlock* b0 = R.schedule.start();
250 R.schedule.AddReturn(b0, R.Int32Constant(1)); 244 R.schedule.AddReturn(b0, R.Int32Constant(1));
251 245
252 R.allocCode(); 246 R.allocCode();
253 TestInstr* i0 = TestInstr::New(R.zone(), 100); 247 TestInstr* i0 = TestInstr::New(R.zone(), 100);
254 TestInstr* g = TestInstr::New(R.zone(), 103); 248 TestInstr* g = TestInstr::New(R.zone(), 103);
255 R.code->StartBlock(R.RpoFor(b0)); 249 R.code->StartBlock(R.RpoFor(b0));
256 R.code->AddInstruction(i0); 250 R.code->AddInstruction(i0);
257 R.code->AddInstruction(g); 251 R.code->AddInstruction(g);
258 R.code->EndBlock(R.RpoFor(b0)); 252 R.code->EndBlock(R.RpoFor(b0));
259 253
260 CHECK(R.code->instructions().size() == 4); 254 CHECK(R.code->instructions().size() == 2);
261 for (size_t i = 0; i < R.code->instructions().size(); ++i) {
262 CHECK_EQ(i % 2 == 0, R.code->instructions()[i]->IsGapMoves());
263 }
264 255
265 int indexes[] = {0, 2, -1}; 256 int index = 0;
266 for (int i = 0; indexes[i] >= 0; i++) { 257 for (auto instr : R.code->instructions()) {
267 int index = indexes[i]; 258 UnallocatedOperand* op1 = R.NewUnallocated(index++);
268 259 UnallocatedOperand* op2 = R.NewUnallocated(index++);
269 UnallocatedOperand* op1 = R.NewUnallocated(index + 6); 260 instr->GetOrCreateParallelMove(TestInstr::START, R.zone())
270 UnallocatedOperand* op2 = R.NewUnallocated(index + 12); 261 ->AddMove(op1, op2, R.zone());
271 262 ParallelMove* move = instr->GetParallelMove(TestInstr::START);
272 R.code->AddGapMove(index, op1, op2);
273 GapInstruction* gap = R.code->GapAt(index);
274 ParallelMove* move = gap->GetParallelMove(GapInstruction::START);
275 CHECK(move); 263 CHECK(move);
276 const ZoneList<MoveOperands>* move_operands = move->move_operands(); 264 const ZoneList<MoveOperands>* move_operands = move->move_operands();
277 CHECK_EQ(1, move_operands->length()); 265 CHECK_EQ(1, move_operands->length());
278 MoveOperands* cur = &move_operands->at(0); 266 MoveOperands* cur = &move_operands->at(0);
279 CHECK_EQ(op1, cur->source()); 267 CHECK_EQ(op1, cur->source());
280 CHECK_EQ(op2, cur->destination()); 268 CHECK_EQ(op2, cur->destination());
281 } 269 }
282 } 270 }
283 271
284 272
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 CHECK(inputs[z].Equals(m->InputAt(z))); 316 CHECK(inputs[z].Equals(m->InputAt(z)));
329 } 317 }
330 318
331 for (size_t z = 0; z < k; z++) { 319 for (size_t z = 0; z < k; z++) {
332 CHECK(temps[z].Equals(m->TempAt(z))); 320 CHECK(temps[z].Equals(m->TempAt(z)));
333 } 321 }
334 } 322 }
335 } 323 }
336 } 324 }
337 } 325 }
OLDNEW
« no previous file with comments | « src/compiler/register-allocator-verifier.cc ('k') | test/cctest/compiler/test-jump-threading.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698