From 1fbb484ea45f85740b7450b175096e5fcff6ecd9 Mon Sep 17 00:00:00 2001 From: Julian Gross Date: Fri, 7 May 2021 12:38:12 +0200 Subject: [PATCH] [WIP][mlir] Resolve memref dependency in canonicalize pass. Splitting the memref dialect lead to an introduction of several dependencies to avoid compilation issues. The canonicalize pass also depends on the memref dialect, but it shouldn't. This patch resolves the dependencies and the unintuitive includes are removed. However, the dependency moves to the constructor of the std dialect. Differential Revision: https://reviews.llvm.org/D102060 --- mlir/include/mlir/Dialect/StandardOps/IR/Ops.h | 1 + mlir/include/mlir/Dialect/StandardOps/IR/Ops.td | 3 +++ mlir/include/mlir/Transforms/Passes.td | 1 - mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 1 - .../lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp | 1 - mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp | 1 - mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp | 1 - mlir/lib/Transforms/Canonicalizer.cpp | 1 - 8 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h index 56478b273484..7d3c72349bf8 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h @@ -14,6 +14,7 @@ #ifndef MLIR_DIALECT_STANDARDOPS_IR_OPS_H #define MLIR_DIALECT_STANDARDOPS_IR_OPS_H +#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Dialect.h" diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index c997ed0d9579..74efd0f7960c 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -27,6 +27,9 @@ def StandardOps_Dialect : Dialect { let name = "std"; let cppNamespace = ""; let hasConstantMaterializer = 1; + // TODO: This dependency is needed to handle memref ops in the + // canonicalize pass and should be resolved. + let dependentDialects = ["memref::MemRefDialect"]; } // Base class for Standard dialect ops. diff --git a/mlir/include/mlir/Transforms/Passes.td b/mlir/include/mlir/Transforms/Passes.td index d14216b24b0d..b833ab47b414 100644 --- a/mlir/include/mlir/Transforms/Passes.td +++ b/mlir/include/mlir/Transforms/Passes.td @@ -362,7 +362,6 @@ def Canonicalizer : Pass<"canonicalize"> { details. }]; let constructor = "mlir::createCanonicalizerPass()"; - let dependentDialects = ["memref::MemRefDialect"]; } def CSE : Pass<"cse"> { diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index e96934088f61..8471de0a0415 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -18,7 +18,6 @@ #include "mlir/Dialect/GPU/Passes.h" #include "mlir/Dialect/LLVMIR/NVVMDialect.h" #include "mlir/Dialect/Math/IR/Math.h" -#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/IR/BlockAndValueMapping.h" #include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp index 851ec5051a6b..01ff9b1974d4 100644 --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -23,7 +23,6 @@ #include "mlir/Analysis/Utils.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/Affine/Passes.h" -#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "mlir/Transforms/LoopUtils.h" diff --git a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp index 9ee807589242..126041a6e9f7 100644 --- a/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Bufferize.cpp @@ -8,7 +8,6 @@ #include "mlir/Transforms/Bufferize.h" #include "PassDetail.h" -#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/Passes.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/SCF/Transforms.h" diff --git a/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp index ea2f97d7d056..95bc5457933e 100644 --- a/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/Bufferize.cpp @@ -8,7 +8,6 @@ #include "mlir/Transforms/Bufferize.h" #include "PassDetail.h" -#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/Shape/Transforms/Passes.h" #include "mlir/Pass/Pass.h" diff --git a/mlir/lib/Transforms/Canonicalizer.cpp b/mlir/lib/Transforms/Canonicalizer.cpp index 2d987778f22f..27a0fe57c04b 100644 --- a/mlir/lib/Transforms/Canonicalizer.cpp +++ b/mlir/lib/Transforms/Canonicalizer.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "PassDetail.h" -#include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "mlir/Transforms/Passes.h"