1 //===-- runtime/support.cpp -----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "flang/Runtime/support.h"
10 #include "ISO_Fortran_util.h"
11 #include "type-info.h"
12 #include "flang/Runtime/descriptor.h"
14 namespace Fortran::runtime
{
16 RT_EXT_API_GROUP_BEGIN
18 bool RTDEF(IsContiguous
)(const Descriptor
&descriptor
) {
19 return descriptor
.IsContiguous();
22 bool RTDEF(IsAssumedSize
)(const Descriptor
&descriptor
) {
23 return ISO::IsAssumedSize(&descriptor
.raw());
26 void RTDEF(CopyAndUpdateDescriptor
)(Descriptor
&to
, const Descriptor
&from
,
27 const typeInfo::DerivedType
*newDynamicType
,
28 ISO::CFI_attribute_t newAttribute
, enum LowerBoundModifier newLowerBounds
) {
31 DescriptorAddendum
*toAddendum
{to
.Addendum()};
32 INTERNAL_CHECK(toAddendum
);
33 toAddendum
->set_derivedType(newDynamicType
);
34 to
.raw().elem_len
= newDynamicType
->sizeInBytes();
36 to
.raw().attribute
= newAttribute
;
37 if (newLowerBounds
!= LowerBoundModifier::Preserve
) {
38 const ISO::CFI_index_t newLowerBound
{
39 newLowerBounds
== LowerBoundModifier::SetToOnes
? 1 : 0};
40 const int rank
{to
.rank()};
41 for (int i
= 0; i
< rank
; ++i
) {
42 to
.GetDimension(i
).SetLowerBound(newLowerBound
);
49 } // namespace Fortran::runtime