CIRCT 20.0.0git
Loading...
Searching...
No Matches
StripContracts.cpp
Go to the documentation of this file.
1//===- StripContracts.cpp -------------------------------------------------===//
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
11#include "mlir/Pass/Pass.h"
12
13namespace circt {
14namespace verif {
15#define GEN_PASS_DEF_STRIPCONTRACTSPASS
16#include "circt/Dialect/Verif/Passes.h.inc"
17} // namespace verif
18} // namespace circt
19
20using namespace mlir;
21using namespace circt;
22using namespace verif;
23
24namespace {
25struct StripContractsPass
26 : public verif::impl::StripContractsPassBase<StripContractsPass> {
27 void runOnOperation() override {
28 getOperation()->walk([](ContractOp op) {
29 op->replaceUsesWithIf(op.getInputs(), [&](OpOperand &operand) {
30 return operand.getOwner() != op;
31 });
32 // Prevent removal of self-referential contracts that have other users.
33 // Removing them would result in invalid IR.
34 for (auto operand : op->getOperands())
35 if (operand.getDefiningOp() == op)
36 for (auto *user : operand.getUsers())
37 if (user != op)
38 return;
39 op->dropAllReferences();
40 op->erase();
41 });
42 }
43};
44} // namespace
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition verif.py:1