LLVM 22.0.0git
BPFSelectionDAGInfo.cpp
Go to the documentation of this file.
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"
15using namespace llvm;
16
17#define DEBUG_TYPE "bpf-selectiondag-info"
18
20 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
21 SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
22 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
23 // Requires the copy size to be a constant.
25 if (!ConstantSize)
26 return SDValue();
27
28 unsigned CopyLen = ConstantSize->getZExtValue();
29 unsigned StoresNumEstimate = alignTo(CopyLen, Alignment) >> Log2(Alignment);
30 // Impose the same copy length limit as MaxStoresPerMemcpy.
31 if (StoresNumEstimate > getCommonMaxStoresPerMemFunc())
32 return SDValue();
33
34 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Glue);
35
36 Dst = DAG.getNode(BPFISD::MEMCPY, dl, VTs, Chain, Dst, Src,
37 DAG.getConstant(CopyLen, dl, MVT::i64),
38 DAG.getConstant(Alignment.value(), dl, MVT::i64));
39
40 return Dst.getValue(0);
41}
return SDValue()
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
unsigned getCommonMaxStoresPerMemFunc() const
uint64_t getZExtValue() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDValue getValue(unsigned R) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:649
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition Alignment.h:197
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Definition Alignment.h:77
This class contains a discriminated union of information about pointers in memory operands,...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.