1//===-- XCoreSelectionDAGInfo.cpp - XCore SelectionDAG Info ---------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the XCoreSelectionDAGInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "XCoreTargetMachine.h"
14using namespace llvm;
15
16#define DEBUG_TYPE "xcore-selectiondag-info"
17
18SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
19 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
20 SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
21 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
22 unsigned SizeBitWidth = Size.getValueSizeInBits();
23 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
24 if (!AlwaysInline && Alignment >= Align(4) &&
25 DAG.MaskedValueIsZero(Op: Size, Mask: APInt(SizeBitWidth, 3))) {
26 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
27 TargetLowering::ArgListTy Args;
28 TargetLowering::ArgListEntry Entry;
29 Entry.Ty = DAG.getDataLayout().getIntPtrType(C&: *DAG.getContext());
30 Entry.Node = Dst; Args.push_back(x: Entry);
31 Entry.Node = Src; Args.push_back(x: Entry);
32 Entry.Node = Size; Args.push_back(x: Entry);
33
34 TargetLowering::CallLoweringInfo CLI(DAG);
35 CLI.setDebugLoc(dl)
36 .setChain(Chain)
37 .setLibCallee(CC: TLI.getLibcallCallingConv(Call: RTLIB::MEMCPY),
38 ResultType: Type::getVoidTy(C&: *DAG.getContext()),
39 Target: DAG.getExternalSymbol(
40 Sym: "__memcpy_4", VT: TLI.getPointerTy(DL: DAG.getDataLayout())),
41 ArgsList: std::move(Args))
42 .setDiscardResult();
43
44 std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
45 return CallResult.second;
46 }
47
48 // Otherwise have the target-independent code call memcpy.
49 return SDValue();
50}
51

source code of llvm/lib/Target/XCore/XCoreSelectionDAGInfo.cpp