blob: 0cfd5826aadf9056a0c0332bf41b2a78d0428867 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===-- AArch64SelectionDAGInfo.cpp - AArch64 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 AArch64SelectionDAGInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#include "AArch64TargetMachine.h"
15using namespace llvm;
16
17#define DEBUG_TYPE "aarch64-selectiondag-info"
18
Eric Christopher078a2b62014-06-10 18:06:28 +000019AArch64SelectionDAGInfo::AArch64SelectionDAGInfo(const DataLayout *DL)
20 : TargetSelectionDAGInfo(DL) {}
Tim Northover3b0846e2014-05-24 12:50:23 +000021
22AArch64SelectionDAGInfo::~AArch64SelectionDAGInfo() {}
23
24SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
25 SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Dst, SDValue Src,
26 SDValue Size, unsigned Align, bool isVolatile,
27 MachinePointerInfo DstPtrInfo) const {
28 // Check to see if there is a specialized entry-point for memory zeroing.
29 ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
30 ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
31 const char *bzeroEntry =
Eric Christopher57c23192014-06-10 18:06:25 +000032 (V && V->isNullValue())
33 ? DAG.getTarget().getSubtarget<AArch64Subtarget>().getBZeroEntry()
34 : nullptr;
Tim Northover3b0846e2014-05-24 12:50:23 +000035 // For small size (< 256), it is not beneficial to use bzero
36 // instead of memset.
37 if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
38 const AArch64TargetLowering &TLI =
Eric Christopherd9134482014-08-04 21:25:23 +000039 *DAG.getTarget().getSubtarget<AArch64Subtarget>().getTargetLowering();
Tim Northover3b0846e2014-05-24 12:50:23 +000040
41 EVT IntPtr = TLI.getPointerTy();
42 Type *IntPtrTy = getDataLayout()->getIntPtrType(*DAG.getContext());
43 TargetLowering::ArgListTy Args;
44 TargetLowering::ArgListEntry Entry;
45 Entry.Node = Dst;
46 Entry.Ty = IntPtrTy;
47 Args.push_back(Entry);
48 Entry.Node = Size;
49 Args.push_back(Entry);
50 TargetLowering::CallLoweringInfo CLI(DAG);
51 CLI.setDebugLoc(dl).setChain(Chain)
52 .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
Juergen Ributzka3bd03c72014-07-01 22:01:54 +000053 DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0)
Tim Northover3b0846e2014-05-24 12:50:23 +000054 .setDiscardResult();
55 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
56 return CallResult.second;
57 }
58 return SDValue();
59}