diff options
author | Richard Osborne <richard@xmos.com> | 2014-02-27 13:39:07 +0000 |
---|---|---|
committer | Richard Osborne <richard@xmos.com> | 2014-02-27 13:39:07 +0000 |
commit | c26292d4dcc3f11279eb6bc524344d926bf3465e (patch) | |
tree | 334ca39f955d867d2ee684e3772d9679707351ef /lib/Target/XCore | |
parent | 83eab939a4f85b8571cee5c3907ac3de0f642f06 (diff) | |
download | llvm-c26292d4dcc3f11279eb6bc524344d926bf3465e.tar.gz llvm-c26292d4dcc3f11279eb6bc524344d926bf3465e.tar.bz2 llvm-c26292d4dcc3f11279eb6bc524344d926bf3465e.tar.xz |
[XCore] Target optimized library function __memcpy_4()
Summary:
If the src, dst and size of a memcpy are known to be 4 byte aligned we
can call __memcpy_4() instead of memcpy().
Reviewers: robertlytton
Reviewed By: robertlytton
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2871
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/XCore')
-rw-r--r-- | lib/Target/XCore/XCoreSelectionDAGInfo.cpp | 33 | ||||
-rw-r--r-- | lib/Target/XCore/XCoreSelectionDAGInfo.h | 9 |
2 files changed, 42 insertions, 0 deletions
diff --git a/lib/Target/XCore/XCoreSelectionDAGInfo.cpp b/lib/Target/XCore/XCoreSelectionDAGInfo.cpp index 44aeb6057c..68ede6ae6d 100644 --- a/lib/Target/XCore/XCoreSelectionDAGInfo.cpp +++ b/lib/Target/XCore/XCoreSelectionDAGInfo.cpp @@ -21,3 +21,36 @@ XCoreSelectionDAGInfo::XCoreSelectionDAGInfo(const XCoreTargetMachine &TM) XCoreSelectionDAGInfo::~XCoreSelectionDAGInfo() { } + +SDValue XCoreSelectionDAGInfo:: +EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain, + SDValue Dst, SDValue Src, SDValue Size, unsigned Align, + bool isVolatile, bool AlwaysInline, + MachinePointerInfo DstPtrInfo, + MachinePointerInfo SrcPtrInfo) const +{ + unsigned SizeBitWidth = Size.getValueType().getSizeInBits(); + // Call __memcpy_4 if the src, dst and size are all 4 byte aligned. + if (!AlwaysInline && (Align & 3) == 0 && + DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) { + const TargetLowering &TLI = *DAG.getTarget().getTargetLowering(); + TargetLowering::ArgListTy Args; + TargetLowering::ArgListEntry Entry; + Entry.Ty = TLI.getDataLayout()->getIntPtrType(*DAG.getContext()); + Entry.Node = Dst; Args.push_back(Entry); + Entry.Node = Src; Args.push_back(Entry); + Entry.Node = Size; Args.push_back(Entry); + + TargetLowering::CallLoweringInfo + CLI(Chain, Type::getVoidTy(*DAG.getContext()), false, false, false, false, + 0, TLI.getLibcallCallingConv(RTLIB::MEMCPY), /*isTailCall=*/false, + /*doesNotRet=*/false, /*isReturnValueUsed=*/false, + DAG.getExternalSymbol("__memcpy_4", TLI.getPointerTy()), Args, DAG, dl); + std::pair<SDValue,SDValue> CallResult = + TLI.LowerCallTo(CLI); + return CallResult.second; + } + + // Otherwise have the target-independent code call memcpy. + return SDValue(); +} diff --git a/lib/Target/XCore/XCoreSelectionDAGInfo.h b/lib/Target/XCore/XCoreSelectionDAGInfo.h index 0386968638..31704f388a 100644 --- a/lib/Target/XCore/XCoreSelectionDAGInfo.h +++ b/lib/Target/XCore/XCoreSelectionDAGInfo.h @@ -24,6 +24,15 @@ class XCoreSelectionDAGInfo : public TargetSelectionDAGInfo { public: explicit XCoreSelectionDAGInfo(const XCoreTargetMachine &TM); ~XCoreSelectionDAGInfo(); + + virtual SDValue + EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, + SDValue Chain, + SDValue Op1, SDValue Op2, + SDValue Op3, unsigned Align, bool isVolatile, + bool AlwaysInline, + MachinePointerInfo DstPtrInfo, + MachinePointerInfo SrcPtrInfo) const; }; } |