1//===- OpenACCRuntimeDescriptors.def - ACC descriptor catalog ---*- 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/// \file
9///
10/// X-macro catalog of the argument descriptors the compiler materializes for
11/// the `arg_descs` parameter of the `__tgt_acc_data_*` entry points. Field
12/// order, field types, and padding are part of the runtime ABI and must match
13/// the `AccDataDesc*` types of the offload runtime, which are not restated
14/// here. Include this file after defining ACC_DESC_BEGIN.
15///
16/// ACC_DESC_BEGIN(Enum, NameStr, DescKind)
17/// Enum - enumerator used as DataDescriptor::Enum
18/// NameStr - name of the runtime type this layout materializes
19/// DescKind - `acc::DataDescKind` the runtime reads from the version field
20///
21/// ACC_DESC_FIELD(Enum, Field, TypeToken)
22/// Field - enumerator used as Enum##Field::Field, in declaration order
23/// TypeToken - MLIR LLVM type token (Int8, Int32, Int64, Ptr), or Base for
24/// the descriptor a layout nests
25///
26/// ACC_DESC_END(Enum)
27///
28//===----------------------------------------------------------------------===//
29
30#ifndef ACC_DESC_BEGIN
31#error "define ACC_DESC_BEGIN before including OpenACCRuntimeDescriptors.def"
32#endif
33
34#ifndef ACC_DESC_FIELD
35#define ACC_DESC_FIELD(Enum, Field, TypeToken)
36#endif
37
38#ifndef ACC_DESC_END
39#define ACC_DESC_END(Enum)
40#endif
41
42// A mapping that needs no descriptor of its own, used as the base of an
43// OpenACC overlay that only carries bounds.
44ACC_DESC_BEGIN(AccDataDescGeneric, "AccDataDescGeneric", DataDescKind::none)
45ACC_DESC_FIELD(AccDataDescGeneric, Version, Int32)
46ACC_DESC_FIELD(AccDataDescGeneric, Padding, Int32)
47ACC_DESC_END(AccDataDescGeneric)
48
49// A mapping described by a Fortran descriptor (`CFI_cdesc_t` of
50// ISO_Fortran_binding.h), which the descriptor field addresses.
51ACC_DESC_BEGIN(AccDataDescCFI, "AccDataDescCFI", DataDescKind::cfi)
52ACC_DESC_FIELD(AccDataDescCFI, Version, Int32)
53ACC_DESC_FIELD(AccDataDescCFI, CFIDescriptor, Ptr)
54ACC_DESC_END(AccDataDescCFI)
55
56// A mapping described by the memref descriptor the memref-to-LLVM conversion
57// produced, which the descriptor field addresses.
58ACC_DESC_BEGIN(AccDataDescMemRef, "AccDataDescMemRef", DataDescKind::memref)
59ACC_DESC_FIELD(AccDataDescMemRef, Version, Int32)
60ACC_DESC_FIELD(AccDataDescMemRef, Rank, Int8)
61ACC_DESC_FIELD(AccDataDescMemRef, ElementSize, Int64)
62ACC_DESC_FIELD(AccDataDescMemRef, MemRefDescriptor, Ptr)
63ACC_DESC_END(AccDataDescMemRef)
64
65// Bounds of a mapping, overlaid on the descriptor that states its storage.
66// Rank is the number of bounds and each array below holds that many entries,
67// in dimension order.
68ACC_DESC_BEGIN(AccDataDescOpenACC, "AccDataDescOpenACC", DataDescKind::openacc)
69ACC_DESC_FIELD(AccDataDescOpenACC, Base, Base)
70ACC_DESC_FIELD(AccDataDescOpenACC, Rank, Int8)
71ACC_DESC_FIELD(AccDataDescOpenACC, ElementSize, Int64)
72ACC_DESC_FIELD(AccDataDescOpenACC, LowerBounds, Ptr)
73ACC_DESC_FIELD(AccDataDescOpenACC, UpperBounds, Ptr)
74ACC_DESC_FIELD(AccDataDescOpenACC, Extents, Ptr)
75ACC_DESC_FIELD(AccDataDescOpenACC, StridesInBytes, Ptr)
76ACC_DESC_FIELD(AccDataDescOpenACC, StartIndices, Ptr)
77ACC_DESC_END(AccDataDescOpenACC)
78
79#undef ACC_DESC_BEGIN
80#undef ACC_DESC_FIELD
81#undef ACC_DESC_END
82