From dc1ae05c0b2882e96a7fde67f6f90cd480e974c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 13 Nov 2018 19:43:38 +0900 Subject: [PATCH] [enco] Introduce enco_dump_all_instrs (#2252) This commit implements enco_dump_all_instrs debugging helper. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Support/Debugging.cpp | 47 +++++++++++++++++++++++++++++ contrib/enco/core/src/Support/Debugging.h | 8 +++++ 2 files changed, 55 insertions(+) diff --git a/contrib/enco/core/src/Support/Debugging.cpp b/contrib/enco/core/src/Support/Debugging.cpp index 25ad1e4..37f4f70 100644 --- a/contrib/enco/core/src/Support/Debugging.cpp +++ b/contrib/enco/core/src/Support/Debugging.cpp @@ -217,3 +217,50 @@ DEBUGGING_API_P(enco_dump_all_ops, coco::Module, m) std::cout << desc << std::endl; } } + +/** + * SECTION: Instr + */ +namespace +{ + +std::string kind(const coco::Instr *ins) +{ + struct InstrKind : public coco::Instr::Visitor + { + std::string visit(const coco::Eval *) override { return "Eval"; } + std::string visit(const coco::Copy *) override { return "Copy"; } + std::string visit(const coco::Shuffle *) override { return "Shuffle"; } + }; + + InstrKind v; + + return ins->accept(v); +} + +pp::LinearDocument describe(const coco::Instr *ins) +{ + pp::LinearDocument doc; + + doc.append("addr: ", ins); + doc.append("kind: ", kind(ins)); + doc.append("parent: ", ins->parent()); + + return doc; +} + +} // namespace + +DEBUGGING_API_P(enco_dump_all_instrs, coco::Module, m) +{ + for (uint32_t n = 0; n < m->entity()->instr()->size(); ++n) + { + auto ins = m->entity()->instr()->at(n); + assert(ins != nullptr); + + auto setter = [ins](pp::LinearDocument &doc) { doc.append(describe(ins)); }; + auto desc = section("instr").build(setter); + + std::cout << desc << std::endl; + } +} diff --git a/contrib/enco/core/src/Support/Debugging.h b/contrib/enco/core/src/Support/Debugging.h index e87e14d..ea51429 100644 --- a/contrib/enco/core/src/Support/Debugging.h +++ b/contrib/enco/core/src/Support/Debugging.h @@ -57,6 +57,14 @@ DEBUGGING_API_P(enco_dump_op_tree, coco::Op); */ DEBUGGING_API_P(enco_dump_all_ops, coco::Module); +/** + * Print the details of all the allocated coco::Instr in coco::Module + * + * (gdb) call enco_dump_all_instrs(module) + * (gdb) call enco_dump_all_instrs(0x...) + */ +DEBUGGING_API_P(enco_dump_all_instrs, coco::Module); + #undef DEBUGGING_API_P #endif // __ENCO_SUPPORT_DEBUGGING_H__ -- 2.7.4