[llvm-dev] ADDING A CUSTOM INSTRINSIC

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[llvm-dev] ADDING A CUSTOM INSTRINSIC

Tim Northover via llvm-dev
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] ADDING A CUSTOM INSTRINSIC

Tim Northover via llvm-dev
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 <[hidden email]> 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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...