aboutsummaryrefslogtreecommitdiff
path: root/backend/include/rcc/CodeGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-07 02:15:09 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-07 02:15:09 +0800
commite16de95dce32f077361577377d5c52fc4ad78339 (patch)
treeea563652a95e6e32eb86ce68845a2005d83a85d5 /backend/include/rcc/CodeGen
parent76d89700953ddd81cf31ab8f260eddf67e93aa85 (diff)
downloadrcc-project-e16de95dce32f077361577377d5c52fc4ad78339.tar.gz
rcc-project-e16de95dce32f077361577377d5c52fc4ad78339.tar.xz
[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.
Diffstat (limited to 'backend/include/rcc/CodeGen')
-rw-r--r--backend/include/rcc/CodeGen/TargetRegisterInfo.h7
1 files changed, 7 insertions, 0 deletions
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<RegisterUnitLane> Units;
bool IsConstant = false;
bool IsArtificial = false;
+ bool IsReserved = false;
+ std::vector<std::string> 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<RegisterUnitID, std::size_t> UnitToIndex;
std::unordered_map<PhysicalRegister, std::size_t> RegisterToIndex;
std::unordered_map<std::string, std::size_t> RegisterNameToIndex;
+ std::unordered_map<std::string, std::size_t> AlternativeRegisterNameToIndex;
std::unordered_map<SubRegIndex, std::size_t> SubRegIndexToIndex;
std::unordered_map<std::string, std::size_t> SubRegNameToIndex;
std::unordered_map<RegisterClassID, std::size_t> ClassToIndex;