[llvm] ddb2dc5 - ARM: Move gnu half convert calling conv config into tablegen (#153394)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 01:36:32 PDT 2025


Author: Matt Arsenault
Date: 2025-08-14T17:36:29+09:00
New Revision: ddb2dc50af270902547f367c5f9155ed682b6d70

URL: https://github.com/llvm/llvm-project/commit/ddb2dc50af270902547f367c5f9155ed682b6d70
DIFF: https://github.com/llvm/llvm-project/commit/ddb2dc50af270902547f367c5f9155ed682b6d70.diff

LOG: ARM: Move gnu half convert calling conv config into tablegen (#153394)

Added: 
    

Modified: 
    llvm/include/llvm/IR/RuntimeLibcalls.td
    llvm/lib/IR/RuntimeLibcalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index b6664fb2ba908..29eb6485c15da 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1494,6 +1494,28 @@ def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
   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.
+def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
+  [{TT.isWatchABI() ? DefaultCC :
+    (isAAPCS_ABI(TT, ABIName) ? CallingConv::ARM_AAPCS : CallingConv::ARM_APCS)}]
+>;
+
+def GNUEABIHalfConvertCalls :
+  LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
+    RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
+                              !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 WindowARMDivRemCalls : LibcallImpls<
   (add __rt_sdiv, __rt_sdiv64, __rt_udiv, __rt_udiv64),
   isOSWindows> {

diff  --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index ff54d2da4ea2f..ac845c4998783 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -42,16 +42,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
         setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_AAPCS);
         setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_AAPCS);
         setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_AAPCS);
-        setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee,
-                                  CallingConv::ARM_AAPCS);
-        setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee,
-                                  CallingConv::ARM_AAPCS);
       } else {
         setLibcallImplCallingConv(RTLIB::__truncsfhf2, CallingConv::ARM_APCS);
         setLibcallImplCallingConv(RTLIB::__truncdfhf2, CallingConv::ARM_APCS);
         setLibcallImplCallingConv(RTLIB::__extendhfsf2, CallingConv::ARM_APCS);
-        setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee, CallingConv::ARM_APCS);
-        setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee, CallingConv::ARM_APCS);
       }
     }
 


        


More information about the llvm-commits mailing list