Index: mlir/include/mlir/Reducer/CMakeLists.txt =================================================================== --- mlir/include/mlir/Reducer/CMakeLists.txt +++ mlir/include/mlir/Reducer/CMakeLists.txt @@ -1,5 +1,5 @@ set(LLVM_TARGET_DEFINITIONS Passes.td) -mlir_tablegen(Passes.h.inc -gen-pass-decls) +mlir_tablegen(Passes.h.inc -gen-pass-decls -name Reducer) add_public_tablegen_target(MLIRReducerIncGen) add_mlir_doc(Passes -gen-pass-doc ReducerPasses ./) Index: mlir/include/mlir/Reducer/OptReductionPass.h =================================================================== --- mlir/include/mlir/Reducer/OptReductionPass.h +++ mlir/include/mlir/Reducer/OptReductionPass.h @@ -28,23 +28,12 @@ class OptReductionPass : public OptReductionBase { public: - OptReductionPass(const Tester &test, MLIRContext *context, - std::unique_ptr optPass); + OptReductionPass() = default; - OptReductionPass(const OptReductionPass &srcPass); + OptReductionPass(const OptReductionPass &srcPass) = default; /// Runs the pass instance in the pass pipeline. void runOnOperation() override; - -private: - // Points to the context to be used in the pass manager. - MLIRContext *context; - - // This is used to test the interesting behavior of the transformed module. - const Tester &test; - - // Points to the mlir-opt pass to be called. - std::unique_ptr optPass; }; } // end namespace mlir Index: mlir/include/mlir/Reducer/Passes.h =================================================================== --- /dev/null +++ mlir/include/mlir/Reducer/Passes.h @@ -0,0 +1,27 @@ +//===- Passes.h - Reducer Pass Construction and Registration ----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +#ifndef MLIR_REDUCER_PASSES_H +#define MLIR_REDUCER_PASSES_H + +#include "mlir/Pass/Pass.h" +#include "mlir/Reducer/OptReductionPass.h" +#include "mlir/Reducer/ReductionTreePass.h" + +namespace mlir { + +std::unique_ptr createReductionTreePass(); + +std::unique_ptr createOptReductionPass(); + +/// Generate the code for registering reducer passes. +#define GEN_PASS_REGISTRATION +#include "mlir/Reducer/Passes.h.inc" + +} // end namespace mlir + +#endif // MLIR_REDUCER_PASSES_H Index: mlir/include/mlir/Reducer/Passes.td =================================================================== --- mlir/include/mlir/Reducer/Passes.td +++ mlir/include/mlir/Reducer/Passes.td @@ -15,12 +15,37 @@ include "mlir/Pass/PassBase.td" +def CommonReductionPassOptions { + list