From b0797fc8f7ccee26eb9fde1031683e81c87aa35c 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 15:01:44 +0900 Subject: [PATCH] [coco] Add 'output' method in Module (#780) This commit adds 'output' method in Module class, which allows users to access Output list inside Module. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Module.h | 5 +++++ contrib/coco/core/include/coco/IR/OutputList.h | 15 +++++++++++++++ contrib/coco/core/src/IR/Module.cpp | 8 ++++++++ contrib/coco/core/src/IR/Module.test.cpp | 3 +++ 4 files changed, 31 insertions(+) create mode 100644 contrib/coco/core/include/coco/IR/OutputList.h diff --git a/contrib/coco/core/include/coco/IR/Module.h b/contrib/coco/core/include/coco/IR/Module.h index d1a1060..15bfaae 100644 --- a/contrib/coco/core/include/coco/IR/Module.h +++ b/contrib/coco/core/include/coco/IR/Module.h @@ -4,6 +4,7 @@ #include "coco/IR/EntityManager.h" #include "coco/IR/Block.h" #include "coco/IR/InputList.h" +#include "coco/IR/OutputList.h" #include @@ -38,6 +39,10 @@ public: virtual const InputList *input(void) const = 0; public: + virtual OutputList *output(void) = 0; + virtual const OutputList *output(void) const = 0; + +public: static std::unique_ptr create(void); }; diff --git a/contrib/coco/core/include/coco/IR/OutputList.h b/contrib/coco/core/include/coco/IR/OutputList.h new file mode 100644 index 0000000..de5ab80 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/OutputList.h @@ -0,0 +1,15 @@ +#ifndef __COCO_IR_OUTPUT_LIST_H__ +#define __COCO_IR_OUTPUT_LIST_H__ + +#include "coco/IR/Output.h" + +#include "coco/ADT/PtrList.h" + +namespace coco +{ + +using OutputList = PtrList; + +} // namespace coco + +#endif // __COCO_IR_OUTPUT_LIST_H__ diff --git a/contrib/coco/core/src/IR/Module.cpp b/contrib/coco/core/src/IR/Module.cpp index c4bf357..8315c1c 100644 --- a/contrib/coco/core/src/IR/Module.cpp +++ b/contrib/coco/core/src/IR/Module.cpp @@ -74,6 +74,13 @@ public: public: coco::InputList *input(void) override { return _input.get(); } const coco::InputList *input(void) const override { return _input.get(); } + +public: + std::unique_ptr _output; + +public: + coco::OutputList *output(void) override { return _output.get(); } + const coco::OutputList *output(void) const override { return _output.get(); } }; } // namespace @@ -101,6 +108,7 @@ std::unique_ptr Module::create(void) // 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->_output = nncc::foundation::make_unique(); m->_instr_link = std::move(ins_link); m->_block_link = std::move(blk_link); diff --git a/contrib/coco/core/src/IR/Module.test.cpp b/contrib/coco/core/src/IR/Module.test.cpp index be4c1c0..92b92ee 100644 --- a/contrib/coco/core/src/IR/Module.test.cpp +++ b/contrib/coco/core/src/IR/Module.test.cpp @@ -34,4 +34,7 @@ TEST(IR_MODULE, create) ASSERT_NE(mutable_m->input(), nullptr); ASSERT_EQ(immutable_m->input(), mutable_m->input()); + + ASSERT_NE(mutable_m->output(), nullptr); + ASSERT_EQ(immutable_m->output(), mutable_m->output()); } -- 2.7.4