Skip to content

Commit

Permalink
Generalize the pass hierarchy by adding a general OpPass<PassT, OpT>.
Browse files Browse the repository at this point in the history
This pass class generalizes the current functionality between FunctionPass and ModulePass, and allows for operating on any operation type. The pass manager currently only supports OpPasses operating on FuncOp and ModuleOp, but this restriction will be relaxed in follow-up changes. A utility class OpPassBase<OpT> allows for generically referring to operation specific passes: e.g. FunctionPassBase == OpPassBase<FuncOp>.

PiperOrigin-RevId: 266442239
  • Loading branch information
River707 authored and tensorflower-gardener committed Aug 30, 2019
1 parent 06e8101 commit 1dd9bf4
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 202 deletions.
4 changes: 3 additions & 1 deletion mlir/examples/Linalg/Linalg1/include/linalg1/Passes.h
Expand Up @@ -27,7 +27,9 @@
#include <limits>

namespace mlir {
class ModulePassBase;
class ModuleOp;
template <typename T> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;
} // namespace mlir

namespace linalg {
Expand Down
4 changes: 3 additions & 1 deletion mlir/examples/Linalg/Linalg3/include/linalg3/Transforms.h
Expand Up @@ -27,9 +27,11 @@ namespace mlir {
class AffineForOp;
class AffineMap;
class FuncOp;
class FunctionPassBase;
class Operation;
class Value;

template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;
} // namespace mlir

namespace linalg {
Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/Analysis/Passes.h
Expand Up @@ -27,7 +27,9 @@

namespace mlir {

class FunctionPassBase;
class FuncOp;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;

/// Creates a pass to check memref accesses in a Function.
FunctionPassBase *createMemRefBoundCheckPass();
Expand Down
Expand Up @@ -23,9 +23,10 @@

namespace mlir {
class FuncOp;
class FunctionPassBase;
struct LogicalResult;
class MLIRContext;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;
class RewritePattern;

// Owning list of rewriting patterns.
Expand Down
5 changes: 4 additions & 1 deletion mlir/include/mlir/Conversion/GPUToCUDA/GPUToCUDAPass.h
Expand Up @@ -27,14 +27,17 @@ namespace mlir {

class FuncOp;
class Location;
class ModulePassBase;
class ModuleOp;
class OpBuilder;
class Value;

namespace LLVM {
class LLVMDialect;
}

template <typename T> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;

using OwnedCubin = std::unique_ptr<std::vector<char>>;
using CubinGenerator = std::function<OwnedCubin(const std::string &, FuncOp &)>;

Expand Down
5 changes: 4 additions & 1 deletion mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
Expand Up @@ -21,9 +21,12 @@

namespace mlir {
class LLVMTypeConverter;
class ModulePassBase;
class OwningRewritePatternList;

class ModuleOp;
template <typename OpT> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;

/// Collect a set of patterns to convert from the GPU dialect to NVVM.
void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
OwningRewritePatternList &patterns);
Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h
Expand Up @@ -20,7 +20,9 @@
#include <memory>

namespace mlir {
class FunctionPassBase;
class FuncOp;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;

/// Create a pass that converts loop nests into GPU kernels. It considers
/// top-level affine.for and linalg.for operations as roots of loop nests and
Expand Down
Expand Up @@ -33,7 +33,8 @@ class LLVMTypeConverter;
struct LogicalResult;
class MLIRContext;
class ModuleOp;
class ModulePassBase;
template <typename T> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;
class RewritePattern;
class Type;

Expand Down
5 changes: 4 additions & 1 deletion mlir/include/mlir/Conversion/VectorToLLVM/VectorToLLVM.h
Expand Up @@ -19,9 +19,12 @@

namespace mlir {
class LLVMTypeConverter;
class ModulePassBase;
class ModuleOp;
class OwningRewritePatternList;

template <typename T> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;

/// Collect a set of patterns to convert from the Vector dialect to LLVM.
void populateVectorToLLVMConversionPatterns(LLVMTypeConverter &converter,
OwningRewritePatternList &patterns);
Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/Dialect/FxpMathOps/Passes.h
Expand Up @@ -23,7 +23,9 @@
#define MLIR_DIALECT_FXPMATHOPS_PASSES_H

namespace mlir {
class FunctionPassBase;
class FuncOp;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;

namespace fxpmath {

Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/Dialect/GPU/Passes.h
Expand Up @@ -26,7 +26,9 @@

namespace mlir {

class ModulePassBase;
class ModuleOp;
template <typename T> class OpPassBase;
using ModulePassBase = OpPassBase<ModuleOp>;

std::unique_ptr<ModulePassBase> createGpuKernelOutliningPass();

Expand Down
7 changes: 5 additions & 2 deletions mlir/include/mlir/Dialect/Linalg/Passes.h
Expand Up @@ -26,8 +26,11 @@
#include "llvm/ADT/ArrayRef.h"

namespace mlir {
class FunctionPassBase;
class ModulePassBase;
class FuncOp;
class ModuleOp;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;
using ModulePassBase = OpPassBase<ModuleOp>;

namespace linalg {
std::unique_ptr<FunctionPassBase>
Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/Dialect/QuantOps/Passes.h
Expand Up @@ -28,7 +28,9 @@
#include <memory>

namespace mlir {
class FunctionPassBase;
class FuncOp;
template <typename T> class OpPassBase;
using FunctionPassBase = OpPassBase<FuncOp>;

namespace quant {

Expand Down

0 comments on commit 1dd9bf4

Please sign in to comment.