[PATCH] D24071: [compiler-rt] [builtins] Allow building the necessary ARM builtins for MSVC mode with cmake
Renato Golin via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 31 06:08:58 PDT 2016
rengolin added a comment.
In https://reviews.llvm.org/D24071#530159, @mstorsjo wrote:
> Actually, in my testing with a fairly large codebase, it doesn't emit any EABI calls (those are only hooked up in ARMISelLowering.cpp if the target uses EABI) - the only ones outside of the ones that are present in the msvc "builtins" static lib are __moddi3 and __umoddi3.
Probably the last ones missing.
> With a bit of crude hacking, I managed to hook up __rt_sdiv and __rt_sdiv64 to be called in the same fashion as __aeabi_idivmod and __aeabi_ldivmod. But there's another gotcha - __rt_sdiv takes the two operands in the opposite order compared to __aeabi_idivmod. How do I change that for these ones?
Why on Earth would anyone do that, if not on purpose, to make user code non-portable?
Right, then you'll need a more complicated lowering.
Basically, divmod is lowered by a SelectionDAG function that behaves like GNU (returns quot, mod stored in the second argument's address). ARM has a special lowering, which uses EABI reg-return (quot in r0 or r0/r1, mod in r1 or r2/r3).
You can try to flip the arguments in one of the functions, probably both, to swap the arguments before processing.
Using "isWindowsABI" won't work, since "__rt_div" and friends are used elsewhere. Or you can create a special Dag node just for __rt_div and friends, which would be equally ugly.
I seriously hope you can come up with a better idea... :)
More information about the llvm-commits