#pragma once #include "prelude/string.hpp" namespace IR { struct IRSlot { enum class Type { UNKNOWN = 0, STACK, REGISTRY, }; public: IRSlot(StringView addr, unsigned int slot, Type slotType) : m_addr(addr), m_slot(slot), m_slotType(slotType) {} IRSlot() = default; public: Type GetType() const { return m_slotType; } const StringView& GetAddr() const { return m_addr; } unsigned int GetSlot() const { return m_slot; } public: StringView Format() const { StringBuilder sb; switch(GetType()) { case Type::REGISTRY: sb << "r" << GetSlot(); break; case Type::STACK: sb << "s[" << GetSlot() << "]"; break; default: sb << "(UNKNOWN_SLOT_TYPE)"; break; } return sb.view(); } private: StringView m_addr; unsigned int m_slot; Type m_slotType; }; using IRSlotBuilder = Builder; using IRSlotView = View; } // namespace IR