diff --git a/lib/Dialect/CGGI/Transforms/ExpandLUT.cpp b/lib/Dialect/CGGI/Transforms/ExpandLUT.cpp index 066c1ecd1..06f113389 100644 --- a/lib/Dialect/CGGI/Transforms/ExpandLUT.cpp +++ b/lib/Dialect/CGGI/Transforms/ExpandLUT.cpp @@ -68,7 +68,9 @@ struct ExpandLUT : impl::ExpandLUTBase { alignment::populateWithGenerated(patterns); patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/LinAlg/Conversions/LinalgToTensorExt/LinalgToTensorExt.cpp b/lib/Dialect/LinAlg/Conversions/LinalgToTensorExt/LinalgToTensorExt.cpp index 2ee92a798..4f151ea43 100644 --- a/lib/Dialect/LinAlg/Conversions/LinalgToTensorExt/LinalgToTensorExt.cpp +++ b/lib/Dialect/LinAlg/Conversions/LinalgToTensorExt/LinalgToTensorExt.cpp @@ -360,7 +360,9 @@ struct LinalgToTensorExt patterns.add(&solver, context); // Run pattern matching and conversion - if (failed(applyPatternsAndFoldGreedily(module, std::move(patterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(module, std::move(patterns)))) { return signalPassFailure(); } } diff --git a/lib/Dialect/ModArith/Transforms/ConvertToMac.cpp b/lib/Dialect/ModArith/Transforms/ConvertToMac.cpp index 5aebf02d7..296b8909f 100644 --- a/lib/Dialect/ModArith/Transforms/ConvertToMac.cpp +++ b/lib/Dialect/ModArith/Transforms/ConvertToMac.cpp @@ -59,7 +59,9 @@ struct ConvertToMac : impl::ConvertToMacBase { patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/Polynomial/Transforms/NTTRewrites.cpp b/lib/Dialect/Polynomial/Transforms/NTTRewrites.cpp index dd839314c..1fef82122 100644 --- a/lib/Dialect/Polynomial/Transforms/NTTRewrites.cpp +++ b/lib/Dialect/Polynomial/Transforms/NTTRewrites.cpp @@ -23,7 +23,9 @@ struct PolyMulToNTT : impl::PolyMulToNTTBase { RewritePatternSet patterns(context); // TODO(#1095): migrate to mod arith type // patterns.add(patterns.getContext()); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/Secret/Conversions/SecretToCGGI/SecretToCGGI.cpp b/lib/Dialect/Secret/Conversions/SecretToCGGI/SecretToCGGI.cpp index f7b44b883..55cbab0a2 100644 --- a/lib/Dialect/Secret/Conversions/SecretToCGGI/SecretToCGGI.cpp +++ b/lib/Dialect/Secret/Conversions/SecretToCGGI/SecretToCGGI.cpp @@ -713,8 +713,9 @@ struct SecretToCGGI : public impl::SecretToCGGIBase { RewritePatternSet cleanupPatterns(context); patterns.add(context); - if (failed( - applyPatternsAndFoldGreedily(module, std::move(cleanupPatterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(module, std::move(cleanupPatterns)))) { return signalPassFailure(); } } diff --git a/lib/Dialect/Secret/Transforms/CaptureGenericAmbientScope.cpp b/lib/Dialect/Secret/Transforms/CaptureGenericAmbientScope.cpp index cb003c639..04a6bd006 100644 --- a/lib/Dialect/Secret/Transforms/CaptureGenericAmbientScope.cpp +++ b/lib/Dialect/Secret/Transforms/CaptureGenericAmbientScope.cpp @@ -24,7 +24,9 @@ struct CaptureGenericAmbientScope mlir::RewritePatternSet patterns(context); patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/Secret/Transforms/DistributeGeneric.cpp b/lib/Dialect/Secret/Transforms/DistributeGeneric.cpp index 529f2577b..d0f3e9834 100644 --- a/lib/Dialect/Secret/Transforms/DistributeGeneric.cpp +++ b/lib/Dialect/Secret/Transforms/DistributeGeneric.cpp @@ -660,7 +660,9 @@ struct DistributeGeneric // These patterns are shared with canonicalization patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); // used by secret-to- lowering moveMgmtAttrAnnotationFromInnerToOuter(getOperation()); diff --git a/lib/Dialect/Secret/Transforms/MergeAdjacentGenerics.cpp b/lib/Dialect/Secret/Transforms/MergeAdjacentGenerics.cpp index a3f544917..15891c876 100644 --- a/lib/Dialect/Secret/Transforms/MergeAdjacentGenerics.cpp +++ b/lib/Dialect/Secret/Transforms/MergeAdjacentGenerics.cpp @@ -23,7 +23,9 @@ struct MergeAdjacentGenericsPass mlir::RewritePatternSet patterns(context); patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/TOSA/Conversions/TosaToSecretArith/TosaToSecretArith.cpp b/lib/Dialect/TOSA/Conversions/TosaToSecretArith/TosaToSecretArith.cpp index a87f4164b..aa66403f3 100644 --- a/lib/Dialect/TOSA/Conversions/TosaToSecretArith/TosaToSecretArith.cpp +++ b/lib/Dialect/TOSA/Conversions/TosaToSecretArith/TosaToSecretArith.cpp @@ -141,7 +141,9 @@ struct TosaToSecretArith patterns.add(&solver, context); // Run pattern matching and conversion - if (failed(applyPatternsAndFoldGreedily(module, std::move(patterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(module, std::move(patterns)))) { return signalPassFailure(); } } diff --git a/lib/Dialect/TensorExt/Transforms/CollapseInsertionChains.cpp b/lib/Dialect/TensorExt/Transforms/CollapseInsertionChains.cpp index 952d9d1ea..5f9471ad5 100644 --- a/lib/Dialect/TensorExt/Transforms/CollapseInsertionChains.cpp +++ b/lib/Dialect/TensorExt/Transforms/CollapseInsertionChains.cpp @@ -181,7 +181,9 @@ struct CollapseInsertionChains RewritePatternSet patterns(context); patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Dialect/TensorExt/Transforms/InsertRotate.cpp b/lib/Dialect/TensorExt/Transforms/InsertRotate.cpp index 4e10eb9db..fe0c68797 100644 --- a/lib/Dialect/TensorExt/Transforms/InsertRotate.cpp +++ b/lib/Dialect/TensorExt/Transforms/InsertRotate.cpp @@ -91,7 +91,9 @@ struct InsertRotate : impl::InsertRotateBase { alignment::populateWithGenerated(patterns); canonicalization::populateWithGenerated(patterns); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/ApplyFolders/ApplyFolders.cpp b/lib/Transforms/ApplyFolders/ApplyFolders.cpp index f98d54474..1dd1ebcce 100644 --- a/lib/Transforms/ApplyFolders/ApplyFolders.cpp +++ b/lib/Transforms/ApplyFolders/ApplyFolders.cpp @@ -24,7 +24,9 @@ struct ApplyFolders : impl::ApplyFoldersBase { [](tensor::ExtractSliceOp op) { return true; }; tensor::populateFoldConstantExtractSlicePatterns(patterns, controlFn); // Use the greedy pattern driver to apply folders. - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/ConvertIfToSelect/ConvertIfToSelect.cpp b/lib/Transforms/ConvertIfToSelect/ConvertIfToSelect.cpp index 09c4ffc68..cae4c695c 100644 --- a/lib/Transforms/ConvertIfToSelect/ConvertIfToSelect.cpp +++ b/lib/Transforms/ConvertIfToSelect/ConvertIfToSelect.cpp @@ -125,7 +125,9 @@ struct ConvertIfToSelect : impl::ConvertIfToSelectBase { } patterns.add(getOperation(), &solver, context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); LLVM_DEBUG({ annotateSecretness(getOperation(), &solver); }); } diff --git a/lib/Transforms/ConvertSecretExtractToStaticExtract/ConvertSecretExtractToStaticExtract.cpp b/lib/Transforms/ConvertSecretExtractToStaticExtract/ConvertSecretExtractToStaticExtract.cpp index 6a8111042..ab7e0db49 100644 --- a/lib/Transforms/ConvertSecretExtractToStaticExtract/ConvertSecretExtractToStaticExtract.cpp +++ b/lib/Transforms/ConvertSecretExtractToStaticExtract/ConvertSecretExtractToStaticExtract.cpp @@ -185,7 +185,9 @@ struct ConvertSecretExtractToStaticExtract patterns.add(getOperation(), &solver, context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); LLVM_DEBUG({ annotateSecretness(getOperation(), &solver); }); } diff --git a/lib/Transforms/ConvertSecretForToStaticFor/ConvertSecretForToStaticFor.cpp b/lib/Transforms/ConvertSecretForToStaticFor/ConvertSecretForToStaticFor.cpp index 141118daa..4f9c81e06 100644 --- a/lib/Transforms/ConvertSecretForToStaticFor/ConvertSecretForToStaticFor.cpp +++ b/lib/Transforms/ConvertSecretForToStaticFor/ConvertSecretForToStaticFor.cpp @@ -193,7 +193,9 @@ struct ConvertSecretForToStaticFor } patterns.add(&solver, context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/ConvertSecretInsertToStaticInsert/ConvertSecretInsertToStaticInsert.cpp b/lib/Transforms/ConvertSecretInsertToStaticInsert/ConvertSecretInsertToStaticInsert.cpp index 514fe5b01..b7b07815c 100644 --- a/lib/Transforms/ConvertSecretInsertToStaticInsert/ConvertSecretInsertToStaticInsert.cpp +++ b/lib/Transforms/ConvertSecretInsertToStaticInsert/ConvertSecretInsertToStaticInsert.cpp @@ -170,7 +170,9 @@ struct ConvertSecretInsertToStaticInsert patterns.add(getOperation(), &solver, context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); LLVM_DEBUG({ annotateSecretness(getOperation(), &solver); }); } diff --git a/lib/Transforms/ConvertSecretWhileToStaticFor/ConvertSecretWhileToStaticFor.cpp b/lib/Transforms/ConvertSecretWhileToStaticFor/ConvertSecretWhileToStaticFor.cpp index 79e6baf40..bd04586d1 100644 --- a/lib/Transforms/ConvertSecretWhileToStaticFor/ConvertSecretWhileToStaticFor.cpp +++ b/lib/Transforms/ConvertSecretWhileToStaticFor/ConvertSecretWhileToStaticFor.cpp @@ -177,7 +177,9 @@ struct ConvertSecretWhileToStaticFor } patterns.add(&solver, context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/ForwardInsertToExtract/ForwardInsertToExtract.cpp b/lib/Transforms/ForwardInsertToExtract/ForwardInsertToExtract.cpp index 432b14fd2..ab1bbc243 100644 --- a/lib/Transforms/ForwardInsertToExtract/ForwardInsertToExtract.cpp +++ b/lib/Transforms/ForwardInsertToExtract/ForwardInsertToExtract.cpp @@ -122,7 +122,9 @@ struct ForwardInsertToExtract RewritePatternSet patterns(context); DominanceInfo dom(getOperation()); patterns.add(context, dom); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/ForwardStoreToLoad/ForwardStoreToLoad.cpp b/lib/Transforms/ForwardStoreToLoad/ForwardStoreToLoad.cpp index f89f44e32..e348e5557 100644 --- a/lib/Transforms/ForwardStoreToLoad/ForwardStoreToLoad.cpp +++ b/lib/Transforms/ForwardStoreToLoad/ForwardStoreToLoad.cpp @@ -235,7 +235,9 @@ struct ForwardStoreToLoad : impl::ForwardStoreToLoadBase { DominanceInfo dom(getOperation()); patterns.add(context); patterns.add(context, dom); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/LinalgCanonicalizations/LinalgCanonicalizations.cpp b/lib/Transforms/LinalgCanonicalizations/LinalgCanonicalizations.cpp index 327a3b80c..a86d328d6 100644 --- a/lib/Transforms/LinalgCanonicalizations/LinalgCanonicalizations.cpp +++ b/lib/Transforms/LinalgCanonicalizations/LinalgCanonicalizations.cpp @@ -175,7 +175,9 @@ struct LinalgCanonicalizations patterns.add(context); // Run pattern matching and conversion - if (failed(applyPatternsAndFoldGreedily(module, std::move(patterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(module, std::move(patterns)))) { return signalPassFailure(); } } diff --git a/lib/Transforms/MemrefToArith/ExpandCopy.cpp b/lib/Transforms/MemrefToArith/ExpandCopy.cpp index 627af1e6c..56121a967 100644 --- a/lib/Transforms/MemrefToArith/ExpandCopy.cpp +++ b/lib/Transforms/MemrefToArith/ExpandCopy.cpp @@ -104,8 +104,9 @@ struct ExpandCopyPass : impl::ExpandCopyPassBase { mlir::RewritePatternSet patterns(&getContext()); patterns.add(&getContext(), disableAffineLoop); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns), - config); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns), config); } }; diff --git a/lib/Transforms/TensorToScalars/TensorToScalars.cpp b/lib/Transforms/TensorToScalars/TensorToScalars.cpp index 273f176c0..2e7e91d11 100644 --- a/lib/Transforms/TensorToScalars/TensorToScalars.cpp +++ b/lib/Transforms/TensorToScalars/TensorToScalars.cpp @@ -150,8 +150,9 @@ struct TensorToScalars : impl::TensorToScalarsBase { // Empty PatternSet = only run folders (should never fail) RewritePatternSet emptyPatterns(context); - (void)applyPatternsAndFoldGreedily(getOperation(), - std::move(emptyPatterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(emptyPatterns)); } }; diff --git a/lib/Transforms/UnusedMemRef/UnusedMemRef.cpp b/lib/Transforms/UnusedMemRef/UnusedMemRef.cpp index 2fdcc322f..e4edc9857 100644 --- a/lib/Transforms/UnusedMemRef/UnusedMemRef.cpp +++ b/lib/Transforms/UnusedMemRef/UnusedMemRef.cpp @@ -43,7 +43,9 @@ struct RemoveUnusedMemRef MLIRContext* context = &getContext(); RewritePatternSet patterns(context); patterns.add(context); - (void)applyPatternsAndFoldGreedily(getOperation(), std::move(patterns)); + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + (void)applyPatternsGreedily(getOperation(), std::move(patterns)); } }; diff --git a/lib/Transforms/YosysOptimizer/YosysOptimizer.cpp b/lib/Transforms/YosysOptimizer/YosysOptimizer.cpp index 90ee1c405..30e1f039a 100644 --- a/lib/Transforms/YosysOptimizer/YosysOptimizer.cpp +++ b/lib/Transforms/YosysOptimizer/YosysOptimizer.cpp @@ -385,7 +385,9 @@ LogicalResult unrollAndMergeGenerics(Operation *op, int unrollFactor, mlir::RewritePatternSet patterns(op->getContext()); patterns.add( op->getContext(), innerMostLoop); - if (failed(applyPatternsAndFoldGreedily(op, std::move(patterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be + // skipped here. + if (failed(applyPatternsGreedily(op, std::move(patterns)))) { return WalkResult::interrupt(); } @@ -589,7 +591,9 @@ void YosysOptimizer::runOnOperation() { } secret::populateGenericCanonicalizers(cleanupPatterns, ctx); - if (failed(applyPatternsAndFoldGreedily(op, std::move(cleanupPatterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(op, std::move(cleanupPatterns)))) { signalPassFailure(); getOperation()->emitError() << "Failed to cleanup generic ops"; return; @@ -601,7 +605,9 @@ void YosysOptimizer::runOnOperation() { // generic inputs is an easy way to do that. mlir::RewritePatternSet patterns(ctx); patterns.add(ctx); - if (failed(applyPatternsAndFoldGreedily(op, std::move(patterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(op, std::move(patterns)))) { signalPassFailure(); getOperation()->emitError() << "Failed to preprocess generic ops before yosys optimizer"; @@ -636,7 +642,9 @@ void YosysOptimizer::runOnOperation() { // Merge generics after the function bodies are extracted. mlir::RewritePatternSet mergePatterns(ctx); mergePatterns.add(ctx); - if (failed(applyPatternsAndFoldGreedily(op, std::move(mergePatterns)))) { + // TODO (#1221): Investigate whether folding (default: on) can be skipped + // here. + if (failed(applyPatternsGreedily(op, std::move(mergePatterns)))) { signalPassFailure(); getOperation()->emitError() << "Failed to merge generic ops before yosys optimizer";