[Mlir-commits] [mlir] fcb0294 - Revert "[mlir][conversion] NFC - Relax convert-cf-to-llvm and finalize-memref-to-llvm to also work on non-builtin module ops"
Alex Zinenko
llvmlistbot at llvm.org
Fri Aug 4 06:30:21 PDT 2023
Author: Alex Zinenko
Date: 2023-08-04T13:30:13Z
New Revision: fcb0294b587e58e64503a7738a832fd00ab1c08b
URL: https://github.com/llvm/llvm-project/commit/fcb0294b587e58e64503a7738a832fd00ab1c08b
DIFF: https://github.com/llvm/llvm-project/commit/fcb0294b587e58e64503a7738a832fd00ab1c08b.diff
LOG: Revert "[mlir][conversion] NFC - Relax convert-cf-to-llvm and finalize-memref-to-llvm to also work on non-builtin module ops"
This reverts commit cc6b8d8077699916728053dfa760e69e146271cb.
Seems to have been committed accidentally.
Added:
Modified:
mlir/include/mlir/Conversion/Passes.td
mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 382565b59a45ae..9608d771a5dd52 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -249,7 +249,7 @@ def ConvertComplexToStandard : Pass<"convert-complex-to-standard"> {
// ControlFlowToLLVM
//===----------------------------------------------------------------------===//
-def ConvertControlFlowToLLVMPass : Pass<"convert-cf-to-llvm"> {
+def ConvertControlFlowToLLVMPass : Pass<"convert-cf-to-llvm", "ModuleOp"> {
let summary = "Convert ControlFlow operations to the LLVM dialect";
let description = [{
Convert ControlFlow operations into LLVM IR dialect operations.
@@ -257,16 +257,6 @@ def ConvertControlFlowToLLVMPass : Pass<"convert-cf-to-llvm"> {
If other operations are present and their results are required by the LLVM
IR dialect operations, the pass will fail. Any LLVM IR operations or types
already present in the IR will be kept as is.
-
- This pass is not restricted to run to any op but certain conversions are
- omitted when the pass is run on a non-builtin ModuleOp. The omitted
- conversions are the ones that assume a ModuleOp is accessible, for
- manipulating its symbol table (for the purpose of calling into external
- libraries), namely:
- 1. cf.assert lowering
-
- Such decoupling of partial lowerings is particularly useful in the context
- of accelerators that may depend on custom module operations.
}];
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
@@ -655,25 +645,15 @@ def ConvertMathToFuncs : Pass<"convert-math-to-funcs", "ModuleOp"> {
// MemRefToLLVM
//===----------------------------------------------------------------------===//
-def FinalizeMemRefToLLVMConversionPass : Pass<"finalize-memref-to-llvm"> {
+def FinalizeMemRefToLLVMConversionPass :
+ Pass<"finalize-memref-to-llvm", "ModuleOp"> {
let summary = "Finalize MemRef dialect to LLVM dialect conversion";
let description = [{
- Finalize the conversion of the operations from the MemRef dialect to the
- LLVM dialect.
- This conversion will not convert some complex MemRef operations. Make sure
- to run `expand-strided-metadata` beforehand for these.
-
- This pass is not restricted to run to any op but certain conversions are
- omitted when the pass is run on a non-builtin ModuleOp. The omitted
- conversions are the ones that assume a ModuleOp is accessible, for
- manipulating its symbol table (for the purpose of calling into external
- libraries), namely:
- 1. memref.copy lowering
- 2. memref.alloc lowering
- 3. memref.dealloc lowering
-
- Such decoupling of partial lowerings is particularly useful in the context
- of accelerators that may depend on custom module operations.
+ Finalize the conversion of the operations from the MemRef
+ dialect to the LLVM dialect.
+ This conversion will not convert some complex MemRef
+ operations. Make sure to run `expand-strided-metadata`
+ beforehand for these.
}];
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
index ee221c16d246c9..f58f9b4761ad8a 100644
--- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
+++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
@@ -240,25 +240,17 @@ struct SwitchOpLowering : public ConvertOpToLLVMPattern<cf::SwitchOp> {
} // namespace
-static void populateModuleIndependentControlFlowToLLVMConversionPatterns(
+void mlir::cf::populateControlFlowToLLVMConversionPatterns(
LLVMTypeConverter &converter, RewritePatternSet &patterns) {
// clang-format off
patterns.add<
+ AssertOpLowering,
BranchOpLowering,
CondBranchOpLowering,
SwitchOpLowering>(converter);
// clang-format on
}
-void mlir::cf::populateControlFlowToLLVMConversionPatterns(
- LLVMTypeConverter &converter, RewritePatternSet &patterns) {
- // clang-format off
- patterns.add<AssertOpLowering>(converter);
- // clang-format on
- populateModuleIndependentControlFlowToLLVMConversionPatterns(converter,
- patterns);
-}
-
void mlir::cf::populateAssertToLLVMConversionPattern(
LLVMTypeConverter &converter, RewritePatternSet &patterns,
bool abortOnFailure) {
@@ -287,13 +279,8 @@ struct ConvertControlFlowToLLVM
options.useOpaquePointers = useOpaquePointers;
LLVMTypeConverter converter(&getContext(), options);
- if (isa<ModuleOp>(getOperation())) {
- mlir::cf::populateControlFlowToLLVMConversionPatterns(converter,
- patterns);
- } else {
- populateModuleIndependentControlFlowToLLVMConversionPatterns(converter,
- patterns);
- }
+ mlir::cf::populateControlFlowToLLVMConversionPatterns(converter, patterns);
+
if (failed(applyPartialConversion(getOperation(), target,
std::move(patterns))))
signalPassFailure();
diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
index 55372b9c9c1248..d69ee3ff82220e 100644
--- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
+++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
@@ -1865,7 +1865,7 @@ class ExtractStridedMetadataOpLowering
} // namespace
-static void populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
+void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
LLVMTypeConverter &converter, RewritePatternSet &patterns) {
// clang-format off
patterns.add<
@@ -1881,6 +1881,7 @@ static void populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
GetGlobalMemrefOpLowering,
LoadOpLowering,
MemRefCastOpLowering,
+ MemRefCopyOpLowering,
MemorySpaceCastOpLowering,
MemRefReinterpretCastOpLowering,
MemRefReshapeOpLowering,
@@ -1893,15 +1894,6 @@ static void populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
TransposeOpLowering,
ViewOpLowering>(converter);
// clang-format on
-}
-
-void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
- LLVMTypeConverter &converter, RewritePatternSet &patterns) {
- // clang-format off
- patterns.add<
- MemRefCopyOpLowering>(converter);
- // clang-format on
-
auto allocLowering = converter.getOptions().allocLowering;
if (allocLowering == LowerToLLVMOptions::AllocLowering::AlignedAlloc)
patterns.add<AlignedAllocOpLowering, AlignedReallocOpLowering,
@@ -1909,9 +1901,6 @@ void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
else if (allocLowering == LowerToLLVMOptions::AllocLowering::Malloc)
patterns.add<AllocOpLowering, ReallocOpLowering, DeallocOpLowering>(
converter);
-
- populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(converter,
- patterns);
}
namespace {
@@ -1940,12 +1929,6 @@ struct FinalizeMemRefToLLVMConversionPass
&dataLayoutAnalysis);
RewritePatternSet patterns(&getContext());
populateFinalizeMemRefToLLVMConversionPatterns(typeConverter, patterns);
- if (isa<ModuleOp>(getOperation())) {
- populateFinalizeMemRefToLLVMConversionPatterns(typeConverter, patterns);
- } else {
- populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
- typeConverter, patterns);
- }
LLVMConversionTarget target(getContext());
target.addLegalOp<func::FuncOp>();
if (failed(applyPartialConversion(op, target, std::move(patterns))))
More information about the Mlir-commits
mailing list