diff options
Diffstat (limited to 'backend/lib/Target/RISCV/RISCVTarget.cpp')
| -rw-r--r-- | backend/lib/Target/RISCV/RISCVTarget.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
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 <array> #include <cassert> #include <cstddef> #include <cstdint> #include <initializer_list> #include <memory> +#include <span> #include <utility> #include <vector> @@ -93,6 +97,27 @@ Expected<TargetMIRTextInfo> createMIRTextInfo() { return TargetMIRTextInfo::create(std::move(Description), *Registers); } +Expected<TargetDescription> createTargetDescription() { + auto Registers = createRegisterInfo(); + if (!Registers) + return std::unexpected(Registers.error()); + + std::vector<InstructionDescriptor> Descriptors; + std::vector<rcc::ImmediatePredicate> 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<const RegisterMask> createCallPreservedMask() { TargetMIRTextInfoDesc Description; appendGeneratedMIRTextInfo(Description); @@ -100,4 +125,40 @@ std::shared_ptr<const RegisterMask> createCallPreservedMask() { return Description.RegisterMasks.front().Mask; } +std::span<const SchedulingClassInfo> schedulingClasses() noexcept { + return GeneratedSchedulingClasses; +} + +std::span<const EncodingCategoryInfo> encodingCategories() noexcept { + return GeneratedEncodingCategories; +} + +std::span<const AssemblyFormatInfo> assemblyFormats() noexcept { + return GeneratedAssemblyFormats; +} + +std::span<const AssemblyInstructionInfo> 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<const CallingConventionInfo> 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 |
