summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorPiyush Patle <[email protected]>2026-10-14 06:43:49 +0530
committerGitHub <[email protected]>2026-10-14 09:13:49 +0800
commitf9436bb5bdabb9670792b22f79467b0ef16bff47 (patch)
tree909f5655d07898cdce5b07e17903c92b9408eb31 /libcpu
parent270a18d29239b92f21b4c8c0ac18d3a89e660da9 (diff)
[risc-v][vector] Restore vstart after vector configuration
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/risc-v/vector/rvv-1.0/rvv_context.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/libcpu/risc-v/vector/rvv-1.0/rvv_context.h b/libcpu/risc-v/vector/rvv-1.0/rvv_context.h
index 4466b3aeff..f5ec4d4ae8 100644
--- a/libcpu/risc-v/vector/rvv-1.0/rvv_context.h
+++ b/libcpu/risc-v/vector/rvv-1.0/rvv_context.h
@@ -12,17 +12,20 @@
#define __RVV_CONTEXT_1_0_H__
#if defined(ARCH_VECTOR_VLEN_128)
- #define CTX_VECTOR_REGS 64
+#define CTX_VECTOR_REGS 64
#elif defined(ARCH_VECTOR_VLEN_256)
- #define CTX_VECTOR_REGS 128
+#define CTX_VECTOR_REGS 128
#else
#error "No supported VLEN"
#endif /* VLEN */
-#define CTX_VECTOR_REG_NR (CTX_VECTOR_REGS + 4)
+#define CTX_VECTOR_REG_NR (CTX_VECTOR_REGS + 4)
#ifdef __ASSEMBLY__
+/* The following macros contain assembler, not C. */
+/* clang-format off */
+
/**
* ==================================
* VECTOR EXTENSION
@@ -97,16 +100,19 @@
mv t1, t0
- LOAD t0, VEC_FRAME_VSTART(t1)
- csrw vstart, t0
LOAD t0, VEC_FRAME_VCSR(t1)
csrw vcsr, t0
LOAD t0, VEC_FRAME_VTYPE(t1)
LOAD t3, VEC_FRAME_VL(t1)
VEC_CONFIG_SET_VL_VTYPE(t3, t0)
+
+ /* vsetvl resets vstart, so restore the restart index last. */
+ LOAD t0, VEC_FRAME_VSTART(t1)
+ csrw vstart, t0
.endm
+/* clang-format on */
#endif
#endif /* __RVV_CONTEXT_H__ */