Add ImprovedOptimizingUnitTest::CreateParameters for subclasses
Subclasses of ImprovedOptimizingUnitTest might need a different number
of graph parameters. Currently only a parameter is defined and created.
This CL adds ImprovedOptimizingUnitTest::CreateParameters which
subclasses can override to create as many parameters as they need. All
created parameters are added to the entry basic block. The default
implementation of ImprovedOptimizingUnitTest::CreateParameters does
nothing.
Test: run-gtests.sh
Change-Id: I2c6a58232e36d3562fc2bc0cdc289dd739094a73
diff --git a/compiler/optimizing/select_generator_test.cc b/compiler/optimizing/select_generator_test.cc
index 6e65497..6e68c6c 100644
--- a/compiler/optimizing/select_generator_test.cc
+++ b/compiler/optimizing/select_generator_test.cc
@@ -25,6 +25,14 @@
namespace art {
class SelectGeneratorTest : public ImprovedOptimizingUnitTest {
+ private:
+ void CreateParameters() override {
+ parameters_.push_back(new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
+ dex::TypeIndex(0),
+ 0,
+ DataType::Type::kInt32));
+ }
+
public:
void ConstructBasicGraphForSelect(HInstruction* instr) {
HBasicBlock* if_block = new (GetAllocator()) HBasicBlock(graph_);
@@ -75,10 +83,10 @@
// HDivZeroCheck might throw and should not be hoisted from the conditional to an unconditional.
TEST_F(SelectGeneratorTest, testZeroCheck) {
InitGraph();
- HDivZeroCheck* instr = new (GetAllocator()) HDivZeroCheck(parameter_, 0);
+ HDivZeroCheck* instr = new (GetAllocator()) HDivZeroCheck(parameters_[0], 0);
ConstructBasicGraphForSelect(instr);
- ArenaVector<HInstruction*> current_locals({parameter_, graph_->GetIntConstant(1)},
+ ArenaVector<HInstruction*> current_locals({parameters_[0], graph_->GetIntConstant(1)},
GetAllocator()->Adapter(kArenaAllocInstruction));
ManuallyBuildEnvFor(instr, ¤t_locals);
@@ -88,7 +96,9 @@
// Test that SelectGenerator succeeds with HAdd.
TEST_F(SelectGeneratorTest, testAdd) {
InitGraph();
- HAdd* instr = new (GetAllocator()) HAdd(DataType::Type::kInt32, parameter_, parameter_, 0);
+ HAdd* instr = new (GetAllocator()) HAdd(DataType::Type::kInt32,
+ parameters_[0],
+ parameters_[0], 0);
ConstructBasicGraphForSelect(instr);
EXPECT_TRUE(CheckGraphAndTrySelectGenerator());
}