[enco] Support block dump (#2528)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 6 Dec 2018 06:29:01 +0000 (15:29 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 6 Dec 2018 06:29:01 +0000 (15:29 +0900)
This commit implement "enco_dump_block" debugging helper which shows all
the instructions in a given block.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Support/Debugging.cpp
contrib/enco/core/src/Support/Debugging.h

index 987fa1d..519fd1b 100644 (file)
@@ -387,3 +387,27 @@ DEBUGGING_API_P(enco_dump_all_instrs, coco::Module, m)
     std::cout << desc << std::endl;
   }
 }
+
+/**
+ * SECTION: Block
+ */
+namespace
+{
+
+pp::LinearDocument describe(const coco::Block *blk)
+{
+  pp::LinearDocument doc;
+
+  for (auto ins = blk->instr()->head(); ins; ins = ins->next())
+  {
+    auto setter = [ins](pp::LinearDocument &doc) { doc.append(describe(ins)); };
+    auto desc = section("instr").build(setter);
+    doc.append(desc);
+  }
+
+  return doc;
+}
+
+} // namespace
+
+DEBUGGING_API_P(enco_dump_block, coco::Block, blk) { std::cout << describe(blk) << std::endl; }
index bf1d625..a3a36cc 100644 (file)
@@ -81,6 +81,14 @@ DEBUGGING_API_P(enco_dump_all_ops, coco::Module);
  */
 DEBUGGING_API_P(enco_dump_all_instrs, coco::Module);
 
+/**
+ * Print the details of all the instruction in a given block
+ *
+ * (gdb) call enco_dump_block(b)
+ * (gdb) call enco_dump_block(0x...)
+ */
+DEBUGGING_API_P(enco_dump_block, coco::Block);
+
 #undef DEBUGGING_API_P
 
 #endif // __ENCO_SUPPORT_DEBUGGING_H__