[llvm] ARM: Move calling conv config to RuntimeLibcalls (PR #152065)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 5 07:17:43 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/152065
>From 2af18c4eb115b2dce287fda7d22d5ffe2ba7f187 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Mon, 4 Aug 2025 23:18:03 +0900
Subject: [PATCH] ARM: Move calling conv config to RuntimeLibcalls
Consolidate module level ABI into RuntimeLibcalls
---
llvm/lib/IR/RuntimeLibcalls.cpp | 38 +++++++++++++++++++++++--
llvm/lib/Target/ARM/ARMISelLowering.cpp | 19 -------------
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index a8e6c7938cf54..d794c49e56c34 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -9,6 +9,7 @@
#include "llvm/IR/RuntimeLibcalls.h"
#include "llvm/ADT/StringTable.h"
#include "llvm/Support/Debug.h"
+#include "llvm/TargetParser/ARMTargetParser.h"
#define DEBUG_TYPE "runtime-libcalls-info"
@@ -22,8 +23,39 @@ using namespace RTLIB;
#undef GET_SET_TARGET_RUNTIME_LIBCALL_SETS
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT,
- FloatABI::ABIType FloatABIType,
- EABI EABIVersion) {
+ FloatABI::ABIType FloatABIType, EABI EABIVersion,
+ StringRef ABIName) {
+ // 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()) {
+ ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
+
+ if (TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16) {
+ Info.setLibcallImplCallingConv(RTLIB::__truncsfhf2,
+ CallingConv::ARM_AAPCS);
+ Info.setLibcallImplCallingConv(RTLIB::__truncdfhf2,
+ CallingConv::ARM_AAPCS);
+ Info.setLibcallImplCallingConv(RTLIB::__extendhfsf2,
+ CallingConv::ARM_AAPCS);
+ Info.setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee,
+ CallingConv::ARM_AAPCS);
+ Info.setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee,
+ CallingConv::ARM_AAPCS);
+ } else {
+ Info.setLibcallImplCallingConv(RTLIB::__truncsfhf2,
+ CallingConv::ARM_APCS);
+ Info.setLibcallImplCallingConv(RTLIB::__truncdfhf2,
+ CallingConv::ARM_APCS);
+ Info.setLibcallImplCallingConv(RTLIB::__extendhfsf2,
+ CallingConv::ARM_APCS);
+ Info.setLibcallImplCallingConv(RTLIB::__gnu_h2f_ieee,
+ CallingConv::ARM_APCS);
+ Info.setLibcallImplCallingConv(RTLIB::__gnu_f2h_ieee,
+ CallingConv::ARM_APCS);
+ }
+ }
+
static const RTLIB::LibcallImpl AAPCS_Libcalls[] = {
RTLIB::__aeabi_dadd, RTLIB::__aeabi_ddiv,
RTLIB::__aeabi_dmul, RTLIB::__aeabi_dsub,
@@ -75,7 +107,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
if (TT.isARM() || TT.isThumb()) {
- setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
+ setARMLibcallNames(*this, TT, FloatABI, EABIVersion, ABIName);
return;
}
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 7f8b4460bb814..c4b308f5e83ee 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -707,25 +707,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
}
}
- // 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 (TM.isAAPCS_ABI()) {
- 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);
- }
- }
-
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
// a __gnu_ prefix (which is the default).
if (TT.isTargetAEABI()) {
More information about the llvm-commits
mailing list