15 #include "llvm/Support/raw_ostream.h"
17 using namespace circt;
18 using namespace firrtl;
21 struct PrintFIRRTLFieldSourcePass
22 :
public PrintFIRRTLFieldSourcePassBase<PrintFIRRTLFieldSourcePass> {
23 PrintFIRRTLFieldSourcePass(raw_ostream &os) : os(os) {}
25 void visitValue(
const FieldSource &fieldRefs, Value v) {
32 os <<
" : " << p->
src <<
" : {";
33 llvm::interleaveComma(p->path, os);
38 if (p->isSrcWritable())
40 if (p->isSrcTransparent())
46 void visitOp(
const FieldSource &fieldRefs, Operation *op) {
47 for (
auto r : op->getResults())
48 visitValue(fieldRefs, r);
50 for (
auto &r : op->getRegions())
51 for (
auto &b : r.getBlocks())
53 visitOp(fieldRefs, &op);
56 void runOnOperation()
override {
57 auto modOp = getOperation();
58 os <<
"** " << modOp.getName() <<
"\n";
59 auto &fieldRefs = getAnalysis<FieldSource>();
60 for (
auto port : modOp.getBodyBlock()->getArguments())
61 visitValue(fieldRefs, port);
62 for (
auto &op : *modOp.getBodyBlock())
63 visitOp(fieldRefs, &op);
65 markAllAnalysesPreserved();
72 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()
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
mlir::raw_indented_ostream & errs()