aboutsummaryrefslogtreecommitdiff
path: root/backend/include
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-25 03:11:23 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-25 03:11:23 +0800
commitf5d9ddc085055d28d6f9fb3730c3566097f43fb2 (patch)
treed1ca89a409a0d1a167e79e3d1693c22bcfd823a9 /backend/include
parentc3932f55208e3fe2019d26a0e5af421c0b644872 (diff)
downloadrcc-project-f5d9ddc085055d28d6f9fb3730c3566097f43fb2.tar.gz
rcc-project-f5d9ddc085055d28d6f9fb3730c3566097f43fb2.tar.xz
[CodeGen] Implement the greedy register allocator pipeline
Diffstat (limited to 'backend/include')
-rw-r--r--backend/include/rcc/CodeGen/RegAllocCommon.h3
-rw-r--r--backend/include/rcc/CodeGen/VirtRegMap.h18
2 files changed, 16 insertions, 5 deletions
diff --git a/backend/include/rcc/CodeGen/RegAllocCommon.h b/backend/include/rcc/CodeGen/RegAllocCommon.h
index ac3aa56..5994d64 100644
--- a/backend/include/rcc/CodeGen/RegAllocCommon.h
+++ b/backend/include/rcc/CodeGen/RegAllocCommon.h
@@ -19,6 +19,9 @@ struct RegisterAllocationOptions final {
[[nodiscard]] std::unique_ptr<MachineFunctionPass>
createBasicAllocatorPass(const TargetRegisterAllocationInfo &Info,
RegisterAllocationOptions Options = {});
+[[nodiscard]] std::unique_ptr<MachineFunctionPass>
+createGreedyAllocatorPass(const TargetRegisterAllocationInfo &Info,
+ RegisterAllocationOptions Options = {});
} // namespace rcc
diff --git a/backend/include/rcc/CodeGen/VirtRegMap.h b/backend/include/rcc/CodeGen/VirtRegMap.h
index 30ef450..eda71c2 100644
--- a/backend/include/rcc/CodeGen/VirtRegMap.h
+++ b/backend/include/rcc/CodeGen/VirtRegMap.h
@@ -9,6 +9,7 @@
#include <cstdint>
#include <optional>
+#include <string_view>
#include <unordered_map>
#include <vector>
@@ -75,17 +76,24 @@ private:
const TargetDescription &Target,
const VirtRegMap &Mapping);
-class VirtualRegisterRewritePass final : public MachineFunctionPass {
+class VirtRegMapAnalysis final {
public:
- explicit VirtualRegisterRewritePass(const VirtRegMap &Mapping) noexcept : Mapping(&Mapping) {}
+ using Result = VirtRegMap;
+
+ [[nodiscard]] static constexpr std::string_view name() noexcept {
+ return "VirtRegMap";
+ }
+ [[nodiscard]] static Expected<Result> run(MachineFunction &Function,
+ const TargetDescription &Target,
+ MachineFunctionAnalysisManager &Analyses);
+};
+class VirtualRegisterRewritePass final : public MachineFunctionPass {
+public:
[[nodiscard]] const MachinePassContract &contract() const noexcept override;
[[nodiscard]] Expected<MachinePassResult> run(MachineFunction &Function,
const TargetDescription &Target,
MachineFunctionAnalysisManager &Analyses) override;
-
-private:
- const VirtRegMap *Mapping;
};
} // namespace rcc