12 #include "mlir/IR/BuiltinTypes.h"
13 #include "mlir/Pass/Pass.h"
17 #define GEN_PASS_DEF_VERIFYESICONNECTIONS
18 #include "circt/Dialect/ESI/ESIPasses.h.inc"
22 using namespace circt;
26 struct ESIVerifyConnectionsPass
27 :
public impl::VerifyESIConnectionsBase<ESIVerifyConnectionsPass> {
28 void runOnOperation()
override;
32 void ESIVerifyConnectionsPass::runOnOperation() {
34 getOperation()->walk([
this](Operation *op) {
35 for (
const OpResult &v : op->getResults())
36 if (isa<ChannelBundleType>(v.getType())) {
39 mlir::InFlightDiagnostic error =
40 op->emitError(
"bundles must have exactly one use");
41 for (Operation *user : v.getUsers())
42 error.attachNote(user->getLoc()) <<
"bundle used here";
45 }
else if (isa<ChannelType>(v.getType())) {
46 if (std::distance(v.getUses().begin(), v.getUses().end()) <= 1)
48 mlir::InFlightDiagnostic error =
49 op->emitError(
"channels must have at most one use");
50 for (Operation *user : v.getUsers())
51 error.attachNote(user->getLoc()) <<
"channel used here";
58 return std::make_unique<ESIVerifyConnectionsPass>();
std::unique_ptr< OperationPass<> > createESIVerifyConnectionsPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.