[enco/gdb] Print out the producer info. of object (#3005)
author윤지영/On-Device Lab(SR)/Engineer/삼성전자 <jy910.yun@samsung.com>
Mon, 11 Feb 2019 11:42:16 +0000 (20:42 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 11 Feb 2019 11:42:16 +0000 (20:42 +0900)
* [enco/gdb] Print out the producer info. of object

This patch allows print out the producer information of object

Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
* Introduce def_kind function

* Add shuffle case

contrib/enco/core/src/Support/Debugging.cpp

index e4853b4..36a028b 100644 (file)
@@ -102,6 +102,39 @@ DEBUGGING_API_P(enco_dump_all_bags, coco::Module, m)
  */
 namespace
 {
+std::string op_kind(const coco::Op *op);
+
+/**
+ * @brief Return the def(producer) type of object
+ */
+std::string def_kind(const coco::Def *def)
+{
+  if (def)
+  {
+    if (auto instr = dynamic_cast<coco::Instr *>(def->producer()))
+    {
+      std::stringstream ss;
+
+      if (auto eval = instr->asEval())
+      {
+        ss << op_kind(eval->op()) << "(" << instr << ")";
+        return ss.str();
+      }
+      else if (instr->asCopy())
+      {
+        ss << "Copy(" << instr << ")";
+        return ss.str();
+      }
+      else if (instr->asShuffle())
+      {
+        ss << "Shuffle(" << instr << ")";
+        return ss.str();
+      }
+    }
+  }
+
+  return "(unknown)";
+}
 
 pp::LinearDocument describe(const coco::Object *obj)
 {
@@ -109,7 +142,7 @@ pp::LinearDocument describe(const coco::Object *obj)
 
   doc.append("addr: ", obj);
   doc.append("bag: ", obj->bag());
-  // TODO Show Def
+  doc.append("producer: ", def_kind(obj->def()));
   // TODO Show Uses
   // TODO Show FeatureObject/KernelObect info