1 //===-- include/flang/Runtime/array-constructor.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 // External APIs to create temporary storage for array constructors when their 10 // final extents or length parameters cannot be pre-computed. 11 12 #ifndef FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_ 13 #define FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_ 14 15 #include "flang/Runtime/array-constructor-consts.h" 16 #include "flang/Runtime/descriptor.h" 17 #include "flang/Runtime/entry-names.h" 18 #include <cstdint> 19 20 namespace Fortran::runtime { 21 22 // Runtime data structure to hold information about the storage of 23 // an array constructor being constructed. 24 struct ArrayConstructorVector { 25 RT_API_ATTRS ArrayConstructorVector(class Descriptor &to, 26 SubscriptValue nextValuePosition, SubscriptValue actualAllocationSize, 27 const char *sourceFile, int sourceLine, bool useValueLengthParameters) 28 : to{to}, nextValuePosition{nextValuePosition}, 29 actualAllocationSize{actualAllocationSize}, sourceFile{sourceFile}, 30 sourceLine{sourceLine}, 31 useValueLengthParameters_{useValueLengthParameters} {} 32 33 RT_API_ATTRS bool useValueLengthParameters() const { 34 return useValueLengthParameters_; 35 } 36 37 class Descriptor &to; 38 SubscriptValue nextValuePosition; 39 SubscriptValue actualAllocationSize; 40 const char *sourceFile; 41 int sourceLine; 42 43 private: 44 unsigned char useValueLengthParameters_ : 1; 45 }; 46 47 static_assert(sizeof(Fortran::runtime::ArrayConstructorVector) <= 48 MaxArrayConstructorVectorSizeInBytes, 49 "ABI requires sizeof(ArrayConstructorVector) to be smaller than " 50 "MaxArrayConstructorVectorSizeInBytes"); 51 static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <= 52 MaxArrayConstructorVectorAlignInBytes, 53 "ABI requires alignof(ArrayConstructorVector) to be smaller than " 54 "MaxArrayConstructorVectorAlignInBytes"); 55 56 } // namespace Fortran::runtime 57 #endif // FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_ 58