[ConstEval] Switch to tablegen pass generation (#18228)
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.
diff --git a/compiler/src/iree/compiler/ConstEval/BUILD.bazel b/compiler/src/iree/compiler/ConstEval/BUILD.bazel
index 5bc28d3..2751d48 100644
--- a/compiler/src/iree/compiler/ConstEval/BUILD.bazel
+++ b/compiler/src/iree/compiler/ConstEval/BUILD.bazel
@@ -30,7 +30,6 @@
iree_compiler_cc_library(
name = "PassHeaders",
hdrs = [
- "PassDetail.h",
"Passes.h",
"Passes.h.inc",
],
diff --git a/compiler/src/iree/compiler/ConstEval/CMakeLists.txt b/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
index 4492119..2e47016 100644
--- a/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
+++ b/compiler/src/iree/compiler/ConstEval/CMakeLists.txt
@@ -23,7 +23,6 @@
NAME
PassHeaders
HDRS
- "PassDetail.h"
"Passes.h"
"Passes.h.inc"
DEPS
diff --git a/compiler/src/iree/compiler/ConstEval/JitGlobals.cpp b/compiler/src/iree/compiler/ConstEval/JitGlobals.cpp
index 7fb0aec..4fd578a 100644
--- a/compiler/src/iree/compiler/ConstEval/JitGlobals.cpp
+++ b/compiler/src/iree/compiler/ConstEval/JitGlobals.cpp
@@ -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"
@@ -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."),
@@ -609,8 +611,11 @@
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;
@@ -864,6 +869,7 @@
}
}
+private:
std::shared_ptr<CompileOptions> compileOptions;
OpPassManager compilePipeline;
std::string requestedTargetDevice;
@@ -873,14 +879,4 @@
};
} // 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
diff --git a/compiler/src/iree/compiler/ConstEval/PassDetail.h b/compiler/src/iree/compiler/ConstEval/PassDetail.h
deleted file mode 100644
index e1eb95d..0000000
--- a/compiler/src/iree/compiler/ConstEval/PassDetail.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2021 The IREE Authors
-//
-// Licensed 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 IREE_COMPILER_CONSTEVAL_PASSDETAIL_H_
-#define IREE_COMPILER_CONSTEVAL_PASSDETAIL_H_
-
-#include "iree/compiler/Dialect/HAL/Target/TargetRegistry.h"
-#include "mlir/IR/BuiltinOps.h"
-#include "mlir/Pass/Pass.h"
-
-namespace mlir::iree_compiler::ConstEval {
-
-#define GEN_PASS_CLASSES
-#include "iree/compiler/ConstEval/Passes.h.inc"
-
-} // namespace mlir::iree_compiler::ConstEval
-
-#endif // IREE_COMPILER_CONSTEVAL_PASSDETAIL_H_
diff --git a/compiler/src/iree/compiler/ConstEval/Passes.h b/compiler/src/iree/compiler/ConstEval/Passes.h
index a61b19d..75747fe 100644
--- a/compiler/src/iree/compiler/ConstEval/Passes.h
+++ b/compiler/src/iree/compiler/ConstEval/Passes.h
@@ -16,16 +16,6 @@
#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
diff --git a/compiler/src/iree/compiler/ConstEval/Passes.td b/compiler/src/iree/compiler/ConstEval/Passes.td
index 8dc7a21..4e17c5a 100644
--- a/compiler/src/iree/compiler/ConstEval/Passes.td
+++ b/compiler/src/iree/compiler/ConstEval/Passes.td
@@ -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",