summaryrefslogtreecommitdiff
path: root/compiler/common_compiler_test.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2018-06-25 09:32:54 +0100
committerVladimir Marko <vmarko@google.com>2018-06-25 18:43:19 +0100
commita043111e3a2c09b549708a6227a1f54d91da76aa (patch)
tree393fe11cfceccebf474e4bdf36ff79b70b97f589 /compiler/common_compiler_test.cc
parent213ee2da6a1c58d0fc12c937bbd9c9974ca00aca (diff)
Move instruction_set_ to CompilerOptions.
Removes CompilerDriver dependency from ImageWriter and several other classes. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: m test-art-target-gtest Test: testrunner.py --target --optimizing Change-Id: I3c5b8ff73732128b9c4fad9405231a216ea72465
Diffstat (limited to 'compiler/common_compiler_test.cc')
-rw-r--r--compiler/common_compiler_test.cc56
1 files changed, 38 insertions, 18 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 52c767f935..22720ce524 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -153,11 +153,7 @@ void CommonCompilerTest::SetUp() {
{
ScopedObjectAccess soa(Thread::Current());
- const InstructionSet instruction_set = kRuntimeISA;
- // Take the default set of instruction features from the build.
- instruction_set_features_ = InstructionSetFeatures::FromCppDefines();
-
- runtime_->SetInstructionSet(instruction_set);
+ runtime_->SetInstructionSet(instruction_set_);
for (uint32_t i = 0; i < static_cast<uint32_t>(CalleeSaveType::kLastCalleeSaveType); ++i) {
CalleeSaveType type = CalleeSaveType(i);
if (!runtime_->HasCalleeSaveMethod(type)) {
@@ -165,23 +161,48 @@ void CommonCompilerTest::SetUp() {
}
}
- CreateCompilerDriver(compiler_kind_, instruction_set);
+ CreateCompilerDriver();
+ }
+}
+
+void CommonCompilerTest::ApplyInstructionSet() {
+ // Copy local instruction_set_ and instruction_set_features_ to *compiler_options_;
+ CHECK(instruction_set_features_ != nullptr);
+ if (instruction_set_ == InstructionSet::kThumb2) {
+ CHECK_EQ(InstructionSet::kArm, instruction_set_features_->GetInstructionSet());
+ } else {
+ CHECK_EQ(instruction_set_, instruction_set_features_->GetInstructionSet());
}
+ compiler_options_->instruction_set_ = instruction_set_;
+ compiler_options_->instruction_set_features_ =
+ InstructionSetFeatures::FromBitmap(instruction_set_, instruction_set_features_->AsBitmap());
+ CHECK(compiler_options_->instruction_set_features_->Equals(instruction_set_features_.get()));
}
-void CommonCompilerTest::CreateCompilerDriver(Compiler::Kind kind,
- InstructionSet isa,
- size_t number_of_threads) {
+void CommonCompilerTest::OverrideInstructionSetFeatures(InstructionSet instruction_set,
+ const std::string& variant) {
+ instruction_set_ = instruction_set;
+ std::string error_msg;
+ instruction_set_features_ =
+ InstructionSetFeatures::FromVariant(instruction_set, variant, &error_msg);
+ CHECK(instruction_set_features_ != nullptr) << error_msg;
+
+ if (compiler_options_ != nullptr) {
+ ApplyInstructionSet();
+ }
+}
+
+void CommonCompilerTest::CreateCompilerDriver() {
+ ApplyInstructionSet();
+
compiler_options_->boot_image_ = true;
compiler_options_->SetCompilerFilter(GetCompilerFilter());
compiler_options_->image_classes_.swap(*GetImageClasses());
compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
verification_results_.get(),
- kind,
- isa,
- instruction_set_features_.get(),
+ compiler_kind_,
&compiler_options_->image_classes_,
- number_of_threads,
+ number_of_threads_,
/* swap_fd */ -1,
GetProfileCompilationInfo()));
// We typically don't generate an image in unit tests, disable this optimization by default.
@@ -207,11 +228,6 @@ void CommonCompilerTest::SetCompilerKind(Compiler::Kind compiler_kind) {
compiler_kind_ = compiler_kind;
}
-InstructionSet CommonCompilerTest::GetInstructionSet() const {
- DCHECK(compiler_driver_.get() != nullptr);
- return compiler_driver_->GetInstructionSet();
-}
-
void CommonCompilerTest::TearDown() {
compiler_driver_.reset();
callbacks_.reset();
@@ -339,4 +355,8 @@ void CommonCompilerTest::SetDexFilesForOatFile(const std::vector<const DexFile*>
compiler_driver_->dex_to_dex_compiler_.SetDexFiles(dex_files);
}
+void CommonCompilerTest::ClearBootImageOption() {
+ compiler_options_->boot_image_ = false;
+}
+
} // namespace art