Ryan Taylor via llvm-dev
2016-Feb-24 14:42 UTC
[llvm-dev] Invalid number for the given node in SelectionDAG
I'm trying to replace SDIvRem (whch returns two i16 types) with a custom that returns i32 or i16. I am getting the Assertion (!Node || ResNo < Node->getNumValues() && "Invalid result number for the given node!") Seems that it doesn't like returning one value but how do you return more than one value? I am doing this in the LowerOperation for the case SDIVREM and a function LowerSDIVREM inside XXXISelLowering.cpp I looked at some other cases, such as arm, and it generates a pair and then returns the first of the pair, this does not work for me however. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160224/3577db05/attachment.html>
Tim Northover via llvm-dev
2016-Feb-24 15:16 UTC
[llvm-dev] Invalid number for the given node in SelectionDAG
Hi Ryan, On 24 February 2016 at 06:42, Ryan Taylor via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Seems that it doesn't like returning one value but how do you return more > than one value?You create the node using a getNode call that takes either an ArrayRef<EVT> or an SDVTList instead of a single EVT result type. Then you almost always need to write C++ code in ISelDAGToDAG to select it properly. Alternatively, you could lower it to multiple instructions (e.g. division, multiplication and subtraction) and then recombine them at the end with a MERGE_VALUES node as above. Then since each actual instruction only has one value, normal TableGen could handle selection and the generic infrastructure will take care of the MERGE_VALUES.> I looked at some other cases, such as arm, and it generates a pair and then > returns the first of the pair, this does not work for me however.The pair in the ARM case is unrelated to the pair in the DIVREM itself. The second SDValue is the chain that any function call will produce for ordering purposes, which isn't needed because no load/store/side-effecty things can depend on a DIVREM. That first SDValue will be a node with two results as I described above. Cheers. Tim.
Ryan Taylor via llvm-dev
2016-Feb-24 15:18 UTC
[llvm-dev] Invalid number for the given node in SelectionDAG
Tim, Thanks for the reply. I found the merge values function and am trying that route now. Thanks. On Feb 24, 2016 10:16 AM, "Tim Northover" <t.p.northover at gmail.com> wrote:> Hi Ryan, > > On 24 February 2016 at 06:42, Ryan Taylor via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Seems that it doesn't like returning one value but how do you return more > > than one value? > > You create the node using a getNode call that takes either an > ArrayRef<EVT> or an SDVTList instead of a single EVT result type. Then > you almost always need to write C++ code in ISelDAGToDAG to select it > properly. > > Alternatively, you could lower it to multiple instructions (e.g. > division, multiplication and subtraction) and then recombine them at > the end with a MERGE_VALUES node as above. Then since each actual > instruction only has one value, normal TableGen could handle selection > and the generic infrastructure will take care of the MERGE_VALUES. > > > I looked at some other cases, such as arm, and it generates a pair and > then > > returns the first of the pair, this does not work for me however. > > The pair in the ARM case is unrelated to the pair in the DIVREM > itself. The second SDValue is the chain that any function call will > produce for ordering purposes, which isn't needed because no > load/store/side-effecty things can depend on a DIVREM. > > That first SDValue will be a node with two results as I described above. > > Cheers. > > Tim. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160224/bb9f3858/attachment.html>