FLANG
MemoryUtils.h
1//===-- Optimizer/Transforms/MemoryUtils.h ----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12//
13// This file defines a utility to replace fir.alloca by dynamic allocation and
14// deallocation. The exact kind of dynamic allocation is left to be defined by
15// the utility user via callbacks (could be fir.allocmem or custom runtime
16// calls).
17//
18//===----------------------------------------------------------------------===//
19
20#ifndef FORTRAN_OPTIMIZER_TRANSFORMS_MEMORYUTILS_H
21#define FORTRAN_OPTIMIZER_TRANSFORMS_MEMORYUTILS_H
22
23#include "flang/Optimizer/Dialect/FIROps.h"
24
25namespace mlir {
26class RewriterBase;
27}
28
29namespace fir {
30
33using MustRewriteCallBack = llvm::function_ref<bool(fir::AllocaOp)>;
34
41using AllocaRewriterCallBack = llvm::function_ref<mlir::Value(
42 mlir::OpBuilder &, fir::AllocaOp, bool allocaDominatesDeallocLocations)>;
46 llvm::function_ref<void(mlir::Location, mlir::OpBuilder &, mlir::Value)>;
47
56bool replaceAllocas(mlir::RewriterBase &rewriter, mlir::Operation *parentOp,
59
60} // namespace fir
61
62#endif // FORTRAN_OPTIMIZER_TRANSFORMS_MEMORYUTILS_H
Definition: AbstractConverter.h:31
llvm::function_ref< void(mlir::Location, mlir::OpBuilder &, mlir::Value)> DeallocCallBack
Definition: MemoryUtils.h:46
bool replaceAllocas(mlir::RewriterBase &rewriter, mlir::Operation *parentOp, MustRewriteCallBack, AllocaRewriterCallBack, DeallocCallBack)
Definition: MemoryUtils.cpp:269
llvm::function_ref< bool(fir::AllocaOp)> MustRewriteCallBack
Definition: MemoryUtils.h:33
llvm::function_ref< mlir::Value(mlir::OpBuilder &, fir::AllocaOp, bool allocaDominatesDeallocLocations)> AllocaRewriterCallBack
Definition: MemoryUtils.h:42
Definition: AbstractConverter.h:27