X86: Add sandybridge microarchitecture
ART was not aware of sandybridge CPU featureset, so it turned off all
features (ISA: X86 Feature string: -ssse3,-sse4.1,-sse4.2,-avx,-avx2,
-popcnt). Meanwhile, the Android build does turn on the corresponding
compiler flags (ISA: X86 Feature string: ssse3,sse4.1,sse4.2,-avx,
-avx2,popcnt). This change adds "sandybridge" to the relevant lists so
it can detect the features correctly.
Bug: 62389235
Test: Android runs on Chromebooks
Test: m test-art-host-gtest-instruction_set_features_x86_test
(cherry picked from commit 702e27249893104230f826b82b7a3723ec3b7240)
Change-Id: Ie47aed190ac83b35b6d3994d703c463c9efd5e25
diff --git a/runtime/arch/x86/instruction_set_features_x86.cc b/runtime/arch/x86/instruction_set_features_x86.cc
index 5788122..cc0bdf2 100644
--- a/runtime/arch/x86/instruction_set_features_x86.cc
+++ b/runtime/arch/x86/instruction_set_features_x86.cc
@@ -33,23 +33,28 @@
static constexpr const char* x86_known_variants[] = {
"atom",
+ "sandybridge",
"silvermont",
};
static constexpr const char* x86_variants_with_ssse3[] = {
"atom",
+ "sandybridge",
"silvermont",
};
static constexpr const char* x86_variants_with_sse4_1[] = {
+ "sandybridge",
"silvermont",
};
static constexpr const char* x86_variants_with_sse4_2[] = {
+ "sandybridge",
"silvermont",
};
static constexpr const char* x86_variants_with_popcnt[] = {
+ "sandybridge",
"silvermont",
};
diff --git a/runtime/arch/x86/instruction_set_features_x86_test.cc b/runtime/arch/x86/instruction_set_features_x86_test.cc
index 7e6ad3e..c67b4dd 100644
--- a/runtime/arch/x86/instruction_set_features_x86_test.cc
+++ b/runtime/arch/x86/instruction_set_features_x86_test.cc
@@ -69,6 +69,43 @@
EXPECT_FALSE(x86_features->Equals(x86_default_features.get()));
}
+TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSandybridgeVariant) {
+ // Build features for a 32-bit x86 sandybridge processor.
+ std::string error_msg;
+ std::unique_ptr<const InstructionSetFeatures> x86_features(
+ InstructionSetFeatures::FromVariant(kX86, "sandybridge", &error_msg));
+ ASSERT_TRUE(x86_features.get() != nullptr) << error_msg;
+ EXPECT_EQ(x86_features->GetInstructionSet(), kX86);
+ EXPECT_TRUE(x86_features->Equals(x86_features.get()));
+ EXPECT_STREQ("ssse3,sse4.1,sse4.2,-avx,-avx2,popcnt",
+ x86_features->GetFeatureString().c_str());
+ EXPECT_EQ(x86_features->AsBitmap(), 39U);
+
+ // Build features for a 32-bit x86 default processor.
+ std::unique_ptr<const InstructionSetFeatures> x86_default_features(
+ InstructionSetFeatures::FromVariant(kX86, "default", &error_msg));
+ ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg;
+ EXPECT_EQ(x86_default_features->GetInstructionSet(), kX86);
+ EXPECT_TRUE(x86_default_features->Equals(x86_default_features.get()));
+ EXPECT_STREQ("-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt",
+ x86_default_features->GetFeatureString().c_str());
+ EXPECT_EQ(x86_default_features->AsBitmap(), 0U);
+
+ // Build features for a 64-bit x86-64 sandybridge processor.
+ std::unique_ptr<const InstructionSetFeatures> x86_64_features(
+ InstructionSetFeatures::FromVariant(kX86_64, "sandybridge", &error_msg));
+ ASSERT_TRUE(x86_64_features.get() != nullptr) << error_msg;
+ EXPECT_EQ(x86_64_features->GetInstructionSet(), kX86_64);
+ EXPECT_TRUE(x86_64_features->Equals(x86_64_features.get()));
+ EXPECT_STREQ("ssse3,sse4.1,sse4.2,-avx,-avx2,popcnt",
+ x86_64_features->GetFeatureString().c_str());
+ EXPECT_EQ(x86_64_features->AsBitmap(), 39U);
+
+ EXPECT_FALSE(x86_64_features->Equals(x86_features.get()));
+ EXPECT_FALSE(x86_64_features->Equals(x86_default_features.get()));
+ EXPECT_FALSE(x86_features->Equals(x86_default_features.get()));
+}
+
TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSilvermontVariant) {
// Build features for a 32-bit x86 silvermont processor.
std::string error_msg;