<div dir="ltr">Hi Anton,<div><br></div><div>First of all, this patch is not a merge request, but a request for comments.</div><div><br></div><div>Some background...</div><div><br></div><div>We wanted to implement multiple value_in_regs returns (needed for divmod library calls), and that could be changed in the generic code, or in the specific code.</div>
<div><br></div><div>We decided to change in the specific code, as it would be only ARM EABI, and the current LowerDivMod() was the result of that move. However, it had a serious short-coming: it made it really difficult to add 64-bit values to call aeabi_ldivmod. Plus, there are other library calls in ARM and x86 that have the same issue, so we were looking for a generic idea that would work for all targets, but still be generic enough to not get in the way of other library calls.</div>
<div><br></div><div>Furthermore, Amaury is working on an extension to Clang to enable library intrinsic calls, or user functions to be annotated with value_in_regs (via an attribute), and that to be lowered using the same mechanism. So I revisited my old solution, and with a few hacks, I found that it worked out-of-the-box for 64-bit values as well, which is a big plus. But it has two problems (as stated in the diff), plus the issue that the Clang attribute value_in_regs won't say *how* the values will be lowered in registers, in case of multiple values.</div>
<div><br></div><div>So, all in all, this patch won't get in as it is now, and is just a starting point (that works) for a less-hacky way of doing things. A few things I think should be done:</div><div><br></div><div>* Change the RetNum/RetSize by some annotation on the library call. Tim mentioned an extra operand. Or we could improve RTLIB::Libcall.</div>
<div>* Change TLI.usesRegistersForDivMod() by TLI.isLibCallInRegs(LC), so that each back-end can extend only for its own specific functions.</div><div><br></div><div>Any Custom lowering for REM/DIVREM will incur in type legalization nightmare for 64-bit on ARM.</div>
<div><div class="gmail_extra"><br></div></div></div>