feat: introduced blocks and better project structure

This commit is contained in:
2025-12-24 20:13:13 +01:00
parent e8a496d070
commit 7f73b742c2
9 changed files with 525 additions and 453 deletions

50
include/ir/op.hpp Normal file
View File

@@ -0,0 +1,50 @@
#pragma once
#include "prelude/string.hpp"
#include "ir/value.hpp"
namespace IR
{
enum class OpType
{
EXTERN = 0,
FN,
LOAD_CONST,
LOAD,
STORE,
ADD,
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<Op*>;
using OpBuilder = Builder<Op*>;
class OpValued : public Op
{
public:
OpValued(Value dest)
: m_dest(dest) {}
~OpValued() = default;
public:
Value result() const { return m_dest; }
protected:
bool Valued() const override { return true; }
private:
Value m_dest;
};
} // namespace IR