[Mlir-commits] [mlir] [mlir][inliner] Refactor MLIR inliner pass and utils. (PR #84059)
Slava Zakharin
llvmlistbot at llvm.org
Tue Mar 5 12:09:55 PST 2024
================
@@ -0,0 +1,124 @@
+//===- Inliner.h - Inliner pass utilities -----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file declares utility structures for the inliner pass.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_TRANSFORMS_INLINER_H
+#define MLIR_TRANSFORMS_INLINER_H
+
+#include "mlir/Analysis/CallGraph.h"
+#include "mlir/Interfaces/CallInterfaces.h"
+#include "mlir/Pass/AnalysisManager.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Support/LogicalResult.h"
+#include "llvm/ADT/StringMap.h"
+
+namespace mlir {
+class OpPassManager;
+class Operation;
+
+class InlinerConfig {
+public:
+ using PreInlineCallableOptPipelineTy = std::function<void(OpPassManager &)>;
+ using OpPipelinesTy = llvm::StringMap<OpPassManager>;
+
+ InlinerConfig() = default;
+ InlinerConfig(PreInlineCallableOptPipelineTy preInlineCallableOptPipeline,
+ unsigned maxInliningIterations)
+ : preInlineCallableOptPipeline(std::move(preInlineCallableOptPipeline)),
+ maxInliningIterations(maxInliningIterations) {}
+
+ const PreInlineCallableOptPipelineTy &
+ getPreInlineCallableOptPipeline() const {
+ return preInlineCallableOptPipeline;
+ }
+ const OpPipelinesTy &getOpPipelines() const { return opPipelines; }
+ unsigned getMaxInliningIterations() const { return maxInliningIterations; }
+ void
+ setPreInlineCallableOptPipeline(PreInlineCallableOptPipelineTy pipeline) {
+ preInlineCallableOptPipeline = std::move(pipeline);
+ }
+ void setOpPipelines(OpPipelinesTy pipelines) {
+ opPipelines = std::move(pipelines);
+ }
+ void setMaxInliningIterations(unsigned max) { maxInliningIterations = max; }
+
+private:
+ /// An optional function that constructs an optimization pipeline for
+ /// a given operation.
+ PreInlineCallableOptPipelineTy preInlineCallableOptPipeline;
+ /// A map of operation names to pass pipelines to use when optimizing
+ /// callable operations of these types. This provides a specialized pipeline
+ /// instead of the one produced by preInlineCallableOptPipeline.
+ OpPipelinesTy opPipelines;
+ /// For SCC-based inlining algorithms, specifies maximum number of iterations
+ /// when inlining within an SCC.
+ unsigned maxInliningIterations{0};
+};
+
+/// This is an implementation of the inliner
+/// that operates bottom up over the Strongly Connected Components(SCCs)
+/// of the CallGraph. This enables a more incremental propagation
+/// of inlining decisions from the leafs to the roots of the callgraph.
+///
+/// Derived implementations may rely on the same algorithm, but override
+/// the provided hooks to tune various algorithm aspects.
----------------
vzakhari wrote:
Yes it is. Thanks for catching!
https://github.com/llvm/llvm-project/pull/84059
More information about the Mlir-commits
mailing list