LLVM  8.0.1
BPFSelectionDAGInfo.cpp
Go to the documentation of this file.
1 //===-- BPFSelectionDAGInfo.cpp - BPF SelectionDAG Info -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the BPFSelectionDAGInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "BPFTargetMachine.h"
16 #include "llvm/IR/DerivedTypes.h"
17 using namespace llvm;
18 
19 #define DEBUG_TYPE "bpf-selectiondag-info"
20 
22  SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,
23  SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline,
24  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
25  // Requires the copy size to be a constant.
26  ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);
27  if (!ConstantSize)
28  return SDValue();
29 
30  unsigned CopyLen = ConstantSize->getZExtValue();
31  unsigned StoresNumEstimate = alignTo(CopyLen, Align) >> Log2_32(Align);
32  // Impose the same copy length limit as MaxStoresPerMemcpy.
33  if (StoresNumEstimate > getCommonMaxStoresPerMemFunc())
34  return SDValue();
35 
37 
38  Dst = DAG.getNode(BPFISD::MEMCPY, dl, VTs, Chain, Dst, Src,
39  DAG.getConstant(CopyLen, dl, MVT::i64),
40  DAG.getConstant(Align, dl, MVT::i64));
41 
42  return Dst.getValue(0);
43 }
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
Definition: MathExtras.h:685
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
This represents a list of ValueType&#39;s that has been intern&#39;d by a SelectionDAG.
unsigned getCommonMaxStoresPerMemFunc() const
This class contains a discriminated union of information about pointers in memory operands...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:222
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:539
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
uint32_t Size
Definition: Profile.cpp:47
SDValue getValue(unsigned R) const
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override
Emit target-specific code that performs a memcpy.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
static bool isVolatile(Instruction *Inst)
uint64_t getZExtValue() const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...