Skip to content

Commit

Permalink
Merge 'keep common files in flang/'
Browse files Browse the repository at this point in the history
  • Loading branch information
Meinersbur committed Oct 15, 2024
1 parent 7123f2c commit cc21ca9
Show file tree
Hide file tree
Showing 222 changed files with 823 additions and 554 deletions.
14 changes: 7 additions & 7 deletions FortranRuntime/cmake/config.h.cmake.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//===-- cmake/config.h.cmake.in ---------------------------------*- 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
//
//===----------------------------------------------------------------------===//
/*===-- cmake/config.cmake.in ---------------------------------------*- 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_CONFIG_H
#define FORTRAN_RUNTIME_CONFIG_H
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Runtime/allocator-registry.h --------------*- C++ -*-===//
//===-- include/FortranRuntime/Runtime/allocator-registry.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.
Expand All @@ -10,17 +10,10 @@
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_H_

#include "flang/Common/api-attrs.h"
#include "flang/Runtime/allocator-registry-consts.h"
#include <cstdlib>
#include <vector>

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;

#define MAX_ALLOCATOR 7 // 3 bits are reserved in the descriptor.

namespace Fortran::runtime {
Expand Down
48 changes: 48 additions & 0 deletions FortranRuntime/include/FortranRuntime/Runtime/array-constructor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//===-- include/FortranRuntime/Runtime/array-constructor.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_H_
#define FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_

#include "FortranRuntime/Runtime/descriptor.h"
#include "flang/Runtime/array-constructor-consts.h"
#include "flang/Runtime/entry-names.h"
#include <cstdint>

namespace Fortran::runtime {

// Runtime data structure to hold information about the storage of
// an array constructor being constructed.
struct ArrayConstructorVector {
RT_API_ATTRS ArrayConstructorVector(class Descriptor &to,
SubscriptValue nextValuePosition, SubscriptValue actualAllocationSize,
const char *sourceFile, int sourceLine, bool useValueLengthParameters)
: to{to}, nextValuePosition{nextValuePosition},
actualAllocationSize{actualAllocationSize}, sourceFile{sourceFile},
sourceLine{sourceLine},
useValueLengthParameters_{useValueLengthParameters} {}

RT_API_ATTRS bool useValueLengthParameters() const {
return useValueLengthParameters_;
}

class Descriptor &to;
SubscriptValue nextValuePosition;
SubscriptValue actualAllocationSize;
const char *sourceFile;
int sourceLine;

private:
unsigned char useValueLengthParameters_ : 1;
};

} // namespace Fortran::runtime
#endif /* FORTRAN_RUNTIME_ARRAY_CONSTRUCTOR_H_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Runtime/descriptor.h ----------------------*- C++ -*-===//
//===-- include/FortranRuntime/Runtime/descriptor.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.
Expand All @@ -18,24 +18,19 @@
// User C code is welcome to depend on that ISO_Fortran_binding.h file,
// but should never reference this internal header.

#include "FortranRuntime/Runtime/memory.h"
#include "FortranRuntime/Runtime/type-code.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/memory.h"
#include "flang/Runtime/type-code.h"
#include "flang/Runtime/descriptor-consts.h"
#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstddef>
#include <cstdio>
#include <cstring>

namespace Fortran::runtime::typeInfo {
using TypeParameterValue = std::int64_t;
class DerivedType;
} // namespace Fortran::runtime::typeInfo

namespace Fortran::runtime {

using SubscriptValue = ISO::CFI_index_t;
class Terminator;

RT_VAR_GROUP_BEGIN
Expand Down Expand Up @@ -420,13 +415,6 @@ class Descriptor {

void Dump(FILE * = stdout) const;

// 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

RT_API_ATTRS inline bool HasAddendum() const {
return raw_.extra & _CFI_ADDENDUM_FLAG;
}
Expand Down Expand Up @@ -464,6 +452,8 @@ class alignas(Descriptor) StaticDescriptor {
static constexpr bool hasAddendum{ADDENDUM || MAX_LEN_PARMS > 0};
static constexpr std::size_t byteSize{
Descriptor::SizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters)};
static_assert(byteSize <=
MaxDescriptorSizeInBytes(maxRank, hasAddendum, maxLengthTypeParameters));
RT_OFFLOAD_VAR_GROUP_END

RT_API_ATTRS Descriptor &descriptor() {
Expand Down
39 changes: 39 additions & 0 deletions FortranRuntime/include/FortranRuntime/Runtime/io-api-funcs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===-- include/FortranRuntime/Runtime/io-api-funcs.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
//
//===----------------------------------------------------------------------===//

// Defines API between compiled code and I/O runtime library.

#ifndef FORTRAN_RUNTIME_IO_API_FUNCS_H_
#define FORTRAN_RUNTIME_IO_API_FUNCS_H_

#include "flang/Common/uint128.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/iostat.h"
#include "flang/Runtime/magic-numbers.h"
#include <cinttypes>
#include <cstddef>

namespace Fortran::runtime {
class Descriptor;
} // namespace Fortran::runtime

namespace Fortran::runtime::io {

struct NonTbpDefinedIoTable;
class NamelistGroup;
class IoStatementState;
using Cookie = IoStatementState *;
using ExternalUnit = int;
using AsynchronousId = int;

RT_API_ATTRS const char *InquiryKeywordHashDecode(
char *buffer, std::size_t, InquiryKeywordHash);

} // namespace Fortran::runtime::io
#endif /* FORTRAN_RUNTIME_IO_API_FUNCS_H_ */
23 changes: 23 additions & 0 deletions FortranRuntime/include/FortranRuntime/Runtime/iostat-funcs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===-- include/FortranRuntime/Runtime/iostat-funcs.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
//
//===----------------------------------------------------------------------===//

// Defines the values returned by the runtime for IOSTAT= specifiers
// on I/O statements.

#ifndef FORTRAN_RUNTIME_IOSTAT_FUNCS_H_
#define FORTRAN_RUNTIME_IOSTAT_FUNCS_H_

#include "flang/Common/api-attrs.h"
#include "flang/Runtime/iostat.h"

namespace Fortran::runtime::io {

RT_API_ATTRS const char *IostatErrorString(int);

} // namespace Fortran::runtime::io
#endif /* FORTRAN_RUNTIME_IOSTAT_FUNCS_H_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Runtime/memory.h --------------------------*- C++ -*-===//
//===-- include/FortranRuntime/Runtime/memory.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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Runtime/type-code.h -----------------------*- C++ -*-===//
//===-- include/FortranRuntime/Runtime/type-code.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.
Expand Down
118 changes: 0 additions & 118 deletions FortranRuntime/include/flang/Runtime/array-constructor.h

This file was deleted.

4 changes: 2 additions & 2 deletions FortranRuntime/lib/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ set(supported_sources

# List of source not used for GPU offloading.
set(host_sources
../Common/binary-to-decimal.cpp
../Common/decimal-to-binary.cpp
${FLANG_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp
${FLANG_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp
command.cpp
complex-powi.cpp
complex-reduction.c
Expand Down
6 changes: 3 additions & 3 deletions FortranRuntime/lib/Runtime/CUDA/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Runtime/CUDA/allocator.h"
#include "FortranRuntime/Runtime/CUDA/allocator.h"
#include "FortranRuntime/Runtime/allocator-registry.h"
#include "../derived.h"
#include "../stat.h"
#include "../terminator.h"
#include "../type-info.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocator-registry.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Support/Fortran.h"

#include "cuda_runtime.h"
Expand Down
4 changes: 2 additions & 2 deletions FortranRuntime/lib/Runtime/CUDA/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "FortranRuntime/Runtime/CUDA/descriptor.h"
#include "FortranRuntime/Runtime/CUDA/allocator.h"

namespace Fortran::runtime::cuda {
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions FortranRuntime/lib/Runtime/Float128Math/math-entries.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#ifndef FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
#define FORTRAN_RUNTIME_FLOAT128MATH_MATH_ENTRIES_H_
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include "terminator.h"
#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/entry-names.h"
#include <cfloat>
#include <cmath>
#include <type_traits>
Expand Down
Loading

0 comments on commit cc21ca9

Please sign in to comment.