aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorPengcheng Wang <wangpengcheng.pp@bytedance.com>2024-12-12 11:24:07 +0800
committerGitHub <noreply@github.com>2024-12-12 11:24:07 +0800
commitda71203e6fc6b8e08c9979204506d385e9cb07b8 (patch)
tree11cb30160fc9dd3fc66623bc733d95580ef9f489 /llvm/lib/CodeGen/MachineScheduler.cpp
parentfd2f8d485df7742320317b14d49b9d808f70625c (diff)
downloadllvm-da71203e6fc6b8e08c9979204506d385e9cb07b8.zip
llvm-da71203e6fc6b8e08c9979204506d385e9cb07b8.tar.gz
llvm-da71203e6fc6b8e08c9979204506d385e9cb07b8.tar.bz2
[MISched] Unify the way to specify scheduling direction (#119518)
For pre-ra scheduling, we use two options `-misched-topdown` and `-misched-bottomup` to force the direction. While for post-ra scheduling, we use `-misched-postra-direction` with enumerated values (`topdown`, `bottomup` and `bidirectional`). This is not unified and adds some mental burdens. Here we replace these two options `-misched-topdown` and `-misched-bottomup` with `-misched-prera-direction` with the same enumerated values. To avoid the condition of `getNumOccurrences() > 0`, we add a new enum value `Unspecified` and make it the default initial value. These options are hidden, so we needn't keep the compatibility.
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp85
1 files changed, 39 insertions, 46 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index 1722bdd..91aaeea 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -77,30 +77,30 @@ STATISTIC(NumClustered, "Number of load/store pairs clustered");
namespace llvm {
-cl::opt<bool> ForceTopDown("misched-topdown", cl::Hidden,
- cl::desc("Force top-down list scheduling"));
-cl::opt<bool> ForceBottomUp("misched-bottomup", cl::Hidden,
- cl::desc("Force bottom-up list scheduling"));
-namespace MISchedPostRASched {
-enum Direction {
- TopDown,
- BottomUp,
- Bidirectional,
-};
-} // end namespace MISchedPostRASched
-cl::opt<MISchedPostRASched::Direction> PostRADirection(
+cl::opt<MISched::Direction> PreRADirection(
+ "misched-prera-direction", cl::Hidden,
+ cl::desc("Pre reg-alloc list scheduling direction"),
+ cl::init(MISched::Unspecified),
+ cl::values(
+ clEnumValN(MISched::TopDown, "topdown",
+ "Force top-down pre reg-alloc list scheduling"),
+ clEnumValN(MISched::BottomUp, "bottomup",
+ "Force bottom-up pre reg-alloc list scheduling"),
+ clEnumValN(MISched::Bidirectional, "bidirectional",
+ "Force bidirectional pre reg-alloc list scheduling")));
+
+cl::opt<MISched::Direction> PostRADirection(
"misched-postra-direction", cl::Hidden,
cl::desc("Post reg-alloc list scheduling direction"),
- // Default to top-down because it was implemented first and existing targets
- // expect that behavior by default.
- cl::init(MISchedPostRASched::TopDown),
+ cl::init(MISched::Unspecified),
cl::values(
- clEnumValN(MISchedPostRASched::TopDown, "topdown",
+ clEnumValN(MISched::TopDown, "topdown",
"Force top-down post reg-alloc list scheduling"),
- clEnumValN(MISchedPostRASched::BottomUp, "bottomup",
+ clEnumValN(MISched::BottomUp, "bottomup",
"Force bottom-up post reg-alloc list scheduling"),
- clEnumValN(MISchedPostRASched::Bidirectional, "bidirectional",
+ clEnumValN(MISched::Bidirectional, "bidirectional",
"Force bidirectional post reg-alloc list scheduling")));
+
cl::opt<bool>
DumpCriticalPathLength("misched-dcpl", cl::Hidden,
cl::desc("Print critical path length to stdout"));
@@ -3307,19 +3307,15 @@ void GenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
RegionPolicy.ShouldTrackLaneMasks = false;
}
- // Check -misched-topdown/bottomup can force or unforce scheduling direction.
- // e.g. -misched-bottomup=false allows scheduling in both directions.
- assert((!ForceTopDown || !ForceBottomUp) &&
- "-misched-topdown incompatible with -misched-bottomup");
- if (ForceBottomUp.getNumOccurrences() > 0) {
- RegionPolicy.OnlyBottomUp = ForceBottomUp;
- if (RegionPolicy.OnlyBottomUp)
- RegionPolicy.OnlyTopDown = false;
- }
- if (ForceTopDown.getNumOccurrences() > 0) {
- RegionPolicy.OnlyTopDown = ForceTopDown;
- if (RegionPolicy.OnlyTopDown)
- RegionPolicy.OnlyBottomUp = false;
+ if (PreRADirection == MISched::TopDown) {
+ RegionPolicy.OnlyTopDown = true;
+ RegionPolicy.OnlyBottomUp = false;
+ } else if (PreRADirection == MISched::BottomUp) {
+ RegionPolicy.OnlyTopDown = false;
+ RegionPolicy.OnlyBottomUp = true;
+ } else if (PreRADirection == MISched::Bidirectional) {
+ RegionPolicy.OnlyBottomUp = false;
+ RegionPolicy.OnlyTopDown = false;
}
}
@@ -3911,17 +3907,15 @@ void PostGenericScheduler::initPolicy(MachineBasicBlock::iterator Begin,
MF.getSubtarget().overridePostRASchedPolicy(RegionPolicy, NumRegionInstrs);
// After subtarget overrides, apply command line options.
- if (PostRADirection.getNumOccurrences() > 0) {
- if (PostRADirection == MISchedPostRASched::TopDown) {
- RegionPolicy.OnlyTopDown = true;
- RegionPolicy.OnlyBottomUp = false;
- } else if (PostRADirection == MISchedPostRASched::BottomUp) {
- RegionPolicy.OnlyTopDown = false;
- RegionPolicy.OnlyBottomUp = true;
- } else if (PostRADirection == MISchedPostRASched::Bidirectional) {
- RegionPolicy.OnlyBottomUp = false;
- RegionPolicy.OnlyTopDown = false;
- }
+ if (PostRADirection == MISched::TopDown) {
+ RegionPolicy.OnlyTopDown = true;
+ RegionPolicy.OnlyBottomUp = false;
+ } else if (PostRADirection == MISched::BottomUp) {
+ RegionPolicy.OnlyTopDown = false;
+ RegionPolicy.OnlyBottomUp = true;
+ } else if (PostRADirection == MISched::Bidirectional) {
+ RegionPolicy.OnlyBottomUp = false;
+ RegionPolicy.OnlyTopDown = false;
}
}
@@ -4368,10 +4362,9 @@ public:
} // end anonymous namespace
static ScheduleDAGInstrs *createInstructionShuffler(MachineSchedContext *C) {
- bool Alternate = !ForceTopDown && !ForceBottomUp;
- bool TopDown = !ForceBottomUp;
- assert((TopDown || !ForceTopDown) &&
- "-misched-topdown incompatible with -misched-bottomup");
+ bool Alternate =
+ PreRADirection != MISched::TopDown && PreRADirection != MISched::BottomUp;
+ bool TopDown = PreRADirection != MISched::BottomUp;
return new ScheduleDAGMILive(
C, std::make_unique<InstructionShuffler>(Alternate, TopDown));
}