[clang] [llvm] [RISCV][MC] Add experimental Smcsps and Sscsps support (PR #211712)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 08:21:28 PDT 2026


================
@@ -133,10 +133,16 @@ void RISCVInstPrinter::printCSRSystemRegister(const MCInst *MI, unsigned OpNo,
                                               raw_ostream &O) {
   unsigned Imm = MI->getOperand(OpNo).getImm();
   auto Range = RISCVSysReg::lookupSysRegByEncoding(Imm);
+  bool PreferFeatureSpecific = llvm::any_of(Range, [&](const auto &Reg) {
----------------
zeyi2 wrote:

On why I modified this file:

I previously removed `FeaturesRequired` from `mspcs` and `sspcs` as suggested. And I found that it exposed an encoding collision with the SiFive CLIC CSRs `sf.mscratchcswl` and `sf.sscratchcswl`.

Although they use the same CSR encodings, they are not semantic aliases, so `AltSysRegName` does not seem appropriate. This change makes the printer prefer a feature-specific CSR name when its required feature is enabled, and otherwise fall back to the standard CSR name.

Does that seem like the appropriate way to handle the collision?


https://github.com/llvm/llvm-project/pull/211712


More information about the cfe-commits mailing list