Skip to content

ARM: Move calling conv config to RuntimeLibcalls #152065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down
19 changes: 0 additions & 19 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Loading