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
11 changes: 10 additions & 1 deletion llvm/lib/Target/RISCV/RISCVProcessors.td
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
// RISC-V processors supported.
//===----------------------------------------------------------------------===//

// Predefined scheduling direction.
defvar TopDown = [{ MISched::TopDown }];
defvar BottomUp = [{ MISched::BottomUp }];
defvar Bidirectional = [{ MISched::Bidirectional }];

class RISCVTuneInfo {
bits<8> PrefFunctionAlignment = 1;
bits<8> PrefLoopAlignment = 1;
Expand Down Expand Up @@ -37,6 +42,9 @@ class RISCVTuneInfo {

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

// The direction of PostRA scheduling.
code PostRASchedDirection = TopDown;
}

def RISCVTuneInfoTable : GenericTable {
Expand All @@ -49,7 +57,8 @@ def RISCVTuneInfoTable : GenericTable {
"MaxStoresPerMemset", "MaxGluedStoresPerMemcpy",
"MaxStoresPerMemcpyOptSize", "MaxStoresPerMemcpy",
"MaxStoresPerMemmoveOptSize", "MaxStoresPerMemmove",
"MaxLoadsPerMemcmpOptSize", "MaxLoadsPerMemcmp"];
"MaxLoadsPerMemcmpOptSize", "MaxLoadsPerMemcmp",
"PostRASchedDirection"];
}

def getRISCVTuneInfo : SearchIndex {
Expand Down
16 changes: 15 additions & 1 deletion llvm/lib/Target/RISCV/RISCVSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "RISCV.h"
#include "RISCVFrameLowering.h"
#include "RISCVTargetMachine.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/MacroFusion.h"
#include "llvm/CodeGen/ScheduleDAGMutation.h"
#include "llvm/MC/TargetRegistry.h"
Expand Down Expand Up @@ -211,3 +210,18 @@ void RISCVSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
// register-pressure tracking. This will increase compile time.
Policy.ShouldTrackPressure = true;
}

void RISCVSubtarget::overridePostRASchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const {
MISched::Direction PostRASchedDirection = getPostRASchedDirection();
if (PostRASchedDirection == MISched::TopDown) {
Policy.OnlyTopDown = true;
Policy.OnlyBottomUp = false;
} else if (PostRASchedDirection == MISched::BottomUp) {
Policy.OnlyTopDown = false;
Policy.OnlyBottomUp = true;
} else if (PostRASchedDirection == MISched::Bidirectional) {
Policy.OnlyTopDown = false;
Policy.OnlyBottomUp = false;
}
}
11 changes: 11 additions & 0 deletions llvm/lib/Target/RISCV/RISCVSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DataLayout.h"
Expand Down Expand Up @@ -66,6 +67,9 @@ struct RISCVTuneInfo {

unsigned MaxLoadsPerMemcmpOptSize;
unsigned MaxLoadsPerMemcmp;

// The direction of PostRA scheduling.
MISched::Direction PostRASchedDirection;
};

#define GET_RISCVTuneInfoTable_DECL
Expand Down Expand Up @@ -365,8 +369,15 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
: TuneInfo->MaxLoadsPerMemcmp;
}

MISched::Direction getPostRASchedDirection() const {
return TuneInfo->PostRASchedDirection;
}

void overrideSchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const override;

void overridePostRASchedPolicy(MachineSchedPolicy &Policy,
unsigned NumRegionInstrs) const override;
};
} // End llvm namespace

Expand Down
Loading