<div dir="ltr">Do instruction aliases do the job?<div><br></div><div><a href="http://llvm.org/docs/CodeGenerator.html#instruction-alias-processing">http://llvm.org/docs/CodeGenerator.html#instruction-alias-processing</a><br></div><div><br></div><div>Is it ok to have the same source file use LD32 in one instruction but LD.32 in the next one, or do you want different modes?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 8, 2016 at 2:24 PM, Martin J. O'Riordan via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</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="#0563C1" vlink="#954F72"><div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Hi LLVM Dev,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">I have an old problem that I’ve wanted to clean-up for some time.  Our chip has gone through a number of iterations in the past few years, but with each revision there have been changes to some of the mnemonics for instructions.  These are mostly very simple, for example we had a 32-bit load from memory instruction named ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">LD32</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ in one version of the chip, but for a later version this was changed to ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">LD.32</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">The semantics and schedule remained the same, but in the TD file I had to introduce two ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">def</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’s for this (actually, I abstract a bit more and use a ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">defm</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’):<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">def LD32_v1 : Instr<... “LD32” ...>,  Requires<[isV1]>;<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">def LD32_v2 : Instr<... “LD.32” ...>, Requires<[isV2]>;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">This all works fine, but there is a large number of them which makes maintenance difficult.  This also adds to the burden of selection when using ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">BuildMI</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ in the C++ code, as I have to do things like:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">if (isV1())<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">  BuildMI(..., TII->get(SHAVE::LD32_v1)<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">else if (isV2())<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">  BuildMI(..., TII->get(SHAVE::LD32_v2)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">What I would like, is for some mechanism that can substitute the version specific mnemonic dynamically (perhaps using a lookup table), and I could reduce the above to just:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">def LD32 : Instr<... “??MetaMnemonic??” ...>;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">and:<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt;font-family:"Courier New"">BuildMI(..., TII->get(SHAVE::LD32)</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Does anyone know how this can be achieved without resort to placing some Meta-Mnemonic for ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">??MetaMnemonic??</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ and replacing this with the version specific value during AsmPrinting?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Some instructions have more elaborate substitutions, but the general principle is the same and there are a large number of instructions that are affected which makes the TD files very large, and the conditional ‘</span><span style="font-size:12.0pt;font-family:"Courier New"">BuildMI</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ code overcomplicated.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p></div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>