From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Mon, 23 Jul 2018 05:31:51 +0000 (+0900) Subject: [coco] 'Block' as a child of 'Module' (#755) X-Git-Tag: nncc_backup~2349 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49155703677684551fb7d1466775adcac43a84c0;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] 'Block' as a child of 'Module' (#755) This commit introduces 'BlockList' alias, and introduces dummy 'head' implementation required by 'DLinkedList' trait. This dummy 'head' implementation will be replaced with the concreate one later. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/Block.h b/contrib/coco/core/include/coco/IR/Block.h index 1692bd0..1f95aa3 100644 --- a/contrib/coco/core/include/coco/IR/Block.h +++ b/contrib/coco/core/include/coco/IR/Block.h @@ -1,6 +1,8 @@ #ifndef __COCO_IR_BLOCK_H__ #define __COCO_IR_BLOCK_H__ +#include "coco/IR/Module.forward.h" +#include "coco/IR/Block.forward.h" #include "coco/IR/Instr.h" #include "coco/ADT/DLinkedList.h" @@ -8,16 +10,19 @@ namespace coco { +using BlockList = DLinkedList::Head; + /*** * @brief A unit of (grouped) instructions * * Block allows backend to manage a set of instructions as one unit, which is useful for H/W that * has a restriction on code size */ -class Block final +class Block final : public DLinkedList::Node { public: - Block(PtrLink *instr_link) : _instr{this, instr_link} + Block(const PtrLink *block_link, PtrLink *instr_link) + : DLinkedList::Node{block_link}, _instr{this, instr_link} { // DO NOTHING } @@ -31,6 +36,9 @@ public: private: DLinkedList::Head _instr; + +public: + BlockList *head(void) const override; }; } // namespace coco diff --git a/contrib/coco/core/include/coco/IR/Module.forward.h b/contrib/coco/core/include/coco/IR/Module.forward.h new file mode 100644 index 0000000..d043149 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/Module.forward.h @@ -0,0 +1,11 @@ +#ifndef __COCO_IR_MODULE_FORWARD_H__ +#define __COCO_IR_MODULE_FORWARD_H__ + +namespace coco +{ + +class Module; + +} // namespace coco + +#endif // __COCO_IR_MODULE_FORWARD_H__ diff --git a/contrib/coco/core/src/IR/Block.cpp b/contrib/coco/core/src/IR/Block.cpp new file mode 100644 index 0000000..283da58 --- /dev/null +++ b/contrib/coco/core/src/IR/Block.cpp @@ -0,0 +1,14 @@ +#include "coco/IR/Block.h" + +#include + +namespace coco +{ + +BlockList *Block::head(void) const +{ + // TODO Implement this after implemeing 'block()' method in 'Module' class + throw std::runtime_error{"NYI"}; +} + +} // namespace coco diff --git a/contrib/coco/core/src/IR/Block.test.cpp b/contrib/coco/core/src/IR/Block.test.cpp index e5b4ab6..3a4c689 100644 --- a/contrib/coco/core/src/IR/Block.test.cpp +++ b/contrib/coco/core/src/IR/Block.test.cpp @@ -4,8 +4,9 @@ TEST(IR_BLOCK, default_block_has_empty_instr_list) { - coco::PtrLink link; - coco::Block blk{&link}; + coco::PtrLink block_link; + coco::PtrLink instr_link; + coco::Block blk{&block_link, &instr_link}; ASSERT_TRUE(blk.instr()->empty()); ASSERT_EQ(blk.instr()->head(), nullptr);