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/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/compiler/pipeline.h" | 6 #include "src/compiler/pipeline.h" |
7 #include "test/unittests/compiler/instruction-sequence-unittest.h" | 7 #include "test/unittests/compiler/instruction-sequence-unittest.h" |
8 #include "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 block_returns_ = true; | 148 block_returns_ = true; |
149 InstructionOperand inputs[1]{ConvertInputOp(input_op_0)}; | 149 InstructionOperand inputs[1]{ConvertInputOp(input_op_0)}; |
150 return Emit(NewIndex(), kArchRet, 0, nullptr, 1, inputs); | 150 return Emit(NewIndex(), kArchRet, 0, nullptr, 1, inputs); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 PhiInstruction* InstructionSequenceTest::Phi(VReg incoming_vreg_0, | 154 PhiInstruction* InstructionSequenceTest::Phi(VReg incoming_vreg_0, |
155 VReg incoming_vreg_1, | 155 VReg incoming_vreg_1, |
156 VReg incoming_vreg_2, | 156 VReg incoming_vreg_2, |
157 VReg incoming_vreg_3) { | 157 VReg incoming_vreg_3) { |
158 auto phi = new (zone()) PhiInstruction(zone(), NewReg().value_, 10); | |
159 VReg inputs[] = {incoming_vreg_0, incoming_vreg_1, incoming_vreg_2, | 158 VReg inputs[] = {incoming_vreg_0, incoming_vreg_1, incoming_vreg_2, |
160 incoming_vreg_3}; | 159 incoming_vreg_3}; |
161 for (size_t i = 0; i < arraysize(inputs); ++i) { | 160 size_t input_count = 0; |
162 if (inputs[i].value_ == kNoValue) break; | 161 for (; input_count < arraysize(inputs); ++input_count) { |
163 Extend(phi, inputs[i]); | 162 if (inputs[input_count].value_ == kNoValue) break; |
| 163 } |
| 164 CHECK(input_count > 0); |
| 165 auto phi = new (zone()) PhiInstruction(zone(), NewReg().value_, input_count); |
| 166 for (size_t i = 0; i < input_count; ++i) { |
| 167 SetInput(phi, i, inputs[i]); |
164 } | 168 } |
165 current_block_->AddPhi(phi); | 169 current_block_->AddPhi(phi); |
166 return phi; | 170 return phi; |
167 } | 171 } |
168 | 172 |
169 | 173 |
170 void InstructionSequenceTest::Extend(PhiInstruction* phi, VReg vreg) { | 174 PhiInstruction* InstructionSequenceTest::Phi(VReg incoming_vreg_0, |
171 phi->Extend(zone(), vreg.value_); | 175 size_t input_count) { |
| 176 auto phi = new (zone()) PhiInstruction(zone(), NewReg().value_, input_count); |
| 177 SetInput(phi, 0, incoming_vreg_0); |
| 178 current_block_->AddPhi(phi); |
| 179 return phi; |
172 } | 180 } |
173 | 181 |
174 | 182 |
| 183 void InstructionSequenceTest::SetInput(PhiInstruction* phi, size_t input, |
| 184 VReg vreg) { |
| 185 CHECK(vreg.value_ != kNoValue); |
| 186 phi->SetInput(input, vreg.value_); |
| 187 } |
| 188 |
| 189 |
175 InstructionSequenceTest::VReg InstructionSequenceTest::DefineConstant( | 190 InstructionSequenceTest::VReg InstructionSequenceTest::DefineConstant( |
176 int32_t imm) { | 191 int32_t imm) { |
177 VReg vreg = NewReg(); | 192 VReg vreg = NewReg(); |
178 sequence()->AddConstant(vreg.value_, Constant(imm)); | 193 sequence()->AddConstant(vreg.value_, Constant(imm)); |
179 InstructionOperand outputs[1]{ConstantOperand(vreg.value_)}; | 194 InstructionOperand outputs[1]{ConstantOperand(vreg.value_)}; |
180 Emit(vreg.value_, kArchNop, 1, outputs); | 195 Emit(vreg.value_, kArchNop, 1, outputs); |
181 return vreg; | 196 return vreg; |
182 } | 197 } |
183 | 198 |
184 | 199 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 473 |
459 int InstructionSequenceTest::AddInstruction(int instruction_index, | 474 int InstructionSequenceTest::AddInstruction(int instruction_index, |
460 Instruction* instruction) { | 475 Instruction* instruction) { |
461 sequence()->AddInstruction(instruction); | 476 sequence()->AddInstruction(instruction); |
462 return instruction_index; | 477 return instruction_index; |
463 } | 478 } |
464 | 479 |
465 } // namespace compiler | 480 } // namespace compiler |
466 } // namespace internal | 481 } // namespace internal |
467 } // namespace v8 | 482 } // namespace v8 |
OLD | NEW |