Path: blob/main/contrib/llvm-project/llvm/lib/Target/BPF/BPFSelectionDAGInfo.cpp
35268 views
//===-- BPFSelectionDAGInfo.cpp - BPF SelectionDAG Info -------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the BPFSelectionDAGInfo class.9//10//===----------------------------------------------------------------------===//1112#include "BPFTargetMachine.h"13#include "llvm/CodeGen/SelectionDAG.h"14#include "llvm/IR/DerivedTypes.h"15using namespace llvm;1617#define DEBUG_TYPE "bpf-selectiondag-info"1819SDValue BPFSelectionDAGInfo::EmitTargetCodeForMemcpy(20SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src,21SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,22MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {23// Requires the copy size to be a constant.24ConstantSDNode *ConstantSize = dyn_cast<ConstantSDNode>(Size);25if (!ConstantSize)26return SDValue();2728unsigned CopyLen = ConstantSize->getZExtValue();29unsigned StoresNumEstimate = alignTo(CopyLen, Alignment) >> Log2(Alignment);30// Impose the same copy length limit as MaxStoresPerMemcpy.31if (StoresNumEstimate > getCommonMaxStoresPerMemFunc())32return SDValue();3334SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Glue);3536Dst = DAG.getNode(BPFISD::MEMCPY, dl, VTs, Chain, Dst, Src,37DAG.getConstant(CopyLen, dl, MVT::i64),38DAG.getConstant(Alignment.value(), dl, MVT::i64));3940return Dst.getValue(0);41}424344