[llvm-dev] ADDING A CUSTOM INSTRINSIC

Ryan Taylor via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 19 07:34:10 PDT 2017


For the front-end (clang) you'll need:

clang/lib/CodeGen/CGbuiltin.cpp - handle case of new builtin intrinsic
(EmitXXXSpecificBuiltinExpr)
clang/lib/CodeGen/CodeGenFunction.cpp - define llvm::Instrinsic::ID
clang/lib/CodeGen/CodeGenFunction.h - declare llvm::Intrinsic::ID
clang/lib/Sema/SemaChecking.cpp - for semantic checking of your intrinsic
if overloaded, for example, you might not need this step
clang/include/clang/Basic/BuiltinsXXX.def

For backend:

include/llvm/IR/IntrinsicsXXX.td - this is the file we use to def our XXX
intrinsics, just for example, you should have a file here like this, you'll
notice one for every 'in tree' arch
lib/Target/XXX/XXXIntrinsics.td - you don't need this file, you just need
this intrinsic mapping somewhere in the table gen (we have tons of these so
it's nice organization for us), looks like you've already done this step





On Mon, Jun 19, 2017 at 10:15 AM, Sayantan Majumdar via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello all. I am new to LLVM. I have added a custom intrinsic *foo* by
> creating a new folder in *lib/Target/Foo* and creating a new file *Foo.td*.
> I then built the entire llvm project and the intrinsic *foo* has been
> added successfully. But I am unable to figure out how to add the pseudo
> instruction for it. For example if I want my intrinsic foo to perform
> multiplication of two integers, where should I add this instruction? I have
> googled a lot and couldn't find anything concrete.
> --
>
> Sayantan Majumdar
> Research Intern at RISE Lab,
> Indian Institute of Technology Madras, Chennai
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170619/bb805fe8/attachment.html>


More information about the llvm-dev mailing list