Skip to content

[MLIR][NFC] Retire let constructor for Reducer #134786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions mlir/include/mlir/Reducer/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ namespace mlir {
#define GEN_PASS_DECL
#include "mlir/Reducer/Passes.h.inc"

std::unique_ptr<Pass> createReductionTreePass();

std::unique_ptr<Pass> createOptReductionPass();

/// Generate the code for registering reducer passes.
#define GEN_PASS_REGISTRATION
#include "mlir/Reducer/Passes.h.inc"
Expand Down
8 changes: 2 additions & 6 deletions mlir/include/mlir/Reducer/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,19 @@ def CommonReductionPassOptions {
];
}

def ReductionTree : Pass<"reduction-tree"> {
def ReductionTreePass : Pass<"reduction-tree"> {
let summary = "Reduce the input with reduction-tree algorithm";

let constructor = "mlir::createReductionTreePass()";

let options = [
Option<"traversalModeId", "traversal-mode", "unsigned",
/* default */"0",
"The graph traversal mode, the default is single-path mode">,
] # CommonReductionPassOptions.options;
}

def OptReduction : Pass<"opt-reduction-pass", "ModuleOp"> {
def OptReductionPass : Pass<"opt-reduction-pass", "ModuleOp"> {
let summary = "A wrapper pass that reduces the file with optimization passes";

let constructor = "mlir::createOptReductionPass()";

let options = [
Option<"optPass", "opt-pass", "std::string", /* default */"",
"The optimization passes used for reduction, e.g., symbol-dce">,
Expand Down
13 changes: 6 additions & 7 deletions mlir/lib/Reducer/OptReductionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Reducer/Passes.h"
#include "mlir/Reducer/Tester.h"

#include "llvm/Support/Debug.h"

namespace mlir {
#define GEN_PASS_DEF_OPTREDUCTION
#define GEN_PASS_DEF_OPTREDUCTIONPASS
#include "mlir/Reducer/Passes.h.inc"
} // namespace mlir

Expand All @@ -29,8 +30,10 @@ using namespace mlir;

namespace {

class OptReductionPass : public impl::OptReductionBase<OptReductionPass> {
class OptReductionPass : public impl::OptReductionPassBase<OptReductionPass> {
public:
using Base::Base;

/// Runs the pass instance in the pass pipeline.
void runOnOperation() override;
};
Expand Down Expand Up @@ -85,8 +88,4 @@ void OptReductionPass::runOnOperation() {
moduleVariant->destroy();

LLVM_DEBUG(llvm::dbgs() << "Pass Complete\n\n");
}

std::unique_ptr<Pass> mlir::createOptReductionPass() {
return std::make_unique<OptReductionPass>();
}
}
12 changes: 4 additions & 8 deletions mlir/lib/Reducer/ReductionTreePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "llvm/Support/ManagedStatic.h"

namespace mlir {
#define GEN_PASS_DEF_REDUCTIONTREE
#define GEN_PASS_DEF_REDUCTIONTREEPASS
#include "mlir/Reducer/Passes.h.inc"
} // namespace mlir

Expand Down Expand Up @@ -191,10 +191,10 @@ class ReductionPatternInterfaceCollection
/// This class defines the Reduction Tree Pass. It provides a framework to
/// to implement a reduction pass using a tree structure to keep track of the
/// generated reduced variants.
class ReductionTreePass : public impl::ReductionTreeBase<ReductionTreePass> {
class ReductionTreePass
: public impl::ReductionTreePassBase<ReductionTreePass> {
public:
ReductionTreePass() = default;
ReductionTreePass(const ReductionTreePass &pass) = default;
using Base::Base;

LogicalResult initialize(MLIRContext *context) override;

Expand Down Expand Up @@ -256,7 +256,3 @@ LogicalResult ReductionTreePass::reduceOp(ModuleOp module, Region &region) {
return module.emitError() << "unsupported traversal mode detected";
}
}

std::unique_ptr<Pass> mlir::createReductionTreePass() {
return std::make_unique<ReductionTreePass>();
}