Skip to content

Commit b1dafd4

Browse files
committed
Keep common files in flang/
1 parent 33ada12 commit b1dafd4

File tree

224 files changed

+814
-587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+814
-587
lines changed

FortranRuntime/include/flang/Runtime/allocator-registry.h renamed to FortranRuntime/include/FortranRuntime/Runtime/allocator-registry.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang/Runtime/allocator-registry.h --------------*- C++ -*-===//
1+
//===-- include/FortranRuntime/Runtime/allocator-registry.h -----*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,17 +10,10 @@
1010
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
1111

1212
#include "flang/Common/api-attrs.h"
13+
#include "flang/Runtime/allocator-registry-consts.h"
1314
#include <cstdlib>
1415
#include <vector>
1516

16-
static constexpr unsigned kDefaultAllocator = 0;
17-
18-
// Allocator used for CUF
19-
static constexpr unsigned kPinnedAllocatorPos = 1;
20-
static constexpr unsigned kDeviceAllocatorPos = 2;
21-
static constexpr unsigned kManagedAllocatorPos = 3;
22-
static constexpr unsigned kUnifiedAllocatorPos = 4;
23-
2417
#define MAX_ALLOCATOR 7 // 3 bits are reserved in the descriptor.
2518

2619
namespace Fortran::runtime {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===-- include/FortranRuntime/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_ARRAY_CONSTRUCTOR_H_
13+
#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_
14+
15+
#include "FortranRuntime/Runtime/descriptor.h"
16+
#include "flang/Runtime/array-constructor-consts.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+
} // namespace Fortran::runtime
48+
#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */

FortranRuntime/include/flang/Runtime/descriptor.h renamed to FortranRuntime/include/FortranRuntime/Runtime/descriptor.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang/Runtime/descriptor.h ----------------------*- C++ -*-===//
1+
//===-- include/FortranRuntime/Runtime/descriptor.h -------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,24 +18,19 @@
1818
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
1919
// but should never reference this internal header.
2020

21+
#include "FortranRuntime/Runtime/memory.h"
22+
#include "FortranRuntime/Runtime/type-code.h"
2123
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
22-
#include "flang/Runtime/memory.h"
23-
#include "flang/Runtime/type-code.h"
24+
#include "flang/Runtime/descriptor-consts.h"
2425
#include <algorithm>
2526
#include <cassert>
2627
#include <cinttypes>
2728
#include <cstddef>
2829
#include <cstdio>
2930
#include <cstring>
3031

31-
namespace Fortran::runtime::typeInfo {
32-
using TypeParameterValue = std::int64_t;
33-
class DerivedType;
34-
} // namespace Fortran::runtime::typeInfo
35-
3632
namespace Fortran::runtime {
3733

38-
using SubscriptValue = ISO::CFI_index_t;
3934
class Terminator;
4035

4136
RT_VAR_GROUP_BEGIN
@@ -420,13 +415,6 @@ class Descriptor {
420415

421416
void Dump(FILE * = stdout) const;
422417

423-
// Value of the addendum presence flag.
424-
#define _CFI_ADDENDUM_FLAG 1
425-
// Number of bits needed to be shifted when manipulating the allocator index.
426-
#define _CFI_ALLOCATOR_IDX_SHIFT 1
427-
// Allocator index mask.
428-
#define _CFI_ALLOCATOR_IDX_MASK 0b00001110
429-
430418
RT_API_ATTRS inline bool HasAddendum() const {
431419
return raw_.extra & _CFI_ADDENDUM_FLAG;
432420
}
@@ -464,6 +452,8 @@ class alignas(Descriptor) StaticDescriptor {
464452
static constexpr bool hasAddendum{ADDENDUM || MAX_LEN_PARMS > 0};
465453
static constexpr std::size_t byteSize{
466454
Descriptor::SizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters)};
455+
static_assert(byteSize <=
456+
MaxDescriptorSizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters));
467457
RT_OFFLOAD_VAR_GROUP_END
468458

469459
RT_API_ATTRS Descriptor &descriptor() {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===-- include/FortranRuntime/Runtime/io-api-funcs.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 API between compiled code and I/O runtime library.
10+
11+
#ifndef FORTRAN_RUNTIME_IO_API_FUNCS_H_
12+
#define FORTRAN_RUNTIME_IO_API_FUNCS_H_
13+
14+
#include "flang/Common/uint128.h"
15+
#include "flang/Runtime/entry-names.h"
16+
#include "flang/Runtime/io-api.h"
17+
#include "flang/Runtime/iostat.h"
18+
#include "flang/Runtime/magic-numbers.h"
19+
#include <cinttypes>
20+
#include <cstddef>
21+
22+
namespace Fortran::runtime {
23+
class Descriptor;
24+
} // namespace Fortran::runtime
25+
26+
namespace Fortran::runtime::io {
27+
28+
struct NonTbpDefinedIoTable;
29+
class NamelistGroup;
30+
class IoStatementState;
31+
using Cookie = IoStatementState *;
32+
using ExternalUnit = int;
33+
using AsynchronousId = int;
34+
35+
RT_API_ATTRS const char *InquiryKeywordHashDecode(
36+
char *buffer, std::size_t, InquiryKeywordHash);
37+
38+
} // namespace Fortran::runtime::io
39+
#endif /* FORTRAN_RUNTIME_IO_API_FUNCS_H_ */
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- include/FortranRuntime/Runtime/iostat-funcs.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 values returned by the runtime for IOSTAT= specifiers
10+
// on I/O statements.
11+
12+
#ifndef FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
13+
#define FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
14+
15+
#include "flang/Common/api-attrs.h"
16+
#include "flang/Runtime/iostat.h"
17+
18+
namespace Fortran::runtime::io {
19+
20+
RT_API_ATTRS const char *IostatErrorString(int);
21+
22+
} // namespace Fortran::runtime::io
23+
#endif /* FORTRAN_RUNTIME_IOSTAT_FUNCS_H_ */

FortranRuntime/include/flang/Runtime/memory.h renamed to FortranRuntime/include/FortranRuntime/Runtime/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang/Runtime/memory.h --------------------------*- C++ -*-===//
1+
//===-- include/FortranRuntime/Runtime/memory.h -----------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

FortranRuntime/include/flang/Runtime/type-code.h renamed to FortranRuntime/include/FortranRuntime/Runtime/type-code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang/Runtime/type-code.h -----------------------*- C++ -*-===//
1+
//===-- include/FortranRuntime/Runtime/type-code.h --------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

FortranRuntime/include/flang/Runtime/array-constructor.h

Lines changed: 0 additions & 118 deletions
This file was deleted.

FortranRuntime/lib/Runtime/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
4545
add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
4646
endif ()
4747
include_directories(BEFORE
48-
${FLANG_SOURCE_DIR}/include
49-
${FLANG_SOURCE_DIR}/../FortranRuntime/include)
48+
${FLANG_SOURCE_DIR}/include)
5049

5150
# The out of tree builds of the compiler and the Fortran runtime
5251
# must use the same setting of FLANG_RUNTIME_F128_MATH_LIB
@@ -60,6 +59,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
6059
)
6160
endif()
6261

62+
include_directories(BEFORE ../../include)
63+
6364
include(CheckCXXSymbolExists)
6465
include(CheckCXXSourceCompiles)
6566
check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)

FortranRuntime/lib/Runtime/CUDA/allocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "flang/Runtime/CUDA/allocator.h"
9+
#include "FortranRuntime/Runtime/CUDA/allocator.h"
10+
#include "FortranRuntime/Runtime/allocator-registry.h"
1011
#include "../derived.h"
1112
#include "../stat.h"
1213
#include "../terminator.h"
1314
#include "../type-info.h"
1415
#include "flang/ISO_Fortran_binding_wrapper.h"
15-
#include "flang/Runtime/allocator-registry.h"
1616
#include "flang/Support/Fortran.h"
1717

1818
#include "cuda_runtime.h"

0 commit comments

Comments
 (0)