[flang-commits] [flang] cf2942a - [flang] Remove circular dependency between libFIRSupport and libFIRDialect

via flang-commits flang-commits at lists.llvm.org
Wed Mar 8 12:36:53 PST 2023


Author: Renaud-K
Date: 2023-03-08T12:36:32-08:00
New Revision: cf2942a12f5ceca9f2bb701e39626fdd3463286b

URL: https://github.com/llvm/llvm-project/commit/cf2942a12f5ceca9f2bb701e39626fdd3463286b
DIFF: https://github.com/llvm/llvm-project/commit/cf2942a12f5ceca9f2bb701e39626fdd3463286b.diff

LOG: [flang] Remove circular dependency between libFIRSupport and libFIRDialect
Differential revision: https://reviews.llvm.org/D145602

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Support/Utils.h
    flang/lib/Optimizer/Support/CMakeLists.txt

Removed: 
    flang/lib/Optimizer/Support/Utils.cpp


################################################################################
diff  --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index 7d06f56274eac..ebf506543ebf4 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -14,6 +14,7 @@
 #define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
 
 #include "flang/Common/default-kinds.h"
+#include "flang/Optimizer/Dialect/FIROps.h"
 #include "flang/Optimizer/Dialect/FIRType.h"
 #include "mlir/Dialect/Arith/IR/Arith.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
@@ -31,7 +32,27 @@ inline std::int64_t toInt(mlir::arith::ConstantOp cop) {
 // Reconstruct binding tables for dynamic dispatch.
 using BindingTable = llvm::DenseMap<llvm::StringRef, unsigned>;
 using BindingTables = llvm::DenseMap<llvm::StringRef, BindingTable>;
-void buildBindingTables(BindingTables &, mlir::ModuleOp mod);
+
+inline void buildBindingTables(BindingTables &bindingTables,
+                               mlir::ModuleOp mod) {
+
+  // The binding tables are defined in FIR from lowering as fir.dispatch_table
+  // operation. Go through each binding tables and store the procedure name and
+  // binding index for later use by the fir.dispatch conversion pattern.
+  for (auto dispatchTableOp : mod.getOps<fir::DispatchTableOp>()) {
+    unsigned bindingIdx = 0;
+    BindingTable bindings;
+    if (dispatchTableOp.getRegion().empty()) {
+      bindingTables[dispatchTableOp.getSymName()] = bindings;
+      continue;
+    }
+    for (auto dtEntry : dispatchTableOp.getBlock().getOps<fir::DTEntryOp>()) {
+      bindings[dtEntry.getMethod()] = bindingIdx;
+      ++bindingIdx;
+    }
+    bindingTables[dispatchTableOp.getSymName()] = bindings;
+  }
+}
 
 // Translate front-end KINDs for use in the IR and code gen.
 inline std::vector<fir::KindTy>

diff  --git a/flang/lib/Optimizer/Support/CMakeLists.txt b/flang/lib/Optimizer/Support/CMakeLists.txt
index b878a1f86b5d1..6a1c004ac88a4 100644
--- a/flang/lib/Optimizer/Support/CMakeLists.txt
+++ b/flang/lib/Optimizer/Support/CMakeLists.txt
@@ -5,7 +5,6 @@ add_flang_library(FIRSupport
   InitFIR.cpp
   InternalNames.cpp
   KindMapping.cpp
-  Utils.cpp
 
   DEPENDS
   FIROpsIncGen

diff  --git a/flang/lib/Optimizer/Support/Utils.cpp b/flang/lib/Optimizer/Support/Utils.cpp
deleted file mode 100644
index e973bf4c7049b..0000000000000
--- a/flang/lib/Optimizer/Support/Utils.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===-- Utils.cpp ---------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
-//
-//===----------------------------------------------------------------------===//
-
-#include "flang/Optimizer/Support/Utils.h"
-#include "flang/Optimizer/Dialect/FIROps.h"
-
-namespace fir {
-void buildBindingTables(BindingTables &bindingTables, mlir::ModuleOp mod) {
-
-  // The binding tables are defined in FIR from lowering as fir.dispatch_table
-  // operation. Go through each binding tables and store the procedure name and
-  // binding index for later use by the fir.dispatch conversion pattern.
-  for (auto dispatchTableOp : mod.getOps<fir::DispatchTableOp>()) {
-    unsigned bindingIdx = 0;
-    BindingTable bindings;
-    if (dispatchTableOp.getRegion().empty()) {
-      bindingTables[dispatchTableOp.getSymName()] = bindings;
-      continue;
-    }
-    for (auto dtEntry : dispatchTableOp.getBlock().getOps<fir::DTEntryOp>()) {
-      bindings[dtEntry.getMethod()] = bindingIdx;
-      ++bindingIdx;
-    }
-    bindingTables[dispatchTableOp.getSymName()] = bindings;
-  }
-}
-} // namespace fir


        


More information about the flang-commits mailing list