Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable vector unit without misa.V #430

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions gloss/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,20 @@ _skip_init:
csrwi fcsr, 0
1:

/* Check for vector extension support and enable it if found.
* Omit if toolchain doesn't support the vector extension. */
#ifdef __riscv_v
csrr a5, misa
li a4, 0x200000
and a5, a5, a4
beqz a5, 1f
/* Check for vector extension support and enable the vector unit if found.
* Omit if the toolchain doesn't support any vector extension.
* (NB: __riscv_vector is defined for V as well as Zve*.) */
#ifdef __riscv_vector
/* Unfortunately, Zve* (embedded vector extensions) do not set misa.V,
* so, until the RISC-V standard discovery mechanism is finalized, we use
* a trick: we set mstatus.VS to Dirty, and then read it back. It's set to
* Off iff there's no vector unit. This should detect the presence of any
* standard vector extension (V or Zve*) or the absence of all. */
li a5, 0x600
csrs mstatus, a5
csrr a5, mstatus
ori a5, a5, 0x200
csrw mstatus, a5
andi a5, a5, 0x600
beqz a5, 1f
vsetivli x0, 0, e8, m1, ta, ma
csrwi vcsr, 0
1:
Expand Down