From e16de95dce32f077361577377d5c52fc4ad78339 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Fri, 7 Aug 2026 02:15:09 +0800 Subject: [RISCV] Add generated RV64GC register description Add an RCC-owned build-time target description generator and the initial RV64GC register model. Keep ABI aliases separate from canonical MIR register spelling. --- backend/include/rcc/CodeGen/TargetRegisterInfo.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'backend/include/rcc/CodeGen') diff --git a/backend/include/rcc/CodeGen/TargetRegisterInfo.h b/backend/include/rcc/CodeGen/TargetRegisterInfo.h index 9357eb2..ed33263 100644 --- a/backend/include/rcc/CodeGen/TargetRegisterInfo.h +++ b/backend/include/rcc/CodeGen/TargetRegisterInfo.h @@ -38,6 +38,8 @@ struct PhysicalRegisterDesc final { std::vector Units; bool IsConstant = false; bool IsArtificial = false; + bool IsReserved = false; + std::vector AlternativeNames; }; struct SubRegIndexDesc final { @@ -128,6 +130,8 @@ public: [[nodiscard]] const RegisterUnitDesc *registerUnit(RegisterUnitID ID) const noexcept; [[nodiscard]] const PhysicalRegisterDesc *physicalRegister(PhysicalRegister Reg) const noexcept; [[nodiscard]] const PhysicalRegisterDesc *physicalRegister(std::string_view Name) const noexcept; + [[nodiscard]] const PhysicalRegisterDesc * + physicalRegisterByAlternativeName(std::string_view Name) const noexcept; [[nodiscard]] const SubRegIndexDesc *subRegIndex(SubRegIndex Index) const noexcept; [[nodiscard]] const SubRegIndexDesc *subRegIndex(std::string_view Name) const noexcept; [[nodiscard]] const RegisterClassDesc *registerClass(RegisterClassID ID) const noexcept; @@ -146,6 +150,8 @@ public: return physicalRegister(Reg) != nullptr; } + [[nodiscard]] bool isReservedRegister(PhysicalRegister Reg) const noexcept; + [[nodiscard]] LaneMask registerLaneMask(PhysicalRegister Reg) const noexcept; [[nodiscard]] bool isValidLaneMask(PhysicalRegister Reg, LaneMask Lanes) const noexcept; [[nodiscard]] bool regsOverlap(PhysicalRegister Left, PhysicalRegister Right) const noexcept; @@ -186,6 +192,7 @@ private: std::unordered_map UnitToIndex; std::unordered_map RegisterToIndex; std::unordered_map RegisterNameToIndex; + std::unordered_map AlternativeRegisterNameToIndex; std::unordered_map SubRegIndexToIndex; std::unordered_map SubRegNameToIndex; std::unordered_map ClassToIndex; -- cgit v1.2.3