CIRCT 22.0.0git
Loading...
Searching...
No Matches
pipelines.cpp
Go to the documentation of this file.
1//===- pipelines.cpp - Arcilator lowering 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//
9// This file implements the 'arcilator' lowering pipelines.
10//
11//===----------------------------------------------------------------------===//
12
14
28#include "mlir/Transforms/Passes.h"
29
30using namespace mlir;
31using namespace circt;
32using namespace arc;
33
35 OpPassManager &pm, const ArcPreprocessingOptions &options) {
36 pm.addPass(om::createStripOMPass());
37 pm.addPass(emit::createStripEmitPass());
38 pm.addPass(createLowerFirMemPass());
39 pm.addPass(createLowerVerifSimulationsPass());
40 {
41 arc::AddTapsOptions opts;
42 opts.tapPorts = options.observePorts;
43 opts.tapWires = options.observeWires;
44 opts.tapNamedValues = options.observeNamedValues;
45 pm.addPass(arc::createAddTapsPass(opts));
46 }
47 pm.addPass(arc::createStripSVPass());
48 {
49 arc::InferMemoriesOptions opts;
50 opts.tapPorts = options.observePorts;
51 opts.tapMemories = options.observeMemories;
52 pm.addPass(arc::createInferMemoriesPass(opts));
53 }
54 pm.addPass(sim::createLowerDPIFunc());
55 pm.addPass(createCSEPass());
56 pm.addPass(arc::createArcCanonicalizerPass());
57}
58
59void circt::populateArcConversionPipeline(OpPassManager &pm,
60 const ArcConversionOptions &options) {
61 {
62 ConvertToArcsPassOptions opts;
63 opts.tapRegisters = options.observeRegisters;
64 pm.addPass(createConvertToArcsPass(opts));
65 }
66 if (options.shouldDedup)
67 pm.addPass(arc::createDedupPass());
68 pm.addPass(hw::createFlattenModules());
69 pm.addPass(createCSEPass());
70 pm.addPass(arc::createArcCanonicalizerPass());
71}
72
74 OpPassManager &pm, const ArcOptimizationOptions &options) {
75 // Perform arc-level optimizations that are not specific to software
76 // simulation.
77 pm.addPass(arc::createSplitLoopsPass());
78 if (options.shouldDedup)
79 pm.addPass(arc::createDedupPass());
80 {
81 arc::InferStatePropertiesOptions opts;
82 opts.detectEnables = options.shouldDetectEnables;
83 opts.detectResets = options.shouldDetectResets;
84 pm.addPass(arc::createInferStateProperties(opts));
85 }
86 pm.addPass(createCSEPass());
87 pm.addPass(arc::createArcCanonicalizerPass());
88 pm.addNestedPass<hw::HWModuleOp>(arc::createMergeTaps());
89 if (options.shouldMakeLUTs)
90 pm.addPass(arc::createMakeTablesPass());
91 pm.addPass(createCSEPass());
92 pm.addPass(arc::createArcCanonicalizerPass());
93
94 // Now some arguments may be unused because reset conditions are not passed as
95 // inputs anymore pm.addPass(arc::createRemoveUnusedArcArgumentsPass());
96 // Because we replace a lot of StateOp inputs with constants in the enable
97 // patterns we may be able to sink a lot of them
98 // TODO: maybe merge RemoveUnusedArcArguments with SinkInputs?
99 // pm.addPass(arc::createSinkInputsPass());
100 // pm.addPass(createCSEPass());
101 // pm.addPass(createSimpleCanonicalizerPass());
102 // Removing some muxes etc. may lead to additional dedup opportunities
103 // if (options.shouldDedup)
104 // pm.addPass(arc::createDedupPass());
105}
106
108 OpPassManager &pm, const ArcStateLoweringOptions &options) {
109 pm.addPass(arc::createLowerStatePass());
110
111 // TODO: LowerClocksToFuncsPass might not properly consider scf.if operations
112 // (or nested regions in general) and thus errors out when muxes are also
113 // converted in the hw.module or arc.model
114 // TODO: InlineArcs seems to not properly handle scf.if operations, thus the
115 // following is commented out
116 // pm.addPass(arc::createMuxToControlFlowPass());
117 if (options.shouldInline)
118 pm.addPass(arc::createInlineArcsPass());
119
120 pm.addPass(arc::createMergeIfsPass());
121 pm.addPass(createCSEPass());
122 pm.addPass(arc::createArcCanonicalizerPass());
123}
124
126 OpPassManager &pm, const ArcStateAllocationOptions &options) {
127 pm.addPass(arc::createLowerArcsToFuncsPass());
128 pm.nest<arc::ModelOp>().addPass(arc::createAllocateStatePass());
129 pm.addPass(arc::createLowerClocksToFuncsPass()); // no CSE between state alloc
130 // and clock func lowering
131 if (options.splitFuncsThreshold.getNumOccurrences()) {
132 pm.addPass(arc::createSplitFuncs({options.splitFuncsThreshold}));
133 }
134 pm.addPass(createCSEPass());
135 pm.addPass(arc::createArcCanonicalizerPass());
136}
137
138void circt::populateArcToLLVMPipeline(OpPassManager &pm) {
139 pm.addPass(createLowerArcToLLVMPass());
140 pm.addPass(createCSEPass());
141 pm.addPass(arc::createArcCanonicalizerPass());
142}
Definition arc.py:1
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
void populateArcStateLoweringPipeline(mlir::OpPassManager &pm, const ArcStateLoweringOptions &options={})
void populateArcOptimizationPipeline(mlir::OpPassManager &pm, const ArcOptimizationOptions &options={})
void populateArcConversionPipeline(mlir::OpPassManager &pm, const ArcConversionOptions &options={})
std::unique_ptr< mlir::Pass > createLowerFirMemPass()
std::unique_ptr< OperationPass< ModuleOp > > createLowerArcToLLVMPass()
void populateArcPreprocessingPipeline(mlir::OpPassManager &pm, const ArcPreprocessingOptions &options={})
void populateArcToLLVMPipeline(mlir::OpPassManager &pm)
void populateArcStateAllocationPipeline(mlir::OpPassManager &pm, const ArcStateAllocationOptions &options={})
Option< bool > observeRegisters
Definition pipelines.h:50
Option< bool > shouldDedup
Definition pipelines.h:54
Option< bool > shouldMakeLUTs
Definition pipelines.h:77
Option< bool > shouldDetectResets
Definition pipelines.h:72
Option< bool > shouldDetectEnables
Definition pipelines.h:67
Option< bool > observeNamedValues
Definition pipelines.h:35
Option< bool > observeMemories
Definition pipelines.h:40
Option< unsigned > splitFuncsThreshold
Definition pipelines.h:96