[coco] Introduce producer and consumers helpers (#1513)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 17 Sep 2018 04:24:17 +0000 (13:24 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 17 Sep 2018 04:24:17 +0000 (13:24 +0900)
This commit introduces producer and consumers helpers for Object values.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/Object.h
contrib/coco/core/src/IR/Object.cpp

index a57fdf3..61b98db 100644 (file)
@@ -57,6 +57,7 @@ private:
   ObjectInfo *info(void) const;
 
 public:
+  // WARN These methods are deprecated. Please use 'producer' and 'consumers' instead.
   Producer *def(void) const;
   const ConsumerSet *user(void) const;
 
@@ -64,6 +65,12 @@ private:
   Dep _dep;
 };
 
+// @brief Return the producer of a given object if it exists
+Object::Producer *producer(const Object *);
+
+// @brief Return a set of consumers of a given object.
+Object::ConsumerSet consumers(const Object *);
+
 } // namespace coco
 
 #endif // __COCO_IR_OBJECT_H__
index ff5a262..664ba32 100644 (file)
@@ -34,4 +34,7 @@ Object::Producer *Object::def(void) const
 
 const Object::ConsumerSet *Object::user(void) const { return info()->user(); }
 
+Object::Producer *producer(const Object *obj) { return obj->def(); }
+Object::ConsumerSet consumers(const Object *obj) { return *(obj->user()); }
+
 } // namespace coco