Skip to content

Commit 747454b

Browse files
authored
[SOL] Set max stores per mem func depending on the target features (#14)
1 parent d832fd2 commit 747454b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

llvm/lib/Target/BPF/BPFISelLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
162162
MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = 0;
163163
MaxStoresPerMemmove = MaxStoresPerMemmoveOptSize = 0;
164164
} else {
165+
auto SelectionDAGInfo = STI.getSelectionDAGInfo();
166+
SelectionDAGInfo->setSolanaFlag(STI.isSolana());
165167
// inline memcpy() for kernel to see explicit copy
166168
unsigned CommonMaxStores =
167-
STI.getSelectionDAGInfo()->getCommonMaxStoresPerMemFunc();
169+
SelectionDAGInfo->getCommonMaxStoresPerMemFunc();
168170

169171
MaxStoresPerMemset = MaxStoresPerMemsetOptSize = CommonMaxStores;
170172
MaxStoresPerMemcpy = MaxStoresPerMemcpyOptSize = CommonMaxStores;

llvm/lib/Target/BPF/BPFSelectionDAGInfo.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,23 @@ namespace llvm {
1919

2020
class BPFSelectionDAGInfo : public SelectionDAGTargetInfo {
2121
public:
22+
BPFSelectionDAGInfo() : isSolana(false) {}
2223
SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl,
2324
SDValue Chain, SDValue Dst, SDValue Src,
2425
SDValue Size, Align Alignment,
2526
bool isVolatile, bool AlwaysInline,
2627
MachinePointerInfo DstPtrInfo,
2728
MachinePointerInfo SrcPtrInfo) const override;
2829

29-
unsigned getCommonMaxStoresPerMemFunc() const { return 128; }
30+
unsigned getCommonMaxStoresPerMemFunc() const {
31+
return isSolana ? 4 : 128;
32+
}
33+
void setSolanaFlag(bool value) const {
34+
isSolana = value;
35+
}
36+
37+
private:
38+
mutable bool isSolana;
3039

3140
};
3241

llvm/lib/Target/BPF/BPFSubtarget.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@ BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
6262
const std::string &FS, const TargetMachine &TM)
6363
: BPFGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), InstrInfo(),
6464
FrameLowering(initializeSubtargetDependencies(CPU, FS)),
65-
TLInfo(TM, *this) {}
65+
TLInfo(TM, *this) {
66+
TSInfo.setSolanaFlag(IsSolana);
67+
}

0 commit comments

Comments
 (0)