CIRCT 22.0.0git
Loading...
Searching...
No Matches
MaterializeConstraintsPass.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/IR/PatternMatch.h"
12
13namespace circt {
14namespace rtg {
15#define GEN_PASS_DEF_MATERIALIZECONSTRAINTSPASS
16#include "circt/Dialect/RTG/Transforms/RTGPasses.h.inc"
17} // namespace rtg
18} // namespace circt
19
20using namespace mlir;
21using namespace circt;
22using namespace circt::rtg;
23
24//===----------------------------------------------------------------------===//
25// Materialize Constraints Pass
26//===----------------------------------------------------------------------===//
27
28namespace {
29struct MaterializeConstraintsPass
30 : public rtg::impl::MaterializeConstraintsPassBase<
31 MaterializeConstraintsPass> {
32 using Base::Base;
33 void runOnOperation() override;
34};
35} // namespace
36
37void MaterializeConstraintsPass::runOnOperation() {
38 getOperation()->walk([&](ImplicitConstraintOpInterface op) {
39 if (op.isConstraintMaterialized())
40 return;
41
42 OpBuilder builder(op);
43 builder.setInsertionPointAfter(op);
44 auto *newOp = op.materializeConstraint(builder);
45 if (newOp == op)
46 return;
47 if (newOp && op->getNumResults() > 0)
48 op->replaceAllUsesWith(newOp);
49 assert(newOp ||
50 op->getNumResults() == 0 &&
51 "cannot erase operation without result value replacements");
52 op->erase();
53 });
54}
assert(baseType &&"element must be base type")
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition rtg.py:1