<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 18, 2016 at 5:56 AM, Martin J. O'Riordan <span dir="ltr"><<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-IE" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">Hi Rail,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">We used a very simple pattern expansion (actually, not a pattern fragment).  For example, for AND, ADD (horizontal sum), OR and XOR of 4 elements we use something like the following TableGen structure:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">class HORIZ_Op4<SDNode opc, RegisterClass regVT, ValueType rt, ValueType vt, string asmstr> :<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">    SHAVE_Instr<(outs regVT:$dst), (ins VRF128:$src),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                    !strconcat(asmstr, " $dst $src"),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                    [(set regVT:$dst,<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                      (opc (rt (vector_extract(vt VRF128:$src), 0 ) ),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                        (opc (rt (vector_extract(vt VRF128:$src), 1 ) ),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                          (opc (rt (vector_extract(vt VRF128:$src), 2 ) ),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                            (rt (vector_extract(vt VRF128:$src), 3 ) )<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                          )<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                        )<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                   Â Â Â )<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">                    )]>;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">This is okay for 4 element vectors, and it will get selected if the programmer writes something like:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">vec[0] & vec[1] & vec[2] & vec[3]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">but not with a simple variant like:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">vec[0] & vec[2] & vec[1] & vec[3]<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">If this was properly represented by an ISD node, the other permutations could be more easily handled through normalisation.  We â€œcould” write patterns for each of the permutations, but it is verbose, and in practice most people only write it one way anyway.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">The 8-lane equivalent has TableGen left thinking for quite a long time, and the 16-lane equivalent seems to hang TableGen.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua","serif";color:#1f497d"><u></u> </span></p></div></div></blockquote><div> </div><div>Just out of curiosity how do I specify multiple patterns for the same instruction? I tried putting the pattern in the pattern list but it LLVM complained that I can't set the same register multiple times.</div><div><br></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</div></div>