CIRCT  20.0.0git
KanagawaPassPipelines.cpp
Go to the documentation of this file.
1 //===- KanagawaPassPipelines.cpp - Kanagawa 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 kanagawa;
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 = mlir::GreedySimplifyRegionLevel::Disabled;
25  return mlir::createCanonicalizerPass(config);
26 }
27 
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<kanagawa::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(KanagawaTunnelingOptions{"", ""}));
43  pm.addPass(createPortrefLoweringPass());
44  pm.addPass(createSimpleCanonicalizerPass());
45  pm.nest<DesignOp>().addPass(createCleanSelfdriversPass());
46  pm.addPass(createContainersToHWPass());
48 }
49 
51  pm.nest<kanagawa::DesignOp>()
52  .nest<kanagawa::ClassOp>()
53  .nest<kanagawa::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 Kanagawa sblocks.
66  pm.nest<kanagawa::DesignOp>()
67  .nest<kanagawa::ClassOp>()
68  .nest<kanagawa::MethodOp>()
69  .addPass(kanagawa::createReblockPass());
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 > createContainersToHWPass()
void loadKanagawaLowLevelPassPipeline(mlir::PassManager &pm)
std::unique_ptr< mlir::Pass > createReblockPass()
std::unique_ptr< mlir::Pass > createInlineSBlocksPass()
std::unique_ptr< mlir::Pass > createArgifyBlocksPass()
std::unique_ptr< mlir::Pass > createContainerizePass()
std::unique_ptr< mlir::Pass > createTunnelingPass(const KanagawaTunnelingOptions &={})
std::unique_ptr< mlir::Pass > createPortrefLoweringPass()
void loadKanagawaHighLevelPassPipeline(mlir::PassManager &pm)
std::unique_ptr< mlir::Pass > createCleanSelfdriversPass()
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
std::unique_ptr< mlir::Pass > createMaximizeSSAPass()