LLVM API Documentation
00001 //===-- AArch64SelectionDAGInfo.cpp - AArch64 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 AArch64SelectionDAGInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "AArch64TargetMachine.h" 00015 using namespace llvm; 00016 00017 #define DEBUG_TYPE "aarch64-selectiondag-info" 00018 00019 AArch64SelectionDAGInfo::AArch64SelectionDAGInfo(const DataLayout *DL) 00020 : TargetSelectionDAGInfo(DL) {} 00021 00022 AArch64SelectionDAGInfo::~AArch64SelectionDAGInfo() {} 00023 00024 SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset( 00025 SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Dst, SDValue Src, 00026 SDValue Size, unsigned Align, bool isVolatile, 00027 MachinePointerInfo DstPtrInfo) const { 00028 // Check to see if there is a specialized entry-point for memory zeroing. 00029 ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src); 00030 ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size); 00031 const char *bzeroEntry = 00032 (V && V->isNullValue()) 00033 ? DAG.getTarget().getSubtarget<AArch64Subtarget>().getBZeroEntry() 00034 : nullptr; 00035 // For small size (< 256), it is not beneficial to use bzero 00036 // instead of memset. 00037 if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) { 00038 const AArch64TargetLowering &TLI = 00039 *DAG.getTarget().getSubtarget<AArch64Subtarget>().getTargetLowering(); 00040 00041 EVT IntPtr = TLI.getPointerTy(); 00042 Type *IntPtrTy = getDataLayout()->getIntPtrType(*DAG.getContext()); 00043 TargetLowering::ArgListTy Args; 00044 TargetLowering::ArgListEntry Entry; 00045 Entry.Node = Dst; 00046 Entry.Ty = IntPtrTy; 00047 Args.push_back(Entry); 00048 Entry.Node = Size; 00049 Args.push_back(Entry); 00050 TargetLowering::CallLoweringInfo CLI(DAG); 00051 CLI.setDebugLoc(dl).setChain(Chain) 00052 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()), 00053 DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0) 00054 .setDiscardResult(); 00055 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI); 00056 return CallResult.second; 00057 } 00058 return SDValue(); 00059 }