15 #include "mlir/Pass/Pass.h"
16 #include "llvm/Support/raw_ostream.h"
20 #define GEN_PASS_DEF_PRINTFIRRTLFIELDSOURCEPASS
21 #include "circt/Dialect/FIRRTL/Passes.h.inc"
25 using namespace circt;
26 using namespace firrtl;
29 struct PrintFIRRTLFieldSourcePass
30 :
public circt::firrtl::impl::PrintFIRRTLFieldSourcePassBase<
31 PrintFIRRTLFieldSourcePass> {
32 PrintFIRRTLFieldSourcePass(raw_ostream &os) : os(os) {}
34 void visitValue(
const FieldSource &fieldRefs, Value v) {
41 os <<
" : " << p->
src <<
" : {";
42 llvm::interleaveComma(p->path, os);
47 if (p->isSrcWritable())
49 if (p->isSrcTransparent())
55 void visitOp(
const FieldSource &fieldRefs, Operation *op) {
56 for (
auto r : op->getResults())
57 visitValue(fieldRefs, r);
59 for (
auto &r : op->getRegions())
60 for (
auto &b : r.getBlocks())
62 visitOp(fieldRefs, &op);
65 void runOnOperation()
override {
66 auto modOp = getOperation();
67 os <<
"** " << modOp.getName() <<
"\n";
68 auto &fieldRefs = getAnalysis<FieldSource>();
69 for (
auto port : modOp.getBodyBlock()->getArguments())
70 visitValue(fieldRefs, port);
71 for (
auto &op : *modOp.getBodyBlock())
72 visitOp(fieldRefs, &op);
74 markAllAnalysesPreserved();
81 return std::make_unique<PrintFIRRTLFieldSourcePass>(llvm::errs());
To use this class, retrieve a cached copy from the analysis manager: auto &fieldsource = getAnalysis<...
const PathNode * nodeForValue(Value v) const
std::unique_ptr< mlir::Pass > createFIRRTLFieldSourcePass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.