XCoreSelectionDAGInfo.cpp revision dce4a407a24b04eebc6a376f8e62b41aaa7b071f
1//===-- XCoreSelectionDAGInfo.cpp - XCore 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 XCoreSelectionDAGInfo class. 11// 12//===----------------------------------------------------------------------===// 13 14#include "XCoreTargetMachine.h" 15using namespace llvm; 16 17#define DEBUG_TYPE "xcore-selectiondag-info" 18 19XCoreSelectionDAGInfo::XCoreSelectionDAGInfo(const XCoreTargetMachine &TM) 20 : TargetSelectionDAGInfo(TM) { 21} 22 23XCoreSelectionDAGInfo::~XCoreSelectionDAGInfo() { 24} 25 26SDValue XCoreSelectionDAGInfo:: 27EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain, 28 SDValue Dst, SDValue Src, SDValue Size, unsigned Align, 29 bool isVolatile, bool AlwaysInline, 30 MachinePointerInfo DstPtrInfo, 31 MachinePointerInfo SrcPtrInfo) const 32{ 33 unsigned SizeBitWidth = Size.getValueType().getSizeInBits(); 34 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned. 35 if (!AlwaysInline && (Align & 3) == 0 && 36 DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) { 37 const TargetLowering &TLI = *DAG.getTarget().getTargetLowering(); 38 TargetLowering::ArgListTy Args; 39 TargetLowering::ArgListEntry Entry; 40 Entry.Ty = TLI.getDataLayout()->getIntPtrType(*DAG.getContext()); 41 Entry.Node = Dst; Args.push_back(Entry); 42 Entry.Node = Src; Args.push_back(Entry); 43 Entry.Node = Size; Args.push_back(Entry); 44 45 TargetLowering::CallLoweringInfo CLI(DAG); 46 CLI.setDebugLoc(dl).setChain(Chain) 47 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY), 48 Type::getVoidTy(*DAG.getContext()), 49 DAG.getExternalSymbol("__memcpy_4", TLI.getPointerTy()), 50 &Args, 0) 51 .setDiscardResult(); 52 53 std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI); 54 return CallResult.second; 55 } 56 57 // Otherwise have the target-independent code call memcpy. 58 return SDValue(); 59} 60