Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,20 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
// corresponding branch. This information is used in CGP/SelectOpt to decide
// when to convert selects into branches.
PredictableSelectIsExpensive = Subtarget.predictableSelectIsExpensive();

MaxStoresPerMemsetOptSize = Subtarget.getMaxStoresPerMemset(/*OptSize=*/true);
MaxStoresPerMemset = Subtarget.getMaxStoresPerMemset(/*OptSize=*/false);

MaxGluedStoresPerMemcpy = Subtarget.getMaxGluedStoresPerMemcpy();
MaxStoresPerMemcpyOptSize = Subtarget.getMaxStoresPerMemcpy(/*OptSize=*/true);
MaxStoresPerMemcpy = Subtarget.getMaxStoresPerMemcpy(/*OptSize=*/false);

MaxStoresPerMemmoveOptSize =
Subtarget.getMaxStoresPerMemmove(/*OptSize=*/true);
MaxStoresPerMemmove = Subtarget.getMaxStoresPerMemmove(/*OptSize=*/false);

MaxLoadsPerMemcmpOptSize = Subtarget.getMaxLoadsPerMemcmp(/*OptSize=*/true);
MaxLoadsPerMemcmp = Subtarget.getMaxLoadsPerMemcmp(/*OptSize=*/false);
}

EVT RISCVTargetLowering::getSetCCResultType(const DataLayout &DL,
Expand Down
23 changes: 20 additions & 3 deletions llvm/lib/Target/RISCV/RISCVProcessors.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,32 @@ class RISCVTuneInfo {

// Tail duplication threshold at -O3.
bits<32> TailDupAggressiveThreshold = 6;

bits<32> MaxStoresPerMemsetOptSize = 4;
bits<32> MaxStoresPerMemset = 8;

bits<32> MaxGluedStoresPerMemcpy = 0;
bits<32> MaxStoresPerMemcpyOptSize = 4;
bits<32> MaxStoresPerMemcpy = 8;

bits<32> MaxStoresPerMemmoveOptSize = 4;
bits<32> MaxStoresPerMemmove = 8;

bits<32> MaxLoadsPerMemcmpOptSize = 4;
bits<32> MaxLoadsPerMemcmp = 8;
}

def RISCVTuneInfoTable : GenericTable {
let FilterClass = "RISCVTuneInfo";
let CppTypeName = "RISCVTuneInfo";
let Fields = ["Name", "PrefFunctionAlignment", "PrefLoopAlignment",
"CacheLineSize", "PrefetchDistance",
"MinPrefetchStride", "MaxPrefetchIterationsAhead",
"MinimumJumpTableEntries", "TailDupAggressiveThreshold"];
"CacheLineSize", "PrefetchDistance", "MinPrefetchStride",
"MaxPrefetchIterationsAhead", "MinimumJumpTableEntries",
"TailDupAggressiveThreshold", "MaxStoresPerMemsetOptSize",
"MaxStoresPerMemset", "MaxGluedStoresPerMemcpy",
"MaxStoresPerMemcpyOptSize", "MaxStoresPerMemcpy",
"MaxStoresPerMemmoveOptSize", "MaxStoresPerMemmove",
"MaxLoadsPerMemcmpOptSize", "MaxLoadsPerMemcmp"];
}

def getRISCVTuneInfo : SearchIndex {
Expand Down
37 changes: 37 additions & 0 deletions llvm/lib/Target/RISCV/RISCVSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ struct RISCVTuneInfo {

// Tail duplication threshold at -O3.
unsigned TailDupAggressiveThreshold;

unsigned MaxStoresPerMemsetOptSize;
unsigned MaxStoresPerMemset;

unsigned MaxGluedStoresPerMemcpy;
unsigned MaxStoresPerMemcpyOptSize;
unsigned MaxStoresPerMemcpy;

unsigned MaxStoresPerMemmoveOptSize;
unsigned MaxStoresPerMemmove;

unsigned MaxLoadsPerMemcmpOptSize;
unsigned MaxLoadsPerMemcmp;
};

#define GET_RISCVTuneInfoTable_DECL
Expand Down Expand Up @@ -325,6 +338,30 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
return TuneInfo->TailDupAggressiveThreshold;
}

unsigned getMaxStoresPerMemset(bool OptSize) const {
return OptSize ? TuneInfo->MaxStoresPerMemsetOptSize
: TuneInfo->MaxStoresPerMemset;
}

unsigned getMaxGluedStoresPerMemcpy() const {
return TuneInfo->MaxGluedStoresPerMemcpy;
}

unsigned getMaxStoresPerMemcpy(bool OptSize) const {
return OptSize ? TuneInfo->MaxStoresPerMemcpyOptSize
: TuneInfo->MaxStoresPerMemcpy;
}

unsigned getMaxStoresPerMemmove(bool OptSize) const {
return OptSize ? TuneInfo->MaxStoresPerMemmoveOptSize
: TuneInfo->MaxStoresPerMemmove;
}

unsigned getMaxLoadsPerMemcmp(bool OptSize) const {
return OptSize ? TuneInfo->MaxLoadsPerMemcmpOptSize
: TuneInfo->MaxLoadsPerMemcmp;
}

void overrideSchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const override;
};
Expand Down
Loading