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

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 13 16:38:26 PDT 2025


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/153394

>From 83b3babd3eba6ecf3122d824d8d6de7c60b02c20 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 13 Aug 2025 20:20:53 +0900
Subject: [PATCH] ARM: Move gnu half convert calling conv config into tablegen

---
 llvm/include/llvm/IR/RuntimeLibcalls.td | 13 ++++++++++++-
 llvm/lib/IR/RuntimeLibcalls.cpp         |  6 ------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index b6664fb2ba908..04de19e257c9b 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1482,10 +1482,21 @@ def __aeabi_h2f : RuntimeLibcallImpl<FPEXT_F16_F32>; // CallingConv::ARM_AAPCS
 def __gnu_f2h_ieee : RuntimeLibcallImpl<FPROUND_F32_F16>;
 def __gnu_h2f_ieee : RuntimeLibcallImpl<FPEXT_F16_F32>;
 
+
+// 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()}]>>;
+                              !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).
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-branch-commits mailing list