1 //===-- AArch64SelectionDAGInfo.cpp - AArch64 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 AArch64SelectionDAGInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "AArch64TargetMachine.h"
17 #define DEBUG_TYPE "aarch64-selectiondag-info"
19 SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
20 SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Dst, SDValue Src,
21 SDValue Size, unsigned Align, bool isVolatile,
22 MachinePointerInfo DstPtrInfo) const {
23 // Check to see if there is a specialized entry-point for memory zeroing.
24 ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
25 ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
26 const AArch64Subtarget &STI =
27 DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
28 const char *bzeroEntry =
29 (V && V->isNullValue()) ? STI.getBZeroEntry() : nullptr;
30 // For small size (< 256), it is not beneficial to use bzero
32 if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
33 const AArch64TargetLowering &TLI = *STI.getTargetLowering();
35 EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout());
36 Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
37 TargetLowering::ArgListTy Args;
38 TargetLowering::ArgListEntry Entry;
41 Args.push_back(Entry);
43 Args.push_back(Entry);
44 TargetLowering::CallLoweringInfo CLI(DAG);
45 CLI.setDebugLoc(dl).setChain(Chain)
46 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
47 DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0)
49 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
50 return CallResult.second;