From 3e15bfd7b075209ec3b65d30d0611e060f6fbb77 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Fri, 7 Aug 2026 22:03:11 +0800 Subject: [RISCV] Complete RV64GC instruction description --- backend/lib/Target/RISCV/RISCVTarget.cpp | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'backend/lib/Target/RISCV/RISCVTarget.cpp') diff --git a/backend/lib/Target/RISCV/RISCVTarget.cpp b/backend/lib/Target/RISCV/RISCVTarget.cpp index bbad827..8b3741a 100644 --- a/backend/lib/Target/RISCV/RISCVTarget.cpp +++ b/backend/lib/Target/RISCV/RISCVTarget.cpp @@ -2,11 +2,15 @@ #include "rcc/Target/RISCV/RISCVTarget.h" +#include "rcc/CodeGen/GenericOpcodes.h" + +#include #include #include #include #include #include +#include #include #include @@ -93,6 +97,27 @@ Expected createMIRTextInfo() { return TargetMIRTextInfo::create(std::move(Description), *Registers); } +Expected createTargetDescription() { + auto Registers = createRegisterInfo(); + if (!Registers) + return std::unexpected(Registers.error()); + + std::vector Descriptors; + std::vector Predicates; + appendGeneratedInstructionInfo(Descriptors, Predicates); + auto GenericInfo = appendGenericInstructionInfo(Descriptors, Predicates); + if (!GenericInfo) + return std::unexpected(GenericInfo.error()); + auto Instructions = InstructionSet::create(std::move(Descriptors), std::move(Predicates)); + if (!Instructions) + return std::unexpected(Instructions.error()); + + TargetMIRTextInfoDesc MIRText; + appendGeneratedMIRTextInfo(MIRText); + return TargetDescription::create(std::move(*Instructions), std::move(*Registers), + std::move(MIRText)); +} + std::shared_ptr createCallPreservedMask() { TargetMIRTextInfoDesc Description; appendGeneratedMIRTextInfo(Description); @@ -100,4 +125,40 @@ std::shared_ptr createCallPreservedMask() { return Description.RegisterMasks.front().Mask; } +std::span schedulingClasses() noexcept { + return GeneratedSchedulingClasses; +} + +std::span encodingCategories() noexcept { + return GeneratedEncodingCategories; +} + +std::span assemblyFormats() noexcept { + return GeneratedAssemblyFormats; +} + +std::span assemblyInstructions() noexcept { + return GeneratedAssemblyInstructions; +} + +const AssemblyInstructionInfo *assemblyInstruction(Opcode InstructionOpcode) noexcept { + for (const AssemblyInstructionInfo &Info : GeneratedAssemblyInstructions) { + if (Info.InstructionOpcode == InstructionOpcode) + return &Info; + } + return nullptr; +} + +std::span callingConventions() noexcept { + return GeneratedCallingConventions; +} + +const CallingConventionInfo *callingConvention(CallingConvention ID) noexcept { + for (const CallingConventionInfo &Info : GeneratedCallingConventions) { + if (Info.ID == ID) + return &Info; + } + return nullptr; +} + } // namespace rcc::riscv -- cgit v1.2.3