From e0e615d9da454c2b235a4b3acc0a60d27daa13ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 24 Jul 2018 09:47:28 +0900 Subject: [PATCH] [coco] BlockList in Module (#769) This commit revises Module interface to provide the head of a doubly linked Block list. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Module.h | 5 +++++ contrib/coco/core/src/IR/Module.cpp | 9 +++++++++ contrib/coco/core/src/IR/Module.test.cpp | 3 +++ 3 files changed, 17 insertions(+) diff --git a/contrib/coco/core/include/coco/IR/Module.h b/contrib/coco/core/include/coco/IR/Module.h index 980a0f6..5240e60 100644 --- a/contrib/coco/core/include/coco/IR/Module.h +++ b/contrib/coco/core/include/coco/IR/Module.h @@ -2,6 +2,7 @@ #define __COCO_IR_MODULE_H__ #include "coco/IR/EntityManager.h" +#include "coco/IR/Block.h" #include "coco/IR/InputList.h" #include @@ -29,6 +30,10 @@ public: virtual const EntityManager *entity(void) const = 0; public: + virtual BlockList *block(void) = 0; + virtual const BlockList *block(void) const = 0; + +public: virtual InputList *input(void) = 0; virtual const InputList *input(void) const = 0; diff --git a/contrib/coco/core/src/IR/Module.cpp b/contrib/coco/core/src/IR/Module.cpp index d042749..2c96c56 100644 --- a/contrib/coco/core/src/IR/Module.cpp +++ b/contrib/coco/core/src/IR/Module.cpp @@ -48,6 +48,13 @@ public: const coco::EntityManager *entity(void) const override { return _entity.get(); } public: + std::unique_ptr _block; + +public: + coco::BlockList *block(void) override { return _block.get(); } + const coco::BlockList *block(void) const override { return _block.get(); } + +public: std::unique_ptr _input; public: @@ -75,6 +82,8 @@ std::unique_ptr Module::create(void) } m->_entity = std::move(mgr); + // NOTE BlockManager and BlockList SHOULD share 'blk_link' + m->_block = nncc::foundation::make_unique(m.get(), blk_link.get()); m->_input = nncc::foundation::make_unique(); m->_instr_link = std::move(ins_link); diff --git a/contrib/coco/core/src/IR/Module.test.cpp b/contrib/coco/core/src/IR/Module.test.cpp index 4650292..c5eb505 100644 --- a/contrib/coco/core/src/IR/Module.test.cpp +++ b/contrib/coco/core/src/IR/Module.test.cpp @@ -23,6 +23,9 @@ TEST(IR_MODULE, create) ASSERT_NE(mutable_m->entity()->input(), nullptr); ASSERT_EQ(immutable_m->entity()->input(), mutable_m->entity()->input()); + ASSERT_NE(mutable_m->block(), nullptr); + ASSERT_EQ(immutable_m->block(), mutable_m->block()); + ASSERT_NE(mutable_m->input(), nullptr); ASSERT_EQ(immutable_m->input(), mutable_m->input()); } -- 2.7.4