<div dir="ltr">Hi Tim,<div><br></div><div>Thank you for your response. Meanwhile, I stumbled over the same function.</div><div>I added a case in <span style="font-size:12.8px">ExpandMI for ARM::FOO_CMP. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">First, I want to emit a simple equal comparison for that intrinsic. However, I don't understand how to retrieve the return register for the intrinsic.</span></div><div><span style="font-size:12.8px">I tried the following:</span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">case ARM::FOO: {</span></div><div><span style="font-size:12.8px">      DebugLoc DL = MBBI->getDebugLoc();</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">      BuildMI(&MBB, DL, TII->get(ARM::CMPrr))</span></div><div><span style="font-size:12.8px">        .addReg(MI.getOperand(1).getReg())</span></div><div><span style="font-size:12.8px">        .addReg(MI.getOperand(2).getReg())</span></div><div><span style="font-size:12.8px">        .addImm(ARMCC::NE);</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">      MI.eraseFromParent(); // The pseudo is gone now.</span></div><div><span style="font-size:12.8px">      return true;</span></div><div><span style="font-size:12.8px">    }</span></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">AFAIK, </span><span style="font-size:12.8px">BuildMI() expects another parameter for the destination but how to retrieve that from the pseudo instruction?</span><span style="font-size:12.8px"> </span></div><div><span style="font-size:12.8px">In the future, the implementation of this instruction will get more complex and requires a temporary register for computation. How can I allocate a register at that stage of compiling?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks & Cheers,</span><br></div><div><span style="font-size:12.8px">Max<br></span><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 10, 2017 at 3:30 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Max,<br>
<br>
On 10 February 2017 at 02:12, Max Muster via llvm-dev<br>
<span class="gmail-"><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> Can someone guide me on how to proceed and emit machine instructions for<br>
> that intrinsic?<br>
<br>
</span>Next step is probably to handle FOO_CMP in ARMExpandPseudoInsts.cpp.<br>
It's a pass that runs after most optimizations (maybe even all) so<br>
it's where most sensitive pseudo-instructions are expanded.<br>
<br>
There's plenty of other examples of how to do it in that file (the<br>
ExpandMI function), all following pretty similar patterns.<br>
<br>
Cheers.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div></div></div>