[flang-commits] [flang] [flang][NFC] Refactor to remove .inc file containing shared code (PR #109874)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Wed Sep 25 09:03:36 PDT 2024
================
@@ -0,0 +1,330 @@
+//===-- Pipelines.cpp -- FIR pass pipelines ---------------------*- 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 file defines some utilties to setup FIR pass pipelines. These are
+/// common to flang and the test tools.
+
+#include "flang/Optimizer/Passes/Pipelines.h"
+
+namespace {
+
+static void addNestedPassToAllTopLevelOperations(mlir::PassManager &pm,
+ PassConstructor ctor) {
+ addNestedPassToOps<mlir::func::FuncOp, mlir::omp::DeclareReductionOp,
+ mlir::omp::PrivateClauseOp, fir::GlobalOp>(pm, ctor);
+}
+
+static void
+addNestedPassToAllTopLevelOperationsConditionally(mlir::PassManager &pm,
+ llvm::cl::opt<bool> &disabled,
+ PassConstructor ctor) {
+ if (!disabled)
+ addNestedPassToAllTopLevelOperations(pm, ctor);
+}
+
+} // namespace
+
+namespace fir {
+
+// Add MLIR Canonicalizer pass with region simplification disabled.
+// FIR does not support the promotion of some SSA value to block arguments (or
+// into arith.select operands) that may be done by mlir block merging in the
+// region simplification (e.g., !fir.shape<> SSA values are not supported as
+// block arguments).
+// Aside from the fir.shape issue, moving some abstract SSA value into block
+// arguments may have a heavy cost since it forces their code generation that
+// may be expensive (array temporary). The MLIR pass does not take these
+// extra costs into account when doing block merging.
+static void
+addCanonicalizerPassWithoutRegionSimplification(mlir::OpPassManager &pm) {
+ mlir::GreedyRewriteConfig config;
+ config.enableRegionSimplification = mlir::GreedySimplifyRegionLevel::Disabled;
+ pm.addPass(mlir::createCanonicalizerPass(config));
+}
+
+static void addCfgConversionPass(mlir::PassManager &pm,
----------------
vzakhari wrote:
Thank you very much, Tarun! Yes, can you please also export the `addNestedPassToAllTopLevelOperations*` helpers? The `namespace fir` works well.
https://github.com/llvm/llvm-project/pull/109874
More information about the flang-commits
mailing list