1 //===-- runtime/transformational.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 // Defines the API for the type-independent transformational intrinsic functions
10 // that rearrange data in arrays: CSHIFT, EOSHIFT, PACK, RESHAPE, SPREAD,
11 // TRANSPOSE, and UNPACK.
12 // These are naive allocating implementations; optimized forms that manipulate
13 // pointer descriptors or that supply functional views of arrays remain to
14 // be defined and may instead be part of lowering (see docs/ArrayComposition.md)
15 // for details).
16
17 #ifndef FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
18 #define FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
19
20 #include "descriptor.h"
21 #include "entry-names.h"
22 #include "memory.h"
23
24 namespace Fortran::runtime {
25
26 extern "C" {
27
28 void RTNAME(Reshape)(Descriptor &result, const Descriptor &source,
seg_alloc(rdb_pALLOCATOR alloc,unsigned size)29 const Descriptor &shape, const Descriptor *pad = nullptr,
30 const Descriptor *order = nullptr, const char *sourceFile = nullptr,
31 int line = 0);
32
33 void RTNAME(Cshift)(Descriptor &result, const Descriptor &source,
34 const Descriptor &shift, int dim = 1, const char *sourceFile = nullptr,
35 int line = 0);
36 void RTNAME(CshiftVector)(Descriptor &result, const Descriptor &source,
37 std::int64_t shift, const char *sourceFile = nullptr, int line = 0);
38
39 void RTNAME(Eoshift)(Descriptor &result, const Descriptor &source,
40 const Descriptor &shift, const Descriptor *boundary = nullptr, int dim = 1,
41 const char *sourceFile = nullptr, int line = 0);
42 void RTNAME(EoshiftVector)(Descriptor &result, const Descriptor &source,
43 std::int64_t shift, const Descriptor *boundary = nullptr,
44 const char *sourceFile = nullptr, int line = 0);
seg_realloc(rdb_pALLOCATOR alloc,rdb_ROPESEG * seg,unsigned size)45
46 void RTNAME(Pack)(Descriptor &result, const Descriptor &source,
47 const Descriptor &mask, const Descriptor *vector = nullptr,
48 const char *sourceFile = nullptr, int line = 0);
49
50 void RTNAME(Spread)(Descriptor &result, const Descriptor &source, int dim,
51 std::int64_t ncopies, const char *sourceFile = nullptr, int line = 0);
52
53 void RTNAME(Transpose)(Descriptor &result, const Descriptor &matrix,
54 const char *sourceFile = nullptr, int line = 0);
55
seg_free(rdb_pALLOCATOR alloc,rdb_ROPESEG * seg)56 void RTNAME(Unpack)(Descriptor &result, const Descriptor &vector,
57 const Descriptor &mask, const Descriptor &field,
58 const char *sourceFile = nullptr, int line = 0);
59
60 } // extern "C"
61 } // namespace Fortran::runtime
62 #endif // FORTRAN_RUNTIME_TRANSFORMATIONAL_H_
buf_reserve(rdb_pALLOCATOR alloc,rdb_ROPEBUF * buf,unsigned cap)63