ART: Make InstructionSet an enum class and add kLast.
Adding InstructionSet::kLast shall make it easier to encode
the InstructionSet in fewer bits using BitField<>. However,
introducing `kLast` into the `art` namespace is not a good
idea, so we change the InstructionSet to an enum class.
This also uncovered a case of InstructionSet::kNone being
erroneously used instead of vixl32::Condition::None(), so
it's good to remove `kNone` from the `art` namespace.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I6fa6168dfba4ed6da86d021a69c80224f09997a6
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 1cd9142..46474d2 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -589,7 +589,7 @@
public:
explicit Dex2Oat(TimingLogger* timings) :
compiler_kind_(Compiler::kOptimizing),
- instruction_set_(kRuntimeISA == kArm ? kThumb2 : kRuntimeISA),
+ instruction_set_(kRuntimeISA == InstructionSet::kArm ? InstructionSet::kThumb2 : kRuntimeISA),
// Take the default set of instruction features from the build.
image_file_location_oat_checksum_(0),
image_file_location_oat_data_begin_(0),
@@ -893,13 +893,13 @@
// Checks are all explicit until we know the architecture.
// Set the compilation target's implicit checks options.
switch (instruction_set_) {
- case kArm:
- case kThumb2:
- case kArm64:
- case kX86:
- case kX86_64:
- case kMips:
- case kMips64:
+ case InstructionSet::kArm:
+ case InstructionSet::kThumb2:
+ case InstructionSet::kArm64:
+ case InstructionSet::kX86:
+ case InstructionSet::kX86_64:
+ case InstructionSet::kMips:
+ case InstructionSet::kMips64:
compiler_options_->implicit_null_checks_ = true;
compiler_options_->implicit_so_checks_ = true;
break;
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index 3606c61..2cf0701 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -27,7 +27,7 @@
struct CmdlineType<InstructionSet> : CmdlineTypeParser<InstructionSet> {
Result Parse(const std::string& option) {
InstructionSet set = GetInstructionSetFromString(option.c_str());
- if (set == kNone) {
+ if (set == InstructionSet::kNone) {
return Result::Failure(std::string("Not a valid instruction set: '") + option + "'");
}
return Result::Success(set);
diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc
index 93f5a1d..b139a12 100644
--- a/dex2oat/linker/elf_writer_quick.cc
+++ b/dex2oat/linker/elf_writer_quick.cc
@@ -227,7 +227,8 @@
if (bss_size_ != 0u) {
builder_->GetBss()->WriteNoBitsSection(bss_size_);
}
- if (builder_->GetIsa() == kMips || builder_->GetIsa() == kMips64) {
+ if (builder_->GetIsa() == InstructionSet::kMips ||
+ builder_->GetIsa() == InstructionSet::kMips64) {
builder_->WriteMIPSabiflagsSection();
}
builder_->WriteDynamicSection();
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index 3efebfd..1ee2e4e 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -392,7 +392,7 @@
// TODO: make selectable.
Compiler::Kind compiler_kind = Compiler::kQuick;
- InstructionSet insn_set = kIsTargetBuild ? kThumb2 : kX86;
+ InstructionSet insn_set = kIsTargetBuild ? InstructionSet::kThumb2 : InstructionSet::kX86;
std::string error_msg;
SetupCompiler(compiler_kind, insn_set, std::vector<std::string>(), /*out*/ &error_msg);
@@ -491,7 +491,7 @@
}
TEST_F(OatTest, OatHeaderIsValid) {
- InstructionSet insn_set = kX86;
+ InstructionSet insn_set = InstructionSet::kX86;
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> insn_features(
InstructionSetFeatures::FromVariant(insn_set, "default", &error_msg));
@@ -516,7 +516,7 @@
// TODO: make selectable.
Compiler::Kind compiler_kind = Compiler::kQuick;
InstructionSet insn_set = kRuntimeISA;
- if (insn_set == kArm) insn_set = kThumb2;
+ if (insn_set == InstructionSet::kArm) insn_set = InstructionSet::kThumb2;
std::string error_msg;
std::vector<std::string> compiler_options;
compiler_options.push_back("--compiler-filter=extract");
@@ -844,7 +844,7 @@
}
TEST_F(OatTest, UpdateChecksum) {
- InstructionSet insn_set = kX86;
+ InstructionSet insn_set = InstructionSet::kX86;
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> insn_features(
InstructionSetFeatures::FromVariant(insn_set, "default", &error_msg));