| 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/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 schedule.AddNode(block, node); | 76 schedule.AddNode(block, node); |
| 77 return node; | 77 return node; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int NewInstr() { | 80 int NewInstr() { |
| 81 InstructionCode opcode = static_cast<InstructionCode>(110); | 81 InstructionCode opcode = static_cast<InstructionCode>(110); |
| 82 TestInstr* instr = TestInstr::New(zone(), opcode); | 82 TestInstr* instr = TestInstr::New(zone(), opcode); |
| 83 return code->AddInstruction(instr); | 83 return code->AddInstruction(instr); |
| 84 } | 84 } |
| 85 | 85 |
| 86 UnallocatedOperand* NewUnallocated(int vreg) { | 86 UnallocatedOperand Unallocated(int vreg) { |
| 87 return UnallocatedOperand(UnallocatedOperand::ANY, vreg).Copy(zone()); | 87 return UnallocatedOperand(UnallocatedOperand::ANY, vreg); |
| 88 } | 88 } |
| 89 | 89 |
| 90 RpoNumber RpoFor(BasicBlock* block) { | 90 RpoNumber RpoFor(BasicBlock* block) { |
| 91 return RpoNumber::FromInt(block->rpo_number()); | 91 return RpoNumber::FromInt(block->rpo_number()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 InstructionBlock* BlockAt(BasicBlock* block) { | 94 InstructionBlock* BlockAt(BasicBlock* block) { |
| 95 return code->InstructionBlockAt(RpoFor(block)); | 95 return code->InstructionBlockAt(RpoFor(block)); |
| 96 } | 96 } |
| 97 BasicBlock* GetBasicBlock(int instruction_index) { | 97 BasicBlock* GetBasicBlock(int instruction_index) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 TestInstr* g = TestInstr::New(R.zone(), 103); | 248 TestInstr* g = TestInstr::New(R.zone(), 103); |
| 249 R.code->StartBlock(R.RpoFor(b0)); | 249 R.code->StartBlock(R.RpoFor(b0)); |
| 250 R.code->AddInstruction(i0); | 250 R.code->AddInstruction(i0); |
| 251 R.code->AddInstruction(g); | 251 R.code->AddInstruction(g); |
| 252 R.code->EndBlock(R.RpoFor(b0)); | 252 R.code->EndBlock(R.RpoFor(b0)); |
| 253 | 253 |
| 254 CHECK(R.code->instructions().size() == 2); | 254 CHECK(R.code->instructions().size() == 2); |
| 255 | 255 |
| 256 int index = 0; | 256 int index = 0; |
| 257 for (auto instr : R.code->instructions()) { | 257 for (auto instr : R.code->instructions()) { |
| 258 UnallocatedOperand* op1 = R.NewUnallocated(index++); | 258 UnallocatedOperand op1 = R.Unallocated(index++); |
| 259 UnallocatedOperand* op2 = R.NewUnallocated(index++); | 259 UnallocatedOperand op2 = R.Unallocated(index++); |
| 260 instr->GetOrCreateParallelMove(TestInstr::START, R.zone()) | 260 instr->GetOrCreateParallelMove(TestInstr::START, R.zone()) |
| 261 ->AddMove(op1, op2, R.zone()); | 261 ->AddMove(op1, op2); |
| 262 ParallelMove* move = instr->GetParallelMove(TestInstr::START); | 262 ParallelMove* move = instr->GetParallelMove(TestInstr::START); |
| 263 CHECK(move); | 263 CHECK(move); |
| 264 const ZoneList<MoveOperands>* move_operands = move->move_operands(); | 264 CHECK_EQ(1u, move->size()); |
| 265 CHECK_EQ(1, move_operands->length()); | 265 MoveOperands* cur = move->at(0); |
| 266 MoveOperands* cur = &move_operands->at(0); | 266 CHECK(op1 == cur->source()); |
| 267 CHECK_EQ(op1, cur->source()); | 267 CHECK(op2 == cur->destination()); |
| 268 CHECK_EQ(op2, cur->destination()); | |
| 269 } | 268 } |
| 270 } | 269 } |
| 271 | 270 |
| 272 | 271 |
| 273 TEST(InstructionOperands) { | 272 TEST(InstructionOperands) { |
| 274 Zone zone; | 273 Zone zone; |
| 275 | 274 |
| 276 { | 275 { |
| 277 TestInstr* i = TestInstr::New(&zone, 101); | 276 TestInstr* i = TestInstr::New(&zone, 101); |
| 278 CHECK_EQ(0, static_cast<int>(i->OutputCount())); | 277 CHECK_EQ(0, static_cast<int>(i->OutputCount())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 302 for (size_t i = 0; i < arraysize(outputs); i++) { | 301 for (size_t i = 0; i < arraysize(outputs); i++) { |
| 303 for (size_t j = 0; j < arraysize(inputs); j++) { | 302 for (size_t j = 0; j < arraysize(inputs); j++) { |
| 304 for (size_t k = 0; k < arraysize(temps); k++) { | 303 for (size_t k = 0; k < arraysize(temps); k++) { |
| 305 TestInstr* m = | 304 TestInstr* m = |
| 306 TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps); | 305 TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps); |
| 307 CHECK(i == m->OutputCount()); | 306 CHECK(i == m->OutputCount()); |
| 308 CHECK(j == m->InputCount()); | 307 CHECK(j == m->InputCount()); |
| 309 CHECK(k == m->TempCount()); | 308 CHECK(k == m->TempCount()); |
| 310 | 309 |
| 311 for (size_t z = 0; z < i; z++) { | 310 for (size_t z = 0; z < i; z++) { |
| 312 CHECK(outputs[z].Equals(m->OutputAt(z))); | 311 CHECK(outputs[z] == *m->OutputAt(z)); |
| 313 } | 312 } |
| 314 | 313 |
| 315 for (size_t z = 0; z < j; z++) { | 314 for (size_t z = 0; z < j; z++) { |
| 316 CHECK(inputs[z].Equals(m->InputAt(z))); | 315 CHECK(inputs[z] == *m->InputAt(z)); |
| 317 } | 316 } |
| 318 | 317 |
| 319 for (size_t z = 0; z < k; z++) { | 318 for (size_t z = 0; z < k; z++) { |
| 320 CHECK(temps[z].Equals(m->TempAt(z))); | 319 CHECK(temps[z] == *m->TempAt(z)); |
| 321 } | 320 } |
| 322 } | 321 } |
| 323 } | 322 } |
| 324 } | 323 } |
| 325 } | 324 } |
| OLD | NEW |