--- /dev/null
+#ifndef __COCO_IR_BLOCK_INDEX_H__
+#define __COCO_IR_BLOCK_INDEX_H__
+
+#include <cstdint>
+
+namespace coco
+{
+
+/**
+ * @brief A BlockIndex denotes the index of a block in a block list
+ */
+class BlockIndex final
+{
+private:
+ static const uint32_t undefined = 0xffffffff;
+
+public:
+ BlockIndex() : _value{undefined}
+ {
+ // DO NOTHING
+ }
+
+public:
+ BlockIndex(uint32_t value) { set(value); }
+
+public:
+ bool valid(void) const { return _value != undefined; }
+
+public:
+ uint32_t value(void) const { return _value; }
+
+public:
+ void set(uint32_t value);
+ void reset(void) { _value = undefined; }
+
+private:
+ uint32_t _value;
+};
+
+static inline bool operator<(const BlockIndex &lhs, const BlockIndex &rhs)
+{
+ return lhs.value() < rhs.value();
+}
+
+} // namespace coco
+
+#endif // __COCO_IR_BLOCK_INDEX_H__
--- /dev/null
+#include "coco/IR/BlockIndex.h"
+
+#include <cassert>
+
+namespace coco
+{
+
+void BlockIndex::set(uint32_t value)
+{
+ assert(value != undefined);
+ _value = value;
+}
+
+} // namespace coco
--- /dev/null
+#include "coco/IR/BlockIndex.h"
+
+#include <gtest/gtest.h>
+
+namespace
+{
+
+class BlockIndexTest : public ::testing::Test
+{
+};
+
+} // namespace
+
+TEST_F(BlockIndexTest, default_constructor)
+{
+ coco::BlockIndex blk_ind;
+
+ ASSERT_FALSE(blk_ind.valid());
+}
+
+TEST_F(BlockIndexTest, explicit_constructor)
+{
+ coco::BlockIndex blk_ind{3};
+
+ ASSERT_TRUE(blk_ind.valid());
+ ASSERT_EQ(blk_ind.value(), 3);
+}
+
+TEST_F(BlockIndexTest, operator_lt)
+{
+ // Valid index is always less than undefined one.
+ ASSERT_TRUE(coco::BlockIndex(3) < coco::BlockIndex());
+ ASSERT_TRUE(coco::BlockIndex(3) < coco::BlockIndex(4));
+}