-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
Merged
arsenm
merged 2 commits into
main
from
users/arsenm/arm/move-remaining-half-convert-calling-conv-config-tablegen
Sep 11, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1614,13 +1614,6 @@ 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>; | ||
|
|
||
| // 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; | ||
| } | ||
|
|
||
| // 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. | ||
|
|
@@ -1629,6 +1622,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()}]>> { | ||
| 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()}]>> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise |
||
| 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 GNUEABIHalfConvertCalls : | ||
| LibcallImpls<(add __gnu_f2h_ieee, __gnu_h2f_ieee), | ||
| RuntimeLibcallPredicate<[{!TT.isOSBinFormatMachO() && | ||
|
|
@@ -1755,7 +1769,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, | ||
|
|
@@ -1769,8 +1785,10 @@ def ARMSystemLibrary | |
|
|
||
| AEABICalls, | ||
| AEABI45MemCalls, | ||
| ARMLibgccHalfConvertCalls, | ||
| EABIHalfConvertCalls, | ||
| GNUEABIHalfConvertCalls, | ||
| ARMDoubleToHalfCalls, | ||
|
|
||
| // Use divmod compiler-rt calls for iOS 5.0 and later. | ||
| LibcallImpls<(add __divmodsi4, __udivmodsi4), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
That's what tests are for. https://github.com/llvm/llvm-project/blob/681046e3a5d9892711846ff1eb01b112357fdacc/llvm/test/CodeGen/ARM/issue147935-half-convert-libcall-abi.ll should cover this
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.
Sadly that test coverage is missing the cases for MachO/WatchABI. Would you mind adding a few cases to ensure that that the WatchOS ABI targets are properly handled?
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 tried to do this before, but update_llc_test_checks for some reason breaks on the watchOS triples. I do see no difference with and without this, but those triples also do not use the libcalls in the first place.
Part of the problem I'm trying to solve here is the conflation of does-this-call-exist and will this call be 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.
Hacked the triple into update_llc_test_checks