Skip to content

Commit e6005bd

Browse files
committed
XCore: Declare libcalls used for align 4 memcpy
This usage was hidden in XCoreSelectionDAGInfo and bypassed the usual libcall system, so define these for later use.
1 parent 2a403de commit e6005bd

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ def AEABI_MEMCLR8 : RuntimeLibcall;
371371
// Hexagon calls
372372
def HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES : RuntimeLibcall;
373373

374+
// XCore calls
375+
def MEMCPY_ALIGN_4 : RuntimeLibcall;
376+
374377
//--------------------------------------------------------------------
375378
// Define implementation default libcalls
376379
//--------------------------------------------------------------------
@@ -1544,6 +1547,12 @@ def _allrem : RuntimeLibcallImpl<SREM_I64>; // CallingConv::X86_StdCall
15441547
def _aullrem : RuntimeLibcallImpl<UREM_I64>; // CallingConv::X86_StdCall
15451548
def _allmul : RuntimeLibcallImpl<MUL_I64>; // CallingConv::X86_StdCall
15461549

1550+
//===----------------------------------------------------------------------===//
1551+
// XCore Runtime Libcalls
1552+
//===----------------------------------------------------------------------===//
1553+
1554+
def __memcpy_4 : RuntimeLibcallImpl<MEMCPY_ALIGN_4>;
1555+
15471556
//===----------------------------------------------------------------------===//
15481557
// ZOS Runtime Libcalls
15491558
//===----------------------------------------------------------------------===//

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
627627

628628
if (TT.isSystemZ() && TT.isOSzOS())
629629
setZOSLibCallNameOverrides();
630+
631+
if (TT.getArch() == Triple::ArchType::xcore)
632+
setLibcallImpl(RTLIB::MEMCPY_ALIGN_4, RTLIB::__memcpy_4);
630633
}

llvm/lib/Target/XCore/XCoreSelectionDAGInfo.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
3939
Entry.Node = Src; Args.push_back(Entry);
4040
Entry.Node = Size; Args.push_back(Entry);
4141

42+
const char *MemcpyAlign4Name = TLI.getLibcallName(RTLIB::MEMCPY_ALIGN_4);
43+
CallingConv::ID CC = TLI.getLibcallCallingConv(RTLIB::MEMCPY_ALIGN_4);
44+
4245
TargetLowering::CallLoweringInfo CLI(DAG);
4346
CLI.setDebugLoc(dl)
4447
.setChain(Chain)
45-
.setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
46-
Type::getVoidTy(*DAG.getContext()),
47-
DAG.getExternalSymbol(
48-
"__memcpy_4", TLI.getPointerTy(DAG.getDataLayout())),
49-
std::move(Args))
48+
.setLibCallee(
49+
CC, Type::getVoidTy(*DAG.getContext()),
50+
DAG.getExternalSymbol(MemcpyAlign4Name,
51+
TLI.getPointerTy(DAG.getDataLayout())),
52+
std::move(Args))
5053
.setDiscardResult();
5154

5255
std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);

0 commit comments

Comments
 (0)