[llvm-dev] Adding libcall support for Rust's new vector math library

Sjoerd Meijer via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 8 02:48:30 PDT 2021


Sounds like a good plan to me, but perhaps others know more/better.
Clang option -fveclib=‚Äč can be used to specify a vector library, so I think the infrastructure is there and you'll just need to plumb in support for yours.

Cheers.
________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Jacob Lifshay via llvm-dev <llvm-dev at lists.llvm.org>
Sent: 08 June 2021 03:19
To: llvm-dev <llvm-dev at lists.llvm.org>
Cc: Jubilee Young <workingjubilee at gmail.com>
Subject: [llvm-dev] Adding libcall support for Rust's new vector math library

We're writing a vector math library for use with Rust's Project Portable SIMD, where we would like to have fast architecture-independent implementations of functions like vectorized cos that are available from Rust's `core` library, where the requirement is that it can't depend on system libraries such as libc or libm. In order to have Rust code run as fast as possible, we want to have the Rust compiler generate calls to LLVM intrinsics such as llvm.cos.v4f32 allowing LLVM to optimize those intrinsics and generate native instructions where available, otherwise generating calls to the Rust vector math library functions that implement the appropriate functions.

Tracking issue for vector math library with more details:
https://github.com/rust-lang/stdsimd/issues/109

WIP vector math library:
https://salsa.debian.org/Kazan-team/vector-math/

What all is required to get LLVM to generate libcalls to our vector math library? Does this sound like a good plan?

Also, there are some math functions that don't currently have generic LLVM intrinsics, that several different architectures support, such as sinpi which is supported by AMDGPU (multiply input by 0.5 then use the `sin` instruction), OpenCL-flavored SPIR-V, Libre-SOC's SimpleV (not in LLVM yet), and probably others too.

Jacob Lifshay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210608/b2416259/attachment.html>


More information about the llvm-dev mailing list