From 432efe39315ed5ad0162f9c08dbf10941bc21dc1 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Mon, 3 Aug 2026 19:24:30 +0800 Subject: [CodeGen] Add target MIR text schema --- backend/include/rcc/CodeGen/MachineFrameInfo.h | 41 +++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'backend/include/rcc/CodeGen/MachineFrameInfo.h') diff --git a/backend/include/rcc/CodeGen/MachineFrameInfo.h b/backend/include/rcc/CodeGen/MachineFrameInfo.h index b837ff3..7c42bc2 100644 --- a/backend/include/rcc/CodeGen/MachineFrameInfo.h +++ b/backend/include/rcc/CodeGen/MachineFrameInfo.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -38,46 +39,58 @@ public: return StackID(DefaultStackValue); } - [[nodiscard]] static constexpr StackID safeStack() noexcept { - return StackID(SafeStackValue); - } - - [[nodiscard]] static constexpr StackID shadowCallStack() noexcept { - return StackID(ShadowCallStackValue); + [[nodiscard]] static constexpr StackID sgprSpillStack() noexcept { + return StackID(SGPRSpillStackValue); } [[nodiscard]] static constexpr StackID scalableVectorStack() noexcept { return StackID(ScalableVectorStackValue); } - [[nodiscard]] static Expected targetStack(std::uint32_t Value); + [[nodiscard]] static constexpr StackID wasmLocalStack() noexcept { + return StackID(WasmLocalStackValue); + } + + [[nodiscard]] static constexpr StackID scalablePredicateVectorStack() noexcept { + return StackID(ScalablePredicateVectorStackValue); + } + + [[nodiscard]] static constexpr StackID noAllocStack() noexcept { + return StackID(NoAllocStackValue); + } + + [[nodiscard]] static Expected fromValue(std::uint32_t Value); [[nodiscard]] constexpr std::uint32_t value() const noexcept { return Value; } - [[nodiscard]] constexpr bool isTargetStack() const noexcept { - return Value >= FirstTargetStackValue; + [[nodiscard]] constexpr bool isSpecialStack() const noexcept { + return Value != DefaultStackValue; } [[nodiscard]] constexpr bool isValid() const noexcept { - return Value <= ScalableVectorStackValue || isTargetStack(); + return Value <= ScalablePredicateVectorStackValue || Value == NoAllocStackValue; } friend constexpr bool operator==(StackID Left, StackID Right) noexcept = default; private: static constexpr std::uint32_t DefaultStackValue = 0; - static constexpr std::uint32_t SafeStackValue = 1; - static constexpr std::uint32_t ShadowCallStackValue = 2; - static constexpr std::uint32_t ScalableVectorStackValue = 3; - static constexpr std::uint32_t FirstTargetStackValue = 256; + static constexpr std::uint32_t SGPRSpillStackValue = 1; + static constexpr std::uint32_t ScalableVectorStackValue = 2; + static constexpr std::uint32_t WasmLocalStackValue = 3; + static constexpr std::uint32_t ScalablePredicateVectorStackValue = 4; + static constexpr std::uint32_t NoAllocStackValue = 255; explicit constexpr StackID(std::uint32_t Value) noexcept : Value(Value) {} std::uint32_t Value = DefaultStackValue; }; +[[nodiscard]] std::optional parseStackIDName(std::string_view Name) noexcept; +[[nodiscard]] std::string_view getStackIDName(StackID ID) noexcept; + struct StackObjectLifetimeRange final { MachineInstrStableID Begin; MachineInstrStableID End; -- cgit v1.2.3