CIRCT 20.0.0git
Loading...
Searching...
No Matches
ESIVerifyConnections.cpp
Go to the documentation of this file.
1//===- ESIVerifyConnections.cpp ---------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12
13#include "mlir/IR/BuiltinTypes.h"
14#include "mlir/Pass/Pass.h"
15
16namespace circt {
17namespace esi {
18#define GEN_PASS_DEF_VERIFYESICONNECTIONS
19#include "circt/Dialect/ESI/ESIPasses.h.inc"
20} // namespace esi
21} // namespace circt
22
23using namespace circt;
24using namespace circt::esi;
25
26namespace {
27struct ESIVerifyConnectionsPass
28 : public impl::VerifyESIConnectionsBase<ESIVerifyConnectionsPass> {
29 void runOnOperation() override;
30};
31} // anonymous namespace
32
33void ESIVerifyConnectionsPass::runOnOperation() {
34 // Walk the tree and look for ops which produce ESI types. Check each one.
35 getOperation()->walk([this](Operation *op) {
36 for (const OpResult &v : op->getResults())
37 if (isa<ChannelBundleType>(v.getType())) {
38 if (v.hasOneUse())
39 continue;
40 mlir::InFlightDiagnostic error =
41 op->emitError("bundles must have exactly one use");
42 for (Operation *user : v.getUsers())
43 error.attachNote(user->getLoc()) << "bundle used here";
44 signalPassFailure();
45
46 } else if (auto cv = dyn_cast<mlir::TypedValue<ChannelType>>(v)) {
47 if (failed(ChannelType::verifyChannel(cv)))
48 signalPassFailure();
49 }
50 });
51}
52
53std::unique_ptr<OperationPass<>> circt::esi::createESIVerifyConnectionsPass() {
54 return std::make_unique<ESIVerifyConnectionsPass>();
55}
std::unique_ptr< OperationPass<> > createESIVerifyConnectionsPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition esi.py:1