Skip to content

XCore: Declare libcalls used for align 4 memcpy #144976

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
wants to merge 1 commit into
base: users/arsenm/hexagon/add-libcall-definitions-special-memcpy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions llvm/include/llvm/IR/RuntimeLibcalls.td
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ def AEABI_MEMCLR8 : RuntimeLibcall;
// Hexagon calls
def HEXAGON_MEMCPY_LIKELY_ALIGNED_MIN32BYTES_MULT8BYTES : RuntimeLibcall;

// XCore calls
def MEMCPY_ALIGN_4 : RuntimeLibcall;

//--------------------------------------------------------------------
// Define implementation default libcalls
//--------------------------------------------------------------------
Expand Down Expand Up @@ -1544,6 +1547,12 @@ def _allrem : RuntimeLibcallImpl<SREM_I64>; // CallingConv::X86_StdCall
def _aullrem : RuntimeLibcallImpl<UREM_I64>; // CallingConv::X86_StdCall
def _allmul : RuntimeLibcallImpl<MUL_I64>; // CallingConv::X86_StdCall

//===----------------------------------------------------------------------===//
// XCore Runtime Libcalls
//===----------------------------------------------------------------------===//

def __memcpy_4 : RuntimeLibcallImpl<MEMCPY_ALIGN_4>;

//===----------------------------------------------------------------------===//
// ZOS Runtime Libcalls
//===----------------------------------------------------------------------===//
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/IR/RuntimeLibcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,

if (TT.isSystemZ() && TT.isOSzOS())
setZOSLibCallNameOverrides();

if (TT.getArch() == Triple::ArchType::xcore)
setLibcallImpl(RTLIB::MEMCPY_ALIGN_4, RTLIB::__memcpy_4);
}
13 changes: 8 additions & 5 deletions llvm/lib/Target/XCore/XCoreSelectionDAGInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
Entry.Node = Src; Args.push_back(Entry);
Entry.Node = Size; Args.push_back(Entry);

const char *MemcpyAlign4Name = TLI.getLibcallName(RTLIB::MEMCPY_ALIGN_4);
CallingConv::ID CC = TLI.getLibcallCallingConv(RTLIB::MEMCPY_ALIGN_4);

TargetLowering::CallLoweringInfo CLI(DAG);
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
Type::getVoidTy(*DAG.getContext()),
DAG.getExternalSymbol(
"__memcpy_4", TLI.getPointerTy(DAG.getDataLayout())),
std::move(Args))
.setLibCallee(
CC, Type::getVoidTy(*DAG.getContext()),
DAG.getExternalSymbol(MemcpyAlign4Name,
TLI.getPointerTy(DAG.getDataLayout())),
std::move(Args))
.setDiscardResult();

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