diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td index 1f596184f3d6a..a774a20d8d0d6 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.td +++ b/llvm/include/llvm/IR/RuntimeLibcalls.td @@ -1576,13 +1576,6 @@ def __aeabi_h2f : RuntimeLibcallImpl; // CallingConv::ARM_AAPCS def __gnu_f2h_ieee : RuntimeLibcallImpl; def __gnu_h2f_ieee : RuntimeLibcallImpl; -// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI -// they have a __gnu_ prefix (which is the default). -def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f), - isTargetAEABIAndAAPCS_ABI> { - let CallingConv = ARM_AAPCS; -} - // The half <-> float conversion functions are always soft-float on // non-watchos platforms, but are needed for some targets which use a // hard-float calling convention by default. @@ -1591,6 +1584,27 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv< (isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}] >; +def ARMLibgccHalfConvertCalls : + LibcallImpls<(add __truncsfhf2, __extendhfsf2), + RuntimeLibcallPredicate<[{!TT.isTargetAEABI() && TT.isOSBinFormatMachO()}]>> { + let CallingConv = ARMHalfConvertLibcallCallingConv; +} + +// FIXME: These conditions are probably bugged. We're using the +// default libgcc call when the other cases are replaced. +def ARMDoubleToHalfCalls : + LibcallImpls<(add __truncdfhf2), + RuntimeLibcallPredicate<[{!TT.isTargetAEABI()}]>> { + let CallingConv = ARMHalfConvertLibcallCallingConv; +} + +// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI +// they have a __gnu_ prefix (which is the default). +def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f), + isTargetAEABIAndAAPCS_ABI> { + let CallingConv = ARM_AAPCS; +} + def GNUEABIHalfConvertCalls : LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee), RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() && @@ -1717,7 +1731,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">; def ARMSystemLibrary : SystemRuntimeLibrary, LibmHasFrexpF32, LibmHasLdexpF32, LibmHasFrexpF128, LibmHasLdexpF128, @@ -1731,8 +1747,10 @@ def ARMSystemLibrary AEABICalls, AEABI45MemCalls, + ARMLibgccHalfConvertCalls, EABIHalfConvertCalls, GNUEABIHalfConvertCalls, + ARMDoubleToHalfCalls, // Use divmod compiler-rt calls for iOS 5.0 and later. LibcallImpls<(add __divmodsi4, __udivmodsi4), diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index 3c324f2fe0d84..7ea2e46a54183 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -33,25 +33,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT, EABI EABIVersion, StringRef ABIName) { setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion, ABIName); - - if (TT.isARM() || TT.isThumb()) { - // The half <-> float conversion functions are always soft-float on - // non-watchos platforms, but are needed for some targets which use a - // hard-float calling convention by default. - if (!TT.isWatchABI()) { - if (isAAPCS_ABI(TT, ABIName)) { - setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_AAPCS); - setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_AAPCS); - setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_AAPCS); - } else { - setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_APCS); - setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_APCS); - setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_APCS); - } - } - - return; - } } LLVM_ATTRIBUTE_ALWAYS_INLINE