-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Hexagon: Move runtime libcall configuration to tablegen #147482
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
arsenm
wants to merge
1
commit into
users/arsenm/dag/use-fast-variants-math-libcalls
Choose a base branch
from
users/arsenm/hexagon/move-runtime-libcall-config-tablegen
base: users/arsenm/dag/use-fast-variants-math-libcalls
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hexagon: Move runtime libcall configuration to tablegen #147482
arsenm
wants to merge
1
commit into
users/arsenm/dag/use-fast-variants-math-libcalls
from
users/arsenm/hexagon/move-runtime-libcall-config-tablegen
+11
−35
Conversation
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 was referenced Jul 8, 2025
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-hexagon Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/147482.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 2099aae877861..e40e71f13af42 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -1414,6 +1414,7 @@ def AVRSystemLibrary
// Hexagon Runtime Libcalls
//===----------------------------------------------------------------------===//
+defset list<RuntimeLibcallImpl> HexagonLibcalls = {
def __hexagon_divsi3 : RuntimeLibcallImpl<SDIV_I32>;
def __hexagon_divdi3 : RuntimeLibcallImpl<SDIV_I64>;
def __hexagon_udivsi3 : RuntimeLibcallImpl<UDIV_I32>;
@@ -1446,6 +1447,16 @@ def __hexagon_fast2_sqrtdf2 : RuntimeLibcallImpl<FAST_SQRT_F64>;
def __hexagon_memcpy_likely_aligned_min32bytes_mult8bytes
: RuntimeLibcallImpl<HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES>;
+}
+
+def isHexagon : RuntimeLibcallPredicate<"TT.getArch() == Triple::hexagon">;
+
+def HexagonSystemLibrary
+ : SystemRuntimeLibrary<isHexagon,
+ (add (sub DefaultLibcallImpls32,
+ __adddf3, __divsf3, __udivsi3, __udivdi3,
+ __umoddi3, __divdf3, __muldf3, __divsi3, __subdf3, sqrtf,
+ __divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls)>;
//===----------------------------------------------------------------------===//
// Lanai Runtime Libcalls
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index b60b065c80346..179cc0b1ef58d 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -254,41 +254,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
setLibcallImpl(RTLIB::MULO_I128, RTLIB::Unsupported);
}
- if (TT.getArch() == Triple::ArchType::hexagon) {
- setLibcallImpl(RTLIB::SDIV_I32, RTLIB::__hexagon_divsi3);
- setLibcallImpl(RTLIB::SDIV_I64, RTLIB::__hexagon_divdi3);
- setLibcallImpl(RTLIB::UDIV_I32, RTLIB::__hexagon_udivsi3);
- setLibcallImpl(RTLIB::UDIV_I64, RTLIB::__hexagon_udivdi3);
- setLibcallImpl(RTLIB::SREM_I32, RTLIB::__hexagon_modsi3);
- setLibcallImpl(RTLIB::SREM_I64, RTLIB::__hexagon_moddi3);
- setLibcallImpl(RTLIB::UREM_I32, RTLIB::__hexagon_umodsi3);
- setLibcallImpl(RTLIB::UREM_I64, RTLIB::__hexagon_umoddi3);
-
- // Prefix is: nothing for "slow-math",
- // "fast2_" for V5+ fast-math double-precision
- // (actually, keep fast-math and fast-math2 separate for now)
-
- setLibcallImpl(RTLIB::FAST_ADD_F64, RTLIB::__hexagon_fast_adddf3);
- setLibcallImpl(RTLIB::FAST_SUB_F64, RTLIB::__hexagon_fast_subdf3);
- setLibcallImpl(RTLIB::FAST_MUL_F64, RTLIB::__hexagon_fast_muldf3);
- setLibcallImpl(RTLIB::FAST_DIV_F64, RTLIB::__hexagon_fast_divdf3);
- setLibcallImpl(RTLIB::FAST_DIV_F32, RTLIB::__hexagon_fast_divsf3);
- setLibcallImpl(RTLIB::FAST_SQRT_F32, RTLIB::__hexagon_fast2_sqrtf);
- // This is the only fast library function for sqrtd.
- setLibcallImpl(RTLIB::FAST_SQRT_F64, RTLIB::__hexagon_fast2_sqrtdf2);
-
- setLibcallImpl(RTLIB::ADD_F64, RTLIB::__hexagon_adddf3);
- setLibcallImpl(RTLIB::SUB_F64, RTLIB::__hexagon_subdf3);
- setLibcallImpl(RTLIB::MUL_F64, RTLIB::__hexagon_muldf3);
- setLibcallImpl(RTLIB::DIV_F64, RTLIB::__hexagon_divdf3);
- setLibcallImpl(RTLIB::DIV_F32, RTLIB::__hexagon_divsf3);
- setLibcallImpl(RTLIB::SQRT_F32, RTLIB::__hexagon_sqrtf);
-
- setLibcallImpl(
- RTLIB::HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES,
- RTLIB::__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes);
- }
-
if (TT.getArch() == Triple::ArchType::msp430) {
setLibcallImplCallingConv(RTLIB::__mspabi_mpyll,
CallingConv::MSP430_BUILTIN);
|
RKSimon
approved these changes
Jul 8, 2025
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.
LGTM
454e0e4
to
ef8813a
Compare
920b061
to
24ff719
Compare
ef8813a
to
8c552af
Compare
24ff719
to
714bcdf
Compare
This was referenced Jul 9, 2025
714bcdf
to
83257ed
Compare
8c552af
to
48350d5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.