Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Hexagon/HexagonSelectionDAGInfo.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- HexagonSelectionDAGInfo.cpp - Hexagon 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 HexagonSelectionDAGInfo class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "HexagonTargetMachine.h"
14
#include "llvm/CodeGen/SelectionDAG.h"
15
using namespace llvm;
16
17
#define DEBUG_TYPE "hexagon-selectiondag-info"
18
19
SDValue HexagonSelectionDAGInfo::EmitTargetCodeForMemcpy(
20
    SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
21
    SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
22
5
    MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
23
5
  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
24
5
  if (AlwaysInline || (Align & 0x3) != 0 || 
!ConstantSize3
)
25
2
    return SDValue();
26
3
27
3
  uint64_t SizeVal = ConstantSize->getZExtValue();
28
3
  if (SizeVal < 32 || (SizeVal % 8) != 0)
29
0
    return SDValue();
30
3
31
3
  // Special case aligned memcpys with size >= 32 bytes and a multiple of 8.
32
3
  //
33
3
  const TargetLowering &TLI = *DAG.getSubtarget().getTargetLowering();
34
3
  TargetLowering::ArgListTy Args;
35
3
  TargetLowering::ArgListEntry Entry;
36
3
  Entry.Ty = DAG.getDataLayout().getIntPtrType(*DAG.getContext());
37
3
  Entry.Node = Dst;
38
3
  Args.push_back(Entry);
39
3
  Entry.Node = Src;
40
3
  Args.push_back(Entry);
41
3
  Entry.Node = Size;
42
3
  Args.push_back(Entry);
43
3
44
3
  const char *SpecialMemcpyName =
45
3
      "__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes";
46
3
  const MachineFunction &MF = DAG.getMachineFunction();
47
3
  bool LongCalls = MF.getSubtarget<HexagonSubtarget>().useLongCalls();
48
3
  unsigned Flags = LongCalls ? 
HexagonII::HMOTF_ConstExtended0
: 0;
49
3
50
3
  TargetLowering::CallLoweringInfo CLI(DAG);
51
3
  CLI.setDebugLoc(dl)
52
3
      .setChain(Chain)
53
3
      .setLibCallee(
54
3
          TLI.getLibcallCallingConv(RTLIB::MEMCPY),
55
3
          Type::getVoidTy(*DAG.getContext()),
56
3
          DAG.getTargetExternalSymbol(
57
3
              SpecialMemcpyName, TLI.getPointerTy(DAG.getDataLayout()), Flags),
58
3
          std::move(Args))
59
3
      .setDiscardResult();
60
3
61
3
  std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
62
3
  return CallResult.second;
63
3
}