diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h --- 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 @@ // Reconstruct binding tables for dynamic dispatch. using BindingTable = llvm::DenseMap; using BindingTables = llvm::DenseMap; -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()) { + unsigned bindingIdx = 0; + BindingTable bindings; + if (dispatchTableOp.getRegion().empty()) { + bindingTables[dispatchTableOp.getSymName()] = bindings; + continue; + } + for (auto dtEntry : dispatchTableOp.getBlock().getOps()) { + bindings[dtEntry.getMethod()] = bindingIdx; + ++bindingIdx; + } + bindingTables[dispatchTableOp.getSymName()] = bindings; + } +} // Translate front-end KINDs for use in the IR and code gen. inline std::vector diff --git a/flang/lib/Optimizer/Support/CMakeLists.txt b/flang/lib/Optimizer/Support/CMakeLists.txt --- a/flang/lib/Optimizer/Support/CMakeLists.txt +++ b/flang/lib/Optimizer/Support/CMakeLists.txt @@ -5,7 +5,6 @@ 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 --- 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()) { - unsigned bindingIdx = 0; - BindingTable bindings; - if (dispatchTableOp.getRegion().empty()) { - bindingTables[dispatchTableOp.getSymName()] = bindings; - continue; - } - for (auto dtEntry : dispatchTableOp.getBlock().getOps()) { - bindings[dtEntry.getMethod()] = bindingIdx; - ++bindingIdx; - } - bindingTables[dispatchTableOp.getSymName()] = bindings; - } -} -} // namespace fir