1 //===-- HexagonSelectionDAGInfo.cpp - Hexagon 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 HexagonSelectionDAGInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "HexagonTargetMachine.h"
15 #include "llvm/CodeGen/SelectionDAG.h"
18 #define DEBUG_TYPE "hexagon-selectiondag-info"
21 HexagonSelectionDAGInfo::
22 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
23 SDValue Dst, SDValue Src, SDValue Size, unsigned Align,
24 bool isVolatile, bool AlwaysInline,
25 MachinePointerInfo DstPtrInfo,
26 MachinePointerInfo SrcPtrInfo) const {
27 ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
28 if (AlwaysInline || (Align & 0x3) != 0 || !ConstantSize)
31 uint64_t SizeVal = ConstantSize->getZExtValue();
32 if (SizeVal < 32 || (SizeVal % 8) != 0)
35 // Special case aligned memcpys with size >= 32 bytes and a multiple of 8.
37 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
38 TargetLowering::ArgListTy Args;
39 TargetLowering::ArgListEntry Entry;
40 Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
42 Args.push_back(Entry);
44 Args.push_back(Entry);
46 Args.push_back(Entry);
48 const char *SpecialMemcpyName =
49 "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
51 TargetLowering::CallLoweringInfo CLI(DAG);
54 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
55 Type::getVoidTy(*DAG.getContext()),
56 DAG.getTargetExternalSymbol(
57 SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout())),
61 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
62 return CallResult.second;