In file included from test.c:1:
/home/user3/LLVM_RISCV/llvm-project/build/lib/clang/17/include/riscv_vector.h:18:2: error: "Vector intrinsics require the vector extension."
#error "Vector intrinsics require the vector extension."
^
test.c:5:21: error: call to undeclared function 'vsetvl_e64m8'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
unsigned long vl = vsetvl_e64m8(4);
^
2 errors generated.
How can I specify to clang that I am trying to use risc-v Vector extension and how can I get rid of these errors?
Please help.
Is riscv64, aka riscv64-unknown-elf, a bare-metal triple, really what you want?
What ISA does your target hardware have? Bare-metal triples default to rv64imac, whereas hosted (BSDs, Linux, etc) default to rv64gc.
As already mentioned, if you want to change the set of extensions then you use the -march option. If your core has the full-fat V extension then add v to the end, whereas if it’s an embedded core then you may need to subset it with the various Zve* instead.
So I tried running the same code using the following command:
clang -march=rv64izve32x1p0 test.c
I am now getting just this error:
test.c:5:21: error: call to undeclared function 'vsetvl_e64m8'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
unsigned long vl = vsetvl_e64m8(4);
^
1 error generated.
I have built my llvm using the instructions given on this page.