#pragma once #include "prelude/string.hpp" #include "ir/value.hpp" namespace IR { enum class OpType { EXTERN = 0, FN, ALLOCATE, LOAD, STORE, ADD, SUB, MUL, DIV, CALL, COUNT_OPS, }; #define OP_TYPE(x) \ OpType GetType() const override { return OpType::x; } class Op { public: virtual OpType GetType() const = 0; virtual bool Valued() const { return false; }; virtual ~Op() {} virtual StringView Format(int indent) const = 0; }; using OpView = View; using OpBuilder = Builder; class OpValued : public Op { public: OpValued(ValueHandle *dest) : m_dest(dest) {} ~OpValued() = default; public: ValueHandle *result() const { return m_dest; } protected: bool Valued() const override { return true; } private: ValueHandle *m_dest; }; } // namespace IR