[PATCH] EABI Divmod Legal

Renato Golin renato.golin at linaro.org
Mon Sep 2 14:34:29 PDT 2013


Hi Anton,

First of all, this patch is not a merge request, but a request for comments.

Some background...

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.

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.

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.

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:

* Change the RetNum/RetSize by some annotation on the library call. Tim
mentioned an extra operand. Or we could improve RTLIB::Libcall.
* Change TLI.usesRegistersForDivMod() by TLI.isLibCallInRegs(LC), so that
each back-end can extend only for its own specific functions.

Any Custom lowering for REM/DIVREM will incur in type legalization
nightmare for 64-bit on ARM.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130902/f32c1b00/attachment.html>


More information about the llvm-commits mailing list