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!