Revert^2 "Use CPP defines for default x86 and x86_64 ISA features"
This reverts commit 12cde746b872c149a542ada0277040068af6606c.
Reason for revert: Fixing CL
Bug: 155324337
Test: atest ArtGtestsTarget
Test: m test-art-host-gtest
Change-Id: I36774cd33266fa33af803a555612e93eb9eef764
diff --git a/runtime/arch/x86/instruction_set_features_x86.cc b/runtime/arch/x86/instruction_set_features_x86.cc
index 0c3d26e..858c320 100644
--- a/runtime/arch/x86/instruction_set_features_x86.cc
+++ b/runtime/arch/x86/instruction_set_features_x86.cc
@@ -97,6 +97,12 @@
X86FeaturesUniquePtr X86InstructionSetFeatures::FromVariant(
const std::string& variant, std::string* error_msg ATTRIBUTE_UNUSED,
bool x86_64) {
+ const bool is_runtime_isa =
+ kRuntimeISA == (x86_64 ? InstructionSet::kX86_64 : InstructionSet::kX86);
+ if (is_runtime_isa && variant == "default") {
+ return FromCppDefines(x86_64);
+ }
+
bool has_SSSE3 = FindVariantInArray(x86_variants_with_ssse3, arraysize(x86_variants_with_ssse3),
variant);
bool has_SSE4_1 = FindVariantInArray(x86_variants_with_sse4_1,
diff --git a/runtime/arch/x86/instruction_set_features_x86_test.cc b/runtime/arch/x86/instruction_set_features_x86_test.cc
index cdf15af..ce8e9f4 100644
--- a/runtime/arch/x86/instruction_set_features_x86_test.cc
+++ b/runtime/arch/x86/instruction_set_features_x86_test.cc
@@ -21,15 +21,18 @@
namespace art {
TEST(X86InstructionSetFeaturesTest, X86FeaturesFromDefaultVariant) {
+ const bool is_runtime_isa = kRuntimeISA == InstructionSet::kX86;
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> x86_features(
InstructionSetFeatures::FromVariant(InstructionSet::kX86, "default", &error_msg));
ASSERT_TRUE(x86_features.get() != nullptr) << error_msg;
EXPECT_EQ(x86_features->GetInstructionSet(), InstructionSet::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(), 0U);
+ EXPECT_EQ(x86_features->GetFeatureString(),
+ is_runtime_isa ? X86InstructionSetFeatures::FromCppDefines()->GetFeatureString()
+ : "-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt");
+ EXPECT_EQ(x86_features->AsBitmap(),
+ is_runtime_isa ? X86InstructionSetFeatures::FromCppDefines()->AsBitmap() : 0);
}
TEST(X86InstructionSetFeaturesTest, X86FeaturesFromAtomVariant) {
@@ -44,16 +47,6 @@
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));
@@ -65,8 +58,6 @@
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) {
@@ -81,16 +72,6 @@
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));
@@ -102,8 +83,6 @@
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) {
@@ -118,16 +97,6 @@
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));
@@ -139,8 +108,6 @@
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) {
@@ -155,16 +122,6 @@
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));
@@ -176,7 +133,5 @@
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 2b307da..3201050 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
@@ -21,15 +21,18 @@
namespace art {
TEST(X86_64InstructionSetFeaturesTest, X86Features) {
+ const bool is_runtime_isa = kRuntimeISA == InstructionSet::kX86_64;
std::string error_msg;
std::unique_ptr<const InstructionSetFeatures> x86_64_features(
InstructionSetFeatures::FromVariant(InstructionSet::kX86_64, "default", &error_msg));
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_STREQ("-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt",
- x86_64_features->GetFeatureString().c_str());
- EXPECT_EQ(x86_64_features->AsBitmap(), 0U);
+ EXPECT_EQ(x86_64_features->GetFeatureString(),
+ is_runtime_isa ? X86_64InstructionSetFeatures::FromCppDefines()->GetFeatureString()
+ : "-ssse3,-sse4.1,-sse4.2,-avx,-avx2,-popcnt");
+ EXPECT_EQ(x86_64_features->AsBitmap(),
+ is_runtime_isa ? X86_64InstructionSetFeatures::FromCppDefines()->AsBitmap() : 0);
}
} // namespace art