FLANG
include
flang
Runtime
ragged.h
1
//===-- Runtime/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_RUNTIME_RAGGED_H_
10
#define FORTRAN_RUNTIME_RAGGED_H_
11
12
#include "flang/Runtime/entry-names.h"
13
#include <cstdint>
14
15
namespace
Fortran::runtime {
16
17
// A ragged array header block.
18
// The header block is used to create the "array of arrays" ragged data
19
// structure. It contains a pair in `flags` to indicate if the header points to
20
// an array of headers (isIndirection) or data elements and the rank of the
21
// pointed-to array. The rank is the length of the extents vector accessed
22
// through `extentPointer`. The `bufferPointer` is overloaded
23
// and is null, points to an array of headers (isIndirection), or data.
24
// By default, a header is set to zero, which is its unused state.
25
// This layout is runtime ABI; compiler-generated code from older flang
26
// versions may allocate and access ragged arrays with it.
27
struct
RaggedArrayHeader
{
28
std::uint64_t flags;
29
void
*bufferPointer;
30
std::int64_t *extentPointer;
31
};
32
33
extern
"C"
{
34
35
// For more on ragged arrays see https://en.wikipedia.org/wiki/Jagged_array.
36
// Flang historically generated ragged arrays as a generalization for
37
// non-rectangular array temporaries; these entry points are retained as ABI
38
// for previously compiled objects. Ragged arrays can be allocated recursively
39
// and on demand. Structurally, each leaf is an optional rectangular array of
40
// elements. The shape of each leaf is independent and may be computed on
41
// demand. Each branch node is an optional, possibly sparse rectangular array of
42
// headers. The shape of each branch is independent and may be computed on
43
// demand. Ragged arrays preserve a correspondence between a multidimensional
44
// iteration space and array access vectors, which is helpful for dependence
45
// analysis.
46
47
// Runtime helper for allocation of ragged array buffers.
48
// A pointer to the header block to be allocated is given as header. The flag
49
// isHeader indicates if a block of headers or data is to be allocated. A
50
// non-negative rank indicates the length of the extentVector, which is a list
51
// of non-negative extents. elementSize is the size of a data element in the
52
// rectangular space defined by the extentVector.
53
void
*RTDECL(RaggedArrayAllocate)(
void
*header,
bool
isHeader,
54
std::int64_t rank, std::int64_t elementSize, std::int64_t *extentVector);
55
56
// Runtime helper for deallocation of ragged array buffers. The root header of
57
// the ragged array structure is passed to deallocate the entire ragged array.
58
void
RTDECL(RaggedArrayDeallocate)(
void
*raggedArrayHeader);
59
60
}
// extern "C"
61
}
// namespace Fortran::runtime
62
#endif
// FORTRAN_RUNTIME_RAGGED_H_
Fortran::runtime::RaggedArrayHeader
Definition
ragged.h:27
Generated on
for FLANG by
1.14.0