[flang-commits] [flang] [flang][cuda] Add conversion pass for cuf.allocate and cuf.deallocate (PR #101563)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Aug 2 11:11:22 PDT 2024


================
@@ -0,0 +1,154 @@
+//===-- CufOpConversion.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
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Common/Fortran.h"
+#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
+#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
+#include "flang/Optimizer/Dialect/FIRDialect.h"
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/HLFIR/HLFIROps.h"
+#include "flang/Runtime/allocatable.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+namespace fir {
+#define GEN_PASS_DEF_CUFOPCONVERSION
+#include "flang/Optimizer/Transforms/Passes.h.inc"
+} // namespace fir
+
+using namespace fir;
+using namespace mlir;
+using namespace Fortran::runtime;
+
+namespace {
+
+template <typename OpTy>
+static bool isBoxGlobal(OpTy op) {
+  if (auto declareOp =
+          mlir::dyn_cast<fir::DeclareOp>(op.getBox().getDefiningOp())) {
----------------
vzakhari wrote:

Should we use `dyn_cast_or_null` and `isa_and_nonnull` in this routine?

https://github.com/llvm/llvm-project/pull/101563


More information about the flang-commits mailing list