<div dir="ltr"><div><div>Thanks for your reply.<br><br></div>I was able to fix the problem by having a return type for result. <br></div>Something like:<br>SDNode *Result = CurDAG->getMachineNode(Mips::INSTR, SDLoc(Node), <br>                                        ReturnValueVT, MVT::Other,  Ops); <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 9, 2015 at 5:05 PM, Daniel Sanders <span dir="ltr"><<a href="mailto:Daniel.Sanders@imgtec.com" target="_blank">Daniel.Sanders@imgtec.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Have you found the mips_cfcmsa intrinsic? It's the only example of a INTRINSIC_W_CHAIN with a result and an argument that I can think of.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">This is just a guess but does the BWT_DROP_RESULT instruction have an output? If not, I'd guess that the problem is that ReplaceUses() is trying to use the first output of
 Result (which has no outputs and therefore asserts when it this is attempted) as a replacement for the first output of Node.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Ambuj Agrawal<br>
<b>Sent:</b> 09 March 2015 11:07<br>
<b>To:</b> <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> [LLVMdev] LLVM Backend DAGToDAGISel INTRINSIC<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I am currently working on DAGToDAGISel class for MIPS and am trying to figure out a way to use INTRINSIC_W_CHAIN for an intrinsic which can return a value.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">My intrinsic is defined as:<br>
  Intrinsic<[llvm_i32_ty],[llvm_i32_ty,llvm_i32_ty,llvm_i32_ty,llvm_i32_ty],[IntrReadWriteArgMem]>;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">i.e. it has four arguments and one return value<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">In DAGToDAGISel when I try to pass it with four arguments and a return register it fails the assertion `ResNo < NumValues && "Illegal result number!"'.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">More specifically I am doing something like:<br>
              EVT ReturnValueVT = Node->getValueType(0) ;<br>
              SDValue ChainIn = Node->getOperand(0);<br>
              SDValue Zero = CurDAG->getCopyFromReg(ChainIn, DL,<br>
                                                                      Mips::ZERO, MVT::i32);<br>
              SDValue op0 = Node->getOperand(2);<br>
              SDValue op1 = Node->getOperand(3);<br>
              SDValue op2= Node->getOperand(4);<br>
              SDValue op3 = Node->getOperand(5);      <br>
              SDValue Ops[]= { op0, op1, op2, op3, Zero, ChainIn };<br>
              SDNode *Result = CurDAG->getMachineNode(Mips::BWT_DROP_RESULT, SDLoc(Node),
<br>
                                        ReturnValueVT, Ops);<br>
              ReplaceUses(Node, Result);  <br>
              return std::make_pair(true, Result); <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Any clues on how INTRINSIC_W_CHAIN differs from INTRINSIC_VOID?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<p class="MsoNormal">Ambuj Agrawal<u></u><u></u></p>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>