// TODO Optimize this!
std::set<coco::Bag *> res;
+ auto accessed_by_host = [code](const coco::Bag *b) {
+ auto block_of = [](coco::Locatable *loc) -> coco::Block * {
+ if (auto ins = loc->loc())
+ {
+ if (auto blk = ins->parent())
+ {
+ return blk;
+ }
+ }
+
+ return nullptr;
+ };
+
+ auto is_host_block = [code](const coco::Block *blk) {
+ return (blk) ? (code->ann()->find(blk) == nullptr) : false;
+ };
+
+ for (const auto &updater : coco::updaters(b))
+ {
+ if (is_host_block(block_of(updater)))
+ {
+ return true;
+ }
+ }
+
+ for (const auto &reader : coco::readers(b))
+ {
+ if (is_host_block(block_of(reader)))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
for (uint32_t n = 0; n < code->module()->entity()->bag()->size(); ++n)
{
auto bag = code->module()->entity()->bag()->at(n);
if (!bag->isInput() && !bag->isOutput())
{
- res.insert(bag);
+ if (accessed_by_host(bag))
+ {
+ res.insert(bag);
+ }
}
}