CIRCT  19.0.0git
IbisPassPipelines.cpp
Go to the documentation of this file.
1 //===- IbisPassPipelines.cpp - Ibis pass pipelines ------------------------===//
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 
13 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
14 #include "mlir/Transforms/Passes.h"
15 
16 using namespace mlir;
17 using namespace circt;
18 using namespace ibis;
19 
20 /// Create a simple canonicalizer pass.
21 static std::unique_ptr<Pass> createSimpleCanonicalizerPass() {
22  mlir::GreedyRewriteConfig config;
23  config.useTopDownTraversal = true;
24  config.enableRegionSimplification = false;
25  return mlir::createCanonicalizerPass(config);
26 }
27 
28 void circt::ibis::loadIbisLowLevelPassPipeline(mlir::PassManager &pm) {
29  // Inner ref: We create an inner ref verification pass to initially validate
30  // the IR, as well as after all structure-changing passes.
31  // In the future, could consider hiding this behind a flag to reduce overhead.
33  pm.nest<ibis::DesignOp>().addPass(createContainerizePass());
35 
36  // Pre-tunneling CSE pass. This ensures that duplicate get_port calls are
37  // removed before we start tunneling - no reason to tunnel the same thing
38  // twice.
39  pm.addPass(mlir::createCSEPass());
40  pm.nest<DesignOp>().addPass(
41  createTunnelingPass(IbisTunnelingOptions{"", ""}));
43  pm.addPass(createPortrefLoweringPass());
44  pm.addPass(createSimpleCanonicalizerPass());
45  pm.nest<DesignOp>().addPass(createCleanSelfdriversPass());
46  pm.addPass(createContainersToHWPass());
48 }
49 
50 void circt::ibis::loadIbisHighLevelPassPipeline(mlir::PassManager &pm) {
51  pm.nest<ibis::DesignOp>()
52  .nest<ibis::ClassOp>()
53  .nest<ibis::MethodOp>()
55  pm.addPass(mlir::createMem2Reg());
56 
57  // TODO @mortbopet: Add a verification pass to ensure that there are no more
58  // memref.alloca's - we want all memories to be mem2reg'able, unless they are
59  // member variable accesses.
60  // - just add it as an illegal op.
61 
62  // Now, perform SSA maximizations.
63  pm.addPass(circt::createMaximizeSSAPass());
64 
65  // SSA maximal form achieved. Reconstruct the Ibis sblocks.
66  pm.nest<ibis::DesignOp>()
67  .nest<ibis::ClassOp>()
68  .nest<ibis::MethodOp>()
69  .addPass(ibis::createReblockPass());
70  pm.addPass(ibis::createArgifyBlocksPass());
71  pm.addPass(createSimpleCanonicalizerPass());
72 }
static std::unique_ptr< Pass > createSimpleCanonicalizerPass()
Create a simple canonicalizer pass.
std::unique_ptr< mlir::Pass > createVerifyInnerRefNamespacePass()
std::unique_ptr< mlir::Pass > createReblockPass()
std::unique_ptr< mlir::Pass > createInlineSBlocksPass()
std::unique_ptr< mlir::Pass > createTunnelingPass(const IbisTunnelingOptions &={})
void loadIbisHighLevelPassPipeline(mlir::PassManager &pm)
void loadIbisLowLevelPassPipeline(mlir::PassManager &pm)
std::unique_ptr< mlir::Pass > createCleanSelfdriversPass()
std::unique_ptr< mlir::Pass > createContainerizePass()
std::unique_ptr< mlir::Pass > createArgifyBlocksPass()
std::unique_ptr< mlir::Pass > createContainersToHWPass()
std::unique_ptr< mlir::Pass > createPortrefLoweringPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
std::unique_ptr< mlir::Pass > createMaximizeSSAPass()