Skip to content

Commit cc21ca9

Browse files
committed
Merge 'keep common files in flang/'
1 parent 7123f2c commit cc21ca9

File tree

222 files changed

+823
-554
lines changed

Some content is hidden

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

222 files changed

+823
-554
lines changed

FortranRuntime/cmake/config.h.cmake.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//===-- cmake/config.h.cmake.in ---------------------------------*- 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-
//===----------------------------------------------------------------------===//
1+
/*===-- cmake/config.cmake.in ---------------------------------------*- 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+
*===----------------------------------------------------------------------===*/
88

99
#ifndef FORTRAN_RUNTIME_CONFIG_H
1010
#define FORTRAN_RUNTIME_CONFIG_H

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ set(supported_sources
6565

6666
# List of source not used for GPU offloading.
6767
set(host_sources
68-
../Common/binary-to-decimal.cpp
69-
../Common/decimal-to-binary.cpp
68+
${FLANG_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp
69+
${FLANG_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp
7070
command.cpp
7171
complex-powi.cpp
7272
complex-reduction.c

0 commit comments

Comments
 (0)