Skip to content

[RISCV] Support CoreV SIMD builtins in Clang

Created by: melonedo

This PR adds on top of #27 support for clang to use __builtin_riscv_cv_simd_xxx functions. To avoid merge conflicts, a copy of #27 is also included here temporarily before it is merged.

In this PR, I defined Clang builtins according to corev-builtin-spec.md. Their signature should match the specification. To support these builtin functions in a straightforward way in LLVM, I also defined synonymous LLVM intrinsics with format llvm.riscv.cv.simd.xxx. However, LLVM does not seem very happy with i16 or i8 arguments which do not perfectly fit in a machine register, so all i8 or i16arguments are zero-extended to i32 before the corresponding LLVM intrinsic is called.

With the constraint of llvm lit, the tests for Clang only reach LLVM IR level, which is not ideal. Although it can be manually checked they do generate CoreV instructions here, I believe tests that compile to assembly are needed as https://github.com/openhwgroup/corev-llvm-project/issues/28#issuecomment-1428203145 points out.

Merge request reports

Loading