// SPDX-License-Identifier: GPL-3.0-or-later #ifndef RCC_TOOLING_PIPELINEDRIVER_H #define RCC_TOOLING_PIPELINEDRIVER_H #include "rcc/CodeGen/MIRParser/MIRParser.h" #include "rcc/CodeGen/MachinePassManager.h" #include "rcc/Tooling/BackendInvocation.h" #include #include #include #include #include namespace rcc { class TargetDescription; namespace tooling { enum class BackendStage : std::uint8_t { PreLegalizerMIR, LegalizedMIR, RegisterBankMIR, SelectedMIR, PostSSAMIR, PostRegisterAllocationMIR, FinalMIR, }; enum class SnapshotPhase : std::uint8_t { Stage, BeforePass, AfterPass, }; struct PipelineControls final { std::optional StartBefore; std::optional StartAfter; std::optional StopBefore; std::optional StopAfter; std::vector PrintBefore; std::vector PrintAfter; std::optional StopAtStage; bool CaptureStageSnapshots = false; bool VerifyEach = true; bool DetectUnreportedChanges = true; bool SimplifyMIR = false; }; struct PipelineSnapshot final { SnapshotPhase Phase = SnapshotPhase::Stage; BackendStage Stage = BackendStage::PreLegalizerMIR; std::string Function; std::string Pass; std::uint32_t Occurrence = 0; std::string MIR; }; struct ExecutedPass final { std::string Function; std::string Pass; std::uint32_t Occurrence = 0; friend bool operator==(const ExecutedPass &, const ExecutedPass &) = default; }; struct PipelineRunResult final { std::vector ExecutedPasses; std::vector Snapshots; }; [[nodiscard]] Expected verifyRV64GCInvocation(const BackendInvocation &Invocation); [[nodiscard]] Expected runRV64GCPipeline(mir::MIRDocument &Document, const TargetDescription &Target, const BackendInvocation &Invocation, PipelineControls Controls = {}, MachinePassInstrumentation *Instrumentation = nullptr); [[nodiscard]] BackendStage stageForFunction(const MachineFunction &Function) noexcept; [[nodiscard]] std::string_view spelling(BackendStage Stage) noexcept; [[nodiscard]] Expected parseBackendStage(std::string_view Value); } // namespace tooling } // namespace rcc #endif // RCC_TOOLING_PIPELINEDRIVER_H