| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Files in this directory are used by Flang (the compiler) and FortranRuntime | ||
| (the runtime library for Flang-compiled programs). They must be compatible by | ||
| both. For definitions used only by Flang, consider | ||
| `flang/{lib,include/flang}/Support` instead. For definitions used only by | ||
| FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`. | ||
|
|
||
| The requirements for common code include: | ||
|
|
||
| * No dependence to LLVM, including LLVMSupport. | ||
|
|
||
| * No link-dependence to the C++ runtime. This means that e.g. `std::string` | ||
| cannot be used. | ||
|
|
||
| * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used | ||
| instead. | ||
|
|
||
| * Preprocessor macros from `config.h` and CMake | ||
| `(target/add)_compile_definitions` must be defined by both build scripts. | ||
| See `flang/cmake/modules/FlangCommon.cmake`. | ||
|
|
||
| * Some header files are included from `.c` files. | ||
| `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C. | ||
|
|
||
| * Global declarations may need to be annotated using definitions from | ||
| `api-attrs.h`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,4 +141,4 @@ class RealCharacteristics { | |
| }; | ||
|
|
||
| } // namespace Fortran::common | ||
| #endif // FORTRAN_COMMON_REAL_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,4 @@ | |
|
|
||
| #endif // _WIN32 | ||
|
|
||
| #endif // FORTRAN_COMMON_WINDOWS_INCLUDE_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Files in this directory are used by Flang (the compiler) and FortranRuntime | ||
| (the runtime library for Flang-compiled programs). They must be compatible by | ||
| both. For definitions used only by Flang, consider | ||
| `flang/{lib,include/flang}/Support` instead. For definitions used only by | ||
| FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`. | ||
|
|
||
| The requirements for common code include: | ||
|
|
||
| * No dependence to LLVM, including LLVMSupport. | ||
|
|
||
| * No link-dependence to the C++ runtime. This means that e.g. `std::string` | ||
| cannot be used. | ||
|
|
||
| * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used | ||
| instead. | ||
|
|
||
| * Preprocessor macros from `config.h` and CMake | ||
| `(target/add)_compile_definitions` must be defined by both build scripts. | ||
| See `flang/cmake/modules/FlangCommon.cmake`. | ||
|
|
||
| * Some header files are included from `.c` files. | ||
| `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C. | ||
|
|
||
| * Global declarations may need to be annotated using definitions from | ||
| `api-attrs.h`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //===-- include/flang/Runtime/allocator-registry-consts.h -------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ | ||
| #define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ | ||
|
|
||
| static constexpr unsigned kDefaultAllocator = 0; | ||
|
|
||
| // Allocator used for CUF | ||
| static constexpr unsigned kPinnedAllocatorPos = 1; | ||
| static constexpr unsigned kDeviceAllocatorPos = 2; | ||
| static constexpr unsigned kManagedAllocatorPos = 3; | ||
| static constexpr unsigned kUnifiedAllocatorPos = 4; | ||
|
|
||
| #endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| //===-- include/flang/Runtime/array-constructor-consts.h --------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // External APIs to create temporary storage for array constructors when their | ||
| // final extents or length parameters cannot be pre-computed. | ||
|
|
||
| #ifndef FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_ | ||
| #define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_ | ||
|
|
||
| #include "flang/Runtime/descriptor-consts.h" | ||
| #include "flang/Runtime/entry-names.h" | ||
| #include <cstdint> | ||
|
|
||
| namespace Fortran::runtime { | ||
| struct ArrayConstructorVector; | ||
|
|
||
| // Max sizeof(ArrayConstructorVector) and sizeof(ArrayConstructorVector) for any | ||
| // target. | ||
| // TODO: Use target-specific size/alignment instead of overapproximation. | ||
| constexpr std::size_t MaxArrayConstructorVectorSizeInBytes = 2 * 40; | ||
| constexpr std::size_t MaxArrayConstructorVectorAlignInBytes = 8; | ||
|
|
||
| extern "C" { | ||
| // API to initialize an ArrayConstructorVector before any values are pushed to | ||
| // it. Inlined code is only expected to allocate the "ArrayConstructorVector" | ||
| // class instance storage with sufficient size (using | ||
| // "2*sizeof(ArrayConstructorVector)" on the host should be safe regardless of | ||
| // the target the runtime is compiled for). This avoids the need for the runtime | ||
| // to maintain a state, or to use dynamic allocation for it. "vectorClassSize" | ||
| // is used to validate that lowering allocated enough space for it. | ||
| void RTDECL(InitArrayConstructorVector)(ArrayConstructorVector &vector, | ||
| Descriptor &to, bool useValueLengthParameters, int vectorClassSize, | ||
| const char *sourceFile = nullptr, int sourceLine = 0); | ||
|
|
||
| // Generic API to push any kind of entity into the array constructor (any | ||
| // Fortran type and any rank). | ||
| void RTDECL(PushArrayConstructorValue)( | ||
| ArrayConstructorVector &vector, const Descriptor &from); | ||
|
|
||
| // API to push scalar array constructor value of: | ||
| // - a numerical or logical type, | ||
| // - or a derived type that has no length parameters, and no allocatable | ||
| // component (that would require deep copies). | ||
| // It requires no descriptor for the value that is passed via its base address. | ||
| void RTDECL(PushArrayConstructorSimpleScalar)( | ||
| ArrayConstructorVector &vector, void *from); | ||
| } // extern "C" | ||
| } // namespace Fortran::runtime | ||
| #endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_CONSTS_H_ */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,4 +62,4 @@ std::int32_t RTNAME(GetCwd)( | |
| } | ||
| } // namespace Fortran::runtime | ||
|
|
||
| #endif // FORTRAN_RUNTIME_COMMAND_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| //===-- include/flang/Runtime/descriptor-consts.h ---------------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_ | ||
| #define FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_ | ||
|
|
||
| #include "flang/Common/ISO_Fortran_binding_wrapper.h" | ||
| #include "flang/Common/api-attrs.h" | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
|
|
||
| // Value of the addendum presence flag. | ||
| #define _CFI_ADDENDUM_FLAG 1 | ||
| // Number of bits needed to be shifted when manipulating the allocator index. | ||
| #define _CFI_ALLOCATOR_IDX_SHIFT 1 | ||
| // Allocator index mask. | ||
| #define _CFI_ALLOCATOR_IDX_MASK 0b00001110 | ||
|
|
||
| namespace Fortran::runtime::typeInfo { | ||
| using TypeParameterValue = std::int64_t; | ||
| class DerivedType; | ||
| } // namespace Fortran::runtime::typeInfo | ||
|
|
||
| namespace Fortran::runtime { | ||
| class Descriptor; | ||
| using SubscriptValue = ISO::CFI_index_t; | ||
|
|
||
| /// Returns size in bytes of the descriptor (not the data) | ||
| /// This must be at least as large as the largest descriptor of any target | ||
| /// triple. | ||
| static constexpr RT_API_ATTRS std::size_t MaxDescriptorSizeInBytes( | ||
| int rank, bool addendum = false, int lengthTypeParameters = 0) { | ||
| // Layout: | ||
| // | ||
| // fortran::runtime::Descriptor { | ||
| // ISO::CFI_cdesc_t { | ||
| // void *base_addr; (pointer -> up to 8 bytes) | ||
| // size_t elem_len; (up to 8 bytes) | ||
| // int version; (up to 4 bytes) | ||
| // CFI_rank_t rank; (unsigned char -> 1 byte) | ||
| // CFI_type_t type; (signed char -> 1 byte) | ||
| // CFI_attribute_t attribute; (unsigned char -> 1 byte) | ||
| // unsigned char extra; (1 byte) | ||
| // } | ||
| // } | ||
| // fortran::runtime::Dimension[rank] { | ||
| // ISO::CFI_dim_t { | ||
| // CFI_index_t lower_bound; (ptrdiff_t -> up to 8 bytes) | ||
| // CFI_index_t extent; (ptrdiff_t -> up to 8 bytes) | ||
| // CFI_index_t sm; (ptrdiff_t -> up to 8 bytes) | ||
| // } | ||
| // } | ||
| // fortran::runtime::DescriptorAddendum { | ||
| // const typeInfo::DerivedType *derivedType_; (pointer -> up to 8 | ||
| // bytes) typeInfo::TypeParameterValue len_[lenParameters]; (int64_t -> 8 | ||
| // bytes) | ||
| // } | ||
| std::size_t bytes{24u + rank * 24u}; | ||
| if (addendum || lengthTypeParameters > 0) { | ||
| if (lengthTypeParameters < 1) | ||
| lengthTypeParameters = 1; | ||
| bytes += 8u + static_cast<std::size_t>(lengthTypeParameters) * 8u; | ||
| } | ||
| return bytes; | ||
| } | ||
|
|
||
| } // namespace Fortran::runtime | ||
| #endif /* FORTRAN_RUNTIME_DESCRIPTOR_CONSTS_H_ */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,4 @@ NORETURN void RTNAME(ReportFatalUserError)( | |
|
|
||
| FORTRAN_EXTERN_C_END | ||
|
|
||
| #endif // FORTRAN_RUNTIME_STOP_H_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Files in this directory are used by Flang (the compiler) and FortranRuntime | ||
| (the runtime library for Flang-compiled programs). They must be compatible by | ||
| both. For definitions used only by Flang, consider | ||
| `flang/{lib,include/flang}/Support` instead. For definitions used only by | ||
| FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`. | ||
|
|
||
| The requirements for common code include: | ||
|
|
||
| * No dependence to LLVM, including LLVMSupport. | ||
|
|
||
| * No link-dependence to the C++ runtime. This means that e.g. `std::string` | ||
| cannot be used. | ||
|
|
||
| * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used | ||
| instead. | ||
|
|
||
| * Preprocessor macros from `config.h` and CMake | ||
| `(target/add)_compile_definitions` must be defined by both build scripts. | ||
| See `flang/cmake/modules/FlangCommon.cmake`. | ||
|
|
||
| * Some header files are included from `.c` files. | ||
| `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C. | ||
|
|
||
| * Global declarations may need to be annotated using definitions from | ||
| `api-attrs.h`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Files in this directory are used by Flang (the compiler) and FortranRuntime | ||
| (the runtime library for Flang-compiled programs). They must be compatible by | ||
| both. For definitions used only by Flang, consider | ||
| `flang/{lib,include/flang}/Support` instead. For definitions used only by | ||
| FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`. | ||
|
|
||
| The requirements for common code include: | ||
|
|
||
| * No dependence to LLVM, including LLVMSupport. | ||
|
|
||
| * No link-dependence to the C++ runtime. This means that e.g. `std::string` | ||
| cannot be used. | ||
|
|
||
| * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used | ||
| instead. | ||
|
|
||
| * Preprocessor macros from `config.h` and CMake | ||
| `(target/add)_compile_definitions` must be defined by both build scripts. | ||
| See `flang/cmake/modules/FlangCommon.cmake`. | ||
|
|
||
| * Some header files are included from `.c` files. | ||
| `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C. | ||
|
|
||
| * Global declarations may need to be annotated using definitions from | ||
| `api-attrs.h`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Files in this directory are used by Flang (the compiler) and FortranRuntime | ||
| (the runtime library for Flang-compiled programs). They must be compatible by | ||
| both. For definitions used only by Flang, consider | ||
| `flang/{lib,include/flang}/Support` instead. For definitions used only by | ||
| FortranRuntime, consider `FortranRuntime/{lib,include/FortranRuntime}/Runtime`. | ||
|
|
||
| The requirements for common code include: | ||
|
|
||
| * No dependence to LLVM, including LLVMSupport. | ||
|
|
||
| * No link-dependence to the C++ runtime. This means that e.g. `std::string` | ||
| cannot be used. | ||
|
|
||
| * No use of `std::optional<T>`; `fortran::common::optional<T>` can be used | ||
| instead. | ||
|
|
||
| * Preprocessor macros from `config.h` and CMake | ||
| `(target/add)_compile_definitions` must be defined by both build scripts. | ||
| See `flang/cmake/modules/FlangCommon.cmake`. | ||
|
|
||
| * Some header files are included from `.c` files. | ||
| `#include <flang/Common/c-or-cpp.h>` can help to support C++ and C. | ||
|
|
||
| * Global declarations may need to be annotated using definitions from | ||
| `api-attrs.h`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| add_flang_unittest(FlangCommonTests | ||
| FastIntSetTest.cpp | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
| add_flang_nongtest_unittest(quick-sanity-test | ||
| FortranDecimal | ||
| ) | ||
|
|
||
| # This test is not run by default as it takes a long time to execute. | ||
| add_flang_nongtest_unittest(thorough-test | ||
| SLOW_TEST | ||
| FortranDecimal | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,3 @@ | ||
| #include "flang/Common/decimal.h" | ||
| #include "llvm/Support/raw_ostream.h" | ||
| #include <cinttypes> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,3 @@ | ||
| #include "flang/Common/decimal.h" | ||
| #include "llvm/Support/raw_ostream.h" | ||
| #include <cinttypes> | ||
|
|
||