[Mlir-commits] [mlir] 1bfdf7c - [mlir] [VectorOps] Expose lowering pass options programmatically
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 8 14:58:30 PDT 2020
Author: aartbik
Date: 2020-07-08T14:58:07-07:00
New Revision: 1bfdf7c7e310d69190bbf8c9adcbd853b6b83596
URL: https://github.com/llvm/llvm-project/commit/1bfdf7c7e310d69190bbf8c9adcbd853b6b83596
DIFF: https://github.com/llvm/llvm-project/commit/1bfdf7c7e310d69190bbf8c9adcbd853b6b83596.diff
LOG: [mlir] [VectorOps] Expose lowering pass options programmatically
The ConvertVectorToLLVM pass defines options that can be passed
on the command line (currently only reassociation of FP reductions
through -convert-vector-to-llvm='reassociate-fp-reductions). This
CL enables setting these options programmatically (forward looking
to more options than just reassociation, as well as setting the
values from code rather than command line).
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D83420
Added:
Modified:
mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
index cdff18802616..82aa8287d90f 100644
--- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
+++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
@@ -16,6 +16,18 @@ class ModuleOp;
template <typename T>
class OperationPass;
+/// Options to control Vector to LLVM lowering.
+///
+/// This should kept in sync with VectorToLLVM options defined for the
+/// ConvertVectorToLLVM pass in include/mlir/Conversion/Passes.td
+struct LowerVectorToLLVMOptions {
+ bool reassociateFPReductions = false;
+ LowerVectorToLLVMOptions &setReassociateFPReductions(bool r) {
+ reassociateFPReductions = r;
+ return *this;
+ }
+};
+
/// Collect a set of patterns to convert from Vector contractions to LLVM Matrix
/// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics
/// will be needed when invoking LLVM.
@@ -28,7 +40,8 @@ void populateVectorToLLVMConversionPatterns(
bool reassociateFPReductions = false);
/// Create a pass to convert vector operations to the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertVectorToLLVMPass();
+std::unique_ptr<OperationPass<ModuleOp>> createConvertVectorToLLVMPass(
+ const LowerVectorToLLVMOptions &options = LowerVectorToLLVMOptions());
} // namespace mlir
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 9a66dafc345a..96a8fa4c6f22 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -1180,6 +1180,9 @@ void mlir::populateVectorToLLVMMatrixConversionPatterns(
namespace {
struct LowerVectorToLLVMPass
: public ConvertVectorToLLVMBase<LowerVectorToLLVMPass> {
+ LowerVectorToLLVMPass(const LowerVectorToLLVMOptions &options) {
+ this->reassociateFPReductions = options.reassociateFPReductions;
+ }
void runOnOperation() override;
};
} // namespace
@@ -1210,6 +1213,7 @@ void LowerVectorToLLVMPass::runOnOperation() {
}
}
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertVectorToLLVMPass() {
- return std::make_unique<LowerVectorToLLVMPass>();
+std::unique_ptr<OperationPass<ModuleOp>>
+mlir::createConvertVectorToLLVMPass(const LowerVectorToLLVMOptions &options) {
+ return std::make_unique<LowerVectorToLLVMPass>(options);
}
More information about the Mlir-commits
mailing list