diff options
author | 2024-08-06 07:54:26 +0000 | |
---|---|---|
committer | 2024-08-12 14:00:38 +0000 | |
commit | 4018a7d772fc09c7955eb4c88eea788be5cc2143 (patch) | |
tree | 45ebb2078a2ad1c5d61cfcb76a4585ab84159ef1 /compiler/optimizing/graph_test.cc | |
parent | bed0b477e8f55d57cf100c585eb6d5838c9ffcee (diff) |
ART: Clean up HIR construction in gtests.
Make `OptimizingUnitTestHelper::Make*()` functions add the
the new instruction to the block. If the block already ends
with a control flow instruction, the new instruction is
inserted before the control flow instruction (some tests
create the control flow before adding instruction). Add new
helper functions for additional instruction types, rename
and clean up existing helpers.
Test: m test-art-host-gtest
Change-Id: I0bb88bc4d2ff6ce98ddbec25990a1ae68f582042
Diffstat (limited to 'compiler/optimizing/graph_test.cc')
-rw-r--r-- | compiler/optimizing/graph_test.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/optimizing/graph_test.cc b/compiler/optimizing/graph_test.cc index b5d712736f..46c93aff84 100644 --- a/compiler/optimizing/graph_test.cc +++ b/compiler/optimizing/graph_test.cc @@ -38,18 +38,15 @@ HBasicBlock* GraphTest::CreateIfBlock(HGraph* graph) { HBasicBlock* if_block = new (GetAllocator()) HBasicBlock(graph); graph->AddBlock(if_block); HInstruction* instr = graph->GetIntConstant(4); - HInstruction* equal = new (GetAllocator()) HEqual(instr, instr); - if_block->AddInstruction(equal); - instr = new (GetAllocator()) HIf(equal); - if_block->AddInstruction(instr); + HInstruction* equal = MakeCondition<HEqual>(if_block, instr, instr); + MakeIf(if_block, equal); return if_block; } HBasicBlock* GraphTest::CreateGotoBlock(HGraph* graph) { HBasicBlock* block = new (GetAllocator()) HBasicBlock(graph); graph->AddBlock(block); - HInstruction* got = new (GetAllocator()) HGoto(); - block->AddInstruction(got); + MakeGoto(block); return block; } @@ -70,8 +67,7 @@ HBasicBlock* GraphTest::CreateReturnBlock(HGraph* graph) { HBasicBlock* GraphTest::CreateExitBlock(HGraph* graph) { HBasicBlock* block = new (GetAllocator()) HBasicBlock(graph); graph->AddBlock(block); - HInstruction* exit_instr = new (GetAllocator()) HExit(); - block->AddInstruction(exit_instr); + MakeExit(block); return block; } |