diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-07 02:15:09 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-07 02:15:09 +0800 |
| commit | e16de95dce32f077361577377d5c52fc4ad78339 (patch) | |
| tree | ea563652a95e6e32eb86ce68845a2005d83a85d5 /backend/include/rcc | |
| parent | 76d89700953ddd81cf31ab8f260eddf67e93aa85 (diff) | |
| download | rcc-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')
| -rw-r--r-- | backend/include/rcc/CodeGen/TargetRegisterInfo.h | 7 | ||||
| -rw-r--r-- | backend/include/rcc/Target/RISCV/RISCVTarget.h | 23 |
2 files changed, 30 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; diff --git a/backend/include/rcc/Target/RISCV/RISCVTarget.h b/backend/include/rcc/Target/RISCV/RISCVTarget.h new file mode 100644 index 0000000..948e22d --- /dev/null +++ b/backend/include/rcc/Target/RISCV/RISCVTarget.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_TARGET_RISCV_RISCVTARGET_H +#define RCC_TARGET_RISCV_RISCVTARGET_H + +#include "rcc/CodeGen/TargetMIRTextInfo.h" +#include "rcc/CodeGen/TargetRegisterInfo.h" +#include "rcc/Support/Error.h" +#include "rcc/Target/RISCV/RISCVRegisters.h" + +#include <cstdint> +#include <memory> + +namespace rcc::riscv { + +[[nodiscard]] Expected<PhysicalRegister> physicalRegister(PhysicalRegisterID ID); +[[nodiscard]] Expected<TargetRegisterInfo> createRegisterInfo(); +[[nodiscard]] Expected<TargetMIRTextInfo> createMIRTextInfo(); +[[nodiscard]] std::shared_ptr<const RegisterMask> createCallPreservedMask(); + +} // namespace rcc::riscv + +#endif // RCC_TARGET_RISCV_RISCVTARGET_H |
