Skip to content

Commit

Permalink
[SOL] Set max stores per mem func depending on the target features (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov committed Jul 26, 2021
1 parent d832fd2 commit 747454b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion llvm/lib/Target/BPF/BPFISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion llvm/lib/Target/BPF/BPFSelectionDAGInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ 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,
bool isVolatile, bool AlwaysInline,
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;

};

Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/BPF/BPFSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 747454b

Please sign in to comment.