[llvm-dev] Adding a new instruction

Ammar Naqvi via llvm-dev llvm-dev at lists.llvm.org
Sun Apr 17 18:30:19 PDT 2016


Hello Everyone,

I'm trying to add a new instruction to LLVM; a binary operator named
"increment" that adds 1 to its LHS value.

I've followed this http://llvm.org/docs/ExtendingLLVM.html and added my
operator in the required places however, LLVM does not recognize the
"increment" opcode instruction in the bitcode file; I get the error: *expected
instruction opcode*. at the place of "increment".

Then i try doing a make from build directory to make sure my instruction is
added to the necessary files however i get the *error:*

*/home/test/llvm/include/llvm/IR/Instruction.def: In function ‘LLVMOpcode
map_to_llvmopcode(int)’:*
*/home/test/llvm/lib/IR/Core.cpp:971:54: error: ‘LLVMincrement’ was not
declared in this scope*
* #define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;*
*                                                      ^*
*/home/test/llvm/include/llvm/IR/Instruction.def:42:48: note: in expansion
of macro ‘HANDLE_INST’*
* #define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode,
Class)*
*                                                ^*
*/home/test/llvm/include/llvm/IR/Instruction.def:136:1: note: in expansion
of macro ‘HANDLE_BINARY_INST’*
* HANDLE_BINARY_INST(23, increment, BinaryOperator) . . .*

I'm really stuck at this point and can not see the error through, any help
is greatly appreciated!

Thanks! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160417/d1db902e/attachment.html>


More information about the llvm-dev mailing list