diff options
author | 2024-08-15 07:40:38 +0000 | |
---|---|---|
committer | 2024-08-21 09:12:50 +0000 | |
commit | c08fb725b561ead05dc120f2e92ea5228d14eec0 (patch) | |
tree | c306cd68d8f26a33b3c45e2f07db695dccc00e6e /compiler/optimizing/codegen_test.cc | |
parent | 1ea8807afeea6cd48127449cbd10458cc32cf4ce (diff) |
Change `MakeCondition()` to take `IfCondition`...
... instead of the instruction type argument.
And continue with loop construction cleanup in gtests.
Test: m test-art-host-gtest
Change-Id: I8cb83ae0c6d3cdb2a2ee4da0608cfeb69df722eb
Diffstat (limited to 'compiler/optimizing/codegen_test.cc')
-rw-r--r-- | compiler/optimizing/codegen_test.cc | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index e3366760ca..7365f0fb7f 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -424,7 +424,7 @@ TEST_F(CodegenTest, NonMaterializedCondition) { entry->AddSuccessor(first_block); HIntConstant* constant0 = graph->GetIntConstant(0); HIntConstant* constant1 = graph->GetIntConstant(1); - HEqual* equal = MakeCondition<HEqual>(first_block, constant0, constant0); + HInstruction* equal = MakeCondition(first_block, kCondEQ, constant0, constant0); MakeIf(first_block, equal); HBasicBlock* then_block = new (GetAllocator()) HBasicBlock(graph); @@ -491,7 +491,7 @@ TEST_F(CodegenTest, MaterializedCondition1) { HIntConstant* cst_lhs = graph->GetIntConstant(lhs[i]); HIntConstant* cst_rhs = graph->GetIntConstant(rhs[i]); - HInstruction* cmp_lt = MakeCondition<HLessThan>(code_block, cst_lhs, cst_rhs); + HInstruction* cmp_lt = MakeCondition(code_block, kCondLT, cst_lhs, cst_rhs); MakeReturn(code_block, cmp_lt); graph->BuildDominatorTree(); @@ -547,7 +547,7 @@ TEST_F(CodegenTest, MaterializedCondition2) { HIntConstant* cst_lhs = graph->GetIntConstant(lhs[i]); HIntConstant* cst_rhs = graph->GetIntConstant(rhs[i]); - HInstruction* cmp_lt = MakeCondition<HLessThan>(if_block, cst_lhs, cst_rhs); + HInstruction* cmp_lt = MakeCondition(if_block, kCondLT, cst_lhs, cst_rhs); // We insert a fake instruction to separate the HIf from the HLessThan // and force the materialization of the condition. HInstruction* force_materialization = @@ -599,87 +599,61 @@ void CodegenTest::TestComparison(IfCondition condition, int64_t j, DataType::Type type, const CodegenTargetConfig target_config) { - HGraph* graph = CreateGraph(); - - HBasicBlock* entry_block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(entry_block); - graph->SetEntryBlock(entry_block); - MakeGoto(entry_block); - - HBasicBlock* block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(block); - - HBasicBlock* exit_block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(exit_block); - graph->SetExitBlock(exit_block); - MakeExit(exit_block); - - entry_block->AddSuccessor(block); - block->AddSuccessor(exit_block); + HBasicBlock* block = InitEntryMainExitGraph(); HInstruction* op1; HInstruction* op2; if (type == DataType::Type::kInt32) { - op1 = graph->GetIntConstant(i); - op2 = graph->GetIntConstant(j); + op1 = graph_->GetIntConstant(i); + op2 = graph_->GetIntConstant(j); } else { DCHECK_EQ(type, DataType::Type::kInt64); - op1 = graph->GetLongConstant(i); - op2 = graph->GetLongConstant(j); + op1 = graph_->GetLongConstant(i); + op2 = graph_->GetLongConstant(j); } - HInstruction* comparison = nullptr; bool expected_result = false; const uint64_t x = i; const uint64_t y = j; switch (condition) { case kCondEQ: - comparison = MakeCondition<HEqual>(block, op1, op2); expected_result = (i == j); break; case kCondNE: - comparison = MakeCondition<HNotEqual>(block, op1, op2); expected_result = (i != j); break; case kCondLT: - comparison = MakeCondition<HLessThan>(block, op1, op2); expected_result = (i < j); break; case kCondLE: - comparison = MakeCondition<HLessThanOrEqual>(block, op1, op2); expected_result = (i <= j); break; case kCondGT: - comparison = MakeCondition<HGreaterThan>(block, op1, op2); expected_result = (i > j); break; case kCondGE: - comparison = MakeCondition<HGreaterThanOrEqual>(block, op1, op2); expected_result = (i >= j); break; case kCondB: - comparison = MakeCondition<HBelow>(block, op1, op2); expected_result = (x < y); break; case kCondBE: - comparison = MakeCondition<HBelowOrEqual>(block, op1, op2); expected_result = (x <= y); break; case kCondA: - comparison = MakeCondition<HAbove>(block, op1, op2); expected_result = (x > y); break; case kCondAE: - comparison = MakeCondition<HAboveOrEqual>(block, op1, op2); expected_result = (x >= y); break; } + HInstruction* comparison = MakeCondition(block, condition, op1, op2); MakeReturn(block, comparison); - graph->BuildDominatorTree(); + graph_->BuildDominatorTree(); std::unique_ptr<CompilerOptions> compiler_options = CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default"); - RunCode(target_config, *compiler_options, graph, [](HGraph*) {}, true, expected_result); + RunCode(target_config, *compiler_options, graph_, [](HGraph*) {}, true, expected_result); } TEST_F(CodegenTest, ComparisonsInt) { |