1 //===-- XCoreSelectionDAGInfo.cpp - XCore SelectionDAG Info ---------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the XCoreSelectionDAGInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "XCoreTargetMachine.h"
17 #define DEBUG_TYPE "xcore-selectiondag-info"
19 SDValue XCoreSelectionDAGInfo::
20 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
21 SDValue Dst, SDValue Src, SDValue Size, unsigned Align,
22 bool isVolatile, bool AlwaysInline,
23 MachinePointerInfo DstPtrInfo,
24 MachinePointerInfo SrcPtrInfo) const
26 unsigned SizeBitWidth = Size.getValueType().getSizeInBits();
27 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
28 if (!AlwaysInline && (Align & 3) == 0 &&
29 DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) {
30 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
31 TargetLowering::ArgListTy Args;
32 TargetLowering::ArgListEntry Entry;
33 Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
34 Entry.Node = Dst; Args.push_back(Entry);
35 Entry.Node = Src; Args.push_back(Entry);
36 Entry.Node = Size; Args.push_back(Entry);
38 TargetLowering::CallLoweringInfo CLI(DAG);
41 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
42 Type::getVoidTy(*DAG.getContext()),
43 DAG.getExternalSymbol("__memcpy_4",
44 TLI.getPointerTy(DAG.getDataLayout())),
48 std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
49 return CallResult.second;
52 // Otherwise have the target-independent code call memcpy.