diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-22 18:49:08 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-22 18:49:08 +0800 |
| commit | 8a4bb6e3b0bffa0ed79b51347b12ee4293b622a7 (patch) | |
| tree | 51278f18d8954e7abb5820cb9d529e3d5e5f322b /backend/lib/Tooling | |
| parent | 9ca9fb23124e8c5d714e9668210855a23dd2a72f (diff) | |
| download | rcc-project-8a4bb6e3b0bffa0ed79b51347b12ee4293b622a7.tar.gz rcc-project-8a4bb6e3b0bffa0ed79b51347b12ee4293b622a7.tar.xz | |
[CodeGen] Generate RISC-V macro fusion rules
Diffstat (limited to 'backend/lib/Tooling')
| -rw-r--r-- | backend/lib/Tooling/PipelineDriver.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/backend/lib/Tooling/PipelineDriver.cpp b/backend/lib/Tooling/PipelineDriver.cpp index 76951b6..0ba0c54 100644 --- a/backend/lib/Tooling/PipelineDriver.cpp +++ b/backend/lib/Tooling/PipelineDriver.cpp @@ -79,6 +79,24 @@ struct FunctionRunResult final { }); } +[[nodiscard]] bool hasDebugType(const BackendInvocation &Invocation, + std::string_view DebugType) noexcept { + const auto Option = std::ranges::find(Invocation.TargetOptions, std::string_view{"debug-only"}, + &BackendOption::Name); + if (Option == Invocation.TargetOptions.end()) + return false; + std::string_view Types = Option->Value; + while (!Types.empty()) { + const std::size_t Comma = Types.find(','); + if (Types.substr(0, Comma) == DebugType) + return true; + if (Comma == std::string_view::npos) + break; + Types.remove_prefix(Comma + 1U); + } + return false; +} + [[nodiscard]] std::optional<BackendStage> stageAfterPass(std::string_view Pass) noexcept { if (Pass == "legalizer") return BackendStage::LegalizedMIR; @@ -108,12 +126,14 @@ createPasses(const MachineFunction &Function, const BackendInvocation &Invocatio GlobalISelAbort = *Parsed; } MachineFunctionPassManager Pipeline(Options); + const bool DebugMachineScheduler = hasDebugType(Invocation, "machine-scheduler"); if (Invocation.PassPipeline.size() == 1 && Invocation.PassPipeline.front() == "default") { auto Added = riscv::addCanonicalPipeline( Pipeline, Function, Subtarget, riscv::RISCVPipelineOptions{.Optimization = Invocation.Optimization, .UseTargetCopyInstructions = true, - .GlobalISelAbort = GlobalISelAbort}); + .GlobalISelAbort = GlobalISelAbort, + .DebugMachineScheduler = DebugMachineScheduler}); if (!Added) return std::unexpected(Added.error()); } else { @@ -130,7 +150,8 @@ createPasses(const MachineFunction &Function, const BackendInvocation &Invocatio Name, Subtarget, riscv::RISCVPipelineOptions{.Optimization = Invocation.Optimization, .UseTargetCopyInstructions = UseTargetCopyInstructions, - .GlobalISelAbort = GlobalISelAbort}); + .GlobalISelAbort = GlobalISelAbort, + .DebugMachineScheduler = DebugMachineScheduler}); if (!Pass) return std::unexpected(Pass.error()); auto Added = Pipeline.addPass(std::move(*Pass)); |
