#include "coco/IR/DepSet.h"
#include "coco/IR/ReadSet.h"
#include "coco/IR/UpdateSet.h"
+#include "coco/IR/Input.forward.h"
+#include "coco/IR/Output.forward.h"
#include "coco/IR/Locatable.h"
#include <set>
const UpdateSet *updates(void) const;
public:
+ Input *input(void) const { return _input; }
+ Output *output(void) const { return _output; }
+
+public:
// @brief Replace all the occurence of a bag (except those in Input/Output) with another bag
//
// NOTE reaplceWith(b) works correctly only when b is neither Input nor Output
UpdateSet *updates(void) { return &_updates; }
private:
+ // WARN Only Input is allowed to access this method
+ void input(Input *i) { _input = i; }
+ // WARN Only Output is allowed to access this method
+ void output(Output *o) { _output = o; }
+
+private:
std::unique_ptr<BagInfo> _info;
private:
ReadSet _reads;
/** @brief Direct updates (not through Object) */
UpdateSet _updates;
+
+ Input *_input = nullptr;
+ Output *_output = nullptr;
};
// @brief Return a set of objects that depends on a given bag
--- /dev/null
+#ifndef __COCO_IR_INPUT_FORWARD_H__
+#define __COCO_IR_INPUT_FORWARD_H__
+
+namespace coco
+{
+
+class Input;
+
+} // namespace coco
+
+#endif // __COCO_IR_INPUT_FORWARD_H__
--- /dev/null
+#ifndef __COCO_IR_OUTPUT_FORWARD_H__
+#define __COCO_IR_OUTPUT_FORWARD_H__
+
+namespace coco
+{
+
+class Output;
+
+} // namespace coco
+
+#endif // __COCO_IR_OUTPUT_FORWARD_H__
uint32_t Bag::size(void) const { return _info->size(); }
-bool Bag::isInput(void) const { return _info->mask()->masked(BagMask::Input); }
-bool Bag::isOutput(void) const { return _info->mask()->masked(BagMask::Output); }
+bool Bag::isInput(void) const { return _input != nullptr; }
+bool Bag::isOutput(void) const { return _output != nullptr; }
const DepSet *Bag::deps(void) const { return &_deps; }
const ReadSet *Bag::reads(void) const { return &_reads; }
void Input::onTake(Bag *bag)
{
- auto info = bag->_info.get();
- assert(info != nullptr);
- assert(!info->mask()->masked(BagMask::Input));
-
- info->mask()->set(BagMask::Input);
+ assert(bag->input() == nullptr);
+ bag->input(this);
}
void Input::onRelease(Bag *bag)
{
- auto info = bag->_info.get();
- assert(info != nullptr);
- assert(info->mask()->masked(BagMask::Input));
-
- info->mask()->unset(BagMask::Input);
+ assert(bag->input() == this);
+ bag->input(nullptr);
}
} // namespace coco
void Output::onTake(Bag *bag)
{
- auto info = bag->_info.get();
- assert(info != nullptr);
- assert(!info->mask()->masked(BagMask::Output));
-
- info->mask()->set(BagMask::Output);
+ assert(bag->output() == nullptr);
+ bag->output(this);
}
void Output::onRelease(Bag *bag)
{
- auto info = bag->_info.get();
- assert(info != nullptr);
- assert(info->mask()->masked(BagMask::Output));
-
- info->mask()->unset(BagMask::Output);
+ assert(bag->output() == this);
+ bag->output(nullptr);
}
} // namespace coco