This commit adds 'ElemID' class to distinguish element IDs from
usual numeric values.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
--- /dev/null
+#ifndef __COCO_IR_ELEM_ID_H__
+#define __COCO_IR_ELEM_ID_H__
+
+#include <cstdint>
+
+namespace coco
+{
+
+class ElemID final
+{
+public:
+ explicit ElemID(uint32_t value) : _value{value}
+ {
+ // DO NOTHING
+ }
+
+public:
+ uint32_t value(void) const { return _value; }
+
+private:
+ uint32_t const _value;
+};
+
+} // namespace coco
+
+#endif // __COCO_IR_ELEM_ID_H__
--- /dev/null
+#include "coco/IR/ElemID.h"
+
+#include <vector>
+
+#include <gtest/gtest.h>
+
+TEST(IR_ELEM_ID, constructor)
+{
+ coco::ElemID id{128};
+
+ ASSERT_EQ(id.value(), 128);
+}
+
+TEST(IR_ELEM_ID, std_vector_compatible)
+{
+ // ElemID SHOULD be compatible with standard container (including std::vector)
+ std::vector<coco::ElemID> vec;
+
+ vec.emplace_back(coco::ElemID{128});
+
+ ASSERT_EQ(vec.at(0).value(), 128);
+}