2014-05-24 20:50:23 +08:00
|
|
|
//===-- AArch64SelectionDAGInfo.cpp - AArch64 SelectionDAG Info -----------===//
|
2014-03-29 18:18:08 +08: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 20:50:23 +08:00
|
|
|
// This file implements the AArch64SelectionDAGInfo class.
|
2014-03-29 18:18:08 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
#include "AArch64TargetMachine.h"
|
2014-03-29 18:18:08 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
#define DEBUG_TYPE "aarch64-selectiondag-info"
|
2014-04-22 10:41:26 +08:00
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
|
2014-03-29 18:18:08 +08: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 16:39:06 +08:00
|
|
|
const AArch64Subtarget &STI =
|
|
|
|
DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
|
2014-03-29 18:18:08 +08:00
|
|
|
const char *bzeroEntry =
|
2015-02-20 16:39:06 +08:00
|
|
|
(V && V->isNullValue()) ? STI.getBZeroEntry() : nullptr;
|
2014-03-29 18:18:08 +08:00
|
|
|
// For small size (< 256), it is not beneficial to use bzero
|
|
|
|
// instead of memset.
|
|
|
|
if (bzeroEntry && (!SizeValue || SizeValue->getZExtValue() > 256)) {
|
2015-02-20 16:39:06 +08:00
|
|
|
const AArch64TargetLowering &TLI = *STI.getTargetLowering();
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-07-09 10:09:04 +08:00
|
|
|
EVT IntPtr = TLI.getPointerTy(DAG.getDataLayout());
|
|
|
|
Type *IntPtrTy = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
|
2014-03-29 18:18:08 +08:00
|
|
|
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-18 05:50:17 +08:00
|
|
|
TargetLowering::CallLoweringInfo CLI(DAG);
|
|
|
|
CLI.setDebugLoc(dl).setChain(Chain)
|
|
|
|
.setCallee(CallingConv::C, Type::getVoidTy(*DAG.getContext()),
|
2014-07-02 06:01:54 +08:00
|
|
|
DAG.getExternalSymbol(bzeroEntry, IntPtr), std::move(Args), 0)
|
2014-05-18 05:50:17 +08:00
|
|
|
.setDiscardResult();
|
2014-03-29 18:18:08 +08:00
|
|
|
std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
|
|
|
|
return CallResult.second;
|
|
|
|
}
|
|
|
|
return SDValue();
|
|
|
|
}
|