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 #define DEBUG_TYPE "xcore-selectiondag-info"
15 #include "XCoreTargetMachine.h"
18 XCoreSelectionDAGInfo::XCoreSelectionDAGInfo(const XCoreTargetMachine &TM)
19 : TargetSelectionDAGInfo(TM) {
22 XCoreSelectionDAGInfo::~XCoreSelectionDAGInfo() {
25 SDValue XCoreSelectionDAGInfo::
26 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
27 SDValue Dst, SDValue Src, SDValue Size, unsigned Align,
28 bool isVolatile, bool AlwaysInline,
29 MachinePointerInfo DstPtrInfo,
30 MachinePointerInfo SrcPtrInfo) const
32 unsigned SizeBitWidth = Size.getValueType().getSizeInBits();
33 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
34 if (!AlwaysInline && (Align & 3) == 0 &&
35 DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) {
36 const TargetLowering &TLI = *DAG.getTarget().getTargetLowering();
37 TargetLowering::ArgListTy Args;
38 TargetLowering::ArgListEntry Entry;
39 Entry.Ty = TLI.getDataLayout()->getIntPtrType(*DAG.getContext());
40 Entry.Node = Dst; Args.push_back(Entry);
41 Entry.Node = Src; Args.push_back(Entry);
42 Entry.Node = Size; Args.push_back(Entry);
44 TargetLowering::CallLoweringInfo
45 CLI(Chain, Type::getVoidTy(*DAG.getContext()), false, false, false, false,
46 0, TLI.getLibcallCallingConv(RTLIB::MEMCPY), /*isTailCall=*/false,
47 /*doesNotRet=*/false, /*isReturnValueUsed=*/false,
48 DAG.getExternalSymbol("__memcpy_4", TLI.getPointerTy()), Args, DAG, dl);
49 std::pair<SDValue,SDValue> CallResult =
51 return CallResult.second;
54 // Otherwise have the target-independent code call memcpy.