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

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

Issue 893913004: [turbofan] push virtual register field down to InstructionOperand (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return node; 83 return node;
84 } 84 }
85 85
86 int NewInstr() { 86 int NewInstr() {
87 InstructionCode opcode = static_cast<InstructionCode>(110); 87 InstructionCode opcode = static_cast<InstructionCode>(110);
88 TestInstr* instr = TestInstr::New(zone(), opcode); 88 TestInstr* instr = TestInstr::New(zone(), opcode);
89 return code->AddInstruction(instr); 89 return code->AddInstruction(instr);
90 } 90 }
91 91
92 UnallocatedOperand* NewUnallocated(int vreg) { 92 UnallocatedOperand* NewUnallocated(int vreg) {
93 UnallocatedOperand* unallocated = 93 return new (zone()) UnallocatedOperand(UnallocatedOperand::ANY, vreg);
94 new (zone()) UnallocatedOperand(UnallocatedOperand::ANY);
95 unallocated->set_virtual_register(vreg);
96 return unallocated;
97 } 94 }
98 95
99 InstructionBlock* BlockAt(BasicBlock* block) { 96 InstructionBlock* BlockAt(BasicBlock* block) {
100 return code->InstructionBlockAt(block->GetRpoNumber()); 97 return code->InstructionBlockAt(block->GetRpoNumber());
101 } 98 }
102 BasicBlock* GetBasicBlock(int instruction_index) { 99 BasicBlock* GetBasicBlock(int instruction_index) {
103 const InstructionBlock* block = 100 const InstructionBlock* block =
104 code->GetInstructionBlock(instruction_index); 101 code->GetInstructionBlock(instruction_index);
105 return schedule.rpo_order()->at(block->rpo_number().ToSize()); 102 return schedule.rpo_order()->at(block->rpo_number().ToSize());
106 } 103 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 TEST(InstructionOperands) { 288 TEST(InstructionOperands) {
292 Zone zone; 289 Zone zone;
293 290
294 { 291 {
295 TestInstr* i = TestInstr::New(&zone, 101); 292 TestInstr* i = TestInstr::New(&zone, 101);
296 CHECK_EQ(0, static_cast<int>(i->OutputCount())); 293 CHECK_EQ(0, static_cast<int>(i->OutputCount()));
297 CHECK_EQ(0, static_cast<int>(i->InputCount())); 294 CHECK_EQ(0, static_cast<int>(i->InputCount()));
298 CHECK_EQ(0, static_cast<int>(i->TempCount())); 295 CHECK_EQ(0, static_cast<int>(i->TempCount()));
299 } 296 }
300 297
298 int vreg = 15;
301 InstructionOperand* outputs[] = { 299 InstructionOperand* outputs[] = {
302 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 300 new (&zone)
303 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 301 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
304 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 302 new (&zone)
305 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)}; 303 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
304 new (&zone)
305 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
306 new (&zone)
307 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg)};
306 308
307 InstructionOperand* inputs[] = { 309 InstructionOperand* inputs[] = {
308 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 310 new (&zone)
309 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 311 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
310 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 312 new (&zone)
311 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)}; 313 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
314 new (&zone)
315 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
316 new (&zone)
317 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg)};
312 318
313 InstructionOperand* temps[] = { 319 InstructionOperand* temps[] = {
314 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 320 new (&zone)
315 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 321 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
316 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), 322 new (&zone)
317 new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)}; 323 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
324 new (&zone)
325 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg),
326 new (&zone)
327 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, vreg)};
318 328
319 for (size_t i = 0; i < arraysize(outputs); i++) { 329 for (size_t i = 0; i < arraysize(outputs); i++) {
320 for (size_t j = 0; j < arraysize(inputs); j++) { 330 for (size_t j = 0; j < arraysize(inputs); j++) {
321 for (size_t k = 0; k < arraysize(temps); k++) { 331 for (size_t k = 0; k < arraysize(temps); k++) {
322 TestInstr* m = 332 TestInstr* m =
323 TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps); 333 TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps);
324 CHECK(i == m->OutputCount()); 334 CHECK(i == m->OutputCount());
325 CHECK(j == m->InputCount()); 335 CHECK(j == m->InputCount());
326 CHECK(k == m->TempCount()); 336 CHECK(k == m->TempCount());
327 337
328 for (size_t z = 0; z < i; z++) { 338 for (size_t z = 0; z < i; z++) {
329 CHECK(outputs[z]->Equals(m->OutputAt(z))); 339 CHECK(outputs[z]->Equals(m->OutputAt(z)));
330 } 340 }
331 341
332 for (size_t z = 0; z < j; z++) { 342 for (size_t z = 0; z < j; z++) {
333 CHECK(inputs[z]->Equals(m->InputAt(z))); 343 CHECK(inputs[z]->Equals(m->InputAt(z)));
334 } 344 }
335 345
336 for (size_t z = 0; z < k; z++) { 346 for (size_t z = 0; z < k; z++) {
337 CHECK(temps[z]->Equals(m->TempAt(z))); 347 CHECK(temps[z]->Equals(m->TempAt(z)));
338 } 348 }
339 } 349 }
340 } 350 }
341 } 351 }
342 } 352 }
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/unittests/compiler/instruction-sequence-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698