diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-11 17:38:11 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-11 17:38:11 +0800 |
| commit | 4fe5ee649927d54d6fb74904d7b97ad0f63fd587 (patch) | |
| tree | 75f85f5e6cae3a871fe42d025dca04eeb7c31cfd /backend/include/rcc/Target/RISCV | |
| parent | 6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0 (diff) | |
| download | rcc-project-4fe5ee649927d54d6fb74904d7b97ad0f63fd587.tar.gz rcc-project-4fe5ee649927d54d6fb74904d7b97ad0f63fd587.tar.xz | |
[RISCV] Legalize fixed-baseline RV64 MachineIR
Diffstat (limited to 'backend/include/rcc/Target/RISCV')
| -rw-r--r-- | backend/include/rcc/Target/RISCV/RISCVFunctionInfo.h | 63 |
1 files changed, 63 insertions, 0 deletions
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 <cstddef> +#include <cstdint> +#include <span> +#include <string> +#include <vector> + +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<void> verify() const; + [[nodiscard]] Expected<RISCVFunctionInfo> + clone(const MachineFunctionCloneContext &Context) const; + [[nodiscard]] std::string print() const; + [[nodiscard]] Expected<std::vector<std::byte>> encode() const; + [[nodiscard]] static Expected<RISCVFunctionInfo> + decode(std::uint32_t Version, std::span<const std::byte> 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 |
