#include "coco/IR/ObjectSet.h"
#include "coco/IR/DepSet.h"
+#include "coco/IR/ReadSet.h"
#include "coco/IR/Locatable.h"
#include <set>
public:
// @brief Return the set of Dep links that point to this bag
const DepSet *deps(void) const;
- // WARN This method will be deprecated. Please below "readers" instead
- ReaderSet reads(void) const;
+ // @brief Return the set of Read links that point to this bag
+ const ReadSet *reads(void) const;
// WARN This method will be dpercated. Please use below "updaters" instead
UpdaterSet updates(void) const;
#ifndef __COCO_IR_READ_SET_H__
#define __COCO_IR_READ_SET_H__
-#include "coco/IR/Read.h"
+#include "coco/IR/Read.forward.h"
#include <set>
#include "coco/IR/BagInfo.h"
#include "coco/IR/Object.h"
+#include "coco/IR/Read.h"
#include <nncc/foundation/Memory.h>
bool Bag::isOutput(void) const { return _info->mask()->masked(BagMask::Output); }
const DepSet *Bag::deps(void) const { return _info->deps(); }
-
-Bag::ReaderSet Bag::reads(void) const
-{
- Bag::ReaderSet res;
-
- for (auto obj : dependent_objects(this))
- {
- for (auto use : *obj->user())
- {
- res.insert(use);
- }
- }
-
- for (auto read : *_info->reads())
- {
- auto reader = read->reader();
- assert(reader != nullptr);
- res.insert(reader);
- }
-
- return res;
-}
+const ReadSet *Bag::reads(void) const { return _info->reads(); }
Bag::UpdaterSet Bag::updates(void) const
{
return res;
}
-Bag::ReaderSet readers(const Bag *b) { return b->reads(); }
+Bag::ReaderSet readers(const Bag *b)
+{
+ Bag::ReaderSet res;
+
+ for (auto obj : dependent_objects(b))
+ {
+ for (auto use : *obj->user())
+ {
+ res.insert(use);
+ }
+ }
+
+ for (auto read : *b->reads())
+ {
+ auto reader = read->reader();
+ assert(reader != nullptr);
+ res.insert(reader);
+ }
+
+ return res;
+}
+
Bag::UpdaterSet updaters(const Bag *b) { return b->updates(); }
} // namespace coco
ASSERT_EQ(b.size(), 3);
// Bag has no read/updates at the beginning
- EXPECT_EQ(b.reads().size(), 0);
+ EXPECT_EQ(b.reads()->size(), 0);
EXPECT_EQ(b.updates().size(), 0);
}
ASSERT_EQ(slot.bag(), bag);
- {
- auto reads = bag->reads();
-
- ASSERT_EQ(reads.size(), 1);
- ASSERT_NE(reads.find(&read), reads.end());
- }
+ ASSERT_EQ(bag->reads()->size(), 1);
+ ASSERT_NE(bag->reads()->find(&slot), bag->reads()->end());
slot.bag(nullptr);
- {
- auto reads = bag->reads();
-
- ASSERT_EQ(slot.bag(), nullptr);
+ ASSERT_EQ(slot.bag(), nullptr);
- ASSERT_EQ(reads.size(), 0);
- }
+ ASSERT_EQ(bag->reads()->size(), 0);
}
TEST_F(ReadTest, unlink_on_destruction)
read.bag(bag);
}
- ASSERT_EQ(bag->reads().size(), 0);
+ ASSERT_EQ(bag->reads()->size(), 0);
}