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.
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
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