This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] builtins: Allow building windows arm functions for mingw
ClosedPublic

Authored by mstorsjo on Nov 1 2016, 5:34 AM.

Details

Summary

When building with clang/LLVM in MSVC mode, the msvcrt libraries contain these functions.

When building in a mingw environment, we need to provide them somehow, e.g. via compiler-rt.

The aeabi divmod functions work in the same way as the corresponding __rt_*div* functions for windows, but their parameters are swapped. The functions for converting float to integer and vice versa are the same as their aeabi equivalents, only with different function names.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo updated this revision to Diff 76543.Nov 1 2016, 5:34 AM
mstorsjo retitled this revision from to [compiler-rt] builtins: Allow building windows arm functions for mingw.
mstorsjo updated this object.
mstorsjo added reviewers: rengolin, compnerd.
mstorsjo added a subscriber: llvm-commits.
compnerd requested changes to this revision.Nov 15 2016, 11:05 AM
compnerd edited edge metadata.

I think its nicer to split out the conversion functions for windows into a separate file that can be conditionally built.

lib/builtins/arm/aeabi_idivmod.S
20 ↗(On Diff #76543)

Id rather sink this around the DEFINE_COMPILERRT_FUNCTION. There is a single use, and that makes it more apparent that we are trying to rename the function.

lib/builtins/arm/aeabi_ldivmod.S
21 ↗(On Diff #76543)

Similar.

This revision now requires changes to proceed.Nov 15 2016, 11:05 AM

I think its nicer to split out the conversion functions for windows into a separate file that can be conditionally built.

Sure, will do.

lib/builtins/arm/aeabi_idivmod.S
20 ↗(On Diff #76543)

Well, the same name is used at the end in END_COMPILERRT_FUNCTION as well, although that's a no-op on non-elf platforms. Do you still want the ifdef moved around DEFINE_COMPILERRT_FUNCTION, even though it no longer properly matches the corresponding no-op END_COMPILERRT_FUNCTION in that case?

mstorsjo updated this revision to Diff 78257.Nov 16 2016, 1:49 PM
mstorsjo edited edge metadata.

Moved the int/float conversion wrappers to a separate file. Didn't change the ifdefs for renaming aeabi div functions yet, while awaiting feedback on whether that's really desired.

compnerd added inline comments.Nov 18 2016, 12:41 PM
lib/builtins/arm/aeabi_idivmod.S
18 ↗(On Diff #78257)

Can you please use the

#if defined(__MINGW32__)

form? It makes modifying it easier in the future. (Throughout)

20 ↗(On Diff #76543)

Thats a good point. Lets avoid that then.

lib/builtins/mingw_fixfloat.c
68 ↗(On Diff #78257)

Please clang-format this file.

mstorsjo updated this revision to Diff 78573.Nov 18 2016, 1:05 PM
mstorsjo edited edge metadata.

Changed to use "#if defined(MINGW32)" instead of "#ifdef MINGW32", ran "clang-format -style=LLVM" on the new source file.

compnerd accepted this revision.Nov 19 2016, 1:07 PM
compnerd edited edge metadata.
compnerd added inline comments.
lib/builtins/arm/aeabi_uldivmod.S
36 ↗(On Diff #78573)

Prefer ip over r12. Its easier to remember that as a mnemonic (intra-procedural [scratch]).

This revision is now accepted and ready to land.Nov 19 2016, 1:07 PM
mstorsjo added inline comments.Nov 19 2016, 1:12 PM
lib/builtins/arm/aeabi_uldivmod.S
36 ↗(On Diff #78573)

Ok, I can change that, but do note that the existing code already uses r12 and not ip, right above this block. Do you still prefer ip while making it inconsistent with the rest?

This revision was automatically updated to reflect the committed changes.