llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.03k stars 11.58k forks source link

Is there any generic cpu model support for RVV?Or how to add a cpu model for RISCV? #88851

Open dinyy opened 5 months ago

dinyy commented 5 months ago

While I‘m tryring OpenCL(PoCL) on RISC-V,it call llvm to generate it's kernel. I want to use -march=rv64gcv, but it occurs that I need -mcpu when I use opt. I need a cpu model which support RVV. Now I change the code in llvm-project/llvm/lib/Target/RISCV/RISCVProcessors.td that : image but I don't find other place to change,I saw that page,but code has been changed so much.

dinyy commented 5 months ago

I saw a PR here.But it occured some conflicts.

llvmbot commented 5 months ago

@llvm/issue-subscribers-backend-risc-v

Author: None (dinyy)

While I‘m tryring OpenCL(PoCL) on RISC-V,it call llvm to generate it's kernel. I want to use `-march=rv64gcv`, but it occurs that I need `-mcpu` when I use opt. I need a cpu model which support RVV. Now I change the code in `llvm-project/llvm/lib/Target/RISCV/RISCVProcessors.td` that : ![image](https://github.com/llvm/llvm-project/assets/107465691/ee44f36c-11d4-41e2-9c0c-4a53ab46801c) but I don't find other place to change,I saw that [page](https://discourse.llvm.org/t/custom-risc-v-processor-can-be-selected-via-mcpu-in-llc-but-not-in-clang/5849),but code has been changed so much.
topperc commented 5 months ago

When https://discourse.llvm.org/t/custom-risc-v-processor-can-be-selected-via-mcpu-in-llc-but-not-in-clang/5849 was written, there were two files that contained the list of CPUs. One for the backend and one for the frontend.

Since early 2023, RISCVProcessors.td is used by both the frontend and the backend.

michaelmaitland commented 5 months ago

I saw a PR https://github.com/llvm/llvm-project/pull/84877.But it occured some conflicts.

Have you seen https://github.com/llvm/llvm-project/pull/76357?

I think -march=rva23s64 and -march=rva23u64 profile has V extension. I did search for +v on this commit. You can see more about what extensions are part of which profiles here.

topperc commented 5 months ago

I think -march=rva23s64 and -march=rva23u64 profile has V extension. I did search for +v on this commit. You can see more about what extensions are part of which profiles here.

-march is a clang option. The description mentions the opt tool which does not support -march

dinyy commented 5 months ago

I think -march=rva23s64 and -march=rva23u64 profile has V extension. I did search for +v on this commit. You can see more about what extensions are part of which profiles here.

-march is a clang option. The description mentions the opt tool which does not support -march

So I must add a cpu model, do you mean I could add a cpu model just by changing llvm-project/llvm/lib/Target/RISCV/RISCVProcessors.td? But I added as above picture, and failed.

michaelmaitland commented 5 months ago

https://github.com/llvm/llvm-project/commit/63f742c15f01a25c60f0090a3aceb15bb8985e5e might help you see what is needed to add a new mcpu. It looks like you were on the right path in your original screen shot.

dinyy commented 5 months ago

63f742c might help you see what is needed to add a new mcpu. It looks like you were on the right path in your original screen shot.

Thank you very much, I will try again.

wangpc-pp commented 5 months ago

I saw a PR here.But it occured some conflicts.

I can fix these conflicts and thanks for raising this problem! I think this can be a good use case to push #84877 forward. cc @asb @preames