CIRCT 22.0.0git
Loading...
Searching...
No Matches
WrapProceduralOps.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/Dialect/Func/IR/FuncOps.h"
12#include "mlir/Dialect/SCF/IR/SCF.h"
13
14namespace circt {
15namespace llhd {
16#define GEN_PASS_DEF_WRAPPROCEDURALOPSPASS
17#include "circt/Dialect/LLHD/Transforms/LLHDPasses.h.inc"
18} // namespace llhd
19} // namespace circt
20
21using namespace mlir;
22using namespace circt;
23using namespace circt::llhd;
24
25namespace {
26struct WrapProceduralOpsPass
27 : public llhd::impl::WrapProceduralOpsPassBase<WrapProceduralOpsPass> {
28 void runOnOperation() override;
29};
30} // namespace
31
32void WrapProceduralOpsPass::runOnOperation() {
33 for (auto &op : llvm::make_early_inc_range(getOperation().getOps())) {
34 if (!isa<scf::SCFDialect>(op.getDialect()) && !isa<func::CallOp>(op))
35 continue;
36 auto builder = OpBuilder(&op);
37 auto wrapperOp = llhd::CombinationalOp::create(builder, op.getLoc(),
38 op.getResultTypes());
39 op.replaceAllUsesWith(wrapperOp);
40 builder.createBlock(&wrapperOp.getBody());
41 auto yieldOp = llhd::YieldOp::create(builder, op.getLoc(), op.getResults());
42 op.moveBefore(yieldOp);
43 ++numOpsWrapped;
44 }
45}
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.