Skip to content

Commit

Permalink
[ConstEval] Switch to tablegen pass generation (iree-org#18228)
Browse files Browse the repository at this point in the history
This switches the pass generation definition to tablegen. The cleanup
includes switching passes to follow the `create*Pass` naming convention
and moving data members to private.
  • Loading branch information
marbre authored Aug 19, 2024
1 parent 2d629c6 commit f224bc8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 48 deletions.
1 change: 0 additions & 1 deletion compiler/src/iree/compiler/ConstEval/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ iree_gentbl_cc_library(
iree_compiler_cc_library(
name = "PassHeaders",
hdrs = [
"PassDetail.h",
"Passes.h",
"Passes.h.inc",
],
Expand Down
1 change: 0 additions & 1 deletion compiler/src/iree/compiler/ConstEval/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ iree_cc_library(
NAME
PassHeaders
HDRS
"PassDetail.h"
"Passes.h"
"Passes.h.inc"
DEPS
Expand Down
22 changes: 9 additions & 13 deletions compiler/src/iree/compiler/ConstEval/JitGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "iree/compiler/ConstEval/PassDetail.h"
#include "iree/compiler/ConstEval/Passes.h"
#include "iree/compiler/ConstEval/Runtime.h"
#include "iree/compiler/Dialect/HAL/Target/TargetOptions.h"
Expand All @@ -30,6 +29,9 @@

namespace mlir::iree_compiler::ConstEval {

#define GEN_PASS_DEF_JITGLOBALSPASS
#include "iree/compiler/ConstEval/Passes.h.inc"

static llvm::cl::opt<std::string> clJitTargetDevice(
"iree-consteval-jit-target-device",
llvm::cl::desc("Overrides the target device used for JIT'ing."),
Expand Down Expand Up @@ -609,8 +611,11 @@ class ProgramBuilder {
InitializationAnalysis initializationAnalysis;
};

struct JitGlobalsPass : public JitGlobalsBase<JitGlobalsPass> {
JitGlobalsPass(const JitGlobalsOptions &options)
class JitGlobalsPass final : public impl::JitGlobalsPassBase<JitGlobalsPass> {
public:
JitGlobalsPass() : JitGlobalsPass(JitGlobalsPassOptions{}) {}

JitGlobalsPass(const JitGlobalsPassOptions &options)
: compileOptions(std::make_shared<CompileOptions>()),
compilePipeline("builtin.module") {
targetRegistry = options.targetRegistry;
Expand Down Expand Up @@ -864,6 +869,7 @@ struct JitGlobalsPass : public JitGlobalsBase<JitGlobalsPass> {
}
}

private:
std::shared_ptr<CompileOptions> compileOptions;
OpPassManager compilePipeline;
std::string requestedTargetDevice;
Expand All @@ -873,14 +879,4 @@ struct JitGlobalsPass : public JitGlobalsBase<JitGlobalsPass> {
};

} // namespace

std::unique_ptr<OperationPass<ModuleOp>>
createJitGlobalsPass(const JitGlobalsOptions &options) {
return std::make_unique<JitGlobalsPass>(options);
}

std::unique_ptr<OperationPass<ModuleOp>> createJitGlobalsPass() {
return std::make_unique<JitGlobalsPass>(JitGlobalsOptions{});
}

} // namespace mlir::iree_compiler::ConstEval
21 changes: 0 additions & 21 deletions compiler/src/iree/compiler/ConstEval/PassDetail.h

This file was deleted.

10 changes: 0 additions & 10 deletions compiler/src/iree/compiler/ConstEval/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ namespace mlir::iree_compiler::ConstEval {
#define GEN_PASS_DECL
#include "iree/compiler/ConstEval/Passes.h.inc"

/// Creates a pass which uses the compiler and runtime to Jit global
/// initializers eligible for optimization and uses the actual results to
/// simplify the globals in the module.
std::unique_ptr<OperationPass<ModuleOp>>
createJitGlobalsPass(const JitGlobalsOptions &options);

// Creates with the global target registry (for opt and such). This
// may only have access to the VMVX backend.
std::unique_ptr<OperationPass<ModuleOp>> createJitGlobalsPass();

void registerConstEvalPasses();

} // namespace mlir::iree_compiler::ConstEval
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/iree/compiler/ConstEval/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

include "mlir/Pass/PassBase.td"

def JitGlobals :
def JitGlobalsPass :
Pass<"iree-consteval-jit-globals", "ModuleOp"> {
let summary = "Jits global initializers and evaluates them into concrete values";
let constructor = "mlir::iree_compiler::ConstEval::createJitGlobalsPass()";
let options = [
Option<
"targetRegistry", "target-registry",
Expand Down

0 comments on commit f224bc8

Please sign in to comment.