From 0bb35fa2306a66f1f0baf118619b5c1640ed9c01 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 12 Aug 2026 21:56:37 +0800 Subject: [GlobalISel] Split the generic pipeline components --- backend/include/rcc/CodeGen/GlobalISel/Legalizer.h | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 backend/include/rcc/CodeGen/GlobalISel/Legalizer.h (limited to 'backend/include/rcc/CodeGen/GlobalISel/Legalizer.h') diff --git a/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h b/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h new file mode 100644 index 0000000..7f86d16 --- /dev/null +++ b/backend/include/rcc/CodeGen/GlobalISel/Legalizer.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_CODEGEN_GLOBALISEL_LEGALIZER_H +#define RCC_CODEGEN_GLOBALISEL_LEGALIZER_H + +#include "rcc/CodeGen/GlobalISel/LegalizerInfo.h" +#include "rcc/CodeGen/MachinePass.h" + +#include + +namespace rcc { + +class Legalizer final : public MachineFunctionPass { +public: + explicit Legalizer(const LegalizerInfo *Info) : Info(Info) {} + explicit Legalizer(const LegalizerInfo &Info) : Info(&Info) {} + explicit Legalizer(std::unique_ptr Info) + : OwnedInfo(std::move(Info)), Info(OwnedInfo.get()) {} + + [[nodiscard]] const MachinePassContract &contract() const noexcept override; + [[nodiscard]] Expected run(MachineFunction &Function, + const TargetDescription &Target, + MachineAnalysisManager &Analyses) override; + +private: + [[nodiscard]] Expected runImplementation(MachineFunction &Function, + const TargetDescription &Target, + MachineActionReplay &Actions); + + std::unique_ptr OwnedInfo; + const LegalizerInfo *Info = nullptr; +}; + +} // namespace rcc + +#endif // RCC_CODEGEN_GLOBALISEL_LEGALIZER_H -- cgit v1.2.3