return res;
}
-
-// WARN Deprecated
-/** @brief Return a set of Bag to be allocated */
-// NOTE An input/output bag may be included in the retrun set of "intermediates"
-std::set<coco::Bag *> intermediates(const enco::Code *code)
-{
- // NOTE The current implementation may allocate unnecessary buffers (such as weight)
- // 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) {
- auto m = blk->module();
- auto ann_ctx = enco::SubnetManager::context(m);
- return (blk) ? (ann_ctx->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);
-
- // TODO Remove unnecessary indentation
- {
- if (accessed_by_host(bag))
- {
- res.insert(bag);
- }
- }
- }
-
- return res;
-}
} // namespace
namespace enco