[cfe-dev] Questions on adding a CLANG builtin to connect to a LLVM intrinsic

Jessica Clarke via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 18 03:52:56 PST 2022


On 18 Jan 2022, at 11:34, David Mallasén Quintana via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hello,
> 
> I have added new instructions to the RISC-V LLVM backend for some
> specific hardware I developed and I want to access a sequence of them
> directly from C code. As of now I do this using inline assembly but it
> can be a bit cumbersome. If I'm not mistaken the way to go would be to
> access this functionality from C with CLANG builtins and lowering this
> to machine code with LLVM intrinsics that generate my target RISC-V
> instructions.
> 
> I have seen the documentation on how to add LLVM intrinsics. However,
> I can't find something similar with CLANG builtins, so any pointers to
> some documentation would be greatly appreciated. Also, if there is a
> better way of achieving this I would be grateful for some information
> on how it could be done.

Just git grep for your favourite RISC-V builtin and copy it? You should
find two relevant files, ignoring tests.

Jess



More information about the cfe-dev mailing list