[clang] [llvm] [RISC-V][MC][RVY] Update to v0.9.11 specification and add Zcy (PR #248355)

Alexander Richardson via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 3 09:53:35 PST 2026


https://github.com/arichardson updated https://github.com/llvm/llvm-project/pull/248355

>From 69e34267cf1f26ae0a7a9472309a3fad48a3ced8 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Wed, 2 Dec 2026 23:05:40 -0800
Subject: [PATCH 1/2] [nspr] initial commit

---
 .../Driver/print-supported-extensions-riscv.c |   5 +-
 .../RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp  |   7 +
 llvm/lib/Target/RISCV/RISCVFeatures.td        |  13 +-
 llvm/lib/Target/RISCV/RISCVSubtarget.cpp      |   1 +
 llvm/lib/TargetParser/RISCVISAInfo.cpp        |  55 +++--
 llvm/test/CodeGen/RISCV/attributes.ll         |   8 +-
 llvm/test/CodeGen/RISCV/features-info.ll      |   1 +
 llvm/test/MC/RISCV/rvy-build-attributes.s     |  40 ++--
 llvm/test/MC/RISCV/rvy-invalid-attributes.s   |  40 ++--
 llvm/test/MC/RISCV/rvy/rvy-option-arch.s      |  46 ++--
 llvm/test/MC/RISCV/rvy/rvy-zyhybrid.s         |  12 +-
 .../TargetParser/RISCVISAInfoTest.cpp         | 211 +++++++++++-------
 12 files changed, 267 insertions(+), 172 deletions(-)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c b/clang/test/Driver/print-supported-extensions-riscv.c
index df6e22716822fe..0950acba4ca834 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -248,12 +248,13 @@
 // CHECK-NEXT:     xwchc                2.2       'Xwchc' (WCH/QingKe additional compressed opcodes)
 // CHECK-EMPTY:
 // CHECK-NEXT: Experimental extensions
-// CHECK-NEXT:     y                    0.910     'Y' ('Base Y' (CHERI))
+// CHECK-NEXT:     y                    0.911     'Y' ('Base Y' (CHERI))
 // CHECK-NEXT:     p                    0.21      'P' ('Base P' (Packed SIMD))
 // CHECK-NEXT:     zibi                 0.1       'Zibi' (Branch with Immediate)
 // CHECK-NEXT:     zicfilp              1.0       'Zicfilp' (Landing pad)
 // CHECK-NEXT:     zilx                 0.1       'Zilx' (Indexed Integer Load Instructions)
-// CHECK-NEXT:     zyhybrid             0.910     'Zyhybrid' (Hybrid Extension for RVI Compatibility)
+// CHECK-NEXT:     zyhybrid             0.911     'Zyhybrid' (Hybrid Extension for RVI Compatibility)
+// CHECK-NEXT:     zcy                  0.911     'Zcy' (Compressed Capability Load and Store Instructions)
 // CHECK-NEXT:     zvabd                0.9       'Zvabd' (Vector Absolute Difference)
 // CHECK-NEXT:     zvbc32e              0.7       'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements)
 // CHECK-NEXT:     zvdot4a8i            0.1       'Zvdot4a8i' (Vector 4-element Dot Product of packed 8-bit Integers)
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
index dbc477475d01bb..71718751e643bc 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
@@ -90,6 +90,13 @@ createRISCVMCObjectFileInfo(MCContext &Ctx, bool PIC,
 }
 
 void RISCV::updateCZceFeatureImplications(MCSubtargetInfo &STI) {
+  // Add Zcy if Y and C or Zce are enabled.
+  if (STI.hasFeature(RISCV::FeatureStdExtY) &&
+      (STI.hasFeature(RISCV::FeatureStdExtC) ||
+       STI.hasFeature(RISCV::FeatureStdExtZce)) &&
+      !STI.hasFeature(RISCV::FeatureStdExtZcy))
+    STI.ToggleFeature(RISCV::FeatureStdExtZcy);
+
   // Add Zcd if C and D are enabled and we aren't targeting 64-bit RVY.
   if (STI.hasFeature(RISCV::FeatureStdExtC) &&
       STI.hasFeature(RISCV::FeatureStdExtD) &&
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 9ec9829ddaf24d..56d81697615619 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1346,10 +1346,14 @@ def HasStdExtZbkbOrP
 // - -y, +zyhybrid: RVY in Integral Pointer Mode (RVI compatible, but custom-3
 //                  no longer reserved for vendor extension).
 def FeatureStdExtY
-    : RISCVExperimentalExtension<0, 910, "'Base Y' (CHERI)", [],
+    : RISCVExperimentalExtension<0, 911, "'Base Y' (CHERI)", [],
                                  "HasStdExtYCapMode">;
+def FeatureStdExtZcy
+    : RISCVExperimentalExtension<
+          0, 911, "Compressed Capability Load and Store Instructions",
+          [FeatureStdExtZca]>;
 def FeatureStdExtZyhybrid
-    : RISCVExperimentalExtension<0, 910,
+    : RISCVExperimentalExtension<0, 911,
                                  "Hybrid Extension for RVI Compatibility">;
 
 def HasYInstructions
@@ -1357,6 +1361,11 @@ def HasYInstructions
       AssemblerPredicate<(any_of FeatureStdExtY, FeatureStdExtZyhybrid),
                          "'Base Y' (CHERI) or "
                          "'Zyhybrid' (Hybrid Extension for RVI Compatibility)">;
+def HasStdExtZcy
+    : Predicate<"Subtarget->hasStdExtZcy()">,
+      AssemblerPredicate<
+          (all_of FeatureStdExtZcy),
+          "'Zcy' (Compressed Capability Load and Store Instructions)">;
 def HasStdExtZyhybrid
     : Predicate<"Subtarget->hasStdExtZyhybrid()">,
       AssemblerPredicate<(all_of FeatureStdExtZyhybrid),
diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
index 6177f209a79e52..614702778b40ce 100644
--- a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
+++ b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
@@ -79,6 +79,7 @@ RISCVSubtarget::initializeSubtargetDependencies(const Triple &TT, StringRef CPU,
   // Re-sync the flags.
   HasStdExtZcd = hasFeature(RISCV::FeatureStdExtZcd);
   HasStdExtZcf = hasFeature(RISCV::FeatureStdExtZcf);
+  HasStdExtZcy = hasFeature(RISCV::FeatureStdExtZcy);
   HasStdExtC = hasFeature(RISCV::FeatureStdExtC);
   HasStdExtZce = hasFeature(RISCV::FeatureStdExtZce);
 
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 70f7e33b7ef3b9..54b77d04f36d1a 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -759,10 +759,6 @@ static Error getIncompatibleError(StringRef Ext1, StringRef Ext2) {
                   "' extensions are incompatible");
 }
 
-static Error getBaseIncompatibleError(StringRef Ext, StringRef Base) {
-  return getError("'" + Ext + "' is incompatible with " + Base + " base");
-}
-
 static Error getExtensionRequiresError(StringRef Ext, StringRef ReqExt) {
   return getError("'" + Ext + "' requires '" + ReqExt +
                   "' extension to also be specified");
@@ -829,20 +825,22 @@ Error RISCVISAInfo::checkDependency() {
   if (Exts.count("zclsd") != 0 && Exts.count("zcf") != 0)
     return getIncompatibleError("zclsd", "zcf");
 
-  if (Exts.count("y") != 0) {
+  if (Exts.count("zcy") != 0) {
+    if (!Exts.count("y"))
+      return getExtensionRequiresError("zcy", "y");
     if (XLen == 32) {
-      // On RV32Y systems the zclsd/zcf encodings are used for y load/stores.
+      // On RV32Y, Zcy reuses the encodings of Zcf and Zclsd.
       if (Exts.count("zclsd") != 0)
-        return getBaseIncompatibleError("zclsd", "rv32y");
+        return getIncompatibleError("zclsd", "zcy");
       if (Exts.count("zcf") != 0)
-        return getBaseIncompatibleError("zcf", "rv32y");
+        return getIncompatibleError("zcf", "zcy");
     } else {
-      // On RV64Y systems the zcd encodings are used for y load/stores.
+      // On RV64Y, Zcy reuses the encodings of Zcd (and Zcmp/Zcmt/Xqccmp).
       if (Exts.count("zcd") != 0)
-        return getBaseIncompatibleError("zcd", "rv64y");
+        return getIncompatibleError("zcd", "zcy");
       for (auto Ext : ZcdOverlaps)
         if (Exts.count(Ext))
-          return getBaseIncompatibleError(Ext, "rv64y");
+          return getIncompatibleError(Ext, "zcy");
     }
   }
 
@@ -902,6 +900,13 @@ void RISCVISAInfo::updateImplication() {
     }
   }
 
+  // Add Zcy if Y and C or Zce are enabled.
+  if (Exts.count("y") && (Exts.count("c") || Exts.count("zce")) &&
+      !Exts.count("zcy")) {
+    auto Version = findDefaultVersion("zcy");
+    Exts["zcy"] = *Version;
+  }
+
   // Add Zcd if C and D are enabled and we aren't targeting 64-bit RVY.
   if (Exts.count("c") && Exts.count("d") && !Exts.count("zcd") &&
       (XLen == 32 || !Exts.count("y"))) {
@@ -933,24 +938,26 @@ void RISCVISAInfo::updateImplication() {
   // For RV64:
   //   - No D: Zca alone implies C
   //   - D: Zca + Zcd implies C
-  // For RV32Y (Zcf incompatible):
-  //   - No D (but maybe F): Zca alone implies C
-  //   - F and D: Zca + Zcd implies C
-  // For RV64Y (Zcf and Zcd incompatible):
-  //   - Zca alone implies C
+  // For RV32Y:
+  //   - No D (but maybe F): Zca + Zcy implies C
+  //   - F and D: Zca + Zcy + Zcd implies C
+  // For RV64Y:
+  //   - Zca + Zcy implies C
   if (Exts.count("zca") && !Exts.count("c")) {
     bool ShouldAddC = false;
-    if (XLen == 32) {
+    if (Exts.count("y")) {
+      ShouldAddC = Exts.count("zcy") &&
+                   (XLen == 64 || !Exts.count("d") || Exts.count("zcd"));
+    } else if (XLen == 32) {
       if (Exts.count("d"))
-        ShouldAddC =
-            Exts.count("zcd") && (Exts.count("y") || Exts.count("zcf"));
+        ShouldAddC = Exts.count("zcd") && Exts.count("zcf");
       else if (Exts.count("f"))
-        ShouldAddC = Exts.count("y") || Exts.count("zcf");
+        ShouldAddC = Exts.count("zcf");
       else
         ShouldAddC = true;
     } else if (XLen == 64) {
       if (Exts.count("d"))
-        ShouldAddC = Exts.count("y") || Exts.count("zcd");
+        ShouldAddC = Exts.count("zcd");
       else
         ShouldAddC = true;
     }
@@ -964,9 +971,11 @@ void RISCVISAInfo::updateImplication() {
       Exts.count("zcmp") && Exts.count("zcmt")) {
     bool ShouldAddZce = false;
     if (XLen == 32) {
-      ShouldAddZce = !Exts.count("f") || Exts.count("zcf") || Exts.count("y");
+      ShouldAddZce = Exts.count("y") ? Exts.count("zcy")
+                                     : (!Exts.count("f") || Exts.count("zcf"));
     } else if (XLen == 64) {
-      // Zce is incompatible with RV64Y, only add it if Y is not enabled.
+      // On RV64Y, Zce implies Zcy which conflicts with Zcmp/Zcmt, so only add
+      // Zce if Y is not enabled.
       ShouldAddZce = !Exts.count("y");
     }
     if (ShouldAddZce)
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll
index 44e2a7568ea0aa..e3785e881da145 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -343,6 +343,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+sdtrig  %s -o - | FileCheck --check-prefix=RV64SDTRIG %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-p %s -o - | FileCheck --check-prefix=RV64P %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-y -target-abi lp64 %s -o - | FileCheck --check-prefix=RV64Y %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-y,+experimental-zcy -target-abi lp64 %s -o - | FileCheck --check-prefix=RV64Y-ZCY %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-y,+experimental-zyhybrid -target-abi lp64 %s -o - | FileCheck --check-prefix=RV64Y-ZYHYBRID %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zyhybrid -target-abi lp64 %s -o - | FileCheck --check-prefix=RV64I-ZYHYBRID %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zibi %s -o - | FileCheck --check-prefix=RV64ZIBI %s
@@ -713,9 +714,10 @@
 ; RV64SDEXT: .attribute 5, "rv64i2p1_sdext1p0"
 ; RV64SDTRIG: .attribute 5, "rv64i2p1_sdtrig1p0"
 ; RV64P: .attribute 5, "rv64i2p1_p0p21_zicsr2p0_zmmul1p0_zba1p0_zbb1p0"
-; RV64Y: .attribute 5, "rv64y0p910"
-; RV64Y-ZYHYBRID: .attribute 5, "rv64y0p910_zyhybrid0p910"
-; RV64I-ZYHYBRID: .attribute 5, "rv64i2p1_zyhybrid0p910"
+; RV64Y: .attribute 5, "rv64y0p911"
+; RV64Y-ZCY: .attribute 5, "rv64y0p911_c2p0_zca1p0_zcy0p911"
+; RV64Y-ZYHYBRID: .attribute 5, "rv64y0p911_zyhybrid0p911"
+; RV64I-ZYHYBRID: .attribute 5, "rv64i2p1_zyhybrid0p911"
 ; RV64ZIBI: .attribute 5, "rv64i2p1_zibi0p1"
 ; RV64ZVQWBDOTA8I: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_zvqwbdota8i0p2"
 ; RV64ZVQWBDOTA16I: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zve64x1p0_zvl32b1p0_zvl64b1p0_zvqwbdota16i0p2"
diff --git a/llvm/test/CodeGen/RISCV/features-info.ll b/llvm/test/CodeGen/RISCV/features-info.ll
index 2655ea406b3a4c..1f4ae2c8c1027a 100644
--- a/llvm/test/CodeGen/RISCV/features-info.ll
+++ b/llvm/test/CodeGen/RISCV/features-info.ll
@@ -44,6 +44,7 @@
 ; CHECK-NEXT:   experimental-xsfmclic            - 'XSfmclic' (SiFive CLIC Machine-mode CSRs).
 ; CHECK-NEXT:   experimental-xsfsclic            - 'XSfsclic' (SiFive CLIC Supervisor-mode CSRs).
 ; CHECK-NEXT:   experimental-y                   - 'Y' ('Base Y' (CHERI)).
+; CHECK-NEXT:   experimental-zcy                 - 'Zcy' (Compressed Capability Load and Store Instructions).
 ; CHECK-NEXT:   experimental-zibi                - 'Zibi' (Branch with Immediate).
 ; CHECK-NEXT:   experimental-zicfilp             - 'Zicfilp' (Landing pad).
 ; CHECK-NEXT:   experimental-zilx                - 'Zilx' (Indexed Integer Load Instructions).
diff --git a/llvm/test/MC/RISCV/rvy-build-attributes.s b/llvm/test/MC/RISCV/rvy-build-attributes.s
index 512db1e95f5291..6d230b1c6c7c7a 100644
--- a/llvm/test/MC/RISCV/rvy-build-attributes.s
+++ b/llvm/test/MC/RISCV/rvy-build-attributes.s
@@ -9,12 +9,21 @@
 # RUN: llvm-mc %s -triple=riscv32 -filetype=asm -riscv-add-build-attributes \
 # RUN:   -mattr=+experimental-y,+zca,+f | llvm-mc -triple=riscv32 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV32Y-ZCA-F
+# RUN: llvm-mc %s -triple=riscv32 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+experimental-zcy,+f | llvm-mc -triple=riscv32 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV32YFC
 # RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
 # RUN:   -mattr=+experimental-y,+zca,+d | llvm-mc -triple=riscv64 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV64Y-ZCA-D
 # RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+experimental-zcy,+d | llvm-mc -triple=riscv64 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV64YDC
+# RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
 # RUN:   -mattr=+experimental-y,+zca,+zcb | llvm-mc -triple=riscv64 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV64Y-ZCA-ZCB
+# RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+zca,+zcmp | llvm-mc -triple=riscv64 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV64Y-ZCA-ZCMP
 # RUN: llvm-mc %s -triple=riscv32 -filetype=asm -riscv-add-build-attributes \
 # RUN:   -mattr=+experimental-y,+zce | llvm-mc -triple=riscv32 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV32Y-ZCE
@@ -22,23 +31,26 @@
 # RUN:   -mattr=+experimental-y,+zce,+f | llvm-mc -triple=riscv32 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV32Y-ZCE-F
 
-## RV64Y + D + C: y is enabled, so zcd is not implied.
-# RV64YDC: .attribute 5, "rv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zca1p0"
+## RV64Y + D + C (or Zcy): y is enabled, so zcd is not implied; zca + zcy implies c.
+# RV64YDC: .attribute 5, "rv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zca1p0_zcy0p911"
+
+## RV32Y + F + C (or Zcy): y is enabled, so zcf is not implied; zca + zcy implies c.
+# RV32YFC: .attribute 5, "rv32y0p911_f2p2_c2p0_zicsr2p0_zca1p0_zcy0p911"
 
-## RV32Y + F + C: y is enabled, so zcf is not implied.
-# RV32YFC: .attribute 5, "rv32y0p910_f2p2_c2p0_zicsr2p0_zca1p0"
+## RV32Y + ZCA + F (without Zcy): does not imply c.
+# RV32Y-ZCA-F: .attribute 5, "rv32y0p911_f2p2_zicsr2p0_zca1p0"
 
-## RV32Y + ZCA + F: zca + y implies c on RV32 (y replaces zcf in the implication).
-# RV32Y-ZCA-F: .attribute 5, "rv32y0p910_f2p2_c2p0_zicsr2p0_zca1p0"
+## RV64Y + ZCA + D (without Zcy): does not imply c.
+# RV64Y-ZCA-D: .attribute 5, "rv64y0p911_f2p2_d2p2_zicsr2p0_zca1p0"
 
-## RV64Y + ZCA + D: zca + y implies c on RV64 (y replaces zcd in the implication).
-# RV64Y-ZCA-D: .attribute 5, "rv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zca1p0"
+## RV64Y + ZCA + ZCB (without Zcy): does not imply c or zce.
+# RV64Y-ZCA-ZCB: .attribute 5, "rv64y0p911_zca1p0_zcb1p0"
 
-## RV64Y + ZCA + ZCB: zca + zcb + y does NOT imply zce on RV64Y because Zce is incompatible. zca also implies c.
-# RV64Y-ZCA-ZCB: .attribute 5, "rv64y0p910_c2p0_zca1p0_zcb1p0"
+## RV64Y + ZCA + ZCMP (without Zcy): allowed when Zcy is not enabled.
+# RV64Y-ZCA-ZCMP: .attribute 5, "rv64y0p911_zca1p0_zcmp1p0"
 
-## RV32Y + ZCE: zce implies zca, zcb, zcmp, zcmt. zca implies c.
-# RV32Y-ZCE: .attribute 5, "rv32y0p910_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0"
+## RV32Y + ZCE: zce implies zca, zcb, zcmp, zcmt, and zcy; zca + zcy implies c.
+# RV32Y-ZCE: .attribute 5, "rv32y0p911_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0_zcy0p911"
 
-## RV32Y + ZCE + F: y is enabled, so zcf is not implied by zce + f. zca + y + f implies c.
-# RV32Y-ZCE-F: .attribute 5, "rv32y0p910_f2p2_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0"
+## RV32Y + ZCE + F: y is enabled, so zcf is not implied by zce + f; zca + zcy implies c.
+# RV32Y-ZCE-F: .attribute 5, "rv32y0p911_f2p2_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0_zcy0p911"
diff --git a/llvm/test/MC/RISCV/rvy-invalid-attributes.s b/llvm/test/MC/RISCV/rvy-invalid-attributes.s
index 107e18b6de69bb..c885ad48083692 100644
--- a/llvm/test/MC/RISCV/rvy-invalid-attributes.s
+++ b/llvm/test/MC/RISCV/rvy-invalid-attributes.s
@@ -1,37 +1,41 @@
 # RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+zce /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCE
-# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+zcf /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCF
-# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+zclsd /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCLSD
-# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+zcd /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCD
+# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+experimental-zcy,+zcf /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCF
+# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+experimental-zcy,+zclsd /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCLSD
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+experimental-zcy,+zcd /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCD
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zcy /dev/null 2>&1 | FileCheck %s --check-prefix=RVI-ZCY
 # RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+c,+zcmp /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-C-ZCMP
-# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+zca,+zcmp /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCA-ZCMP
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+experimental-zcy,+zcmp /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCY-ZCMP
 
 # RUN: llvm-mc --verify -triple=riscv64 < %s
 
-# RV64Y-ZCE: LLVM ERROR: 'zcmt' is incompatible with rv64y base
-# RV32Y-ZCF: LLVM ERROR: 'zcf' is incompatible with rv32y base
-# RV32Y-ZCLSD: LLVM ERROR: 'zclsd' is incompatible with rv32y base
-# RV64Y-ZCD: LLVM ERROR: 'zcd' is incompatible with rv64y base
-# RV64Y-C-ZCMP: LLVM ERROR: 'zcmp' is incompatible with rv64y base
-# RV64Y-ZCA-ZCMP: LLVM ERROR: 'zcmp' is incompatible with rv64y base
+# RV64Y-ZCE: LLVM ERROR: 'zcmt' and 'zcy' extensions are incompatible
+# RV32Y-ZCF: LLVM ERROR: 'zcf' and 'zcy' extensions are incompatible
+# RV32Y-ZCLSD: LLVM ERROR: 'zclsd' and 'zcy' extensions are incompatible
+# RV64Y-ZCD: LLVM ERROR: 'zcd' and 'zcy' extensions are incompatible
+# RVI-ZCY: LLVM ERROR: 'zcy' requires 'y' extension to also be specified
+# RV64Y-C-ZCMP: LLVM ERROR: 'zcmp' and 'zcy' extensions are incompatible
+# RV64Y-ZCY-ZCMP: LLVM ERROR: 'zcmp' and 'zcy' extensions are incompatible
 
-.attribute arch, "rv64y0p910_zce" # expected-error {{invalid arch name 'rv64y0p910_zce', 'zcmt' is incompatible with rv64y base}}
+.attribute arch, "rv64y0p911_zce" # expected-error {{invalid arch name 'rv64y0p911_zce', 'zcmt' and 'zcy' extensions are incompatible}}
 
-.attribute arch, "rv32y0p910_zcf" # expected-error {{invalid arch name 'rv32y0p910_zcf', 'zcf' is incompatible with rv32y base}}
+.attribute arch, "rv32y0p911_zcf_zcy0p911" # expected-error {{invalid arch name 'rv32y0p911_zcf_zcy0p911', 'zcf' and 'zcy' extensions are incompatible}}
 
-.attribute arch, "rv32y0p910_zclsd" # expected-error {{invalid arch name 'rv32y0p910_zclsd', 'zclsd' is incompatible with rv32y base}}
+.attribute arch, "rv32y0p911_zclsd_zcy0p911" # expected-error {{invalid arch name 'rv32y0p911_zclsd_zcy0p911', 'zclsd' and 'zcy' extensions are incompatible}}
 
-.attribute arch, "rv64y0p910_zcd" # expected-error {{invalid arch name 'rv64y0p910_zcd', 'zcd' is incompatible with rv64y base}}
+.attribute arch, "rv64y0p911_zcd_zcy0p911" # expected-error {{invalid arch name 'rv64y0p911_zcd_zcy0p911', 'zcd' and 'zcy' extensions are incompatible}}
 
-.attribute arch, "rv64y0p910_c_zcmp" # expected-error {{invalid arch name 'rv64y0p910_c_zcmp', 'zcmp' is incompatible with rv64y base}}
+.attribute arch, "rv64i_zcy0p911" # expected-error {{invalid arch name 'rv64i_zcy0p911', 'zcy' requires 'y' extension to also be specified}}
 
-.attribute arch, "rv64y0p910_zca_zcmp" # expected-error {{invalid arch name 'rv64y0p910_zca_zcmp', 'zcmp' is incompatible with rv64y base}}
+.attribute arch, "rv64y0p911_c_zcmp" # expected-error {{invalid arch name 'rv64y0p911_c_zcmp', 'zcmp' and 'zcy' extensions are incompatible}}
+
+.attribute arch, "rv64y0p911_zcy0p911_zcmp" # expected-error {{invalid arch name 'rv64y0p911_zcy0p911_zcmp', 'zcmp' and 'zcy' extensions are incompatible}}
 
 ## Check that resetToArch does not enable 'zcd' on rv64y or 'zcf' on rv64i.
-.attribute arch, "rv64y0p910_c_d"
+.attribute arch, "rv64y0p911_c_d"
 c.fld fa0, 0(a0) # expected-error:1 {{instruction requires the following: 'C' (Compressed Instructions) and 'D' (Double-Precision Floating-Point) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions)}}
 .option arch, +m
 
-.option arch, rv64y0p910_c_d
+.option arch, rv64y0p911_c_d
 c.fld fa0, 0(a0) # expected-error:1 {{instruction requires the following: 'C' (Compressed Instructions) and 'D' (Double-Precision Floating-Point) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions)}}
 .option arch, +m
 
diff --git a/llvm/test/MC/RISCV/rvy/rvy-option-arch.s b/llvm/test/MC/RISCV/rvy/rvy-option-arch.s
index d45c9f4dde458f..9ddfd9e829870d 100644
--- a/llvm/test/MC/RISCV/rvy/rvy-option-arch.s
+++ b/llvm/test/MC/RISCV/rvy/rvy-option-arch.s
@@ -15,7 +15,7 @@
 //--- rv64.s
 /// Start in RVI compatibility mode: C+D implies Zcd.
 ymodeswi
-// CHECK-LABEL: <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0>:
+// CHECK-LABEL: <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0>:
 // CHECK-NEXT:    ymodeswi
 
 /// `.option pop` restores the mode from before `.option push`.
@@ -23,10 +23,10 @@ ymodeswi
 ymodeswy
 // CHECK-NEXT:    ymodeswy
 /// TODO: This `.option arch` should be implicit in `ymodeswy`.
-.option arch, rv64y0p910_c_d_zyhybrid0p910
+.option arch, rv64y0p911_c_d_zyhybrid0p911
 nop
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0>:
+// CHECK-NEXT:  <$xrv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcy0p911>:
 // CHECK-NEXT:    nop
 .option pop
 
@@ -34,29 +34,29 @@ nop
 /// Zcd until switching back to RVI compatibility mode.
 ymodeswy
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0>:
+// CHECK-NEXT:  <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0>:
 // CHECK-NEXT:    ymodeswy
 /// TODO: This `.option arch` should be implicit in `ymodeswy`.
-.option arch, rv64y0p910_c_d_zyhybrid0p910
+.option arch, rv64y0p911_c_d_zyhybrid0p911
 nop
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0>:
+// CHECK-NEXT:  <$xrv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcy0p911>:
 // CHECK-NEXT:    nop
 .option norvc
 nop
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64y0p910_f2p2_d2p2_zicsr2p0_zyhybrid0p910>:
+// CHECK-NEXT:  <$xrv64y0p911_f2p2_d2p2_zicsr2p0_zyhybrid0p911>:
 // CHECK-NEXT:    nop
 .option rvc
 ymodeswi
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0>:
+// CHECK-NEXT:  <$xrv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcy0p911>:
 // CHECK-NEXT:    ymodeswi
 /// TODO: This `.option arch` should be implicit in `ymodeswi`.
-.option arch, rv64i_c_d_zyhybrid0p910
+.option arch, rv64i_c_d_zyhybrid0p911
 nop
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0>:
+// CHECK-NEXT:  <$xrv64i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0>:
 // CHECK-NEXT:    nop
 // CHECK-EMPTY:
 
@@ -64,19 +64,19 @@ nop
 /// Zcd is compatible with RV32Y, so only Zcf is omitted in capability mode.
 .option arch, +d
 ymodeswy
-// CHECK-LABEL: <$xrv32i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0_zcf1p0>:
+// CHECK-LABEL: <$xrv32i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0_zcf1p0>:
 // CHECK-NEXT:    ymodeswy
 /// TODO: This `.option arch` should be implicit in `ymodeswy`.
-.option arch, rv32y0p910_c_d_zyhybrid0p910
+.option arch, rv32y0p911_c_d_zyhybrid0p911
 ymodeswi
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv32y0p910_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0>:
+// CHECK-NEXT:  <$xrv32y0p911_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0_zcy0p911>:
 // CHECK-NEXT:    ymodeswi
 /// TODO: This `.option arch` should be implicit in `ymodeswi`.
-.option arch, rv32i_c_d_zyhybrid0p910
+.option arch, rv32i_c_d_zyhybrid0p911
 nop
 // CHECK-EMPTY:
-// CHECK-NEXT:  <$xrv32i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0_zcd1p0_zcf1p0>:
+// CHECK-NEXT:  <$xrv32i2p1_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcd1p0_zcf1p0>:
 // CHECK-NEXT:    nop
 // CHECK-EMPTY:
 
@@ -87,21 +87,21 @@ nop
 .option arch, -y
 // CHECK: :[[#@LINE-1]]:16: error: passing '+y'/'-y' is not supported yet; specify a full arch string instead
 
-/// Extensions that conflict with RVY cannot be enabled in capability pointer mode.
+/// Extensions that conflict with Zcy cannot be enabled when Zcy is active.
 ymodeswy
 /// TODO: This `.option arch` should be implicit in `ymodeswy`.
 .ifdef RV64
-.option arch, rv64y0p910_c_d_zyhybrid0p910
+.option arch, rv64y0p911_c_d_zyhybrid0p911
 .option arch, +zcd
-// RV64: :[[#@LINE-1]]:16: error: 'zcd' is incompatible with rv64y base
+// RV64: :[[#@LINE-1]]:16: error: 'zcd' and 'zcy' extensions are incompatible
 .option arch, +zcmp
-// RV64: :[[#@LINE-1]]:16: error: 'zcmp' is incompatible with rv64y base
+// RV64: :[[#@LINE-1]]:16: error: 'zcmp' and 'zcy' extensions are incompatible
 .option arch, +zcmt
-// RV64: :[[#@LINE-1]]:16: error: 'zcmt' is incompatible with rv64y base
+// RV64: :[[#@LINE-1]]:16: error: 'zcmt' and 'zcy' extensions are incompatible
 .else
-.option arch, rv32y0p910_c_d_zyhybrid0p910
+.option arch, rv32y0p911_c_d_zyhybrid0p911
 .option arch, +zcf
-// RV32: :[[#@LINE-1]]:16: error: 'zcf' is incompatible with rv32y base
+// RV32: :[[#@LINE-1]]:16: error: 'zcf' and 'zcy' extensions are incompatible
 .option arch, +zclsd
-// RV32: :[[#@LINE-1]]:16: error: 'zclsd' is incompatible with rv32y base
+// RV32: :[[#@LINE-1]]:16: error: 'zclsd' and 'zcy' extensions are incompatible
 .endif
diff --git a/llvm/test/MC/RISCV/rvy/rvy-zyhybrid.s b/llvm/test/MC/RISCV/rvy/rvy-zyhybrid.s
index 34d95222e5876e..741fc89cf693da 100644
--- a/llvm/test/MC/RISCV/rvy/rvy-zyhybrid.s
+++ b/llvm/test/MC/RISCV/rvy/rvy-zyhybrid.s
@@ -31,9 +31,9 @@ ymodeswi
 // CHECK-NEXT: # <MCInst #[[#MCINST3:]] YMODESWI>{{$}}
 /// TODO: This `.option arch` should be implicit in `ymodeswi`.
 .ifdef RV64
-.option arch, rv64i_c_d_zyhybrid0p910
+.option arch, rv64i_c_d_zyhybrid0p911
 .else
-.option arch, rv32i_c_f_zyhybrid0p910
+.option arch, rv32i_c_f_zyhybrid0p911
 .endif
 yadd a0, a1, a2
 // CHECK-ASM-AND-OBJ: yadd	a0, a1, a2
@@ -49,9 +49,9 @@ ymodeswy
 // CHECK-NEXT: # <MCInst #[[#MCINST5:]] YMODESWY>{{$}}
 /// TODO: This `.option arch` should be implicit in `ymodeswy`.
 .ifdef RV64
-.option arch, rv64y0p910_c_d_zyhybrid0p910
+.option arch, rv64y0p911_c_d_zyhybrid0p911
 .else
-.option arch, rv32y0p910_c_f_zyhybrid0p910
+.option arch, rv32y0p911_c_f_zyhybrid0p911
 .endif
 yadd a0, a1, a2
 // CHECK-ASM-AND-OBJ: yadd	a0, a1, a2
@@ -62,7 +62,7 @@ yadd a0, a1, a2
 // CHECK-NEXT: #  <MCOperand Reg:X12>>
 
 // ATTR-RV32:      TagName: arch
-// ATTR-RV32-NEXT: Value: rv32y0p910_f2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0{{$}}
+// ATTR-RV32-NEXT: Value: rv32y0p911_f2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcy0p911{{$}}
 
 // ATTR-RV64:      TagName: arch
-// ATTR-RV64-NEXT: Value: rv64y0p910_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p910_zca1p0{{$}}
+// ATTR-RV64-NEXT: Value: rv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zyhybrid0p911_zca1p0_zcy0p911{{$}}
diff --git a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
index 9a0577059f2de4..790ea8a22ed7ae 100644
--- a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
@@ -48,22 +48,22 @@ TEST(ParseNormalizedArchString, RejectsConflictingBaseISAs) {
         toString(RISCVISAInfo::parseNormalizedArchString(Input).takeError()),
         "conflicting base ISAs 'e' and 'i'");
   }
-  for (StringRef Input : {"rv32y0p910_i2p1", "rv64y0p910_m2p0_i2p1"}) {
+  for (StringRef Input : {"rv32y0p911_i2p1", "rv64y0p911_m2p0_i2p1"}) {
     EXPECT_EQ(
         toString(RISCVISAInfo::parseNormalizedArchString(Input).takeError()),
         "conflicting base ISAs 'y' and 'i'");
   }
-  for (StringRef Input : {"rv32y0p910_e2p0", "rv64y0p910_m2p0_e2p0"}) {
+  for (StringRef Input : {"rv32y0p911_e2p0", "rv64y0p911_m2p0_e2p0"}) {
     EXPECT_EQ(
         toString(RISCVISAInfo::parseNormalizedArchString(Input).takeError()),
         "conflicting base ISAs 'y' and 'e'");
   }
-  for (StringRef Input : {"rv32i2p0_y0p910", "rv32i2p0_m2p0_y1p0"}) {
+  for (StringRef Input : {"rv32i2p0_y0p911", "rv32i2p0_m2p0_y1p0"}) {
     EXPECT_EQ(
         toString(RISCVISAInfo::parseNormalizedArchString(Input).takeError()),
         "conflicting base ISAs 'i' and 'y'");
   }
-  for (StringRef Input : {"rv32e2p0_y0p910", "rv64e2p0_m2p0_y0p910"}) {
+  for (StringRef Input : {"rv32e2p0_y0p911", "rv64e2p0_m2p0_y0p911"}) {
     EXPECT_EQ(
         toString(RISCVISAInfo::parseNormalizedArchString(Input).takeError()),
         "conflicting base ISAs 'e' and 'y'");
@@ -148,7 +148,7 @@ TEST(ParseNormalizedArchString, DuplicateExtension) {
         "duplicate extension 'a'");
   }
   EXPECT_EQ(
-      toString(RISCVISAInfo::parseNormalizedArchString("rv64y0p910_y0p910")
+      toString(RISCVISAInfo::parseNormalizedArchString("rv64y0p911_y0p911")
                    .takeError()),
       "duplicate extension 'y'");
 }
@@ -170,16 +170,16 @@ TEST(ParseNormalizedArchString, AcceptsValidBaseISAsAndSetsXLen) {
               (RISCVISAUtils::ExtensionVersion{2, 0}));
   EXPECT_EQ(InfoRV32E.getXLen(), 32U);
 
-  auto MaybeRV32Y = RISCVISAInfo::parseNormalizedArchString("rv32y0p910");
+  auto MaybeRV32Y = RISCVISAInfo::parseNormalizedArchString("rv32y0p911");
   ASSERT_THAT_EXPECTED(MaybeRV32Y, Succeeded());
   RISCVISAInfo &InfoRV32Y = **MaybeRV32Y;
   EXPECT_EQ(InfoRV32Y.getExtensions().size(), 2UL);
   EXPECT_TRUE(InfoRV32Y.getExtensions().at("i") ==
               (RISCVISAUtils::ExtensionVersion{2, 1}));
   EXPECT_TRUE(InfoRV32Y.getExtensions().at("y") ==
-              (RISCVISAUtils::ExtensionVersion{0, 910}));
+              (RISCVISAUtils::ExtensionVersion{0, 911}));
   EXPECT_EQ(InfoRV32Y.getXLen(), 32U);
-  EXPECT_EQ(InfoRV32Y.toString(), "rv32y0p910");
+  EXPECT_EQ(InfoRV32Y.toString(), "rv32y0p911");
 
   auto MaybeRV64I = RISCVISAInfo::parseNormalizedArchString("rv64i2p0");
   ASSERT_THAT_EXPECTED(MaybeRV64I, Succeeded());
@@ -197,16 +197,16 @@ TEST(ParseNormalizedArchString, AcceptsValidBaseISAsAndSetsXLen) {
               (RISCVISAUtils::ExtensionVersion{2, 0}));
   EXPECT_EQ(InfoRV64E.getXLen(), 64U);
 
-  auto MaybeRV64Y = RISCVISAInfo::parseNormalizedArchString("rv64y0p910");
+  auto MaybeRV64Y = RISCVISAInfo::parseNormalizedArchString("rv64y0p911");
   ASSERT_THAT_EXPECTED(MaybeRV64Y, Succeeded());
   RISCVISAInfo &InfoRV64Y = **MaybeRV64Y;
   EXPECT_EQ(InfoRV64Y.getExtensions().size(), 2UL);
   EXPECT_TRUE(InfoRV64Y.getExtensions().at("i") ==
               (RISCVISAUtils::ExtensionVersion{2, 1}));
   EXPECT_TRUE(InfoRV64Y.getExtensions().at("y") ==
-              (RISCVISAUtils::ExtensionVersion{0, 910}));
+              (RISCVISAUtils::ExtensionVersion{0, 911}));
   EXPECT_EQ(InfoRV64Y.getXLen(), 64U);
-  EXPECT_EQ(InfoRV64Y.toString(), "rv64y0p910");
+  EXPECT_EQ(InfoRV64Y.toString(), "rv64y0p911");
 }
 
 TEST(ParseNormalizedArchString, AcceptsArbitraryExtensionsAndVersions) {
@@ -285,11 +285,11 @@ TEST(ParseArchString, RejectsInvalidBaseISA) {
         toString(RISCVISAInfo::parseArchString(Input, true, false).takeError()),
         "invalid standard user-level extension 'e'");
   }
-  for (StringRef Input : {"rv32y0p910i", "rv64y0p910i"}) {
+  for (StringRef Input : {"rv32y0p911i", "rv64y0p911i"}) {
     EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
               "invalid standard user-level extension 'i'");
   }
-  for (StringRef Input : {"rv32y0p910e", "rv64y0p910e"}) {
+  for (StringRef Input : {"rv32y0p911e", "rv64y0p911e"}) {
     EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
               "invalid standard user-level extension 'e'");
   }
@@ -299,9 +299,9 @@ TEST(ParseArchString, RejectsInvalidYPosition) {
   // 'y' is only allowed as a base ISA ('rv32y' or 'rv64y'). Anything else
   // should be rejected as an invalid extension.
   for (StringRef Input :
-       {"rv32ey0p910", "rv64ey0p910", "rv32iy0p910", "rv64iy0p910",
-        "rv32gy0p910", "rv64gy0p910", "rv32imy0p910", "rv64imy0p910",
-        "rv32i2p1_y0p910", "rv32i_m_y0p910", "rv64y0p910_y0p910"}) {
+       {"rv32ey0p911", "rv64ey0p911", "rv32iy0p911", "rv64iy0p911",
+        "rv32gy0p911", "rv64gy0p911", "rv32imy0p911", "rv64imy0p911",
+        "rv32i2p1_y0p911", "rv32i_m_y0p911", "rv64y0p911_y0p911"}) {
     EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
               "invalid standard user-level extension 'y'");
   }
@@ -316,19 +316,19 @@ TEST(ParseArchString, RejectsInvalidYPosition) {
 TEST(ParseArchString, AcceptsRVYBaseISA) {
   // With version check enabled (default), we must specify the version for
   // experimental extension 'y'.
-  auto MaybeRV32Y = RISCVISAInfo::parseArchString("rv32y0p910", true);
+  auto MaybeRV32Y = RISCVISAInfo::parseArchString("rv32y0p911", true);
   ASSERT_THAT_EXPECTED(MaybeRV32Y, Succeeded());
   RISCVISAInfo &InfoRV32Y = **MaybeRV32Y;
   const auto &ExtsRV32Y = InfoRV32Y.getExtensions();
   EXPECT_EQ(ExtsRV32Y.size(), 2UL); // i, y
   EXPECT_TRUE(ExtsRV32Y.at("i") == (RISCVISAUtils::ExtensionVersion{2, 1}));
-  EXPECT_TRUE(ExtsRV32Y.at("y") == (RISCVISAUtils::ExtensionVersion{0, 910}));
+  EXPECT_TRUE(ExtsRV32Y.at("y") == (RISCVISAUtils::ExtensionVersion{0, 911}));
   EXPECT_EQ(InfoRV32Y.getXLen(), 32U);
-  EXPECT_EQ(InfoRV32Y.toString(), "rv32y0p910");
+  EXPECT_EQ(InfoRV32Y.toString(), "rv32y0p911");
 
-  // rv32y0p910m should succeed and contain i, m, y0p910, zmmul, with 'i'
+  // rv32y0p911m should succeed and contain i, m, y0p911, zmmul, with 'i'
   // omitted and 'y' ordered before 'm', round-tripping through both parsers.
-  auto MaybeRV32YM = RISCVISAInfo::parseArchString("rv32y0p910m", true);
+  auto MaybeRV32YM = RISCVISAInfo::parseArchString("rv32y0p911m", true);
   ASSERT_THAT_EXPECTED(MaybeRV32YM, Succeeded());
   RISCVISAInfo &InfoRV32YM = **MaybeRV32YM;
   EXPECT_EQ(InfoRV32YM.getExtensions().size(), 4UL); // i, m, y, zmmul
@@ -337,9 +337,9 @@ TEST(ParseArchString, AcceptsRVYBaseISA) {
   EXPECT_TRUE(InfoRV32YM.getExtensions().at("m") ==
               (RISCVISAUtils::ExtensionVersion{2, 0}));
   EXPECT_TRUE(InfoRV32YM.getExtensions().at("y") ==
-              (RISCVISAUtils::ExtensionVersion{0, 910}));
+              (RISCVISAUtils::ExtensionVersion{0, 911}));
   std::string RV32YMStr = InfoRV32YM.toString();
-  EXPECT_EQ(RV32YMStr, "rv32y0p910_m2p0_zmmul1p0");
+  EXPECT_EQ(RV32YMStr, "rv32y0p911_m2p0_zmmul1p0");
   auto RoundTripArch = RISCVISAInfo::parseArchString(RV32YMStr, true);
   ASSERT_THAT_EXPECTED(RoundTripArch, Succeeded());
   EXPECT_EQ((*RoundTripArch)->toString(), RV32YMStr);
@@ -352,15 +352,15 @@ TEST(ParseArchString, AcceptsRVYBaseISA) {
   ASSERT_THAT_EXPECTED(MaybeNoVal, Succeeded());
   EXPECT_EQ((*MaybeNoVal)->getExtensions().size(), 2UL);
 
-  auto MaybeRV64Y = RISCVISAInfo::parseArchString("rv64y0p910", true);
+  auto MaybeRV64Y = RISCVISAInfo::parseArchString("rv64y0p911", true);
   ASSERT_THAT_EXPECTED(MaybeRV64Y, Succeeded());
   RISCVISAInfo &InfoRV64Y = **MaybeRV64Y;
   const auto &ExtsRV64Y = InfoRV64Y.getExtensions();
   EXPECT_EQ(ExtsRV64Y.size(), 2UL); // i, y
   EXPECT_TRUE(ExtsRV64Y.at("i") == (RISCVISAUtils::ExtensionVersion{2, 1}));
-  EXPECT_TRUE(ExtsRV64Y.at("y") == (RISCVISAUtils::ExtensionVersion{0, 910}));
+  EXPECT_TRUE(ExtsRV64Y.at("y") == (RISCVISAUtils::ExtensionVersion{0, 911}));
   EXPECT_EQ(InfoRV64Y.getXLen(), 64U);
-  EXPECT_EQ(InfoRV64Y.toString(), "rv64y0p910");
+  EXPECT_EQ(InfoRV64Y.toString(), "rv64y0p911");
 }
 
 TEST(ParseArchString, RejectsUnsupportedBaseISA) {
@@ -775,7 +775,7 @@ TEST(ParseArchString, RejectsUnrecognizedVersionForExperimentalExtension) {
   EXPECT_EQ(
       toString(RISCVISAInfo::parseArchString("rv64y0p97", true).takeError()),
       "unsupported version number 0.97 for experimental extension 'y' "
-      "(this compiler supports 0.910)");
+      "(this compiler supports 0.911)");
 }
 
 TEST(ParseArchString, RejectsExtensionVersionForG) {
@@ -871,35 +871,43 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
   }
   EXPECT_EQ(
       toString(
-          RISCVISAInfo::parseArchString("rv32y0p910_zcf", true).takeError()),
-      "'zcf' is incompatible with rv32y base");
+          RISCVISAInfo::parseArchString("rv32i_zcy0p911", true).takeError()),
+      "'zcy' requires 'y' extension to also be specified");
+  EXPECT_EQ(toString(RISCVISAInfo::parseArchString(
+                         "rv64i_zyhybrid0p911_zcy0p911", true)
+                         .takeError()),
+            "'zcy' requires 'y' extension to also be specified");
   EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv32y0p910_zclsd", true).takeError()),
-      "'zclsd' is incompatible with rv32y base");
+      toString(RISCVISAInfo::parseArchString("rv32y0p911_zcf_zcy0p911", true)
+                   .takeError()),
+      "'zcf' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv64y0p910_zcd", true).takeError()),
-      "'zcd' is incompatible with rv64y base");
+      toString(RISCVISAInfo::parseArchString("rv32y0p911_zclsd_zcy0p911", true)
+                   .takeError()),
+      "'zclsd' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv64y0p910_zcmp", true).takeError()),
-      "'zcmp' is incompatible with rv64y base");
+      toString(RISCVISAInfo::parseArchString("rv64y0p911_zcd_zcy0p911", true)
+                   .takeError()),
+      "'zcd' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv64y0p910_zcmt", true).takeError()),
-      "'zcmt' is incompatible with rv64y base");
+      toString(RISCVISAInfo::parseArchString("rv64y0p911_zcy0p911_zcmp", true)
+                   .takeError()),
+      "'zcmp' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv64y0p910_xqccmp", true).takeError()),
-      "'xqccmp' is incompatible with rv64y base");
-  // RV64Y is incompatible with Zce (because Zce implies Zcmt/Zcmp which overlap
-  // with RV64Y). This behaves exactly the same as enabling Zcd and Zce on a
-  // RVI (conflict via Zcmt).
+      toString(RISCVISAInfo::parseArchString("rv64y0p911_zcy0p911_zcmt", true)
+                   .takeError()),
+      "'zcmt' and 'zcy' extensions are incompatible");
+  EXPECT_EQ(
+      toString(RISCVISAInfo::parseArchString("rv64y0p911_zcy0p911_xqccmp", true)
+                   .takeError()),
+      "'xqccmp' and 'zcy' extensions are incompatible");
+  // RV64Y is incompatible with Zce (because Zce implies Zcy and Zcmt/Zcmp
+  // which overlap with Zcy on RV64Y). This behaves the same as enabling Zcd
+  // and Zce on RVI (conflict via Zcmt).
   EXPECT_EQ(
       toString(
-          RISCVISAInfo::parseArchString("rv64y0p910_zce", true).takeError()),
-      "'zcmt' is incompatible with rv64y base");
+          RISCVISAInfo::parseArchString("rv64y0p911_zce", true).takeError()),
+      "'zcmt' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
       toString(
           RISCVISAInfo::parseArchString("rv64i_zcd_zce", true).takeError()),
@@ -1197,11 +1205,11 @@ TEST(ParseArchString, ZceImplication) {
   EXPECT_EQ(ExtsRV64IDZce.count("zcmp"), 1U);
   EXPECT_EQ(ExtsRV64IDZce.count("zcmt"), 1U);
 
-  // RV32Y Zce: zcf incompatible, but zcmp/zcmt compatible. zca + y implies c.
-  auto MaybeRV32YZce = RISCVISAInfo::parseArchString("rv32y0p910_zce", true);
+  // RV32Y Zce: implies zcy (and c via zca + zcy), zcmp/zcmt compatible.
+  auto MaybeRV32YZce = RISCVISAInfo::parseArchString("rv32y0p911_zce", true);
   ASSERT_THAT_EXPECTED(MaybeRV32YZce, Succeeded());
   const auto &ExtsRV32YZce = (*MaybeRV32YZce)->getExtensions();
-  EXPECT_EQ(ExtsRV32YZce.size(), 9UL);
+  EXPECT_EQ(ExtsRV32YZce.size(), 10UL);
   EXPECT_EQ(ExtsRV32YZce.count("i"), 1U);
   EXPECT_EQ(ExtsRV32YZce.count("y"), 1U);
   EXPECT_EQ(ExtsRV32YZce.count("c"), 1U);
@@ -1211,12 +1219,13 @@ TEST(ParseArchString, ZceImplication) {
   EXPECT_EQ(ExtsRV32YZce.count("zce"), 1U);
   EXPECT_EQ(ExtsRV32YZce.count("zcmp"), 1U);
   EXPECT_EQ(ExtsRV32YZce.count("zcmt"), 1U);
+  EXPECT_EQ(ExtsRV32YZce.count("zcy"), 1U);
 
-  // RV32Y Zce with F: zcf incompatible, so zcf is not implied.
-  auto MaybeRV32YFZce = RISCVISAInfo::parseArchString("rv32y0p910_f_zce", true);
+  // RV32Y Zce with F: implies zcy rather than zcf.
+  auto MaybeRV32YFZce = RISCVISAInfo::parseArchString("rv32y0p911_f_zce", true);
   ASSERT_THAT_EXPECTED(MaybeRV32YFZce, Succeeded());
   const auto &ExtsRV32YFZce = (*MaybeRV32YFZce)->getExtensions();
-  EXPECT_EQ(ExtsRV32YFZce.size(), 10UL);
+  EXPECT_EQ(ExtsRV32YFZce.size(), 11UL);
   EXPECT_EQ(ExtsRV32YFZce.count("i"), 1U);
   EXPECT_EQ(ExtsRV32YFZce.count("y"), 1U);
   EXPECT_EQ(ExtsRV32YFZce.count("c"), 1U);
@@ -1228,6 +1237,7 @@ TEST(ParseArchString, ZceImplication) {
   EXPECT_EQ(ExtsRV32YFZce.count("zcf"), 0U);
   EXPECT_EQ(ExtsRV32YFZce.count("zcmp"), 1U);
   EXPECT_EQ(ExtsRV32YFZce.count("zcmt"), 1U);
+  EXPECT_EQ(ExtsRV32YFZce.count("zcy"), 1U);
 }
 
 TEST(ParseArchString, ZcaImpliesC) {
@@ -1296,67 +1306,92 @@ TEST(ParseArchString, ZcaImpliesC) {
   EXPECT_EQ(ExtsRV64IDZca.count("c"), 0U);
 }
 
-TEST(ParseArchString, RVYZcaImpliesC) {
-  // RV32Y without D (maybe with F): Zca implies C (Zcf opcodes remapped in Y).
-  for (StringRef Input : {"rv32y_zca", "rv32yf_zca"}) {
+TEST(ParseArchString, RVYZcaZcyImpliesC) {
+  // Without Zcy, Zca (and Zcf/Zclsd/Zcd/Zcmp/Zcmt) on RV32Y/RV64Y are valid
+  // but do not imply C.
+  for (StringRef Input :
+       {"rv32y_zca", "rv32yf_zca", "rv32yf_zca_zcf", "rv32y_zclsd",
+        "rv32yfd_zca_zcd", "rv64y_zca", "rv64yf_zca", "rv64yfd_zca",
+        "rv64yfd_zca_zcd", "rv64y_zca_zcmp", "rv64y_zca_zcmt"}) {
+    auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
+    ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
+    const auto &Exts = (*ISAInfo)->getExtensions();
+    EXPECT_EQ(Exts.count("c"), 0U) << Input;
+    EXPECT_EQ(Exts.count("zca"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zcy"), 0U) << Input;
+  }
+
+  // RV32Y without D (maybe with F): Zca + Zcy implies C (Zcy implies Zca).
+  for (StringRef Input :
+       {"rv32y_zca_zcy", "rv32y_zcy", "rv32yf_zca_zcy", "rv32yf_zcy"}) {
     auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
     ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
     const auto &Exts = (*ISAInfo)->getExtensions();
     EXPECT_EQ(Exts.count("c"), 1U);
     EXPECT_EQ(Exts.count("zca"), 1U);
+    EXPECT_EQ(Exts.count("zcy"), 1U);
     EXPECT_EQ(Exts.count("zcf"), 0U);
     EXPECT_EQ(Exts.count("zcd"), 0U);
   }
-  // RV32Y with D: Zca+Zcd implies C (Zcf opcodes remapped in Y)
-  for (StringRef Input : {"rv32yfd_zca_zcd"}) {
+  // RV32Y with D: Zca + Zcy + Zcd implies C.
+  for (StringRef Input : {"rv32yfd_zca_zcd_zcy", "rv32yfd_zcd_zcy"}) {
     auto MaybeRV32YDZcaZcd = RISCVISAInfo::parseArchString(Input, true, false);
     ASSERT_THAT_EXPECTED(MaybeRV32YDZcaZcd, Succeeded());
     const auto &ExtsRV32YDZcaZcd = (*MaybeRV32YDZcaZcd)->getExtensions();
     EXPECT_EQ(ExtsRV32YDZcaZcd.count("c"), 1U);
     EXPECT_EQ(ExtsRV32YDZcaZcd.count("zca"), 1U);
+    EXPECT_EQ(ExtsRV32YDZcaZcd.count("zcy"), 1U);
     EXPECT_EQ(ExtsRV32YDZcaZcd.count("zcf"), 0U);
     EXPECT_EQ(ExtsRV32YDZcaZcd.count("zcd"), 1U);
   }
-  // RV32Y with D but no Zcd: no C
-  for (StringRef Input : {"rv32yfd_zca"}) {
-    auto MaybeRV32YDZcaZcd = RISCVISAInfo::parseArchString(Input, true, false);
-    ASSERT_THAT_EXPECTED(MaybeRV32YDZcaZcd, Succeeded());
-    const auto &ExtsRV32YDZcaZcd = (*MaybeRV32YDZcaZcd)->getExtensions();
-    EXPECT_EQ(ExtsRV32YDZcaZcd.count("c"), 0U);
-    EXPECT_EQ(ExtsRV32YDZcaZcd.count("zca"), 1U);
-    EXPECT_EQ(ExtsRV32YDZcaZcd.count("zcf"), 0U);
-    EXPECT_EQ(ExtsRV32YDZcaZcd.count("zcd"), 0U);
+  // RV32Y with D + Zcy but no Zcd: no C.
+  for (StringRef Input : {"rv32yfd_zca_zcy", "rv32yfd_zcy"}) {
+    auto MaybeRV32YDZca = RISCVISAInfo::parseArchString(Input, true, false);
+    ASSERT_THAT_EXPECTED(MaybeRV32YDZca, Succeeded());
+    const auto &ExtsRV32YDZca = (*MaybeRV32YDZca)->getExtensions();
+    EXPECT_EQ(ExtsRV32YDZca.count("c"), 0U);
+    EXPECT_EQ(ExtsRV32YDZca.count("zca"), 1U);
+    EXPECT_EQ(ExtsRV32YDZca.count("zcy"), 1U);
+    EXPECT_EQ(ExtsRV32YDZca.count("zcf"), 0U);
+    EXPECT_EQ(ExtsRV32YDZca.count("zcd"), 0U);
   }
 
-  // RV64Y: Zca always implies C (regardless of F/D) since Zcf opcodes are
-  // repurposed for 64-bit loads/stores and Zcd for capability loads/stores.
-  for (StringRef Input : {"rv64y_zca", "rv64yf_zca", "rv64yfd_zca"}) {
+  // RV64Y: Zca + Zcy always implies C (regardless of F/D).
+  for (StringRef Input :
+       {"rv64y_zca_zcy", "rv64y_zcy", "rv64yf_zca_zcy", "rv64yfd_zca_zcy"}) {
     auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
     ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
     const auto &Exts = (*ISAInfo)->getExtensions();
     EXPECT_EQ(Exts.count("c"), 1U);
     EXPECT_EQ(Exts.count("zca"), 1U);
+    EXPECT_EQ(Exts.count("zcy"), 1U);
     EXPECT_EQ(Exts.count("zcf"), 0U);
     EXPECT_EQ(Exts.count("zcd"), 0U);
   }
 }
 
 TEST(ParseArchString, RVYFeatureImplicationC) {
-  // rv32y + c + f should not imply zcf
+  // rv32y + c + f should imply zcy, and not zcf
   auto MaybeISAInfo =
       RISCVISAInfo::parseFeatures(32, {"+experimental-y", "+c", "+f"});
   ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zca"));
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zcy"));
   EXPECT_FALSE((*MaybeISAInfo)->hasExtension("zcf"));
-  // rv32y + c + f + d should imply zcd, but not zcf
+  // rv32y + c + f + d should imply zcy and zcd, but not zcf
   MaybeISAInfo =
       RISCVISAInfo::parseFeatures(32, {"+experimental-y", "+c", "+f", "+d"});
   ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zca"));
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zcy"));
   EXPECT_FALSE((*MaybeISAInfo)->hasExtension("zcf"));
   EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zcd"));
-  // rv64y + c + d should not imply zcd
+  // rv64y + c + d should imply zcy, and not zcd
   MaybeISAInfo =
       RISCVISAInfo::parseFeatures(64, {"+experimental-y", "+c", "+d"});
   ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zca"));
+  EXPECT_TRUE((*MaybeISAInfo)->hasExtension("zcy"));
   EXPECT_FALSE((*MaybeISAInfo)->hasExtension("zcd"));
 }
 
@@ -1479,9 +1514,21 @@ TEST(ParseArchString, ZcaZcbZcmpZcmtImpliesZce) {
   EXPECT_EQ(ExtsRV64IFZcaZcbZcmpZcmt.count("zcmp"), 1U);
   EXPECT_EQ(ExtsRV64IFZcaZcbZcmpZcmt.count("zcmt"), 1U);
 
-  // RV32Y Zca+Zcb+Zcmp+Zcmt implies Zce regardless of F (Zcf incompatible)
-  for (StringRef Input : {"rv32y_zca_zcb_zcmp_zcmt", "rv32yf_zca_zcb_zcmp_zcmt",
-                          "rv32yfd_zca_zcb_zcmp_zcmt"}) {
+  // Without Zcy, Zca+Zcb+Zcmp+Zcmt on RV32Y/RV64Y does not imply Zce or C.
+  for (StringRef Input :
+       {"rv32y_zca_zcb_zcmp_zcmt", "rv32yf_zca_zcb_zcmp_zcmt",
+        "rv32yfd_zca_zcb_zcmp_zcmt", "rv64y_zca_zcb_zcmp_zcmt"}) {
+    auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
+    ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
+    const auto &Exts = (*ISAInfo)->getExtensions();
+    EXPECT_EQ(Exts.count("zce"), 0U) << Input;
+    EXPECT_EQ(Exts.count("c"), 0U) << Input;
+    EXPECT_EQ(Exts.count("zcy"), 0U) << Input;
+  }
+
+  // RV32Y Zca+Zcy+Zcb+Zcmp+Zcmt implies Zce regardless of F.
+  for (StringRef Input : {"rv32y_zcy_zcb_zcmp_zcmt", "rv32yf_zcy_zcb_zcmp_zcmt",
+                          "rv32yfd_zcy_zcb_zcmp_zcmt"}) {
     auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
     ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
     const auto &Exts = (*ISAInfo)->getExtensions();
@@ -1494,7 +1541,8 @@ TEST(ParseArchString, ZcaZcbZcmpZcmtImpliesZce) {
     EXPECT_EQ(Exts.count("zce"), 1U);
     EXPECT_EQ(Exts.count("zcmp"), 1U);
     EXPECT_EQ(Exts.count("zcmt"), 1U);
-    EXPECT_EQ(Exts.size(), 9UL + Exts.count("f"));
+    EXPECT_EQ(Exts.count("zcy"), 1U);
+    EXPECT_EQ(Exts.size(), 10UL + Exts.count("f"));
   }
 }
 
@@ -1768,12 +1816,13 @@ R"(All available -march extensions for RISC-V
     xwchc                2.2
 
 Experimental extensions
-    y                    0.910
+    y                    0.911
     p                    0.21
     zibi                 0.1
     zicfilp              1.0       This is a long dummy description
     zilx                 0.1
-    zyhybrid             0.910
+    zyhybrid             0.911
+    zcy                  0.911
     zvabd                0.9
     zvbc32e              0.7
     zvdot4a8i            0.1

>From 5fd99d530ee44bf8f8d34ae45b565dca29000b64 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Thu, 3 Dec 2026 09:53:13 -0800
Subject: [PATCH 2/2] [nspr] update

---
 .../RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp  |  7 +++
 llvm/lib/Target/RISCV/RISCVFeatures.td        |  5 +-
 llvm/lib/Target/RISCV/RISCVSubtarget.cpp      |  3 +
 llvm/lib/TargetParser/RISCVISAInfo.cpp        | 22 +++++---
 llvm/test/MC/RISCV/rvy-build-attributes.s     | 16 ++++++
 llvm/test/MC/RISCV/rvy-invalid-attributes.s   |  6 +-
 .../TargetParser/RISCVISAInfoTest.cpp         | 56 ++++++++++++++++---
 7 files changed, 94 insertions(+), 21 deletions(-)

diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
index 71718751e643bc..1572d17139922d 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
@@ -90,6 +90,13 @@ createRISCVMCObjectFileInfo(MCContext &Ctx, bool PIC,
 }
 
 void RISCV::updateCZceFeatureImplications(MCSubtargetInfo &STI) {
+  // Zce implies Zcmp and Zcmt, except on RV64Y where they conflict with Zcy.
+  if (STI.hasFeature(RISCV::FeatureStdExtZce) &&
+      !(STI.hasFeature(RISCV::Feature64Bit) &&
+        STI.hasFeature(RISCV::FeatureStdExtY)))
+    STI.SetFeatureBitsTransitively(
+        {RISCV::FeatureStdExtZcmp, RISCV::FeatureStdExtZcmt});
+
   // Add Zcy if Y and C or Zce are enabled.
   if (STI.hasFeature(RISCV::FeatureStdExtY) &&
       (STI.hasFeature(RISCV::FeatureStdExtC) ||
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 56d81697615619..77e86f892e0a23 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -476,11 +476,12 @@ def HasStdExtZcmt : Predicate<"Subtarget->hasStdExtZcmt()">,
                            AssemblerPredicate<(all_of FeatureStdExtZcmt),
                            "'Zcmt' (table jump instructions for code-size reduction)">;
 
+// Zce also implies Zcmp and Zcmt except on RV64Y (where it implies Zcy instead).
+// This is handled in RISCVISAInfo and RISCV::updateCZceFeatureImplications.
 def FeatureStdExtZce
     : RISCVExtension<1, 0,
                      "Compressed extensions for microcontrollers",
-                     [FeatureStdExtZca, FeatureStdExtZcb, FeatureStdExtZcmp,
-                      FeatureStdExtZcmt]>;
+                     [FeatureStdExtZca, FeatureStdExtZcb]>;
 
 def FeatureStdExtZcmop
     : RISCVExtension<1, 0, "Compressed May-Be-Operations",
diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
index 614702778b40ce..22bd1ca5d2d7cc 100644
--- a/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
+++ b/llvm/lib/Target/RISCV/RISCVSubtarget.cpp
@@ -82,6 +82,9 @@ RISCVSubtarget::initializeSubtargetDependencies(const Triple &TT, StringRef CPU,
   HasStdExtZcy = hasFeature(RISCV::FeatureStdExtZcy);
   HasStdExtC = hasFeature(RISCV::FeatureStdExtC);
   HasStdExtZce = hasFeature(RISCV::FeatureStdExtZce);
+  HasStdExtZcmp = hasFeature(RISCV::FeatureStdExtZcmp);
+  HasStdExtZcmt = hasFeature(RISCV::FeatureStdExtZcmt);
+  HasStdExtZicsr = hasFeature(RISCV::FeatureStdExtZicsr);
 
   // Can't be fatal: per-function subtargets mean this one may just be the
   // module-level default with no matching function, e.g. -target-abi ilp32f
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 54b77d04f36d1a..29e2bc068fe217 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -881,6 +881,11 @@ void RISCVISAInfo::updateImplication() {
 
   // This loop may execute over 1 iteration since implication can be layered
   // Exits loop if no more implication is applied
+  // Zce implies Zcmp and Zcmt, except on RV64Y where they conflict with Zcy.
+  if (Exts.count("zce") && (XLen == 32 || !Exts.count("y")))
+    for (StringRef Ext : {"zcmp", "zcmt"})
+      Exts.try_emplace(Ext.str(), *findDefaultVersion(Ext));
+
   SmallVector<StringRef, 16> WorkList;
   for (auto const &Ext : Exts)
     WorkList.push_back(Ext.first);
@@ -967,17 +972,16 @@ void RISCVISAInfo::updateImplication() {
     }
   }
 
-  if (!Exts.count("zce") && Exts.count("zca") && Exts.count("zcb") &&
-      Exts.count("zcmp") && Exts.count("zcmt")) {
+  // Add Zce if all its components are enabled: Zca + Zcb + Zcy on RV64Y, and
+  // Zca + Zcb + Zcmp + Zcmt (+ Zcy on RV32Y, or Zcf on RV32 with F) otherwise.
+  if (!Exts.count("zce") && Exts.count("zca") && Exts.count("zcb")) {
     bool ShouldAddZce = false;
-    if (XLen == 32) {
+    if (XLen == 64 && Exts.count("y"))
+      ShouldAddZce = Exts.count("zcy");
+    else if (Exts.count("zcmp") && Exts.count("zcmt"))
       ShouldAddZce = Exts.count("y") ? Exts.count("zcy")
-                                     : (!Exts.count("f") || Exts.count("zcf"));
-    } else if (XLen == 64) {
-      // On RV64Y, Zce implies Zcy which conflicts with Zcmp/Zcmt, so only add
-      // Zce if Y is not enabled.
-      ShouldAddZce = !Exts.count("y");
-    }
+                                     : (XLen == 64 || !Exts.count("f") ||
+                                        Exts.count("zcf"));
     if (ShouldAddZce)
       Exts["zce"] = *findDefaultVersion("zce");
   }
diff --git a/llvm/test/MC/RISCV/rvy-build-attributes.s b/llvm/test/MC/RISCV/rvy-build-attributes.s
index 6d230b1c6c7c7a..f30fb9bd791b6f 100644
--- a/llvm/test/MC/RISCV/rvy-build-attributes.s
+++ b/llvm/test/MC/RISCV/rvy-build-attributes.s
@@ -30,6 +30,15 @@
 # RUN: llvm-mc %s -triple=riscv32 -filetype=asm -riscv-add-build-attributes \
 # RUN:   -mattr=+experimental-y,+zce,+f | llvm-mc -triple=riscv32 -filetype=asm \
 # RUN:   | FileCheck %s --check-prefix=RV32Y-ZCE-F
+# RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+zce | llvm-mc -triple=riscv64 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV64Y-ZCE
+# RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+c,+zcb | llvm-mc -triple=riscv64 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV64Y-ZCE
+# RUN: llvm-mc %s -triple=riscv64 -filetype=asm -riscv-add-build-attributes \
+# RUN:   -mattr=+experimental-y,+zce,+d | llvm-mc -triple=riscv64 -filetype=asm \
+# RUN:   | FileCheck %s --check-prefix=RV64Y-ZCE-D
 
 ## RV64Y + D + C (or Zcy): y is enabled, so zcd is not implied; zca + zcy implies c.
 # RV64YDC: .attribute 5, "rv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zca1p0_zcy0p911"
@@ -54,3 +63,10 @@
 
 ## RV32Y + ZCE + F: y is enabled, so zcf is not implied by zce + f; zca + zcy implies c.
 # RV32Y-ZCE-F: .attribute 5, "rv32y0p911_f2p2_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcmp1p0_zcmt1p0_zcy0p911"
+
+## RV64Y + ZCE: zce implies zca, zcb, and zcy (but not zcmp/zcmt, which conflict
+## with zcy); zca + zcy implies c. Conversely, c + zcb implies zce.
+# RV64Y-ZCE: .attribute 5, "rv64y0p911_c2p0_zca1p0_zcb1p0_zce1p0_zcy0p911"
+
+## RV64Y + ZCE + D: y is enabled, so zcd is not implied.
+# RV64Y-ZCE-D: .attribute 5, "rv64y0p911_f2p2_d2p2_c2p0_zicsr2p0_zca1p0_zcb1p0_zce1p0_zcy0p911"
diff --git a/llvm/test/MC/RISCV/rvy-invalid-attributes.s b/llvm/test/MC/RISCV/rvy-invalid-attributes.s
index c885ad48083692..6a8e7b4ef6f9bb 100644
--- a/llvm/test/MC/RISCV/rvy-invalid-attributes.s
+++ b/llvm/test/MC/RISCV/rvy-invalid-attributes.s
@@ -1,4 +1,4 @@
-# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+zce /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCE
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+zce,+zcmp /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCE-ZCMP
 # RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+experimental-zcy,+zcf /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCF
 # RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-y,+experimental-zcy,+zclsd /dev/null 2>&1 | FileCheck %s --check-prefix=RV32Y-ZCLSD
 # RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-y,+experimental-zcy,+zcd /dev/null 2>&1 | FileCheck %s --check-prefix=RV64Y-ZCD
@@ -8,7 +8,7 @@
 
 # RUN: llvm-mc --verify -triple=riscv64 < %s
 
-# RV64Y-ZCE: LLVM ERROR: 'zcmt' and 'zcy' extensions are incompatible
+# RV64Y-ZCE-ZCMP: LLVM ERROR: 'zcmp' and 'zcy' extensions are incompatible
 # RV32Y-ZCF: LLVM ERROR: 'zcf' and 'zcy' extensions are incompatible
 # RV32Y-ZCLSD: LLVM ERROR: 'zclsd' and 'zcy' extensions are incompatible
 # RV64Y-ZCD: LLVM ERROR: 'zcd' and 'zcy' extensions are incompatible
@@ -16,7 +16,7 @@
 # RV64Y-C-ZCMP: LLVM ERROR: 'zcmp' and 'zcy' extensions are incompatible
 # RV64Y-ZCY-ZCMP: LLVM ERROR: 'zcmp' and 'zcy' extensions are incompatible
 
-.attribute arch, "rv64y0p911_zce" # expected-error {{invalid arch name 'rv64y0p911_zce', 'zcmt' and 'zcy' extensions are incompatible}}
+.attribute arch, "rv64y0p911_zce_zcmt" # expected-error {{invalid arch name 'rv64y0p911_zce_zcmt', 'zcmt' and 'zcy' extensions are incompatible}}
 
 .attribute arch, "rv32y0p911_zcf_zcy0p911" # expected-error {{invalid arch name 'rv32y0p911_zcf_zcy0p911', 'zcf' and 'zcy' extensions are incompatible}}
 
diff --git a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
index 790ea8a22ed7ae..08d14cf798d072 100644
--- a/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/TargetParser/RISCVISAInfoTest.cpp
@@ -901,13 +901,12 @@ TEST(ParseArchString, RejectsConflictingExtensions) {
       toString(RISCVISAInfo::parseArchString("rv64y0p911_zcy0p911_xqccmp", true)
                    .takeError()),
       "'xqccmp' and 'zcy' extensions are incompatible");
-  // RV64Y is incompatible with Zce (because Zce implies Zcy and Zcmt/Zcmp
-  // which overlap with Zcy on RV64Y). This behaves the same as enabling Zcd
-  // and Zce on RVI (conflict via Zcmt).
-  EXPECT_EQ(
-      toString(
-          RISCVISAInfo::parseArchString("rv64y0p911_zce", true).takeError()),
-      "'zcmt' and 'zcy' extensions are incompatible");
+  // On RV64Y, Zce implies Zcy instead of Zcmp/Zcmt, so explicitly requesting
+  // Zcmt alongside Zce conflicts with Zcy. This behaves the same as enabling
+  // Zcd and Zce on RVI (conflict via Zcmt).
+  EXPECT_EQ(toString(RISCVISAInfo::parseArchString("rv64y0p911_zce_zcmt", true)
+                         .takeError()),
+            "'zcmt' and 'zcy' extensions are incompatible");
   EXPECT_EQ(
       toString(
           RISCVISAInfo::parseArchString("rv64i_zcd_zce", true).takeError()),
@@ -1238,6 +1237,37 @@ TEST(ParseArchString, ZceImplication) {
   EXPECT_EQ(ExtsRV32YFZce.count("zcmp"), 1U);
   EXPECT_EQ(ExtsRV32YFZce.count("zcmt"), 1U);
   EXPECT_EQ(ExtsRV32YFZce.count("zcy"), 1U);
+
+  // RV64Y Zce: implies zca, zcb, and zcy (and c via zca + zcy), but not
+  // zcmp/zcmt since they conflict with zcy (and zcd is not implied by D).
+  for (StringRef Input : {"rv64y0p911_zce", "rv64y0p911_f_zce",
+                          "rv64y0p911_f_d_zce"}) {
+    auto ISAInfo = RISCVISAInfo::parseArchString(Input, true);
+    ASSERT_THAT_EXPECTED(ISAInfo, Succeeded()) << Input;
+    const auto &Exts = (*ISAInfo)->getExtensions();
+    EXPECT_EQ(Exts.count("c"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zca"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zcb"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zce"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zcy"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zcmp"), 0U) << Input;
+    EXPECT_EQ(Exts.count("zcmt"), 0U) << Input;
+    EXPECT_EQ(Exts.count("zcd"), 0U) << Input;
+  }
+
+  // The same applies when enabling Zce via target features.
+  auto MaybeRV64YZceFeatures =
+      RISCVISAInfo::parseFeatures(64, {"+experimental-y", "+zce"});
+  ASSERT_THAT_EXPECTED(MaybeRV64YZceFeatures, Succeeded());
+  EXPECT_TRUE((*MaybeRV64YZceFeatures)->hasExtension("c"));
+  EXPECT_TRUE((*MaybeRV64YZceFeatures)->hasExtension("zcy"));
+  EXPECT_FALSE((*MaybeRV64YZceFeatures)->hasExtension("zcmp"));
+  EXPECT_FALSE((*MaybeRV64YZceFeatures)->hasExtension("zcmt"));
+
+  // Explicitly requesting Zcmp or Zcmt alongside RV64Y + Zce is an error.
+  for (StringRef Input : {"rv64y0p911_zce_zcmp", "rv64y0p911_zce_zcmt"})
+    EXPECT_THAT_EXPECTED(RISCVISAInfo::parseArchString(Input, true), Failed())
+        << Input;
 }
 
 TEST(ParseArchString, ZcaImpliesC) {
@@ -1544,6 +1574,18 @@ TEST(ParseArchString, ZcaZcbZcmpZcmtImpliesZce) {
     EXPECT_EQ(Exts.count("zcy"), 1U);
     EXPECT_EQ(Exts.size(), 10UL + Exts.count("f"));
   }
+
+  // RV64Y Zca+Zcb+Zcy implies Zce (Zcmp/Zcmt are not part of Zce on RV64Y).
+  for (StringRef Input :
+       {"rv64y_zca_zcb_zcy", "rv64y_zcb_zcy", "rv64yfd_zcb_zcy"}) {
+    auto ISAInfo = RISCVISAInfo::parseArchString(Input, true, false);
+    ASSERT_THAT_EXPECTED(ISAInfo, Succeeded());
+    const auto &Exts = (*ISAInfo)->getExtensions();
+    EXPECT_EQ(Exts.count("c"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zce"), 1U) << Input;
+    EXPECT_EQ(Exts.count("zcmp"), 0U) << Input;
+    EXPECT_EQ(Exts.count("zcmt"), 0U) << Input;
+  }
 }
 
 TEST(isSupportedExtensionWithVersion, AcceptsSingleExtensionWithVersion) {



More information about the cfe-commits mailing list