From 4fe5ee649927d54d6fb74904d7b97ad0f63fd587 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Tue, 11 Aug 2026 17:38:11 +0800 Subject: [RISCV] Legalize fixed-baseline RV64 MachineIR --- .../include/rcc/Target/RISCV/RISCVFunctionInfo.h | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 backend/include/rcc/Target/RISCV/RISCVFunctionInfo.h (limited to 'backend/include/rcc/Target/RISCV') diff --git a/backend/include/rcc/Target/RISCV/RISCVFunctionInfo.h b/backend/include/rcc/Target/RISCV/RISCVFunctionInfo.h new file mode 100644 index 0000000..2720830 --- /dev/null +++ b/backend/include/rcc/Target/RISCV/RISCVFunctionInfo.h @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_TARGET_RISCV_RISCVFUNCTIONINFO_H +#define RCC_TARGET_RISCV_RISCVFUNCTIONINFO_H + +#include "rcc/CodeGen/TargetFunctionState.h" + +#include +#include +#include +#include +#include + +namespace rcc { + +struct TargetMIRTextInfoDesc; + +namespace riscv { + +class RISCVFunctionInfo final { +public: + RISCVFunctionInfo(std::int32_t VarArgsFrameIndex = 0, + std::int32_t VarArgsSaveSize = 0) noexcept + : VarArgsFrameIndex(VarArgsFrameIndex), VarArgsSaveSize(VarArgsSaveSize) {} + + [[nodiscard]] static constexpr TargetFunctionStateTypeID stableTypeID() noexcept { + return TargetFunctionStateTypeID::fromValue(0x5243435256460001ULL); + } + + [[nodiscard]] static constexpr std::uint32_t schemaVersion() noexcept { + return 1; + } + + [[nodiscard]] Expected verify() const; + [[nodiscard]] Expected + clone(const MachineFunctionCloneContext &Context) const; + [[nodiscard]] std::string print() const; + [[nodiscard]] Expected> encode() const; + [[nodiscard]] static Expected + decode(std::uint32_t Version, std::span Payload); + + [[nodiscard]] std::int32_t varArgsFrameIndex() const noexcept { + return VarArgsFrameIndex; + } + + [[nodiscard]] std::int32_t varArgsSaveSize() const noexcept { + return VarArgsSaveSize; + } + + friend bool operator==(const RISCVFunctionInfo &Left, + const RISCVFunctionInfo &Right) = default; + +private: + std::int32_t VarArgsFrameIndex = 0; + std::int32_t VarArgsSaveSize = 0; +}; + +void configureFunctionInfoMIRSchema(TargetMIRTextInfoDesc &Description); + +} // namespace riscv +} // namespace rcc + +#endif // RCC_TARGET_RISCV_RISCVFUNCTIONINFO_H -- cgit v1.2.3