Hello Ammar,
Can you share the patch of changes in LLVM you have done already?
Regards,
Vladimir
Hello Ammar,
Can you share the patch of changes in LLVM you have done already?
Regards,
Vladimir
Hey Vladmir,
Here’s what and where i added :
1- **llvm/include/llvm/IR/**Instruction.def :
Line 136 : HANDLE_BINARY_INST(23, increment , BinaryOperator) also changed all numbers accordingly
2- **llvm/include/llvm/IR/**Instructions.h:
Line 699:
enum BinOp {
/// *p = v
Xchg,
/// *p = old + v
Add,
/// *p = old + 1
increment,
3-**llvm/include/llvm/IR/InstVisitor.h**
: NO Change, since binary operator visit is already defined
4 - llvm/lib/AsmParser/LLLexer.cpp
:
Line 717 : INSTKEYWORD(add, Add); INSTKEYWORD(increment, increment); INSTKEYWORD(fadd, FAdd);
5 - llvm/lib/AsmParser/LLParser.cpp
:
Line 2865 : case lltok::kw_increment:
Line 2887 : if (Opc == Instruction::Add || Opc == Instruction::increment || Opc == Instruction::Sub ||
Line 2918 : case Instruction::myAdd:
Line 4737 : case lltok::kw_increment:
Line 5942 : case lltok::kw_increment: Operation = AtomicRMWInst::increment; break;
6 - llvm/lib/Bitcode/Reader/BitcodeReader.cpp
:
**Line 748 :**case bitc::BINOP_increment: return IsFP ? -1 : Instruction::increment;
Line 782 : case bitc::RMW_increment: return AtomicRMWInst::increment;
Line 2720 : Opc == Instruction::increment||
Line 4113 : Opc == Instruction::increment||
7 - llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
:
Line 91 : case Instruction::increment:return bitc::BINOP_increment;
Line 116 : case AtomicRMWInst::increment: return bitc::RMW_increment;
8 - llvm/lib/IR/Instruction.cpp
:
Line 211 : case increment: return “increment”;
Line 495 : Opcode == Add || Opcode == increment || Opcode == Mul;
Line 522 : case increment:
9 - llvm/lib/IR/Instructions.cpp
:
Line 1939 : case increment:
I’ve made these changes following the official document here : http://llvm.org/docs/ExtendingLLVM.html
Please let me know if i’m doing something wrong or anything else needs to be changed.
ThankYou!
So i fixed this error, i had to add LLVMincrement in core.h as a BINOP and a couple more fixes after this fix, however, after a successful make, LLVM still does not recognize my increment instruction and i get the error expected instruction opcode when i run with lli.
Please guide if anyone has added any instruction successfully to LLVM, does not necessarily have to be a binary op,i’ll pick up from wherever we are, I can not find anything at all except the official link which doesn’t seem very helpful!