Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Transforms/ViewOpGraph.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
} // end namespace llvm | } // end namespace llvm | ||||
namespace { | namespace { | ||||
// PrintOpPass is simple pass to write graph per function. | // PrintOpPass is simple pass to write graph per function. | ||||
// Note: this is a module pass only to avoid interleaving on the same ostream | // Note: this is a module pass only to avoid interleaving on the same ostream | ||||
// due to multi-threading over functions. | // due to multi-threading over functions. | ||||
struct PrintOpPass : public ModulePass<PrintOpPass> { | struct PrintOpPass : public OperationPass<PrintOpPass, ModuleOp> { | ||||
/// Include the generated pass utilities. | /// Include the generated pass utilities. | ||||
#define GEN_PASS_PrintOpGraph | #define GEN_PASS_PrintOpGraph | ||||
#include "mlir/Transforms/Passes.h.inc" | #include "mlir/Transforms/Passes.h.inc" | ||||
explicit PrintOpPass(raw_ostream &os = llvm::errs(), bool short_names = false, | explicit PrintOpPass(raw_ostream &os = llvm::errs(), bool short_names = false, | ||||
const Twine &title = "") | const Twine &title = "") | ||||
: os(os), title(title.str()), short_names(short_names) {} | : os(os), title(title.str()), short_names(short_names) {} | ||||
Show All 23 Lines | for (Operation &op : module) { | ||||
: ("__" + llvm::utostr(indexed_block.index())); | : ("__" + llvm::utostr(indexed_block.index())); | ||||
llvm::WriteGraph(os, &indexed_block.value(), short_names, | llvm::WriteGraph(os, &indexed_block.value(), short_names, | ||||
Twine(title) + opName + blockName); | Twine(title) + opName + blockName); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void runOnModule() override { processModule(getModule()); } | void runOnOperation() override { processModule(getOperation()); } | ||||
private: | private: | ||||
raw_ostream &os; | raw_ostream &os; | ||||
std::string title; | std::string title; | ||||
int unnamedOpCtr = 0; | int unnamedOpCtr = 0; | ||||
bool short_names; | bool short_names; | ||||
}; | }; | ||||
} // namespace | } // namespace | ||||
Show All 16 Lines |