1 //===-- HexagonSelectionDAGInfo.cpp - Hexagon SelectionDAG Info -----------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file implements the HexagonSelectionDAGInfo class. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "HexagonTargetMachine.h" 15 #include "llvm/CodeGen/SelectionDAG.h" 16 using namespace llvm; 17 18 #define DEBUG_TYPE "hexagon-selectiondag-info" 19 20 SDValue 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) 29 return SDValue(); 30 31 uint64_t SizeVal = ConstantSize->getZExtValue(); 32 if (SizeVal < 32 || (SizeVal % 8) != 0) 33 return SDValue(); 34 35 // Special case aligned memcpys with size >= 32 bytes and a multiple of 8. 36 // 37 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering(); 38 TargetLowering::ArgListTy Args; 39 TargetLowering::ArgListEntry Entry; 40 Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext()); 41 Entry.Node = Dst; 42 Args.push_back(Entry); 43 Entry.Node = Src; 44 Args.push_back(Entry); 45 Entry.Node = Size; 46 Args.push_back(Entry); 47 48 const char *SpecialMemcpyName = 49 "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes"; 50 51 TargetLowering::CallLoweringInfo CLI(DAG); 52 CLI.setDebugLoc(dl) 53 .setChain(Chain) 54 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY), 55 Type::getVoidTy(*DAG.getContext()), 56 DAG.getTargetExternalSymbol( 57 SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout())), 58 std::move(Args), 0) 59 .setDiscardResult(); 60 61 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI); 62 return CallResult.second; 63 } 64