CIRCT  20.0.0git
GoInsertion.cpp
Go to the documentation of this file.
1 //===- GoInsertion.cpp - Go Insertion Pass ----------------------*- 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 //
9 // Contains the definitions of the Go Insertion pass.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 #include "circt/Support/LLVM.h"
17 #include "mlir/IR/BuiltinTypes.h"
18 #include "mlir/IR/OperationSupport.h"
19 
20 namespace circt {
21 namespace calyx {
22 #define GEN_PASS_DEF_GOINSERTION
23 #include "circt/Dialect/Calyx/CalyxPasses.h.inc"
24 } // namespace calyx
25 } // namespace circt
26 
27 using namespace circt;
28 using namespace calyx;
29 using namespace mlir;
30 
31 namespace {
32 
33 struct GoInsertionPass
34  : public circt::calyx::impl::GoInsertionBase<GoInsertionPass> {
35  void runOnOperation() override;
36 };
37 
38 } // end anonymous namespace
39 
40 void GoInsertionPass::runOnOperation() {
41  ComponentOp component = getOperation();
42  auto wiresOp = component.getWiresOp();
43 
44  OpBuilder builder(wiresOp->getRegion(0));
45  auto undefinedOp =
46  builder.create<UndefinedOp>(wiresOp->getLoc(), builder.getI1Type());
47 
48  wiresOp.walk([&](GroupOp group) {
49  OpBuilder builder(group->getRegion(0));
50  // Since the source of a GroupOp's go signal isn't set until the
51  // the Compile Control pass, use an undefined value.
52  auto goOp = builder.create<GroupGoOp>(group->getLoc(), undefinedOp);
53 
54  updateGroupAssignmentGuards(builder, group, goOp);
55  });
56 }
57 
58 std::unique_ptr<mlir::Pass> circt::calyx::createGoInsertionPass() {
59  return std::make_unique<GoInsertionPass>();
60 }
static void updateGroupAssignmentGuards(OpBuilder &builder, GroupOp &group, Op &op)
Updates the guard of each assignment within a group with op.
Definition: CalyxHelpers.h:71
std::unique_ptr< mlir::Pass > createGoInsertionPass()
Definition: GoInsertion.cpp:58
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21