<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’ve implemented something similar, though maybe not similar enough to be able to help you. My target supports increment and decrement, both pre and post, by an explicit constant in the range 1 to 8.<div class=""><br class=""></div><div class="">I didn’t write any custom lowering code, just used setIndexedLoadAction() and setIndexedStoreAction() in my ISelLowering to identify the types and actions, e.g.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>setIndexedLoadAction(ISD::PRE_INC, MVT::i16, Legal);</div><div class=""><br class=""></div><div class="">I didn’t think it was possible to match an indexed load or store using a TableGen pattern because it can’t match instructions with more than one output operand, though maybe things have changed and I’ve not noticed. So, I wrote custom code in my ISelDAGToDAG to match indexed loads and store and to select these instructions. That seems to work fine for constant increments/decrements. I don’t know whether the indexed load and store actions would deal with increment or decrement by a register.</div><div class=""><br class=""></div><div class="">I’ve also got an addressing mode similar to yours in which an address can be formed from a 16-bit register plus a zero-extended 8-bit register. I used a ComplexPattern to match the address expression and MIOperandInfo to specify the classes of the registers, e.g.</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>def memR16R8 : Operand<i16> {</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>let MIOperandInfo = (ops Reg16Class, Reg8Class);</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>...</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div class=""><br class=""></div><div class="">Again, this seems to work OK for me.</div><div class=""><br class=""></div><div class="">Steve</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 30 Oct 2015, at 10:43, Martin J. O'Riordan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">I have a rudimentary implementation for load and store instructions, where the memory address operand is automatically post-incremented when the load or store instruction is issued. However, this is currently coded using custom lowering, and explicit pattern matching in the ‘</span><span style="font-size: 12pt; font-family: 'Courier New';" class="">ISelDAGtoDAG</span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">’ implementation. But it seems to me that I ought to be able to achieve this exclusively using TableGen with minimal custom C++ code, but I can’t quite get the patterns to work to achieve this.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">I have two types of post-increment:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt 36pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -18pt;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><span class="">1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';" class=""> <span class="Apple-converted-space"> </span></span></span></span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">increment by an implied constant which is the size of the object being loaded or stored<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt 36pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: -18pt;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><span class="">2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-family: 'Times New Roman';" class=""> <span class="Apple-converted-space"> </span></span></span></span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">increment by the value contained in another register<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">It should be possible to do these with the same underlying pattern, but providing a DAG fragment like ‘</span><span style="font-size: 12pt; font-family: 'Courier New';" class="">(i32 2)</span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">’ for an ‘</span><span style="font-size: 12pt; font-family: 'Courier New';" class="">i16</span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">’ load explicitly in the TableGen specialisation for the first form, and the actual register chain for the second.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">But I don’t seem to be quite get it to work, and in some cases the patterns I have attempted have crashed TableGen itself<span class="Apple-converted-space"> </span></span><span style="font-size: 12pt; font-family: Wingdings;" class="">L</span><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""> The incrementing store sort of works, but the incrementing load doesn’t (at least not using TableGen alone).<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">The other form of addressing mode is where the address is a “base” plus signed “offset” register. My patterns for this work okay, but I have a limitation. The “offset” register is 16-bits, and in particular, it is the low-order 16-bits of a 32-bit actual register. But even though I have explicitly stated in TableGen that the offset register is 16-bits and stated the appropriate register class, the code-generation still uses the instructions “as if” the offset register is 32-bits.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">Memory addresses in this architecture are 32-bits.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">Has anybody solved similar problems, and have advice or examples of how to do this? Or is simply something that TableGen descriptions cannot completely describe? I have looked at the other targets for inspiration, but they don’t quite seem to do what I need.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class="">Thanks,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""> Martin O’Riordan - Movidius Ltd.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: 'Book Antiqua', serif;" class=""><o:p class=""> </o:p></span></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="color: purple; text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div><br class=""></div></body></html>