Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp
Line
Count
Source
1
//===-- WebAssemblySelectionDAGInfo.cpp - WebAssembly 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
/// \file
10
/// This file implements the WebAssemblySelectionDAGInfo class.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#include "WebAssemblyTargetMachine.h"
15
using namespace llvm;
16
17
#define DEBUG_TYPE "wasm-selectiondag-info"
18
19
533
WebAssemblySelectionDAGInfo::~WebAssemblySelectionDAGInfo() = default; // anchor
20
21
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemcpy(
22
    SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
23
    SDValue Size, unsigned Align, bool IsVolatile, bool AlwaysInline,
24
23
    MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
25
23
  if (!DAG.getMachineFunction()
26
23
           .getSubtarget<WebAssemblySubtarget>()
27
23
           .hasBulkMemory())
28
15
    return SDValue();
29
8
30
8
  SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
31
8
  return DAG.getNode(WebAssemblyISD::MEMORY_COPY, DL, MVT::Other,
32
8
                     {Chain, MemIdx, MemIdx, Dst, Src,
33
8
                      DAG.getZExtOrTrunc(Size, DL, MVT::i32)});
34
8
}
35
36
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemmove(
37
    SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op1, SDValue Op2,
38
    SDValue Op3, unsigned Align, bool IsVolatile,
39
8
    MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
40
8
  return EmitTargetCodeForMemcpy(DAG, DL, Chain, Op1, Op2, Op3, Align,
41
8
                                 IsVolatile, false, DstPtrInfo,
42
8
                                 SrcPtrInfo);
43
8
}
44
45
SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemset(
46
    SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Val,
47
    SDValue Size, unsigned Align, bool IsVolatile,
48
13
    MachinePointerInfo DstPtrInfo) const {
49
13
  if (!DAG.getMachineFunction()
50
13
           .getSubtarget<WebAssemblySubtarget>()
51
13
           .hasBulkMemory())
52
9
    return SDValue();
53
4
54
4
  SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32);
55
4
  // Only low byte matters for val argument, so anyext the i8
56
4
  return DAG.getNode(WebAssemblyISD::MEMORY_FILL, DL, MVT::Other, Chain, MemIdx,
57
4
                     Dst, DAG.getAnyExtOrTrunc(Val, DL, MVT::i32),
58
4
                     DAG.getZExtOrTrunc(Size, DL, MVT::i32));
59
4
}