@@ -468,7 +468,7 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
468
468
469
469
SmallVector<hw::InnerSymAttr> innerSyms;
470
470
SmallVector<RWProbeOp> rwprobes;
471
- for ( auto &op : llvm::make_early_inc_range (*body) ) {
471
+ auto layerBlockWalkResult = layerBlock. walk ([&](Operation *op ) {
472
472
// Record any operations inside the layer block which have inner symbols.
473
473
// Theses may have symbol users which need to be updated.
474
474
if (auto symOp = dyn_cast<hw::InnerSymbolOpInterface>(op))
@@ -488,7 +488,7 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
488
488
if (auto instOp = dyn_cast<InstanceOp>(op)) {
489
489
// Ignore instances which this pass did not create.
490
490
if (!createdInstances.contains (instOp))
491
- continue ;
491
+ return WalkResult::advance () ;
492
492
493
493
LLVM_DEBUG ({
494
494
llvm::dbgs ()
@@ -497,7 +497,7 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
497
497
<< " instance: " << instOp.getName () << " \n " ;
498
498
});
499
499
instOp->moveBefore (layerBlock);
500
- continue ;
500
+ return WalkResult::advance () ;
501
501
}
502
502
503
503
// Handle subfields, subindexes, and subaccesses which are indexing into
@@ -510,24 +510,24 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
510
510
// is exceedingly rare given that subaccesses are almost always unexepcted
511
511
// when this pass runs.)
512
512
if (isa<SubfieldOp, SubindexOp>(op)) {
513
- auto input = op. getOperand (0 );
513
+ auto input = op-> getOperand (0 );
514
514
if (!firrtl::type_cast<FIRRTLBaseType>(input.getType ()).isPassive () &&
515
515
!isAncestorOfValueOwner (layerBlock, input))
516
- op. moveBefore (layerBlock);
517
- continue ;
516
+ op-> moveBefore (layerBlock);
517
+ return WalkResult::advance () ;
518
518
}
519
519
520
520
if (auto subOp = dyn_cast<SubaccessOp>(op)) {
521
521
auto input = subOp.getInput ();
522
522
if (firrtl::type_cast<FIRRTLBaseType>(input.getType ()).isPassive ())
523
- continue ;
523
+ return WalkResult::advance () ;
524
524
525
525
if (!isAncestorOfValueOwner (layerBlock, input) &&
526
526
!isAncestorOfValueOwner (layerBlock, subOp.getIndex ())) {
527
527
subOp->moveBefore (layerBlock);
528
- continue ;
528
+ return WalkResult::advance () ;
529
529
}
530
- auto diag = op. emitOpError ()
530
+ auto diag = op-> emitOpError ()
531
531
<< " has a non-passive operand and captures a value defined "
532
532
" outside its enclosing bind-convention layerblock. The "
533
533
" 'LowerLayers' pass cannot lower this as it would "
@@ -539,7 +539,7 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
539
539
540
540
if (auto rwprobe = dyn_cast<RWProbeOp>(op)) {
541
541
rwprobes.push_back (rwprobe);
542
- continue ;
542
+ return WalkResult::advance () ;
543
543
}
544
544
545
545
if (auto connect = dyn_cast<FConnectLike>(op)) {
@@ -549,22 +549,22 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
549
549
auto dstInLayerBlock = isAncestorOfValueOwner (layerBlock, dst);
550
550
if (!srcInLayerBlock && !dstInLayerBlock) {
551
551
connect->moveBefore (layerBlock);
552
- continue ;
552
+ return WalkResult::advance () ;
553
553
}
554
554
// Create an input port.
555
555
if (!srcInLayerBlock) {
556
- createInputPort (src, op. getLoc ());
557
- continue ;
556
+ createInputPort (src, op-> getLoc ());
557
+ return WalkResult::advance () ;
558
558
}
559
559
// Create an output port.
560
560
if (!dstInLayerBlock) {
561
561
createOutputPort (dst, src);
562
562
if (!isa<RefType>(dst.getType ()))
563
563
connect.erase ();
564
- continue ;
564
+ return WalkResult::advance () ;
565
565
}
566
566
// Source and destination in layer block. Nothing to do.
567
- continue ;
567
+ return WalkResult::advance () ;
568
568
}
569
569
570
570
// Pre-emptively de-squiggle connections that we are creating. This will
@@ -587,15 +587,20 @@ LogicalResult LowerLayersPass::runOnModuleBody(FModuleOp moduleOp,
587
587
*refResolve.getResult ().getUsers ().begin ()))
588
588
if (connect.getDest ().getParentBlock () != body) {
589
589
refResolve->moveBefore (layerBlock);
590
- continue ;
590
+ return WalkResult::advance () ;
591
591
}
592
592
593
593
// For any other ops, create input ports for any captured operands.
594
- for (auto operand : op. getOperands ()) {
594
+ for (auto operand : op-> getOperands ()) {
595
595
if (!isAncestorOfValueOwner (layerBlock, operand))
596
- createInputPort (operand, op. getLoc ());
596
+ createInputPort (operand, op-> getLoc ());
597
597
}
598
- }
598
+
599
+ return WalkResult::advance ();
600
+ });
601
+
602
+ if (layerBlockWalkResult.wasInterrupted ())
603
+ return WalkResult::interrupt ();
599
604
600
605
// Create the new module. This grabs a lock to modify the circuit.
601
606
FModuleOp newModule = buildNewModule (builder, layerBlock, ports);
0 commit comments