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

fix a bug when parsing zvl part of isa string #1810

Closed
wants to merge 1 commit into from

Conversation

ddwolf
Copy link

@ddwolf ddwolf commented Sep 20, 2024

strlen of "zvl" is 3, not 4

test

build spike and enable vector extension

../configure --prefix=$RISCV --with-isa=RV64IMAFDCV_zicntr_zihpm_zvl512
make -j 

write a test case

// filename: a.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
  int vlenb = 0;
  asm volatile ("csrr %0, vlenb\n\t" : "=r"(vlenb));
  printf("vlenb is %d\n", vlenb);
}

compile and build the case

riscv64-unknown-elf-gcc a.c -march=rv64gcv -g -O0 -std=gnu99 -I$RISCV/sysroot/usr/include

run the case

spike  pk a.out -p1 --isa=rv64imafdchv_zicntr_zihpm_zvl64  --priv=msu --hartids=0 

result

vlenb is 64

strlen of "zvl" is 3, not 4

Signed-off-by: dxtao29 <[email protected]>
@ddwolf ddwolf changed the title Update isa_parser.cc fix a bug when parsing zvl part of isa string Sep 20, 2024
Copy link
Collaborator

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct name of the extension is "zvl512b", not "zvl512", so the code does the right thing when the input is correct. But we are obviously doing a bad job of validating inputs here. I'll submit an alternate PR to fix it.

aswaterman added a commit that referenced this pull request Sep 20, 2024
See #1810 for explanation of how this can go wrong.

Resolves #1810
aswaterman added a commit that referenced this pull request Sep 20, 2024
See #1810 for explanation of how this can go wrong.

Resolves #1810
@aswaterman aswaterman reopened this Sep 20, 2024
@aswaterman aswaterman closed this Sep 20, 2024
aswaterman added a commit that referenced this pull request Sep 20, 2024
See #1810 for explanation of how this can go wrong.

Resolves #1810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants