diff options
-rw-r--r-- | runtime/arch/x86/instruction_set_features_x86.cc | 7 | ||||
-rw-r--r-- | runtime/arch/x86/instruction_set_features_x86_test.cc | 56 | ||||
-rw-r--r-- | runtime/arch/x86_64/instruction_set_features_x86_64_test.cc | 6 |
3 files changed, 57 insertions, 12 deletions
diff --git a/runtime/arch/x86/instruction_set_features_x86.cc b/runtime/arch/x86/instruction_set_features_x86.cc index c1add670a9..0c3d26e170 100644 --- a/runtime/arch/x86/instruction_set_features_x86.cc +++ b/runtime/arch/x86/instruction_set_features_x86.cc @@ -118,11 +118,8 @@ X86FeaturesUniquePtr X86InstructionSetFeatures::FromVariant( // Verify that variant is known. bool known_variant = FindVariantInArray(x86_known_variants, arraysize(x86_known_variants), variant); - if (!known_variant) { - if (variant != "default") { - LOG(WARNING) << "Unexpected CPU variant for X86 using defaults: " << variant; - } - return FromCppDefines(x86_64); + if (!known_variant && variant != "default") { + LOG(WARNING) << "Unexpected CPU variant for X86 using defaults: " << variant; } return Create(x86_64, has_SSSE3, has_SSE4_1, has_SSE4_2, has_AVX, has_AVX2, has_POPCNT); diff --git a/runtime/arch/x86/instruction_set_features_x86_test.cc b/runtime/arch/x86/instruction_set_features_x86_test.cc index 7fe522da81..cdf15af9b9 100644 --- a/runtime/arch/x86/instruction_set_features_x86_test.cc +++ b/runtime/arch/x86/instruction_set_features_x86_test.cc @@ -27,9 +27,9 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromDefaultVariant) { ASSERT_TRUE(x86_features.get() != nullptr) << error_msg; EXPECT_EQ(x86_features->GetInstructionSet(), InstructionSet::kX86); EXPECT_TRUE(x86_features->Equals(x86_features.get())); - EXPECT_EQ(InstructionSetFeatures::FromCppDefines()->GetFeatureString(), - x86_features->GetFeatureString()); - EXPECT_EQ(x86_features->AsBitmap(), InstructionSetFeatures::FromCppDefines()->AsBitmap()); + EXPECT_STREQ("-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt", + x86_features->GetFeatureString().c_str()); + EXPECT_EQ(x86_features->AsBitmap(), 0U); } TEST(X86InstructionSetFeaturesTest, X86FeaturesFromAtomVariant) { @@ -44,6 +44,16 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromAtomVariant) { x86_features->GetFeatureString().c_str()); EXPECT_EQ(x86_features->AsBitmap(), 1U); + // Build features for a 32-bit x86 default processor. + std::unique_ptr<const InstructionSetFeatures> x86_default_features( + InstructionSetFeatures::FromVariant(InstructionSet::kX86, "default", &error_msg)); + ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg; + EXPECT_EQ(x86_default_features->GetInstructionSet(), InstructionSet::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 atom processor. std::unique_ptr<const InstructionSetFeatures> x86_64_features( InstructionSetFeatures::FromVariant(InstructionSet::kX86_64, "atom", &error_msg)); @@ -55,6 +65,8 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromAtomVariant) { EXPECT_EQ(x86_64_features->AsBitmap(), 1U); 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, X86FeaturesFromSandybridgeVariant) { @@ -69,6 +81,16 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSandybridgeVariant) { 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(InstructionSet::kX86, "default", &error_msg)); + ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg; + EXPECT_EQ(x86_default_features->GetInstructionSet(), InstructionSet::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(InstructionSet::kX86_64, "sandybridge", &error_msg)); @@ -80,6 +102,8 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSandybridgeVariant) { 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) { @@ -94,6 +118,16 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSilvermontVariant) { 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(InstructionSet::kX86, "default", &error_msg)); + ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg; + EXPECT_EQ(x86_default_features->GetInstructionSet(), InstructionSet::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 silvermont processor. std::unique_ptr<const InstructionSetFeatures> x86_64_features( InstructionSetFeatures::FromVariant(InstructionSet::kX86_64, "silvermont", &error_msg)); @@ -105,6 +139,8 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromSilvermontVariant) { 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, X86FeaturesFromKabylakeVariant) { @@ -119,6 +155,16 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromKabylakeVariant) { x86_features->GetFeatureString().c_str()); EXPECT_EQ(x86_features->AsBitmap(), 63U); + // Build features for a 32-bit x86 default processor. + std::unique_ptr<const InstructionSetFeatures> x86_default_features( + InstructionSetFeatures::FromVariant(InstructionSet::kX86, "default", &error_msg)); + ASSERT_TRUE(x86_default_features.get() != nullptr) << error_msg; + EXPECT_EQ(x86_default_features->GetInstructionSet(), InstructionSet::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 kabylake processor. std::unique_ptr<const InstructionSetFeatures> x86_64_features( InstructionSetFeatures::FromVariant(InstructionSet::kX86_64, "kabylake", &error_msg)); @@ -130,5 +176,7 @@ TEST(X86InstructionSetFeaturesTest, X86FeaturesFromKabylakeVariant) { EXPECT_EQ(x86_64_features->AsBitmap(), 63U); 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())); + } } // namespace art diff --git a/runtime/arch/x86_64/instruction_set_features_x86_64_test.cc b/runtime/arch/x86_64/instruction_set_features_x86_64_test.cc index 86e8911284..2b307daea9 100644 --- a/runtime/arch/x86_64/instruction_set_features_x86_64_test.cc +++ b/runtime/arch/x86_64/instruction_set_features_x86_64_test.cc @@ -27,9 +27,9 @@ TEST(X86_64InstructionSetFeaturesTest, X86Features) { ASSERT_TRUE(x86_64_features.get() != nullptr) << error_msg; EXPECT_EQ(x86_64_features->GetInstructionSet(), InstructionSet::kX86_64); EXPECT_TRUE(x86_64_features->Equals(x86_64_features.get())); - EXPECT_EQ(InstructionSetFeatures::FromCppDefines()->GetFeatureString(), - x86_64_features->GetFeatureString()); - EXPECT_EQ(x86_64_features->AsBitmap(), InstructionSetFeatures::FromCppDefines()->AsBitmap()); + EXPECT_STREQ("-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt", + x86_64_features->GetFeatureString().c_str()); + EXPECT_EQ(x86_64_features->AsBitmap(), 0U); } } // namespace art |