<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="">The intrinsic ID is an int, not a float.<div class=""><br class=""></div><div class="">—escha</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 24, 2016, at 7:49 AM, Ryan Taylor 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 dir="ltr" class=""><div class="">given the following C code:</div><div class=""><br class=""></div><div class="">float b=16, a=0;</div><div class="">int main() {</div><div class=""> float a = sqrt(b);</div><div class=""> return0;</div><div class="">}</div><div class=""><br class=""></div><div class="">I'm trying to lower FSQRT down, but getting a casting issue, my code is:</div><div class=""><br class=""></div><div class="">SDValue XXXLowering::LowerFSQRT(SDValue Op, SelectionDAG &DAG) const {</div><div class=""> SDLoc DL(Op);</div><div class=""> EVT VT = Op.getValueType();</div><div class=""> SDValue LHS = Op.getOperand(0);</div><div class=""><br class=""></div><div class=""> SDValue newNode = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, DAG.getTargetConstantFP(Intrinsic::my_intrinsic, DL, VT), LHS);</div><div class=""> return newNode;</div><div class="">}</div><div class=""><br class=""></div><div class="">The error I'm getting is: Assertion 'isa<X>(Val) && "cast<Ty>() argument of incompatible type!"</div><div class=""><br class=""></div><div class="">Is this the correct way to add intrinsic dag node?</div><div class=""><br class=""></div><div class="">Thanks.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Feb 2, 2016 at 5:10 PM, Ryan Taylor <span dir="ltr" class=""><<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Matt, </div><div class=""><br class=""></div><div class=""> The added intrinsic in DAG looks like:</div><div class=""><br class=""></div><div class="">0xbedb698: i32 = llvm.MyIntrinsic 0xbedb200, 0xbedac18 [ORD=4]</div><div class=""><br class=""></div><div class=""> The builtin in DAG looks like:</div><div class=""><br class=""></div><div class="">0xbedb2a8: i32,ch = llvm 0xbedb158:1, 0xbedb200, 0xbedb158 [ORD=7] [ID=16]<br class=""></div><div class=""><br class=""></div><div class=""> The only difference I'm seeing is the extra operand, which is a 'ch' from a load.<br class=""></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Feb 2, 2016 at 3:55 PM, Matt Arsenault <span dir="ltr" class=""><<a href="mailto:arsenm2@gmail.com" target="_blank" class="">arsenm2@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
> On Feb 2, 2016, at 12:43, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>> wrote:<br class="">
><br class="">
> Matt,<br class="">
><br class="">
</span><span class="">> This seems to generate llvm.my_intrinsic just fine in the DAG, so no DAG errors; however, it won't match. For example, if I call the intrinsic from C, the DAG node looks to be named the same in dotty file but it won't match... am I missing something?<br class="">
><br class="">
> I've done it exactly the way it was done above. The DAG looks great but it won't match. Did I miss something?<br class="">
><br class="">
> Thanks.<br class="">
><br class="">
<br class="">
</span>Are you using the right intrinsic type? Does it have a chain or result?<br class="">
<br class="">
How are you calling it from C? Are you declaring the intrinsic? This can fail if you mismatched the readnone or readonly to the actual intrinsic definition<br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>