Files
2026-01-06 16:39:51 +01:00

35 lines
708 B
C++

#pragma once
#include "ir/op.hpp"
#include "prelude/linkedlist.hpp"
namespace IR
{
using BlockID = unsigned int;
class Block
{
public:
Block(BlockID id, DoubleLinkedList<Op*> ops)
: m_id(id), m_ops(ops) {}
public:
DoubleLinkedList<Op*>& ops() { return m_ops; }
public:
StringView Format(int indent) const
{
StringBuilder sb;
sb.AppendIndent(indent);
sb.AppendFormat("b%d:\n", m_id);
for (ListNode<Op*>* cur = m_ops.Begin(); cur != nullptr; cur = cur->next)
{
sb << cur->value->Format(indent + 2) << '\n';
}
return sb.view();
}
private:
BlockID m_id;
DoubleLinkedList<Op*> m_ops;
};
} // namespace IR