[PATCH] D139840: [mlir][NFC] Make test-lower-to-llvm a named pipeline
Quentin Colombet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 03:13:46 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9983d213a9c6: [mlir][NFC] Make test-lower-to-llvm a named pipeline (authored by qcolombet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139840/new/
https://reviews.llvm.org/D139840
Files:
mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
Index: mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
===================================================================
--- mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
+++ 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 @@
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 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139840.482781.patch
Type: text/x-patch
Size: 3199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221214/77f6805d/attachment-0001.bin>
More information about the llvm-commits
mailing list