16 #include "mlir/IR/Dominance.h"
17 #include "mlir/Interfaces/ControlFlowInterfaces.h"
18 #include "mlir/Interfaces/SideEffectInterfaces.h"
19 #include "mlir/Transforms/ControlFlowSinkUtils.h"
21 #define DEBUG_TYPE "firrtl-layer-sink"
23 using namespace circt;
24 using namespace firrtl;
28 struct LayerSink :
public LayerSinkBase<LayerSink> {
29 void runOnOperation()
override;
33 void LayerSink::runOnOperation() {
36 <<
"Module: '" << getOperation().
getName() <<
"'\n";);
37 auto &domInfo = getAnalysis<mlir::DominanceInfo>();
38 getOperation()->walk([&](LayerBlockOp layerBlock) {
39 SmallVector<Region *> regionsToSink({&layerBlock.getRegion()});
40 numSunk = controlFlowSink(
41 regionsToSink, domInfo,
42 [](Operation *op, Region *) {
return !
hasDontTouch(op); },
43 [](Operation *op, Region *region) {
47 op->moveBefore(®ion->front(), region->front().begin());
53 return std::make_unique<LayerSink>();
bool hasDontTouch(Value value)
Check whether a block argument ("port") or the operation defining a value has a DontTouch annotation,...
std::unique_ptr< mlir::Pass > createLayerSinkPass()
StringAttr getName(ArrayAttr names, size_t idx)
Return the name at the specified index of the ArrayAttr or null if it cannot be determined.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
llvm::raw_ostream & debugPassHeader(const mlir::Pass *pass, int width=80)
Write a boilerplate header for a pass to the debug stream.