// SPDX-License-Identifier: GPL-3.0-or-later // The private header has no stable include-root-relative guard name. // NOLINTNEXTLINE(llvm-header-guard) #ifndef RCC_LIB_CODEGEN_REGALLOCBASE_H #define RCC_LIB_CODEGEN_REGALLOCBASE_H #include "RegAllocInternal.h" #include "rcc/CodeGen/MachineLiveness.h" #include "rcc/CodeGen/RegAllocCommon.h" #include "rcc/CodeGen/TargetRegisterAllocationInfo.h" #include "rcc/CodeGen/VirtRegMap.h" #include namespace rcc { struct AllocationRoundResult final { std::vector Spilled; }; class RegAllocBase { public: virtual ~RegAllocBase() = default; [[nodiscard]] Expected run(); protected: RegAllocBase(MachineFunction &Function, const TargetDescription &Target, const TargetRegisterAllocationInfo &TargetInfo, MachineAnalysisManager &Analyses, RegisterAllocationOptions Options, MachineActionReplay *Actions = nullptr) noexcept : Function(Function), Target(Target), TargetInfo(TargetInfo), Analyses(Analyses), Options(Options), Actions(Actions) {} [[nodiscard]] virtual Expected allocateRound(const LiveIntervalsAnalysis::Result &Intervals, VirtRegMap &Mapping) = 0; MachineFunction &Function; const TargetDescription &Target; const TargetRegisterAllocationInfo &TargetInfo; MachineAnalysisManager &Analyses; RegisterAllocationOptions Options; MachineActionReplay *Actions = nullptr; }; [[nodiscard]] std::vector orderedAllocationIntervals(const LiveIntervalsAnalysis::Result &Intervals, const MachineFunction &Function); } // namespace rcc #endif // RCC_LIB_CODEGEN_REGALLOCBASE_H