#include <stdexcept>
+namespace
+{
+
+// has_inout_bag(m) returns true if there is a pair of coco::Input and coco::Output that share
+// the same bag as their backing storage
+bool has_inout_bag(const coco::Module *m)
+{
+ for (uint32_t n = 0; n < m->entity()->bag()->size(); ++n)
+ {
+ auto bag = m->entity()->bag()->at(n);
+
+ if (bag->isInput() && bag->isOutput())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace
+
namespace enco
{
{
Code code{m, d};
+ // The current implementation will assign memory region for each bag as follows:
+ // Bind input bag to the region provided by Network_input_bind
+ // Bind output bag to the region provided by Network_output_bind
+ // Bind intermediate bag to the region allocated during execution
+ //
+ // Note that this scheme does not work if there is a pair of input/output
+ // that share the same bag as their underlying bag
+ assert(!has_inout_bag(code.module()));
+
// TODO Run various transforms over enco::Code
_os << CppCode{&code} << std::endl;