blob: 5c65b750ee5569eb82a3abbc9cc53479b3f864f0 [file] [log] [blame]
Tim Northover72062f52013-01-31 12:12:40 +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
Tim Northover72062f52013-01-31 12:12:40 +000014#include "AArch64TargetMachine.h"
Tim Northover72062f52013-01-31 12:12:40 +000015using namespace llvm;
16
Stephen Hinesdce4a402014-05-29 02:49:00 -070017#define DEBUG_TYPE "aarch64-selectiondag-info"
Tim Northover72062f52013-01-31 12:12:40 +000018
Stephen Hinesdce4a402014-05-29 02:49:00 -070019AArch64SelectionDAGInfo::AArch64SelectionDAGInfo(const TargetMachine &TM)
20 : TargetSelectionDAGInfo(TM),
21 Subtarget(&TM.getSubtarget<AArch64Subtarget>()) {}
22
23AArch64SelectionDAGInfo::~AArch64SelectionDAGInfo() {}
24
25SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
26 SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Dst, SDValue Src,
27 SDValue Size, unsigned Align, bool isVolatile,
28 MachinePointerInfo DstPtrInfo) const {
29 // Check to see if there is a specialized entry-point for memory zeroing.
30 ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
31 ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
32 const char *bzeroEntry =
33 (V && V->isNullValue()) ? Subtarget->getBZeroEntry() : nullptr;
34 // For small size (< 256), it is not beneficial to use bzero
35 // instead of memset.
36 if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
37 const AArch64TargetLowering &TLI =
38 *static_cast<const AArch64TargetLowering *>(
39 DAG.getTarget().getTargetLowering());
40
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()),
53 DAG.getExternalSymbol(bzeroEntry, IntPtr), &Args, 0)
54 .setDiscardResult();
55 std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
56 return CallResult.second;
57 }
58 return SDValue();
Tim Northover72062f52013-01-31 12:12:40 +000059}