[llvm-dev] Adding a new instruction

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


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!

On 18 April 2016 at 02:10, Vladimir Miloserdov via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello Ammar,
>
> Can you share the patch of changes in LLVM you have done already?
>
> Regards,
> Vladimir
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160418/b1ac629f/attachment.html>


More information about the llvm-dev mailing list