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"
|
|
|
|
|
2014-07-02 08:10:05 +08:00
|
|
|
XCoreSelectionDAGInfo::XCoreSelectionDAGInfo(const DataLayout &DL)
|
|
|
|
: TargetSelectionDAGInfo(&DL) {}
|
2010-04-17 07:04:22 +08:00
|
|
|
|
|
|
|
XCoreSelectionDAGInfo::~XCoreSelectionDAGInfo() {
|
|
|
|
}
|
2014-02-27 21:39:07 +08:00
|
|
|
|
|
|
|
SDValue XCoreSelectionDAGInfo::
|
|
|
|
EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
|
|
|
|
SDValue Dst, SDValue Src, SDValue Size, unsigned Align,
|
|
|
|
bool isVolatile, bool AlwaysInline,
|
|
|
|
MachinePointerInfo DstPtrInfo,
|
|
|
|
MachinePointerInfo SrcPtrInfo) const
|
|
|
|
{
|
|
|
|
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 05:25:23 +08:00
|
|
|
const TargetLowering &TLI =
|
|
|
|
*DAG.getTarget().getSubtargetImpl()->getTargetLowering();
|
2014-02-27 21:39:07 +08:00
|
|
|
TargetLowering::ArgListTy Args;
|
|
|
|
TargetLowering::ArgListEntry Entry;
|
|
|
|
Entry.Ty = TLI.getDataLayout()->getIntPtrType(*DAG.getContext());
|
|
|
|
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);
|
|
|
|
CLI.setDebugLoc(dl).setChain(Chain)
|
|
|
|
.setCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
|
|
|
|
Type::getVoidTy(*DAG.getContext()),
|
|
|
|
DAG.getExternalSymbol("__memcpy_4", TLI.getPointerTy()),
|
2014-07-02 06:01:54 +08:00
|
|
|
std::move(Args), 0)
|
2014-05-18 05:50:17 +08:00
|
|
|
.setDiscardResult();
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|