[llvm] [RISCV] Use vlenb CSR to set Zvl*b feature getHostCPUFeatures. (PR #225486)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 21:12:49 PDT 2026
================
@@ -2618,6 +2618,24 @@ StringMap<bool> sys::getHostCPUFeatures() {
Query[2].Value == /*RISCV_HWPROBE_MISALIGNED_SCALAR_FAST=*/3)
Features["unaligned-scalar-mem"] = true;
+ // Infer Zvl from vlenb CSR.
+ if (Features["v"] || Features["zve32x"]) {
+#if __riscv_xlen == 64
+ uint64_t VLen;
+#elif __riscv_xlen == 32
+ uint32_t VLen;
+#else
+#error "Unknown XLEN"
+#endif
+ // Use the raw CSR number in case assembler doesn't know vlenb.
+ __asm__ volatile("csrr %0, 0xc22" : "=r"(VLen));
+ if (VLen) {
----------------
topperc wrote:
I guess it wouldn't. I'll remove
https://github.com/llvm/llvm-project/pull/225486
More information about the llvm-commits
mailing list