Files
pl/include/ir/block.hpp

36 lines
639 B
C++

#pragma once
#include "ir/op.hpp"
namespace IR
{
using OpView = View<Op*>;
using BlockID = unsigned int;
class Block
{
public:
Block(BlockID id, OpView&& ops)
: m_id(id), m_ops(ops) {}
public:
const OpView& ops() const { return m_ops; }
public:
StringView Format(int indent) const
{
StringBuilder sb;
sb.AppendIndent(indent);
sb.AppendFormat("b%d:\n", m_id);
for (size_t i = 0; i < m_ops.size; ++i)
{
sb << m_ops.data[i]->Format(indent + 2) << '\n';
}
return sb.view();
}
private:
BlockID m_id;
OpView m_ops;
};
} // namespace IR