-
Notifications
You must be signed in to change notification settings - Fork 14.9k
ARM: Move remaining half convert libcall config into tablegen #153408
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
base: main
Are you sure you want to change the base?
ARM: Move remaining half convert libcall config into tablegen #153408
Conversation
@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesThe __truncdfhf2 handling is kind of convoluted, but reproduces Full diff: https://github.com/llvm/llvm-project/pull/153408.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 89bb0be4d26e9..a98e94455dd21 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1532,10 +1532,17 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
(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()}]>> {
+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;
}
@@ -1546,6 +1553,13 @@ def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
let CallingConv = ARM_AAPCS;
}
+def GNUEABIHalfConvertCalls :
+ LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
+ RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
+ !TT.isTargetAEABI()}]>> {
+ let CallingConv = ARMHalfConvertLibcallCallingConv;
+}
+
def WindowARMDivRemCalls : LibcallImpls<
(add __rt_sdiv, __rt_sdiv64, __rt_udiv, __rt_udiv64),
isOSWindows> {
@@ -1665,7 +1679,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">;
def ARMSystemLibrary
: SystemRuntimeLibrary<isARMOrThumb,
- (add WinDefaultLibcallImpls,
+ (add (sub WinDefaultLibcallImpls, ARMLibgccHalfConvertCalls,
+ GNUEABIHalfConvertCalls,
+ ARMDoubleToHalfCalls),
LibcallImpls<(add __powisf2, __powidf2), isNotOSMSVCRT>,
LibmHasFrexpF32, LibmHasLdexpF32,
LibmHasFrexpF128, LibmHasLdexpF128,
@@ -1679,8 +1695,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 ac845c4998783..83f7df5e9f587 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -33,25 +33,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
if (ExceptionModel == ExceptionHandling::SjLj)
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
- 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;
- }
-
if (TT.getArch() == Triple::ArchType::msp430) {
setLibcallImplCallingConv(RTLIB::__mspabi_mpyll,
CallingConv::MSP430_BUILTIN);
|
@llvm/pr-subscribers-tablegen Author: Matt Arsenault (arsenm) ChangesThe __truncdfhf2 handling is kind of convoluted, but reproduces Full diff: https://github.com/llvm/llvm-project/pull/153408.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 89bb0be4d26e9..a98e94455dd21 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1532,10 +1532,17 @@ def ARMHalfConvertLibcallCallingConv : LibcallCallingConv<
(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()}]>> {
+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;
}
@@ -1546,6 +1553,13 @@ def EABIHalfConvertCalls : LibcallImpls<(add __aeabi_f2h, __aeabi_h2f),
let CallingConv = ARM_AAPCS;
}
+def GNUEABIHalfConvertCalls :
+ LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee),
+ RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() &&
+ !TT.isTargetAEABI()}]>> {
+ let CallingConv = ARMHalfConvertLibcallCallingConv;
+}
+
def WindowARMDivRemCalls : LibcallImpls<
(add __rt_sdiv, __rt_sdiv64, __rt_udiv, __rt_udiv64),
isOSWindows> {
@@ -1665,7 +1679,9 @@ def isARMOrThumb : RuntimeLibcallPredicate<"TT.isARM() || TT.isThumb()">;
def ARMSystemLibrary
: SystemRuntimeLibrary<isARMOrThumb,
- (add WinDefaultLibcallImpls,
+ (add (sub WinDefaultLibcallImpls, ARMLibgccHalfConvertCalls,
+ GNUEABIHalfConvertCalls,
+ ARMDoubleToHalfCalls),
LibcallImpls<(add __powisf2, __powidf2), isNotOSMSVCRT>,
LibmHasFrexpF32, LibmHasLdexpF32,
LibmHasFrexpF128, LibmHasLdexpF128,
@@ -1679,8 +1695,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 ac845c4998783..83f7df5e9f587 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -33,25 +33,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
if (ExceptionModel == ExceptionHandling::SjLj)
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
- 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;
- }
-
if (TT.getArch() == Triple::ArchType::msp430) {
setLibcallImplCallingConv(RTLIB::__mspabi_mpyll,
CallingConv::MSP430_BUILTIN);
|
283d03d
to
83b3bab
Compare
da9d432
to
333abd7
Compare
83b3bab
to
2b09c7b
Compare
333abd7
to
e77db15
Compare
e77db15
to
bf4e8a6
Compare
@@ -1497,6 +1490,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()}]>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow this - the old code would add these on !Watch ABI as either AAPCS or APCS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the default values, and !WatchABI is not mutually exclusive. This needs to be expressed as the positive set of cases where it is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but what I mean to say is that this feels like it applies to far more cases than previously.
// default libgcc call when the other cases are replaced. | ||
def ARMDoubleToHalfCalls : | ||
LibcallImpls<(add __truncdfhf2), | ||
RuntimeLibcallPredicate<[{!TT.isTargetAEABI()}]>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise
The __truncdfhf2 handling is kind of convoluted, but reproduces the existing, likely wrong, handling.
bf4e8a6
to
67eb146
Compare
The __truncdfhf2 handling is kind of convoluted, but reproduces
the existing, likely wrong, handling.