Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/XCore/XCoreSelectionDAGInfo.cpp
Line
Count
Source
1
//===-- XCoreSelectionDAGInfo.cpp - XCore SelectionDAG Info ---------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements the XCoreSelectionDAGInfo class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "XCoreTargetMachine.h"
14
using namespace llvm;
15
16
#define DEBUG_TYPE "xcore-selectiondag-info"
17
18
SDValue XCoreSelectionDAGInfo::EmitTargetCodeForMemcpy(
19
    SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
20
    SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
21
4
    MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
22
4
  unsigned SizeBitWidth = Size.getValueSizeInBits();
23
4
  // Call __memcpy_4 if the src, dst and size are all 4 byte aligned.
24
4
  if (!AlwaysInline && (Align & 3) == 0 &&
25
4
      
DAG.MaskedValueIsZero(Size, APInt(SizeBitWidth, 3))3
) {
26
2
    const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
27
2
    TargetLowering::ArgListTy Args;
28
2
    TargetLowering::ArgListEntry Entry;
29
2
    Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
30
2
    Entry.Node = Dst; Args.push_back(Entry);
31
2
    Entry.Node = Src; Args.push_back(Entry);
32
2
    Entry.Node = Size; Args.push_back(Entry);
33
2
34
2
    TargetLowering::CallLoweringInfo CLI(DAG);
35
2
    CLI.setDebugLoc(dl)
36
2
        .setChain(Chain)
37
2
        .setLibCallee(TLI.getLibcallCallingConv(RTLIB::MEMCPY),
38
2
                      Type::getVoidTy(*DAG.getContext()),
39
2
                      DAG.getExternalSymbol(
40
2
                          "__memcpy_4", TLI.getPointerTy(DAG.getDataLayout())),
41
2
                      std::move(Args))
42
2
        .setDiscardResult();
43
2
44
2
    std::pair<SDValue,SDValue> CallResult = TLI.LowerCallTo(CLI);
45
2
    return CallResult.second;
46
2
  }
47
2
48
2
  // Otherwise have the target-independent code call memcpy.
49
2
  return SDValue();
50
2
}