From dcffc3d176c6e6e9b3ed5b1fcb8013eac3d1e2e5 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, 11 Sep 2018 11:58:11 +0900 Subject: [PATCH] [coco] Maintain UpdateSet instead of UpdaterSet (#1437) This commit rewrites BagInfo to maintain UpdateSet instead of UpdaterSet, which is necessary to support Bag-to-Bag substitution. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/BagInfo.h | 7 ++++--- contrib/coco/core/include/coco/IR/UpdateSet.h | 15 +++++++++++++++ contrib/coco/core/src/IR/Bag.cpp | 4 +++- contrib/coco/core/src/IR/Update.cpp | 8 ++++---- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 contrib/coco/core/include/coco/IR/UpdateSet.h diff --git a/contrib/coco/core/include/coco/IR/BagInfo.h b/contrib/coco/core/include/coco/IR/BagInfo.h index 5ac23f9..626f342 100644 --- a/contrib/coco/core/include/coco/IR/BagInfo.h +++ b/contrib/coco/core/include/coco/IR/BagInfo.h @@ -4,6 +4,7 @@ #include "coco/IR/Bag.h" #include "coco/IR/DepSet.h" #include "coco/IR/ReadSet.h" +#include "coco/IR/UpdateSet.h" #include @@ -64,8 +65,8 @@ public: const ReadSet *reads(void) const { return &_reads; } public: - Bag::UpdaterSet *updates(void) { return &_updates; } - const Bag::UpdaterSet *updates(void) const { return &_updates; } + UpdateSet *updates(void) { return &_updates; } + const UpdateSet *updates(void) const { return &_updates; } public: BagMask *mask(void) { return &_mask; } @@ -77,7 +78,7 @@ private: /** @brief Direct reads (not through Object) */ ReadSet _reads; /** @brief Direct updates (not through Object) */ - Bag::UpdaterSet _updates; + UpdateSet _updates; BagMask _mask; }; diff --git a/contrib/coco/core/include/coco/IR/UpdateSet.h b/contrib/coco/core/include/coco/IR/UpdateSet.h new file mode 100644 index 0000000..ae36245 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/UpdateSet.h @@ -0,0 +1,15 @@ +#ifndef __COCO_IR_UPDATE_SET_H__ +#define __COCO_IR_UPDATE_SET_H__ + +#include "coco/IR/Update.h" + +#include + +namespace coco +{ + +using UpdateSet = std::set; + +} // namespace coco + +#endif // __COCO_IR_UPDATE_SET_H__ diff --git a/contrib/coco/core/src/IR/Bag.cpp b/contrib/coco/core/src/IR/Bag.cpp index 2149455..8540dc1 100644 --- a/contrib/coco/core/src/IR/Bag.cpp +++ b/contrib/coco/core/src/IR/Bag.cpp @@ -74,7 +74,9 @@ Bag::UpdaterSet Bag::updates(void) const for (auto update : *_info->updates()) { - res.insert(update); + auto updater = update->updater(); + assert(updater != nullptr); + res.insert(updater); } return res; diff --git a/contrib/coco/core/src/IR/Update.cpp b/contrib/coco/core/src/IR/Update.cpp index 6e0cf45..709b1ba 100644 --- a/contrib/coco/core/src/IR/Update.cpp +++ b/contrib/coco/core/src/IR/Update.cpp @@ -10,11 +10,11 @@ void Update::bag(Bag *bag) { if (_bag) { - if (_link && _updater) + if (_link) { auto info = _link->find(_bag); assert(info != nullptr); - info->updates()->erase(_updater); + info->updates()->erase(this); } _bag = nullptr; } @@ -24,11 +24,11 @@ void Update::bag(Bag *bag) if (bag) { _bag = bag; - if (_link && _updater) + if (_link) { auto info = _link->find(_bag); assert(info != nullptr); - info->updates()->insert(_updater); + info->updates()->insert(this); } } -- 2.7.4