[Mlir-commits] [mlir] 9983d21 - [mlir][NFC] Make test-lower-to-llvm a named pipeline
Quentin Colombet
llvmlistbot at llvm.org
Wed Dec 14 03:13:35 PST 2022
Author: Quentin Colombet
Date: 2022-12-14T11:07:35Z
New Revision: 9983d213a9c67f4f92f01247414c9c828400f90b
URL: https://github.com/llvm/llvm-project/commit/9983d213a9c67f4f92f01247414c9c828400f90b
DIFF: https://github.com/llvm/llvm-project/commit/9983d213a9c67f4f92f01247414c9c828400f90b.diff
LOG: [mlir][NFC] Make test-lower-to-llvm a named pipeline
This patch changes the `test-lower-to-llvm` pass into a named pipeline.
The functionality is unchanged but thanks to this change, we don't have
to pull the dependencies of all the passes that this pass calls.
In other words, `TestLowerToLLVMPass::getDependDialects` was supposed to
transitively declare all the dialects that were used in the union of all
the invoked passes.
NFC
Differential Revision: https://reviews.llvm.org/D139840
Added:
Modified:
mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
index f2f2918044cf8..503817f5a42d7 100644
--- a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
+++ b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
@@ -27,43 +27,26 @@
#include "mlir/IR/DialectRegistry.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
+#include "mlir/Pass/PassOptions.h"
#include "mlir/Transforms/Passes.h"
using namespace mlir;
namespace {
-struct TestLowerToLLVM
- : public PassWrapper<TestLowerToLLVM, OperationPass<ModuleOp>> {
- MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLowerToLLVM)
-
- TestLowerToLLVM() = default;
- TestLowerToLLVM(const TestLowerToLLVM &pass) : PassWrapper(pass) {}
-
- StringRef getArgument() const final { return "test-lower-to-llvm"; }
- StringRef getDescription() const final {
- return "Test lowering to LLVM as a generally usable sink pass";
- }
- void getDependentDialects(DialectRegistry ®istry) const override {
- registry.insert<LLVM::LLVMDialect>();
- }
-
- Option<bool> reassociateFPReductions{
+struct TestLowerToLLVMOptions
+ : public PassPipelineOptions<TestLowerToLLVMOptions> {
+ PassOptions::Option<bool> reassociateFPReductions{
*this, "reassociate-fp-reductions",
llvm::cl::desc("Allow reassociation og FP reductions"),
llvm::cl::init(false)};
-
- void runOnOperation() final;
};
-} // namespace
-void TestLowerToLLVM::runOnOperation() {
- MLIRContext *context = &this->getContext();
- RewritePatternSet patterns(context);
+void buildTestLowerToLLVM(OpPassManager &pm,
+ const TestLowerToLLVMOptions &options) {
// TODO: it is feasible to scope lowering at arbitrary level and introduce
// unrealized casts, but there needs to be the final module-wise cleanup in
// the end. Keep module-level for now.
- PassManager pm(&getContext());
// Blanket-convert any remaining high-level vector ops to loops if any remain.
pm.addNestedPass<func::FuncOp>(createConvertVectorToSCFPass());
@@ -82,7 +65,7 @@ void TestLowerToLLVM::runOnOperation() {
pm.addPass(createConvertVectorToLLVMPass(
// TODO: add more options on a per-need basis.
LowerVectorToLLVMOptions().enableReassociateFPReductions(
- reassociateFPReductions)));
+ options.reassociateFPReductions)));
// Convert Math to LLVM (always needed).
pm.addNestedPass<func::FuncOp>(createConvertMathToLLVMPass());
// Convert MemRef to LLVM (always needed).
@@ -93,14 +76,17 @@ void TestLowerToLLVM::runOnOperation() {
pm.addPass(createConvertIndexToLLVMPass());
// Convert remaining unrealized_casts (always needed).
pm.addPass(createReconcileUnrealizedCastsPass());
- if (failed(pm.run(getOperation()))) {
- getOperation()->dump();
- return signalPassFailure();
- }
}
+} // namespace
namespace mlir {
namespace test {
-void registerTestLowerToLLVM() { PassRegistration<TestLowerToLLVM>(); }
+void registerTestLowerToLLVM() {
+ PassPipelineRegistration<TestLowerToLLVMOptions>(
+ "test-lower-to-llvm",
+ "An example of pipeline to lower the main dialects (arith, linalg, "
+ "memref, scf, vector) down to LLVM.",
+ buildTestLowerToLLVM);
+}
} // namespace test
} // namespace mlir
More information about the Mlir-commits
mailing list