From fbfa40ae68ec42fe8a330f38219bbe4ba8bea0d4 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: Mon, 17 Sep 2018 16:04:23 +0900 Subject: [PATCH] [coco] Manage DepSet/ReadSet/UpdateSet in Bag (#1518) This commit moves DepSet/ReadSet/UpdateSet in BagInto into Bag. This is the first step to unify Bag and BagInfo class. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Bag.h | 16 ++++++++++++++++ contrib/coco/core/include/coco/IR/BagInfo.h | 19 ------------------- contrib/coco/core/src/IR/Bag.cpp | 12 ++++++------ contrib/coco/core/src/IR/Dep.cpp | 11 +++-------- contrib/coco/core/src/IR/Read.cpp | 8 ++------ contrib/coco/core/src/IR/Update.cpp | 8 ++------ 6 files changed, 29 insertions(+), 45 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Bag.h b/contrib/coco/core/include/coco/IR/Bag.h index 4959168..e3a5b12 100644 --- a/contrib/coco/core/include/coco/IR/Bag.h +++ b/contrib/coco/core/include/coco/IR/Bag.h @@ -83,8 +83,24 @@ public: // NOTE Unlike replaceWith(b), replaceAllDepsWith(b) has no restriction void replaceAllDepsWith(Bag *); +public: + // WARN Only Dep is allowed to access this method + DepSet *deps(void) { return &_deps; } + // WARN Only Read is allowed to access this method + ReadSet *reads(void) { return &_reads; } + // WARN Only Update is allowed to access this method + UpdateSet *updates(void) { return &_updates; } + private: std::unique_ptr _info; + +private: + /** @brief Links to dependent Object(s) */ + DepSet _deps; + /** @brief Direct reads (not through Object) */ + ReadSet _reads; + /** @brief Direct updates (not through Object) */ + UpdateSet _updates; }; // @brief Return a set of objects that depends on a given bag diff --git a/contrib/coco/core/include/coco/IR/BagInfo.h b/contrib/coco/core/include/coco/IR/BagInfo.h index 626f342..f098f2c 100644 --- a/contrib/coco/core/include/coco/IR/BagInfo.h +++ b/contrib/coco/core/include/coco/IR/BagInfo.h @@ -57,29 +57,10 @@ private: uint32_t const _size; public: - DepSet *deps(void) { return &_deps; } - const DepSet *deps(void) const { return &_deps; } - -public: - ReadSet *reads(void) { return &_reads; } - const ReadSet *reads(void) const { return &_reads; } - -public: - UpdateSet *updates(void) { return &_updates; } - const UpdateSet *updates(void) const { return &_updates; } - -public: BagMask *mask(void) { return &_mask; } const BagMask *mask(void) const { return &_mask; } private: - /** @brief Links to dependent Object(s) */ - DepSet _deps; - /** @brief Direct reads (not through Object) */ - ReadSet _reads; - /** @brief Direct updates (not through Object) */ - UpdateSet _updates; - BagMask _mask; }; diff --git a/contrib/coco/core/src/IR/Bag.cpp b/contrib/coco/core/src/IR/Bag.cpp index 1175606..c55c93b 100644 --- a/contrib/coco/core/src/IR/Bag.cpp +++ b/contrib/coco/core/src/IR/Bag.cpp @@ -20,9 +20,9 @@ Bag::Bag(std::unique_ptr &&info) : _info{std::move(info)} Bag::~Bag() { // All the references over a bag SHOULD be dropped before its destruction - assert(_info->deps()->size() == 0); - assert(_info->reads()->size() == 0); - assert(_info->updates()->size() == 0); + assert(deps()->size() == 0); + assert(reads()->size() == 0); + assert(updates()->size() == 0); } uint32_t Bag::size(void) const { return _info->size(); } @@ -30,9 +30,9 @@ uint32_t Bag::size(void) const { return _info->size(); } bool Bag::isInput(void) const { return _info->mask()->masked(BagMask::Input); } bool Bag::isOutput(void) const { return _info->mask()->masked(BagMask::Output); } -const DepSet *Bag::deps(void) const { return _info->deps(); } -const ReadSet *Bag::reads(void) const { return _info->reads(); } -const UpdateSet *Bag::updates(void) const { return _info->updates(); } +const DepSet *Bag::deps(void) const { return &_deps; } +const ReadSet *Bag::reads(void) const { return &_reads; } +const UpdateSet *Bag::updates(void) const { return &_updates; } void Bag::replaceWith(Bag *b) { diff --git a/contrib/coco/core/src/IR/Dep.cpp b/contrib/coco/core/src/IR/Dep.cpp index d1a6d13..7429900 100644 --- a/contrib/coco/core/src/IR/Dep.cpp +++ b/contrib/coco/core/src/IR/Dep.cpp @@ -16,11 +16,8 @@ void Dep::bag(Bag *bag) // Remove bag <-> dep link // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - assert(info->deps()->find(this) != info->deps()->end()); - - info->deps()->erase(this); + assert(_bag->deps()->find(this) != _bag->deps()->end()); + _bag->deps()->erase(this); } // Reset _bag @@ -37,9 +34,7 @@ void Dep::bag(Bag *bag) // Create bag <-> dep link // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - info->deps()->insert(this); + _bag->deps()->insert(this); } } diff --git a/contrib/coco/core/src/IR/Read.cpp b/contrib/coco/core/src/IR/Read.cpp index 66b5334..9e1b82a 100644 --- a/contrib/coco/core/src/IR/Read.cpp +++ b/contrib/coco/core/src/IR/Read.cpp @@ -18,9 +18,7 @@ void Read::bag(Bag *bag) { // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - info->reads()->erase(this); + _bag->reads()->erase(this); } _bag = nullptr; } @@ -32,9 +30,7 @@ void Read::bag(Bag *bag) _bag = bag; // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - info->reads()->insert(this); + _bag->reads()->insert(this); } } diff --git a/contrib/coco/core/src/IR/Update.cpp b/contrib/coco/core/src/IR/Update.cpp index 48b6db9..3a37701 100644 --- a/contrib/coco/core/src/IR/Update.cpp +++ b/contrib/coco/core/src/IR/Update.cpp @@ -18,9 +18,7 @@ void Update::bag(Bag *bag) { // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - info->updates()->erase(this); + _bag->updates()->erase(this); } _bag = nullptr; } @@ -32,9 +30,7 @@ void Update::bag(Bag *bag) _bag = bag; // TODO Remove unnecessary indentation { - auto info = _bag->_info.get(); - assert(info != nullptr); - info->updates()->insert(this); + _bag->updates()->insert(this); } } -- 2.7.4