From 495c675771f43cfa12ab7a426a538be72fec1805 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 9 Aug 2026 17:03:19 +0800 Subject: [CodeGen] Implement machine optimization and scheduling --- .../include/rcc/CodeGen/MachineShrinkWrapping.h | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 backend/include/rcc/CodeGen/MachineShrinkWrapping.h (limited to 'backend/include/rcc/CodeGen/MachineShrinkWrapping.h') diff --git a/backend/include/rcc/CodeGen/MachineShrinkWrapping.h b/backend/include/rcc/CodeGen/MachineShrinkWrapping.h new file mode 100644 index 0000000..ec295cd --- /dev/null +++ b/backend/include/rcc/CodeGen/MachineShrinkWrapping.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_CODEGEN_MACHINESHRINKWRAPPING_H +#define RCC_CODEGEN_MACHINESHRINKWRAPPING_H + +#include "rcc/CodeGen/MachinePass.h" + +#include + +namespace rcc { + +class TargetFrameLowering; + +struct MachineShrinkWrappingOptions final { + std::size_t MaximumAnalyzedBlocks = 10'000; +}; + +class MachineShrinkWrappingPass final : public MachineFunctionPass { +public: + explicit MachineShrinkWrappingPass(const TargetFrameLowering &Info, + MachineShrinkWrappingOptions Options = {}) noexcept + : Info(&Info), Options(Options) {} + + [[nodiscard]] const MachinePassContract &contract() const noexcept override; + [[nodiscard]] Expected run(MachineFunction &Function, + const TargetDescription &Target, + MachineAnalysisManager &Analyses) override; + +private: + const TargetFrameLowering *Info; + MachineShrinkWrappingOptions Options; +}; + +} // namespace rcc + +#endif // RCC_CODEGEN_MACHINESHRINKWRAPPING_H -- cgit v1.2.3