From 4018a7d772fc09c7955eb4c88eea788be5cc2143 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 6 Aug 2024 07:54:26 +0000 Subject: 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 --- compiler/optimizing/graph_test.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'compiler/optimizing/graph_test.cc') 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(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; } -- cgit v1.2.3-59-g8ed1b