Coverage Report

Created: 2024-01-17 10:31

/src/llvm-project/llvm/lib/Target/BPF/BPFSelectionDAGInfo.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- BPFSelectionDAGInfo.cpp - BPF 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 BPFSelectionDAGInfo class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "BPFTargetMachine.h"
14
#include "llvm/CodeGen/SelectionDAG.h"
15
#include "llvm/IR/DerivedTypes.h"
16
using namespace llvm;
17
18
#define DEBUG_TYPE "bpf-selectiondag-info"
19
20
SDValue BPFSelectionDAGInfo::EmitTargetCodeForMemcpy(
21
    SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
22
    SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
23
0
    MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
24
  // Requires the copy size to be a constant.
25
0
  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
26
0
  if (!ConstantSize)
27
0
    return SDValue();
28
29
0
  unsigned CopyLen = ConstantSize->getZExtValue();
30
0
  unsigned StoresNumEstimate = alignTo(CopyLen, Alignment) >> Log2(Alignment);
31
  // Impose the same copy length limit as MaxStoresPerMemcpy.
32
0
  if (StoresNumEstimate > getCommonMaxStoresPerMemFunc())
33
0
    return SDValue();
34
35
0
  SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Glue);
36
37
0
  Dst = DAG.getNode(BPFISD::MEMCPY, dl, VTs, Chain, Dst, Src,
38
0
                    DAG.getConstant(CopyLen, dl, MVT::i64),
39
0
                    DAG.getConstant(Alignment.value(), dl, MVT::i64));
40
41
0
  return Dst.getValue(0);
42
0
}