LLVM API Documentation
00001 //===-- XCoreSelectionDAGInfo.cpp - XCore SelectionDAG Info ---------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the XCoreSelectionDAGInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "XCoreTargetMachine.h" 00015 using namespace llvm; 00016 00017 #define DEBUG_TYPE "xcore-selectiondag-info" 00018 00019 XCoreSelectionDAGInfo::XCoreSelectionDAGInfo(const DataLayout &DL) 00020 : TargetSelectionDAGInfo(&DL) {} 00021 00022 XCoreSelectionDAGInfo::~XCoreSelectionDAGInfo() { 00023 } 00024 00025 SDValue XCoreSelectionDAGInfo:: 00026 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain, 00027 SDValue Dst, SDValue Src, SDValue Size, unsigned Align, 00028 bool isVolatile, bool AlwaysInline, 00029 MachinePointerInfo DstPtrInfo, 00030 MachinePointerInfo SrcPtrInfo) const 00031 { 00032 unsigned SizeBitWidth = Size.getValueType().getSizeInBits(); 00033 // Call __memcpy_4 if the src, dst and size are all 4 byte aligned. 00034 if (!AlwaysInline && (Align & 3) == 0 && 00035 DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) { 00036 const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering(); 00037 TargetLowering::ArgListTy Args; 00038 TargetLowering::ArgListEntry Entry; 00039 Entry.Ty = TLI.getDataLayout()->getIntPtrType(*DAG.getContext()); 00040 Entry.Node = Dst; Args.push_back(Entry); 00041 Entry.Node = Src; Args.push_back(Entry); 00042 Entry.Node = Size; Args.push_back(Entry); 00043 00044 TargetLowering::CallLoweringInfo CLI(DAG); 00045 CLI.setDebugLoc(dl).setChain(Chain) 00046 .setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY), 00047 Type::getVoidTy(*DAG.getContext()), 00048 DAG.getExternalSymbol("__memcpy_4", TLI.getPointerTy()), 00049 std::move(Args), 0) 00050 .setDiscardResult(); 00051 00052 std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI); 00053 return CallResult.second; 00054 } 00055 00056 // Otherwise have the target-independent code call memcpy. 00057 return SDValue(); 00058 }