// SPDX-License-Identifier: GPL-3.0-or-later #ifndef RCC_LIB_TARGET_RISCV_RISCVCALLINGCONV_H #define RCC_LIB_TARGET_RISCV_RISCVCALLINGCONV_H #include "rcc/CodeGen/TargetCallLowering.h" #include "rcc/Target/RISCV/RISCVInstructions.h" #include #include #include #include #include namespace rcc::riscv { struct CallingConventionInfo; inline constexpr std::uint64_t XLenBytes = 8; inline constexpr std::uint64_t ABIStackAlignmentBytes = 16; [[nodiscard]] constexpr CallingConventionID callingConventionID(CallingConvention Convention) noexcept { return CallingConventionID::fromValue(static_cast(Convention)); } struct ArgumentAssignmentResult final { std::vector Assignments; StackArgumentArea StackArea; std::size_t FirstUnallocatedGPR = 0; }; [[nodiscard]] Expected verifyValueSequence(std::span Values, bool RequireRegisters); [[nodiscard]] Expected assignArguments(std::span Values, std::size_t FixedArgumentCount, bool IsVariadic, const CallingConventionInfo &Convention); [[nodiscard]] Expected> assignReturns(std::span Values, bool RequireRegisters, const CallingConventionInfo &Convention); [[nodiscard]] bool hasStructReturn(std::span Arguments) noexcept; [[nodiscard]] Expected tailCallRejection(const CallLoweringRequest &Request, const ArgumentAssignmentResult &Arguments, std::span Results, std::span ByValCopies, const CallingConventionInfo &Convention); [[nodiscard]] Expected riscvConvention(CallingConventionID Convention); } // namespace rcc::riscv #endif // RCC_LIB_TARGET_RISCV_RISCVCALLINGCONV_H