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

Unified Diff: test/unittests/compiler/instruction-sequence-unittest.cc

Issue 800493002: [turbofan] improve register allocator testing framework (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler/instruction-sequence-unittest.cc
diff --git a/test/unittests/compiler/instruction-sequence-unittest.cc b/test/unittests/compiler/instruction-sequence-unittest.cc
index 05d3d0ae14a497f9bcbb3706a8d5b45909488a82..6f1ac94caacb17f4173d8f04e93bdd63d86ae365 100644
--- a/test/unittests/compiler/instruction-sequence-unittest.cc
+++ b/test/unittests/compiler/instruction-sequence-unittest.cc
@@ -184,30 +184,46 @@ InstructionSequenceTest::VReg InstructionSequenceTest::DefineConstant(
int InstructionSequenceTest::EmitNop() { return Emit(NewIndex(), kArchNop); }
-int InstructionSequenceTest::EmitI(TestOperand input_op_0) {
- InstructionOperand* inputs[1]{ConvertInputOp(input_op_0)};
- return Emit(NewIndex(), kArchNop, 0, nullptr, 1, inputs);
+static size_t CountInputs(size_t size,
+ InstructionSequenceTest::TestOperand* inputs) {
+ size_t i = 0;
+ for (; i < size; ++i) {
+ if (inputs[i].type_ == InstructionSequenceTest::kInvalid) break;
+ }
+ return i;
+}
+
+
+int InstructionSequenceTest::EmitI(size_t input_size, TestOperand* inputs) {
+ InstructionOperand** mapped_inputs = ConvertInputs(input_size, inputs);
+ return Emit(NewIndex(), kArchNop, 0, nullptr, input_size, mapped_inputs);
+}
+
+
+int InstructionSequenceTest::EmitI(TestOperand input_op_0,
+ TestOperand input_op_1,
+ TestOperand input_op_2,
+ TestOperand input_op_3) {
+ TestOperand inputs[] = {input_op_0, input_op_1, input_op_2, input_op_3};
+ return EmitI(CountInputs(arraysize(inputs), inputs), inputs);
}
InstructionSequenceTest::VReg InstructionSequenceTest::EmitOI(
- TestOperand output_op, TestOperand input_op_0) {
+ TestOperand output_op, size_t input_size, TestOperand* inputs) {
VReg output_vreg = NewReg();
InstructionOperand* outputs[1]{ConvertOutputOp(output_vreg, output_op)};
- InstructionOperand* inputs[1]{ConvertInputOp(input_op_0)};
- Emit(output_vreg.value_, kArchNop, 1, outputs, 1, inputs);
+ InstructionOperand** mapped_inputs = ConvertInputs(input_size, inputs);
+ Emit(output_vreg.value_, kArchNop, 1, outputs, input_size, mapped_inputs);
return output_vreg;
}
-InstructionSequenceTest::VReg InstructionSequenceTest::EmitOII(
- TestOperand output_op, TestOperand input_op_0, TestOperand input_op_1) {
- VReg output_vreg = NewReg();
- InstructionOperand* outputs[1]{ConvertOutputOp(output_vreg, output_op)};
- InstructionOperand* inputs[2]{ConvertInputOp(input_op_0),
- ConvertInputOp(input_op_1)};
- Emit(output_vreg.value_, kArchNop, 1, outputs, 2, inputs);
- return output_vreg;
+InstructionSequenceTest::VReg InstructionSequenceTest::EmitOI(
+ TestOperand output_op, TestOperand input_op_0, TestOperand input_op_1,
+ TestOperand input_op_2, TestOperand input_op_3) {
+ TestOperand inputs[] = {input_op_0, input_op_1, input_op_2, input_op_3};
+ return EmitOI(output_op, CountInputs(arraysize(inputs), inputs), inputs);
}
@@ -216,11 +232,7 @@ InstructionSequenceTest::VReg InstructionSequenceTest::EmitCall(
VReg output_vreg = NewReg();
InstructionOperand* outputs[1]{ConvertOutputOp(output_vreg, output_op)};
CHECK(UnallocatedOperand::cast(outputs[0])->HasFixedPolicy());
- InstructionOperand** mapped_inputs =
- zone()->NewArray<InstructionOperand*>(static_cast<int>(input_size));
- for (size_t i = 0; i < input_size; ++i) {
- mapped_inputs[i] = ConvertInputOp(inputs[i]);
- }
+ InstructionOperand** mapped_inputs = ConvertInputs(input_size, inputs);
Emit(output_vreg.value_, kArchCallCodeObject, 1, outputs, input_size,
mapped_inputs, 0, nullptr, true);
return output_vreg;
@@ -231,11 +243,7 @@ InstructionSequenceTest::VReg InstructionSequenceTest::EmitCall(
TestOperand output_op, TestOperand input_op_0, TestOperand input_op_1,
TestOperand input_op_2, TestOperand input_op_3) {
TestOperand inputs[] = {input_op_0, input_op_1, input_op_2, input_op_3};
- size_t size = 0;
- for (; size < arraysize(inputs); ++size) {
- if (inputs[size].type_ == kInvalid) break;
- }
- return EmitCall(output_op, size, inputs);
+ return EmitCall(output_op, CountInputs(arraysize(inputs), inputs), inputs);
}
@@ -315,6 +323,17 @@ InstructionOperand* InstructionSequenceTest::Unallocated(
}
+InstructionOperand** InstructionSequenceTest::ConvertInputs(
+ size_t input_size, TestOperand* inputs) {
+ InstructionOperand** mapped_inputs =
+ zone()->NewArray<InstructionOperand*>(static_cast<int>(input_size));
+ for (size_t i = 0; i < input_size; ++i) {
+ mapped_inputs[i] = ConvertInputOp(inputs[i]);
+ }
+ return mapped_inputs;
+}
+
+
InstructionOperand* InstructionSequenceTest::ConvertInputOp(TestOperand op) {
if (op.type_ == kImmediate) {
CHECK_EQ(op.vreg_.value_, kNoValue);
@@ -325,6 +344,10 @@ InstructionOperand* InstructionSequenceTest::ConvertInputOp(TestOperand op) {
case kNone:
return Unallocated(op, UnallocatedOperand::NONE,
UnallocatedOperand::USED_AT_START);
+ case kUnique:
+ return Unallocated(op, UnallocatedOperand::NONE);
+ case kUniqueRegister:
+ return Unallocated(op, UnallocatedOperand::MUST_HAVE_REGISTER);
case kRegister:
return Unallocated(op, UnallocatedOperand::MUST_HAVE_REGISTER,
UnallocatedOperand::USED_AT_START);
« no previous file with comments | « test/unittests/compiler/instruction-sequence-unittest.h ('k') | test/unittests/compiler/register-allocator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698