The intrinsic ID is an int, not a float. —escha> On Jun 24, 2016, at 7:49 AM, Ryan Taylor via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > given the following C code: > > float b=16, a=0; > int main() { > float a = sqrt(b); > return0; > } > > I'm trying to lower FSQRT down, but getting a casting issue, my code is: > > SDValue XXXLowering::LowerFSQRT(SDValue Op, SelectionDAG &DAG) const { > SDLoc DL(Op); > EVT VT = Op.getValueType(); > SDValue LHS = Op.getOperand(0); > > SDValue newNode = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, DAG.getTargetConstantFP(Intrinsic::my_intrinsic, DL, VT), LHS); > return newNode; > } > > The error I'm getting is: Assertion 'isa<X>(Val) && "cast<Ty>() argument of incompatible type!" > > Is this the correct way to add intrinsic dag node? > > Thanks. > > > On Tue, Feb 2, 2016 at 5:10 PM, Ryan Taylor <ryta1203 at gmail.com <mailto:ryta1203 at gmail.com>> wrote: > Matt, > > The added intrinsic in DAG looks like: > > 0xbedb698: i32 = llvm.MyIntrinsic 0xbedb200, 0xbedac18 [ORD=4] > > The builtin in DAG looks like: > > 0xbedb2a8: i32,ch = llvm 0xbedb158:1, 0xbedb200, 0xbedb158 [ORD=7] [ID=16] > > The only difference I'm seeing is the extra operand, which is a 'ch' from a load. > > On Tue, Feb 2, 2016 at 3:55 PM, Matt Arsenault <arsenm2 at gmail.com <mailto:arsenm2 at gmail.com>> wrote: > > > On Feb 2, 2016, at 12:43, Ryan Taylor <ryta1203 at gmail.com <mailto:ryta1203 at gmail.com>> wrote: > > > > Matt, > > > > 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? > > > > I've done it exactly the way it was done above. The DAG looks great but it won't match. Did I miss something? > > > > Thanks. > > > > Are you using the right intrinsic type? Does it have a chain or result? > > 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 > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160624/1e694ea9/attachment.html>
That's what I thought but I got the same error with: DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, DAG.getTargetConstant(Intrinsic::my_intrinsic, DL, MVT::i16), LHS); Thanks. What should this call look like? On Fri, Jun 24, 2016 at 10:53 AM, <escha at apple.com> wrote:> The intrinsic ID is an int, not a float. > > —escha > > On Jun 24, 2016, at 7:49 AM, Ryan Taylor via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > given the following C code: > > float b=16, a=0; > int main() { > float a = sqrt(b); > return0; > } > > I'm trying to lower FSQRT down, but getting a casting issue, my code is: > > SDValue XXXLowering::LowerFSQRT(SDValue Op, SelectionDAG &DAG) const { > SDLoc DL(Op); > EVT VT = Op.getValueType(); > SDValue LHS = Op.getOperand(0); > > SDValue newNode = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, > DAG.getTargetConstantFP(Intrinsic::my_intrinsic, DL, VT), LHS); > return newNode; > } > > The error I'm getting is: Assertion 'isa<X>(Val) && "cast<Ty>() argument > of incompatible type!" > > Is this the correct way to add intrinsic dag node? > > Thanks. > > > On Tue, Feb 2, 2016 at 5:10 PM, Ryan Taylor <ryta1203 at gmail.com> wrote: > >> Matt, >> >> The added intrinsic in DAG looks like: >> >> 0xbedb698: i32 = llvm.MyIntrinsic 0xbedb200, 0xbedac18 [ORD=4] >> >> The builtin in DAG looks like: >> >> 0xbedb2a8: i32,ch = llvm 0xbedb158:1, 0xbedb200, 0xbedb158 [ORD=7] [ID=16] >> >> The only difference I'm seeing is the extra operand, which is a 'ch' >> from a load. >> >> On Tue, Feb 2, 2016 at 3:55 PM, Matt Arsenault <arsenm2 at gmail.com> wrote: >> >>> >>> > On Feb 2, 2016, at 12:43, Ryan Taylor <ryta1203 at gmail.com> wrote: >>> > >>> > Matt, >>> > >>> > 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? >>> > >>> > I've done it exactly the way it was done above. The DAG looks great >>> but it won't match. Did I miss something? >>> > >>> > Thanks. >>> > >>> >>> Are you using the right intrinsic type? Does it have a chain or result? >>> >>> 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 >>> >>> >> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160624/80ea2bcd/attachment.html>
I've tried all the types (both for result and Intrinsic ID), can't seem to find what cast is causing the issue here. On Fri, Jun 24, 2016 at 11:47 AM, Ryan Taylor <ryta1203 at gmail.com> wrote:> That's what I thought but I got the same error with: > > DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, > DAG.getTargetConstant(Intrinsic::my_intrinsic, DL, MVT::i16), LHS); > > Thanks. > > What should this call look like? > > > On Fri, Jun 24, 2016 at 10:53 AM, <escha at apple.com> wrote: > >> The intrinsic ID is an int, not a float. >> >> —escha >> >> On Jun 24, 2016, at 7:49 AM, Ryan Taylor via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >> given the following C code: >> >> float b=16, a=0; >> int main() { >> float a = sqrt(b); >> return0; >> } >> >> I'm trying to lower FSQRT down, but getting a casting issue, my code is: >> >> SDValue XXXLowering::LowerFSQRT(SDValue Op, SelectionDAG &DAG) const { >> SDLoc DL(Op); >> EVT VT = Op.getValueType(); >> SDValue LHS = Op.getOperand(0); >> >> SDValue newNode = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, VT, >> DAG.getTargetConstantFP(Intrinsic::my_intrinsic, DL, VT), LHS); >> return newNode; >> } >> >> The error I'm getting is: Assertion 'isa<X>(Val) && "cast<Ty>() argument >> of incompatible type!" >> >> Is this the correct way to add intrinsic dag node? >> >> Thanks. >> >> >> On Tue, Feb 2, 2016 at 5:10 PM, Ryan Taylor <ryta1203 at gmail.com> wrote: >> >>> Matt, >>> >>> The added intrinsic in DAG looks like: >>> >>> 0xbedb698: i32 = llvm.MyIntrinsic 0xbedb200, 0xbedac18 [ORD=4] >>> >>> The builtin in DAG looks like: >>> >>> 0xbedb2a8: i32,ch = llvm 0xbedb158:1, 0xbedb200, 0xbedb158 [ORD=7] >>> [ID=16] >>> >>> The only difference I'm seeing is the extra operand, which is a 'ch' >>> from a load. >>> >>> On Tue, Feb 2, 2016 at 3:55 PM, Matt Arsenault <arsenm2 at gmail.com> >>> wrote: >>> >>>> >>>> > On Feb 2, 2016, at 12:43, Ryan Taylor <ryta1203 at gmail.com> wrote: >>>> > >>>> > Matt, >>>> > >>>> > 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? >>>> > >>>> > I've done it exactly the way it was done above. The DAG looks great >>>> but it won't match. Did I miss something? >>>> > >>>> > Thanks. >>>> > >>>> >>>> Are you using the right intrinsic type? Does it have a chain or result? >>>> >>>> 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 >>>> >>>> >>> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160624/f770d927/attachment.html>