Hexagon: Add libcall declarations for special memcpy#144975
Merged
Conversation
This was referenced Jun 20, 2025
Contributor
Author
This was referenced Jun 20, 2025
Member
|
@llvm/pr-subscribers-backend-hexagon @llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesHexagonSelectionDAGInfo was bypassing the ordinary RuntimeLibcallInfo Full diff: https://github.com/llvm/llvm-project/pull/144975.diff 3 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 71efecdf082af..2efe823a760db 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -368,6 +368,9 @@ def AEABI_MEMCLR : RuntimeLibcall;
def AEABI_MEMCLR4 : RuntimeLibcall;
def AEABI_MEMCLR8 : RuntimeLibcall;
+// Hexagon calls
+def HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES : RuntimeLibcall;
+
//--------------------------------------------------------------------
// Define implementation default libcalls
//--------------------------------------------------------------------
@@ -1247,6 +1250,9 @@ def __hexagon_fast2_sqrtf : RuntimeLibcallImpl<SQRT_F32>;
// This is the only fast library function for sqrtd.
def __hexagon_fast2_sqrtdf2 : RuntimeLibcallImpl<SQRT_F64>;
+def __hexagon_memcpy_likely_aligned_min32bytes_mult8bytes
+ : RuntimeLibcallImpl<HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES>;
+
//===----------------------------------------------------------------------===//
// Mips16 Runtime Libcalls
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 5fccb23e6c5ff..873ee6b509e2d 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -616,6 +616,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
setLibcallImpl(RTLIB::SQRT_F32, RTLIB::__hexagon_fast2_sqrtf);
else
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)
diff --git a/llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp b/llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
index 1b724e8fcae91..610a81fe45c2f 100644
--- a/llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
@@ -41,18 +41,20 @@ SDValue HexagonSelectionDAGInfo::EmitTargetCodeForMemcpy(
Entry.Node = Size;
Args.push_back(Entry);
- const char *SpecialMemcpyName =
- "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
+ const char *SpecialMemcpyName = TLI.getLibcallName(
+ RTLIB::HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES);
const MachineFunction &MF = DAG.getMachineFunction();
bool LongCalls = MF.getSubtarget<HexagonSubtarget>().useLongCalls();
unsigned Flags = LongCalls ? HexagonII::HMOTF_ConstExtended : 0;
+ CallingConv::ID CC = TLI.getLibcallCallingConv(
+ RTLIB::HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES);
+
TargetLowering::CallLoweringInfo CLI(DAG);
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- TLI.getLibcallCallingConv(RTLIB::MEMCPY),
- Type::getVoidTy(*DAG.getContext()),
+ CC, Type::getVoidTy(*DAG.getContext()),
DAG.getTargetExternalSymbol(
SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout()), Flags),
std::move(Args))
|
bdbc320 to
8fec74a
Compare
a845b0e to
2a403de
Compare
8fec74a to
6bfbefe
Compare
2a403de to
4632467
Compare
6bfbefe to
c18ce19
Compare
4632467 to
d3f44e8
Compare
Contributor
Author
c18ce19 to
3271772
Compare
Base automatically changed from
users/arsenm/arm/add-libcall-definitions-eabi-memory-functions
to
main
June 27, 2025 08:43
HexagonSelectionDAGInfo was bypassing the ordinary RuntimeLibcallInfo handling for this case, so define a libcall for it and use it.
d3f44e8 to
944736b
Compare
This was referenced Jun 27, 2025
This was referenced Jul 8, 2025
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
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.

HexagonSelectionDAGInfo was bypassing the ordinary RuntimeLibcallInfo
handling for this case, so define a libcall for it and use it.