Skip to content

Commit 7251c95

Browse files
Meinersbursivan-shani
authored andcommitted
[Flang][NFC] Move runtime library files to flang-rt (llvm#110298)
Mostly mechanical changes in preparation of extracting the Flang-RT "subproject" in llvm#110217. This PR intends to only move pre-existing files to the new folder structure, with no behavioral change. Common files (headers, testing, cmake) shared by Flang-RT and Flang remain in `flang/`. Some cosmetic changes and files paths were necessary: * Relative paths to the new path for the source files and `add_subdirectory`. * Add the new location's include directory to `include_directories` * The unittest/Evaluate directory has unitests for flang-rt and Flang. A new `CMakeLists.txt` was introduced for the flang-rt tests. * Change the `#include` paths relative to the include directive * clang-format on the `#include` directives * Since the paths are part if the copyright header and include guards, a script was used to canonicalize those * `test/Runtime` and runtime tests in `test/Driver` are moved, but the lit.cfg.py mechanism to execute the will only be added in llvm#110217.
1 parent 4e32f0e commit 7251c95

File tree

220 files changed

+825
-726
lines changed

Some content is hidden

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

220 files changed

+825
-726
lines changed

flang-rt/.clang-format

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
3+
BasedOnStyle: LLVM
4+
AlignAfterOpenBracket: DontAlign
5+
AlignEscapedNewlines: DontAlign
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignOperands: false
9+
AlignTrailingComments: false
10+
IncludeCategories:
11+
- Regex: '^<'
12+
Priority: 6
13+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
14+
Priority: 5
15+
- Regex: '^"flang/' # Headers shared with Flang
16+
Priority: 4
17+
- Regex: '^"flang-rt/' # Public Flang-RT headers
18+
Priority: 3
19+
- Regex: '^[^/]*$' # Private headers from same library
20+
Priority: 1
21+
- Regex: '.*' # Private headers from sibling libraries
22+
Priority: 2
23+
...
24+
25+
# vim:set filetype=yaml:

flang-rt/cmake/config.h.cmake.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
*===----------------------------------------------------------------------===*/
8+
9+
#ifndef FORTRAN_RUNTIME_CONFIG_H
10+
#define FORTRAN_RUNTIME_CONFIG_H
11+
12+
/* Define to 1 if you have the `strerror_r' function. */
13+
#cmakedefine01 HAVE_STRERROR_R
14+
15+
/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you
16+
don't. */
17+
#cmakedefine01 HAVE_DECL_STRERROR_S
18+
19+
#endif

flang/examples/ExternalHelloWorld/external-hello.cpp renamed to flang-rt/examples/ExternalHelloWorld/external-hello.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//===-- examples/ExternalHelloWorld/external-hello.cpp ----------*- 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+
19
#include "flang/Runtime/io-api.h"
210
#include "flang/Runtime/main.h"
311
#include "flang/Runtime/stop.h"

flang/include/flang/Runtime/allocator-registry.h renamed to flang-rt/include/flang-rt/runtime/allocator-registry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- runtime/allocator-registry.h ----------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
10-
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
9+
#ifndef FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
10+
#define FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
1111

1212
#include "flang/Common/api-attrs.h"
1313
#include "flang/Runtime/allocator-registry-consts.h"
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
5555

5656
} // namespace Fortran::runtime
5757

58-
#endif // FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_
58+
#endif // FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_

flang/include/flang/Runtime/array-constructor.h renamed to flang-rt/include/flang-rt/runtime/array-constructor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang/Runtime/array-constructor.h ---------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/array-constructor.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.
@@ -9,11 +9,11 @@
99
// External APIs to create temporary storage for array constructors when their
1010
// final extents or length parameters cannot be pre-computed.
1111

12-
#ifndef FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
13-
#define FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
12+
#ifndef FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
13+
#define FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
1414

15+
#include "descriptor.h"
1516
#include "flang/Runtime/array-constructor-consts.h"
16-
#include "flang/Runtime/descriptor.h"
1717
#include "flang/Runtime/entry-names.h"
1818
#include <cstdint>
1919

@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
5454
"MaxArrayConstructorVectorAlignInBytes");
5555

5656
} // namespace Fortran::runtime
57-
#endif // FORTRAN_RUNTIME_ARRAYCONSTRUCTOR_H_
57+
#endif // FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_

flang/runtime/assign-impl.h renamed to flang-rt/include/flang-rt/runtime/assign-impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- runtime/assign-impl.h -----------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/assign-impl.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FORTRAN_RUNTIME_ASSIGN_IMPL_H_
10-
#define FORTRAN_RUNTIME_ASSIGN_IMPL_H_
9+
#ifndef FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
10+
#define FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
1111

1212
#include "flang/Runtime/freestanding-tools.h"
1313

@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
2828
#endif
2929

3030
} // namespace Fortran::runtime
31-
#endif // FORTRAN_RUNTIME_ASSIGN_IMPL_H_
31+
#endif // FLANG_RT_RUNTIME_ASSIGN_IMPL_H_

flang/runtime/buffer.h renamed to flang-rt/include/flang-rt/runtime/buffer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/buffer.h ----------------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/buffer.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.
@@ -8,12 +8,12 @@
88

99
// External file buffering
1010

11-
#ifndef FORTRAN_RUNTIME_BUFFER_H_
12-
#define FORTRAN_RUNTIME_BUFFER_H_
11+
#ifndef FLANG_RT_RUNTIME_BUFFER_H_
12+
#define FLANG_RT_RUNTIME_BUFFER_H_
1313

1414
#include "io-error.h"
15+
#include "memory.h"
1516
#include "flang/Runtime/freestanding-tools.h"
16-
#include "flang/Runtime/memory.h"
1717
#include <algorithm>
1818
#include <cinttypes>
1919
#include <cstring>
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
221221
bool dirty_{false};
222222
};
223223
} // namespace Fortran::runtime::io
224-
#endif // FORTRAN_RUNTIME_BUFFER_H_
224+
#endif // FLANG_RT_RUNTIME_BUFFER_H_

flang/runtime/connection.h renamed to flang-rt/include/flang-rt/runtime/connection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/connection.h ------------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/connection.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.
@@ -8,8 +8,8 @@
88

99
// Fortran I/O connection state (abstracted over internal & external units)
1010

11-
#ifndef FORTRAN_RUNTIME_IO_CONNECTION_H_
12-
#define FORTRAN_RUNTIME_IO_CONNECTION_H_
11+
#ifndef FLANG_RT_RUNTIME_CONNECTION_H_
12+
#define FLANG_RT_RUNTIME_CONNECTION_H_
1313

1414
#include "format.h"
1515
#include "flang/Common/optional.h"
@@ -124,4 +124,4 @@ class SavedPosition {
124124
};
125125

126126
} // namespace Fortran::runtime::io
127-
#endif // FORTRAN_RUNTIME_IO_CONNECTION_H_
127+
#endif // FLANG_RT_RUNTIME_CONNECTION_H_

flang/runtime/derived.h renamed to flang-rt/include/flang-rt/runtime/derived.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/derived.h -------------------------------------------------===//
1+
//===-- include/flang-rt/runtime/derived.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.
@@ -8,8 +8,8 @@
88

99
// Internal runtime utilities for derived type operations.
1010

11-
#ifndef FORTRAN_RUNTIME_DERIVED_H_
12-
#define FORTRAN_RUNTIME_DERIVED_H_
11+
#ifndef FLANG_RT_RUNTIME_DERIVED_H_
12+
#define FLANG_RT_RUNTIME_DERIVED_H_
1313

1414
#include "flang/Common/api-attrs.h"
1515

@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
4848
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
4949

5050
} // namespace Fortran::runtime
51-
#endif // FORTRAN_RUNTIME_DERIVED_H_
51+
#endif // FLANG_RT_RUNTIME_DERIVED_H_

flang/include/flang/Runtime/descriptor.h renamed to flang-rt/include/flang-rt/runtime/descriptor.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- include/flang/Runtime/descriptor.h ----------------------*- C++ -*-===//
1+
//===-- include/flang-rt/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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FORTRAN_RUNTIME_DESCRIPTOR_H_
10-
#define FORTRAN_RUNTIME_DESCRIPTOR_H_
9+
#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_H_
10+
#define FLANG_RT_RUNTIME_DESCRIPTOR_H_
1111

1212
// Defines data structures used during execution of a Fortran program
1313
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -18,10 +18,10 @@
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 "memory.h"
22+
#include "type-code.h"
2123
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
2224
#include "flang/Runtime/descriptor-consts.h"
23-
#include "flang/Runtime/memory.h"
24-
#include "flang/Runtime/type-code.h"
2525
#include <algorithm>
2626
#include <cassert>
2727
#include <cinttypes>
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
482482
};
483483

484484
} // namespace Fortran::runtime
485-
#endif // FORTRAN_RUNTIME_DESCRIPTOR_H_
485+
#endif // FLANG_RT_RUNTIME_DESCRIPTOR_H_

flang/runtime/emit-encoded.h renamed to flang-rt/include/flang-rt/runtime/emit-encoded.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/emit-encoded.h ----------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/emit-encoded.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.
@@ -8,8 +8,8 @@
88

99
// Templates for emitting CHARACTER values with conversion
1010

11-
#ifndef FORTRAN_RUNTIME_EMIT_ENCODED_H_
12-
#define FORTRAN_RUNTIME_EMIT_ENCODED_H_
11+
#ifndef FLANG_RT_RUNTIME_EMIT_ENCODED_H_
12+
#define FLANG_RT_RUNTIME_EMIT_ENCODED_H_
1313

1414
#include "connection.h"
1515
#include "environment.h"
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
114114
}
115115

116116
} // namespace Fortran::runtime::io
117-
#endif // FORTRAN_RUNTIME_EMIT_ENCODED_H_
117+
#endif // FLANG_RT_RUNTIME_EMIT_ENCODED_H_

flang/runtime/environment.h renamed to flang-rt/include/flang-rt/runtime/environment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- runtime/environment.h -----------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/environment.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FORTRAN_RUNTIME_ENVIRONMENT_H_
10-
#define FORTRAN_RUNTIME_ENVIRONMENT_H_
9+
#ifndef FLANG_RT_RUNTIME_ENVIRONMENT_H_
10+
#define FLANG_RT_RUNTIME_ENVIRONMENT_H_
1111

1212
#include "flang/Common/optional.h"
1313
#include "flang/Decimal/decimal.h"
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
6767

6868
} // namespace Fortran::runtime
6969

70-
#endif // FORTRAN_RUNTIME_ENVIRONMENT_H_
70+
#endif // FLANG_RT_RUNTIME_ENVIRONMENT_H_

flang/runtime/file.h renamed to flang-rt/include/flang-rt/runtime/file.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/file.h ------------------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/file.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.
@@ -8,12 +8,12 @@
88

99
// Raw system I/O wrappers
1010

11-
#ifndef FORTRAN_RUNTIME_FILE_H_
12-
#define FORTRAN_RUNTIME_FILE_H_
11+
#ifndef FLANG_RT_RUNTIME_FILE_H_
12+
#define FLANG_RT_RUNTIME_FILE_H_
1313

1414
#include "io-error.h"
15+
#include "memory.h"
1516
#include "flang/Common/optional.h"
16-
#include "flang/Runtime/memory.h"
1717
#include <cinttypes>
1818

1919
namespace Fortran::runtime::io {
@@ -113,4 +113,4 @@ RT_API_ATTRS bool MayWrite(const char *path);
113113
RT_API_ATTRS bool MayReadAndWrite(const char *path);
114114
RT_API_ATTRS std::int64_t SizeInBytes(const char *path);
115115
} // namespace Fortran::runtime::io
116-
#endif // FORTRAN_RUNTIME_FILE_H_
116+
#endif // FLANG_RT_RUNTIME_FILE_H_

flang/runtime/format-implementation.h renamed to flang-rt/include/flang-rt/runtime/format-implementation.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/format-implementation.h -------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/format-implementation.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.
@@ -8,8 +8,8 @@
88

99
// Implements out-of-line member functions of template class FormatControl
1010

11-
#ifndef FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
12-
#define FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
11+
#ifndef FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
12+
#define FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_
1313

1414
#include "emit-encoded.h"
1515
#include "format.h"
@@ -601,4 +601,4 @@ RT_API_ATTRS void FormatControl<CONTEXT>::Finish(Context &context) {
601601
}
602602
}
603603
} // namespace Fortran::runtime::io
604-
#endif // FORTRAN_RUNTIME_FORMAT_IMPLEMENTATION_H_
604+
#endif // FLANG_RT_RUNTIME_FORMAT_IMPLEMENTATION_H_

flang/runtime/format.h renamed to flang-rt/include/flang-rt/runtime/format.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/format.h ----------------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/format.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.
@@ -8,8 +8,8 @@
88

99
// FORMAT string processing
1010

11-
#ifndef FORTRAN_RUNTIME_FORMAT_H_
12-
#define FORTRAN_RUNTIME_FORMAT_H_
11+
#ifndef FLANG_RT_RUNTIME_FORMAT_H_
12+
#define FLANG_RT_RUNTIME_FORMAT_H_
1313

1414
#include "environment.h"
1515
#include "io-error.h"
@@ -201,4 +201,4 @@ template <typename CONTEXT> class FormatControl {
201201
Iteration stack_[maxMaxHeight];
202202
};
203203
} // namespace Fortran::runtime::io
204-
#endif // FORTRAN_RUNTIME_FORMAT_H_
204+
#endif // FLANG_RT_RUNTIME_FORMAT_H_

flang/runtime/internal-unit.h renamed to flang-rt/include/flang-rt/runtime/internal-unit.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- runtime/internal-unit.h ---------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/internal-unit.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.
@@ -8,11 +8,11 @@
88

99
// Fortran internal I/O "units"
1010

11-
#ifndef FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
12-
#define FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
11+
#ifndef FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
12+
#define FLANG_RT_RUNTIME_INTERNAL_UNIT_H_
1313

1414
#include "connection.h"
15-
#include "flang/Runtime/descriptor.h"
15+
#include "descriptor.h"
1616
#include <cinttypes>
1717
#include <type_traits>
1818

@@ -56,4 +56,4 @@ template <Direction DIR> class InternalDescriptorUnit : public ConnectionState {
5656
extern template class InternalDescriptorUnit<Direction::Output>;
5757
extern template class InternalDescriptorUnit<Direction::Input>;
5858
} // namespace Fortran::runtime::io
59-
#endif // FORTRAN_RUNTIME_IO_INTERNAL_UNIT_H_
59+
#endif // FLANG_RT_RUNTIME_INTERNAL_UNIT_H_

0 commit comments

Comments
 (0)