2014-05-24 12:50:23 +00:00
|
|
|
//===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===//
|
2014-03-29 10:18:08 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2014-05-24 12:50:23 +00:00
|
|
|
// This file implements the AArch64SelectionDAGInfo class.
|
2014-03-29 10:18:08 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
#include "AArch64TargetMachine.h"
|
2014-03-29 10:18:08 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
#define DEBUG_TYPE "aarch64-selectiondag-info"
|
2014-04-22 02:41:26 +00:00
|
|
|
|
2014-06-10 18:06:28 +00:00
|
|
|
AArch64SelectionDAGInfo::AArch64SelectionDAGInfo(const DataLayout *DL)
|
|
|
|
: TargetSelectionDAGInfo(DL) {}
|
2014-03-29 10:18:08 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
AArch64SelectionDAGInfo::~AArch64SelectionDAGInfo() {}
|
2014-03-29 10:18:08 +00:00
|
|
|
|
2014-05-24 12:50:23 +00:00
|
|
|
SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
|
2014-03-29 10:18:08 +00:00
|
|
|
SelectionDAG &DAG, SDLoc dl, SDValue Chain, SDValue Dst, SDValue Src,
|
|
|
|
SDValue Size, unsigned Align, bool isVolatile,
|
|
|
|
MachinePointerInfo DstPtrInfo) const {
|
|
|
|
// Check to see if there is a specialized entry-point for memory zeroing.
|
|
|
|
ConstantSDNode *V = dyn_cast<ConstantSDNode>(Src);
|
|
|
|
ConstantSDNode *SizeValue = dyn_cast<ConstantSDNode>(Size);
|
2015-02-20 08:39:06 +00:00
|
|
|
const AArch64Subtarget &STI =
|
|
|
|
DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
|
2014-03-29 10:18:08 +00:00
|
|
|
const char *bzeroEntry =
|
2015-02-20 08:39:06 +00:00
|
|
|
(V && V->isNullValue()) ? STI.getBZeroEntry() : nullptr;
|
2014-03-29 10:18:08 +00:00
|
|
|
// For small size (< 256), it is not beneficial to use bzero
|
|
|
|
// instead of memset.
|
|
|
|
if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
|
2015-02-20 08:39:06 +00:00
|
|
|
const AArch64TargetLowering &TLI = *STI.getTargetLowering();
|
2014-03-29 10:18:08 +00:00
|
|
|
|
|
|
|
EVT IntPtr = TLI.getPointerTy();
|
|
|
|
Type *IntPtrTy = getDataLayout()->getIntPtrType(*DAG.getContext());
|
|
|
|
TargetLowering::ArgListTy Args;
|
|
|
|
TargetLowering::ArgListEntry Entry;
|
|
|
|
Entry.Node = Dst;
|
|
|
|
Entry.Ty = IntPtrTy;
|
|
|
|
Args.push_back(Entry);
|
|
|
|
Entry.Node = Size;
|
|
|
|
Args.push_back(Entry);
|
2014-05-17 21:50:17 +00:00
|
|
|
TargetLowering::CallLoweringInfo CLI(DAG);
|
|
|
|
CLI.setDebugLoc(dl).setChain(Chain)
|
|
|
|
.setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
|
2014-07-01 22:01:54 +00:00
|
|
|
DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0)
|
2014-05-17 21:50:17 +00:00
|
|
|
.setDiscardResult();
|
2014-03-29 10:18:08 +00:00
|
|
|
std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
|
|
|
|
return CallResult.second;
|
|
|
|
}
|
|
|
|
return SDValue();
|
|
|
|
}
|