Added RISC-V IsaDescriptor class, and adjusted RISC-V GPR count depending on ISA base.

This commit is contained in:
Nav
2024-11-29 01:06:44 +00:00
parent cde5d83599
commit 49cf2e5e9a
7 changed files with 398 additions and 2 deletions

View File

@@ -21,11 +21,13 @@ namespace Targets::RiscV
)
: targetConfig(RiscVTargetConfig{targetConfig})
, targetDescriptionFile(targetDescriptionFile)
, isaDescriptor(this->targetDescriptionFile.getIsaDescriptor())
, cpuRegisterAddressSpaceDescriptor(RiscV::generateCpuRegisterAddressSpaceDescriptor())
, csrMemorySegmentDescriptor(this->cpuRegisterAddressSpaceDescriptor.getMemorySegmentDescriptor("cs_registers"))
, gprMemorySegmentDescriptor(this->cpuRegisterAddressSpaceDescriptor.getMemorySegmentDescriptor("gp_registers"))
, cpuPeripheralDescriptor(
RiscV::generateCpuPeripheralDescriptor(
this->isaDescriptor,
this->cpuRegisterAddressSpaceDescriptor,
this->csrMemorySegmentDescriptor,
this->gprMemorySegmentDescriptor
@@ -401,6 +403,7 @@ namespace Targets::RiscV
}
TargetPeripheralDescriptor RiscV::generateCpuPeripheralDescriptor(
const IsaDescriptor& isaDescriptor,
const TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const TargetMemorySegmentDescriptor& csrMemorySegmentDescriptor,
const TargetMemorySegmentDescriptor& gprMemorySegmentDescriptor
@@ -427,7 +430,7 @@ namespace Targets::RiscV
}
).first->second;
for (auto i = std::uint8_t{0}; i <= 31; ++i) {
for (auto i = std::uint8_t{0}; i <= static_cast<std::uint8_t>(isaDescriptor.isReduced() ? 15 : 31); ++i) {
const auto key = "x" + std::to_string(i);
gprGroup.registerDescriptorsByKey.emplace(
key,