2010-04-17 07:04:22 +08:00
|
|
|
//===-- XCoreSelectionDAGInfo.cpp - XCore SelectionDAG Info ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the XCoreSelectionDAGInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-05-12 01:31:57 +08:00
|
|
|
#include "XCoreTargetMachine.h"
|
2010-04-17 07:04:22 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "xcore-selectiondag-info"
|
|
|
|
|
2016-06-12 23:39:02 +08:00
|
|
|
SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
|
|
|
|
SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
|
|
|
|
SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
|
|
|
|
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
|
2014-02-27 21:39:07 +08:00
|
|
|
unsigned SizeBitWidth = Size.getValueType().getSizeInBits();
|
|
|
|
// Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
|
|
|
|
if (!AlwaysInline && (Align & 3) == 0 &&
|
|
|
|
DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))) {
|
2014-08-05 10:39:49 +08:00
|
|
|
const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
|
2014-02-27 21:39:07 +08:00
|
|
|
TargetLowering::ArgListTy Args;
|
|
|
|
TargetLowering::ArgListEntry Entry;
|
2015-07-09 10:09:52 +08:00
|
|
|
Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
|
2014-02-27 21:39:07 +08:00
|
|
|
Entry.Node = Dst; Args.push_back(Entry);
|
|
|
|
Entry.Node = Src; Args.push_back(Entry);
|
|
|
|
Entry.Node = Size; Args.push_back(Entry);
|
|
|
|
|
2014-05-18 05:50:17 +08:00
|
|
|
TargetLowering::CallLoweringInfo CLI(DAG);
|
2015-07-09 10:09:04 +08:00
|
|
|
CLI.setDebugLoc(dl)
|
|
|
|
.setChain(Chain)
|
|
|
|
.setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
|
|
|
|
Type::getVoidTy(*DAG.getContext()),
|
|
|
|
DAG.getExternalSymbol("__memcpy_4",
|
|
|
|
TLI.getPointerTy(DAG.getDataLayout())),
|
2016-06-22 20:54:25 +08:00
|
|
|
std::move(Args))
|
2015-07-09 10:09:04 +08:00
|
|
|
.setDiscardResult();
|
2014-05-18 05:50:17 +08:00
|
|
|
|
|
|
|
std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
|
2014-02-27 21:39:07 +08:00
|
|
|
return CallResult.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise have the target-independent code call memcpy.
|
|
|
|
return SDValue();
|
|
|
|
}
|