[PowerPC] Do not emit record-form rotates when record-form andi/andis suffices
[llvm-core.git] / lib / Target / BPF / BPFSelectionDAGInfo.cpp
blob24d5f59bbfd73e8276ed3717381683171c17b456
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.
12 //===----------------------------------------------------------------------===//
14 #include "BPFTargetMachine.h"
15 #include "llvm/CodeGen/SelectionDAG.h"
16 #include "llvm/IR/DerivedTypes.h"
17 using namespace llvm;
19 #define DEBUG_TYPE "bpf-selectiondag-info"
21 SDValue BPFSelectionDAGInfo::EmitTargetCodeForMemcpy(
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();
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();
36 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Glue);
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));
42 return Dst.getValue(0);