| Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 1 | //===-- 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 Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 14 | #include "AArch64TargetMachine.h" |
| Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 15 | using namespace llvm; |
| 16 | |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 17 | #define DEBUG_TYPE "aarch64-selectiondag-info" |
| Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 18 | |
| Stephen Hines | c6a4f5e | 2014-07-21 00:45:20 -0700 | [diff] [blame^] | 19 | AArch64SelectionDAGInfo::AArch64SelectionDAGInfo(const DataLayout *DL) |
| 20 | : TargetSelectionDAGInfo(DL) {} |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 21 | |
| 22 | AArch64SelectionDAGInfo::~AArch64SelectionDAGInfo() {} |
| 23 | |
| 24 | SDValue 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 = |
| Stephen Hines | c6a4f5e | 2014-07-21 00:45:20 -0700 | [diff] [blame^] | 32 | (V && V->isNullValue()) |
| 33 | ? DAG.getTarget().getSubtarget<AArch64Subtarget>().getBZeroEntry() |
| 34 | : nullptr; |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 35 | // 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 = |
| 39 | *static_cast<const AArch64TargetLowering *>( |
| 40 | DAG.getTarget().getTargetLowering()); |
| 41 | |
| 42 | EVT IntPtr = TLI.getPointerTy(); |
| 43 | Type *IntPtrTy = getDataLayout()->getIntPtrType(*DAG.getContext()); |
| 44 | TargetLowering::ArgListTy Args; |
| 45 | TargetLowering::ArgListEntry Entry; |
| 46 | Entry.Node = Dst; |
| 47 | Entry.Ty = IntPtrTy; |
| 48 | Args.push_back(Entry); |
| 49 | Entry.Node = Size; |
| 50 | Args.push_back(Entry); |
| 51 | TargetLowering::CallLoweringInfo CLI(DAG); |
| 52 | CLI.setDebugLoc(dl).setChain(Chain) |
| 53 | .setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()), |
| Stephen Hines | c6a4f5e | 2014-07-21 00:45:20 -0700 | [diff] [blame^] | 54 | DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0) |
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 55 | .setDiscardResult(); |
| 56 | std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI); |
| 57 | return CallResult.second; |
| 58 | } |
| 59 | return SDValue(); |
| Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 60 | } |