From a228af9abd3ffa5d8cd20029b75af85b688de679 Mon Sep 17 00:00:00 2001 From: Dmitri Makarov Date: Mon, 26 Jul 2021 11:50:33 -0700 Subject: [PATCH] [SOL] Set max stores per mem func depending on the target features --- llvm/lib/Target/BPF/BPFISelLowering.cpp | 4 +++- llvm/lib/Target/BPF/BPFSelectionDAGInfo.h | 11 ++++++++++- llvm/lib/Target/BPF/BPFSubtarget.cpp | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp index 48294d940151f..d73c1c64d4f5b 100644 --- a/llvm/lib/Target/BPF/BPFISelLowering.cpp +++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp @@ -162,9 +162,11 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM, MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = 0; MaxStoresPerMemmove = MaxStoresPerMemmoveOptSize = 0; } else { + auto SelectionDAGInfo = STI.getSelectionDAGInfo(); + SelectionDAGInfo->setSolanaFlag(STI.isSolana()); // inline memcpy() for kernel to see explicit copy unsigned CommonMaxStores = - STI.getSelectionDAGInfo()->getCommonMaxStoresPerMemFunc(); + SelectionDAGInfo->getCommonMaxStoresPerMemFunc(); MaxStoresPerMemset = MaxStoresPerMemsetOptSize = CommonMaxStores; MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = CommonMaxStores; diff --git a/llvm/lib/Target/BPF/BPFSelectionDAGInfo.h b/llvm/lib/Target/BPF/BPFSelectionDAGInfo.h index 79f05e57bb5cd..0cc752ae9503d 100644 --- a/llvm/lib/Target/BPF/BPFSelectionDAGInfo.h +++ b/llvm/lib/Target/BPF/BPFSelectionDAGInfo.h @@ -19,6 +19,7 @@ namespace llvm { class BPFSelectionDAGInfo : public SelectionDAGTargetInfo { public: + BPFSelectionDAGInfo() : isSolana(false) {} SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, @@ -26,7 +27,15 @@ class BPFSelectionDAGInfo : public SelectionDAGTargetInfo { MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const override; - unsigned getCommonMaxStoresPerMemFunc() const { return 128; } + unsigned getCommonMaxStoresPerMemFunc() const { + return isSolana ? 4 : 128; + } + void setSolanaFlag(bool value) const { + isSolana = value; + } + +private: + mutable bool isSolana; }; diff --git a/llvm/lib/Target/BPF/BPFSubtarget.cpp b/llvm/lib/Target/BPF/BPFSubtarget.cpp index e7dc9a429b8ff..df513f5a85f50 100644 --- a/llvm/lib/Target/BPF/BPFSubtarget.cpp +++ b/llvm/lib/Target/BPF/BPFSubtarget.cpp @@ -62,4 +62,6 @@ BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM) : BPFGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), InstrInfo(), FrameLowering(initializeSubtargetDependencies(CPU, FS)), - TLInfo(TM, *this) {} + TLInfo(TM, *this) { + TSInfo.setSolanaFlag(IsSolana); +}