aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen/MachineCopyPropagation.h
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 17:03:19 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 17:03:19 +0800
commit495c675771f43cfa12ab7a426a538be72fec1805 (patch)
tree4107223d6c6ef2e74d56064aa21b196307502342 /backend/include/rcc/CodeGen/MachineCopyPropagation.h
parentda8bc76b4bf7d1a7b025d6c8ef5809551467dcc7 (diff)
downloadrcc-project-495c675771f43cfa12ab7a426a538be72fec1805.tar.gz
rcc-project-495c675771f43cfa12ab7a426a538be72fec1805.tar.xz
[CodeGen] Implement machine optimization and scheduling
Diffstat (limited to 'backend/include/rcc/CodeGen/MachineCopyPropagation.h')
-rw-r--r--backend/include/rcc/CodeGen/MachineCopyPropagation.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/backend/include/rcc/CodeGen/MachineCopyPropagation.h b/backend/include/rcc/CodeGen/MachineCopyPropagation.h
new file mode 100644
index 0000000..5f84ac6
--- /dev/null
+++ b/backend/include/rcc/CodeGen/MachineCopyPropagation.h
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef RCC_CODEGEN_MACHINECOPYPROPAGATION_H
+#define RCC_CODEGEN_MACHINECOPYPROPAGATION_H
+
+#include "rcc/CodeGen/MachinePass.h"
+
+#include <cstddef>
+#include <cstdint>
+
+namespace rcc {
+
+class TargetSSAInfo;
+
+enum class MachineCopyPropagationStage : std::uint8_t {
+ PreRegisterAllocation,
+ PostRegisterAllocation,
+};
+
+struct MachineCopyPropagationOptions final {
+ std::size_t MaximumPropagatedCopies = 10'000;
+};
+
+class MachineCopyPropagationPass final : public MachineFunctionPass {
+public:
+ MachineCopyPropagationPass(const TargetSSAInfo &Info, MachineCopyPropagationStage Stage,
+ MachineCopyPropagationOptions Options = {}) noexcept
+ : Info(&Info), Stage(Stage), Options(Options) {}
+
+ [[nodiscard]] const MachinePassContract &contract() const noexcept override;
+ [[nodiscard]] Expected<MachinePassResult> run(MachineFunction &Function,
+ const TargetDescription &Target,
+ MachineAnalysisManager &Analyses) override;
+
+private:
+ [[nodiscard]] Expected<MachinePassResult>
+ runImplementation(MachineFunction &Function, const TargetDescription &Target) const;
+
+ const TargetSSAInfo *Info;
+ MachineCopyPropagationStage Stage;
+ MachineCopyPropagationOptions Options;
+};
+
+} // namespace rcc
+
+#endif // RCC_CODEGEN_MACHINECOPYPROPAGATION_H