diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 13:23:48 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-09 13:23:48 +0800 |
| commit | da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7 (patch) | |
| tree | 3b64eb08cd6376deceef2d7bac20eea5ce4de184 /backend/lib/CodeGen/RegAllocFast.cpp | |
| parent | e5fdceb9b869f010a2a75638fd38aaf1867f3008 (diff) | |
| download | rcc-project-da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7.tar.gz rcc-project-da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7.tar.xz | |
[CodeGen] Implement RV64GC frame lowering
Diffstat (limited to 'backend/lib/CodeGen/RegAllocFast.cpp')
| -rw-r--r-- | backend/lib/CodeGen/RegAllocFast.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/backend/lib/CodeGen/RegAllocFast.cpp b/backend/lib/CodeGen/RegAllocFast.cpp index 9b087cc..897f217 100644 --- a/backend/lib/CodeGen/RegAllocFast.cpp +++ b/backend/lib/CodeGen/RegAllocFast.cpp @@ -266,7 +266,7 @@ private: return std::unexpected(Evicted.error()); } - auto Candidates = regalloc_detail::allocationOrder(Function, Target, Reg); + auto Candidates = regalloc_detail::allocationOrder(Function, Target, TargetInfo, Reg); if (!Candidates) return std::unexpected(Candidates.error()); for (const PhysicalRegister Candidate : *Candidates) { @@ -319,7 +319,7 @@ private: const Register Reg = *LiveIn.InitialVirtualRegister; if (!Function.registerInfo().isKnownVirtualRegister(Reg)) continue; - auto Candidates = regalloc_detail::allocationOrder(Function, Target, Reg); + auto Candidates = regalloc_detail::allocationOrder(Function, Target, TargetInfo, Reg); if (!Candidates) return std::unexpected(Candidates.error()); if (std::ranges::find(*Candidates, LiveIn.PhysReg) == Candidates->end()) { @@ -577,6 +577,12 @@ Expected<MachinePassResult> FastAllocatorPass::run(MachineFunction &Function, auto Trial = regalloc_detail::cloneForAllocation(Function, Target); if (!Trial) return std::unexpected(Trial.error()); + const std::vector<PhysicalRegister> FunctionReserved = + regalloc_detail::functionReservedRegisters(Function, Target, *Info); + auto TrialReserved = + regalloc_detail::reserveFunctionRegisters(*Trial->ClonedFunction, FunctionReserved); + if (!TrialReserved) + return std::unexpected(TrialReserved.error()); MachineAnalysisManager TrialAnalyses; auto Registered = registerStage11MachineAnalyses(TrialAnalyses); if (!Registered) @@ -602,6 +608,10 @@ Expected<MachinePassResult> FastAllocatorPass::run(MachineFunction &Function, return std::unexpected(regalloc_detail::withPrefix( Allocated.error(), "FastAllocator diverged after a successful transaction preflight: ")); } + auto Reserved = regalloc_detail::reserveFunctionRegisters(Function, FunctionReserved); + if (!Reserved) + return std::unexpected(Reserved.error()); + Allocated->Changed |= *Reserved; return regalloc_detail::passResult(*Allocated); } |
