summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/arch/riscv64/instruction_set_features_riscv64.cc20
-rw-r--r--runtime/arch/riscv64/instruction_set_features_riscv64.h5
-rw-r--r--runtime/arch/riscv64/instruction_set_features_riscv64_test.cc25
3 files changed, 43 insertions, 7 deletions
diff --git a/runtime/arch/riscv64/instruction_set_features_riscv64.cc b/runtime/arch/riscv64/instruction_set_features_riscv64.cc
index 947ea54ddb..445ab8d753 100644
--- a/runtime/arch/riscv64/instruction_set_features_riscv64.cc
+++ b/runtime/arch/riscv64/instruction_set_features_riscv64.cc
@@ -27,10 +27,14 @@ namespace art {
using android::base::StringPrintf;
-// Basic feature set is rv64gcv, aka rv64imafdcv.
+// Basic feature set is rv64gcv_zba_zbb_zbs, aka rv64imafdcv_zba_zbb_zbs.
constexpr uint32_t BasicFeatures() {
return Riscv64InstructionSetFeatures::kExtGeneric |
- Riscv64InstructionSetFeatures::kExtCompressed | Riscv64InstructionSetFeatures::kExtVector;
+ Riscv64InstructionSetFeatures::kExtCompressed |
+ Riscv64InstructionSetFeatures::kExtVector |
+ Riscv64InstructionSetFeatures::kExtZba |
+ Riscv64InstructionSetFeatures::kExtZbb |
+ Riscv64InstructionSetFeatures::kExtZbs;
}
Riscv64FeaturesUniquePtr Riscv64InstructionSetFeatures::FromVariant(
@@ -54,6 +58,15 @@ Riscv64FeaturesUniquePtr Riscv64InstructionSetFeatures::FromCppDefines() {
#ifdef __riscv_v
bits |= kExtVector;
#endif
+#ifdef __riscv_zba
+ bits |= kExtZba;
+#endif
+#ifdef __riscv_zbb
+ bits |= kExtZbb;
+#endif
+#ifdef __riscv_zbs
+ bits |= kExtZbs;
+#endif
return FromBitmap(bits);
}
@@ -90,6 +103,9 @@ static const std::pair<uint32_t, std::string> kExtensionList[] = {
{Riscv64InstructionSetFeatures::kExtGeneric, "rv64g"},
{Riscv64InstructionSetFeatures::kExtCompressed, "c"},
{Riscv64InstructionSetFeatures::kExtVector, "v"},
+ {Riscv64InstructionSetFeatures::kExtZba, "_zba"},
+ {Riscv64InstructionSetFeatures::kExtZbb, "_zbb"},
+ {Riscv64InstructionSetFeatures::kExtZbs, "_zbs"},
};
std::string Riscv64InstructionSetFeatures::GetFeatureString() const {
diff --git a/runtime/arch/riscv64/instruction_set_features_riscv64.h b/runtime/arch/riscv64/instruction_set_features_riscv64.h
index 56c41f085b..8de53d19ca 100644
--- a/runtime/arch/riscv64/instruction_set_features_riscv64.h
+++ b/runtime/arch/riscv64/instruction_set_features_riscv64.h
@@ -31,7 +31,10 @@ class Riscv64InstructionSetFeatures final : public InstructionSetFeatures {
enum {
kExtGeneric = (1 << 0), // G extension covers the basic set IMAFD
kExtCompressed = (1 << 1), // C extension adds compressed instructions
- kExtVector = (1 << 2) // V extension adds vector instructions
+ kExtVector = (1 << 2), // V extension adds vector instructions
+ kExtZba = (1 << 3), // Zba adds address generation bit-manipulation instructions
+ kExtZbb = (1 << 4), // Zbb adds basic bit-manipulation instructions
+ kExtZbs = (1 << 5), // Zbs adds single-bit bit-manipulation instructions
};
static Riscv64FeaturesUniquePtr FromVariant(const std::string& variant, std::string* error_msg);
diff --git a/runtime/arch/riscv64/instruction_set_features_riscv64_test.cc b/runtime/arch/riscv64/instruction_set_features_riscv64_test.cc
index fd9e83b81a..408131696a 100644
--- a/runtime/arch/riscv64/instruction_set_features_riscv64_test.cc
+++ b/runtime/arch/riscv64/instruction_set_features_riscv64_test.cc
@@ -30,10 +30,14 @@ TEST(Riscv64InstructionSetFeaturesTest, Riscv64FeaturesFromDefaultVariant) {
EXPECT_TRUE(riscv64_features->Equals(riscv64_features.get()));
- // rv64gcv, aka rv64imafdcv
- uint32_t expected_extensions = Riscv64InstructionSetFeatures::kExtGeneric |
- Riscv64InstructionSetFeatures::kExtCompressed |
- Riscv64InstructionSetFeatures::kExtVector;
+ // rv64gcv_zba_zbb_zbs, aka rv64imafdcv_zba_zbb_zbs
+ uint32_t expected_extensions =
+ Riscv64InstructionSetFeatures::kExtGeneric |
+ Riscv64InstructionSetFeatures::kExtCompressed |
+ Riscv64InstructionSetFeatures::kExtVector |
+ Riscv64InstructionSetFeatures::kExtZba |
+ Riscv64InstructionSetFeatures::kExtZbb |
+ Riscv64InstructionSetFeatures::kExtZbs;
EXPECT_EQ(riscv64_features->AsBitmap(), expected_extensions);
}
@@ -52,6 +56,19 @@ TEST(Riscv64InstructionSetFeaturesTest, Riscv64FeaturesFromString) {
uint32_t expected_extensions = Riscv64InstructionSetFeatures::kExtGeneric |
Riscv64InstructionSetFeatures::kExtVector;
EXPECT_EQ(rv64gv_features->AsBitmap(), expected_extensions);
+
+ std::unique_ptr<const InstructionSetFeatures> rv64gc_zba_zbb_features(
+ generic_features->AddFeaturesFromString("rv64gc_zba_zbb", &error_msg));
+ ASSERT_TRUE(rv64gc_zba_zbb_features.get() != nullptr) << error_msg;
+
+ EXPECT_FALSE(generic_features->Equals(rv64gc_zba_zbb_features.get()));
+
+ expected_extensions =
+ Riscv64InstructionSetFeatures::kExtGeneric |
+ Riscv64InstructionSetFeatures::kExtCompressed |
+ Riscv64InstructionSetFeatures::kExtZba |
+ Riscv64InstructionSetFeatures::kExtZbb;
+ EXPECT_EQ(rv64gc_zba_zbb_features->AsBitmap(), expected_extensions);
}
} // namespace art