LLVM  13.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"
15 #include "llvm/IR/DerivedTypes.h"
16 using namespace llvm;
17 
18 #define DEBUG_TYPE "bpf-selectiondag-info"
19 
21  SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
22  SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
23  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
24  // Requires the copy size to be a constant.
25  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
26  if (!ConstantSize)
27  return SDValue();
28 
29  unsigned CopyLen = ConstantSize->getZExtValue();
30  unsigned StoresNumEstimate = alignTo(CopyLen, Alignment) >> Log2(Alignment);
31  // Impose the same copy length limit as MaxStoresPerMemcpy.
32  if (StoresNumEstimate > getCommonMaxStoresPerMemFunc())
33  return SDValue();
34 
36 
37  Dst = DAG.getNode(BPFISD::MEMCPY, dl, VTs, Chain, Dst, Src,
38  DAG.getConstant(CopyLen, dl, MVT::i64),
39  DAG.getConstant(Alignment.value(), dl, MVT::i64));
40 
41  return Dst.getValue(0);
42 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::ConstantSDNode
Definition: SelectionDAGNodes.h:1542
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::SDLoc
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Definition: SelectionDAGNodes.h:1078
llvm::BPFISD::MEMCPY
@ MEMCPY
Definition: BPFISelLowering.h:31
llvm::SelectionDAG::getVTList
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
Definition: SelectionDAG.cpp:8147
llvm::MVT::Glue
@ Glue
Definition: MachineValueType.h:262
SelectionDAG.h
llvm::SelectionDAG
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:216
llvm::SelectionDAG::getConstant
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
Definition: SelectionDAG.cpp:1348
llvm::Log2
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition: Alignment.h:207
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:38
llvm::SelectionDAG::getNode
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
Definition: SelectionDAG.cpp:7912
llvm::SDValue::getValue
SDValue getValue(unsigned R) const
Definition: SelectionDAGNodes.h:172
llvm::MVT::Other
@ Other
Definition: MachineValueType.h:42
llvm::ConstantSDNode::getZExtValue
uint64_t getZExtValue() const
Definition: SelectionDAGNodes.h:1557
llvm::BPFSelectionDAGInfo::getCommonMaxStoresPerMemFunc
unsigned getCommonMaxStoresPerMemFunc() const
Definition: BPFSelectionDAGInfo.h:29
llvm::MVT::i64
@ i64
Definition: MachineValueType.h:47
llvm::SDVTList
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
Definition: SelectionDAGNodes.h:79
llvm::BPFSelectionDAGInfo::EmitTargetCodeForMemcpy
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.
Definition: BPFSelectionDAGInfo.cpp:20
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::SDValue
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Definition: SelectionDAGNodes.h:138
DerivedTypes.h
BPFTargetMachine.h