aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Tooling/PipelineDriver.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 13:29:50 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-13 13:29:50 +0800
commit175fdbf4b30eae5e5344cd7fca7e953ca0b2463e (patch)
tree58a62baae7795d8d3c3da4cfbf54dbe4bef8d523 /backend/lib/Tooling/PipelineDriver.cpp
parent393e95fb39d1ddb366b1f17a51166cb3612bbbbd (diff)
downloadrcc-project-175fdbf4b30eae5e5344cd7fca7e953ca0b2463e.tar.gz
rcc-project-175fdbf4b30eae5e5344cd7fca7e953ca0b2463e.tar.xz
[Tooling] Remove the duplicate output kind
Diffstat (limited to 'backend/lib/Tooling/PipelineDriver.cpp')
-rw-r--r--backend/lib/Tooling/PipelineDriver.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/backend/lib/Tooling/PipelineDriver.cpp b/backend/lib/Tooling/PipelineDriver.cpp
index 68cbb57..1a584f7 100644
--- a/backend/lib/Tooling/PipelineDriver.cpp
+++ b/backend/lib/Tooling/PipelineDriver.cpp
@@ -34,8 +34,24 @@ struct FunctionRunResult final {
std::optional<Error> Failure;
};
-[[nodiscard]] unsigned stageOrdinal(BackendStage Stage) noexcept {
- return static_cast<unsigned>(Stage);
+[[nodiscard]] std::uint8_t stageRank(BackendStage Stage) noexcept {
+ switch (Stage) {
+ case BackendStage::PreLegalizerMIR:
+ return 0;
+ case BackendStage::LegalizedMIR:
+ return 1;
+ case BackendStage::RegisterBankMIR:
+ return 2;
+ case BackendStage::SelectedMIR:
+ return 3;
+ case BackendStage::PostSSAMIR:
+ return 4;
+ case BackendStage::PostRegisterAllocationMIR:
+ return 5;
+ case BackendStage::FinalMIR:
+ return 6;
+ }
+ return 0;
}
[[nodiscard]] bool selectorMatches(std::string_view Selector, std::string_view Pass,
@@ -224,7 +240,7 @@ runFunction(MachineFunction &Function, mir::MIRDocument &Document, const TargetD
if (!Captured)
return std::unexpected(Captured.error());
}
- if (Controls.StopAtStage && stageOrdinal(CurrentStage) >= stageOrdinal(*Controls.StopAtStage)) {
+ if (Controls.StopAtStage && !isEarlierStage(CurrentStage, *Controls.StopAtStage)) {
return Result;
}
@@ -289,7 +305,7 @@ runFunction(MachineFunction &Function, mir::MIRDocument &Document, const TargetD
StopMatched = true;
break;
}
- if (Controls.StopAtStage && stageOrdinal(CurrentStage) >= stageOrdinal(*Controls.StopAtStage)) {
+ if (Controls.StopAtStage && !isEarlierStage(CurrentStage, *Controls.StopAtStage)) {
break;
}
}
@@ -314,6 +330,10 @@ runFunction(MachineFunction &Function, mir::MIRDocument &Document, const TargetD
} // namespace
+bool isEarlierStage(BackendStage Left, BackendStage Right) noexcept {
+ return stageRank(Left) < stageRank(Right);
+}
+
BackendStage stageForFunction(const MachineFunction &Function) noexcept {
const MachineFunctionProperties &Properties = Function.properties();
if (Properties.has(MachineFunctionProperty::Selected) &&