diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -1516,6 +1516,7 @@ RVV_VXSAT, RVV_VXRM, RVV_VCSR, + RVV_VLENB, }; static __inline__ __attribute__((__always_inline__, __nodebug__)) @@ -1534,6 +1535,9 @@ case RVV_VCSR: __asm__ __volatile__ ("csrr\t%0, vcsr" : "=r"(__rv) : : "memory"); break; + case RVV_VLENB: + __asm__ __volatile__ ("csrr\t%0, vlenb" : "=r"(__rv) : : "memory"); + break; } return __rv; } diff --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c b/clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c --- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c +++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vread-csr.c @@ -40,3 +40,12 @@ unsigned long vread_csr_vcsr(void) { return vread_csr(RVV_VCSR); } + +// CHECK-LABEL: @vread_csr_vlenb( +// CHECK-NEXT: entry: +// CHECK-NEXT: [[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vlenb", "=r,~{memory}"() #[[ATTR1]], !srcloc !8 +// CHECK-NEXT: ret i64 [[TMP0]] +// +unsigned long vread_csr_vlenb(void) { + return vread_csr(RVV_VLENB); +}