1 //===-- Ragged.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 #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RAGGED_H
10 #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RAGGED_H
11 
12 namespace mlir {
13 class Location;
14 class Value;
15 class ValueRange;
16 } // namespace mlir
17 
18 namespace fir {
19 class FirOpBuilder;
20 } // namespace fir
21 
22 namespace fir::runtime {
23 
24 /// Generate code to instantiate a section of a ragged array. Calls the runtime
25 /// to initialize the data buffer. \p header must be a ragged buffer header (on
26 /// the heap) and will be initialized, if and only if the rank of \p extents is
27 /// at least 1 and all values in the vector of extents are positive. \p extents
28 /// must be a vector of Value of type `i64`. \p eleSize is in bytes, not bits.
29 void genRaggedArrayAllocate(mlir::Location loc, fir::FirOpBuilder &builder,
30                             mlir::Value header, bool asHeaders,
31                             mlir::Value eleSize, mlir::ValueRange extents);
32 
33 /// Generate a call to the runtime routine to deallocate a ragged array data
34 /// structure on the heap.
35 void genRaggedArrayDeallocate(mlir::Location loc, fir::FirOpBuilder &builder,
36                               mlir::Value header);
37 
38 } // namespace fir::runtime
39 #endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RAGGED_H
40