Skip to content

Commit c91ba04

Browse files
authored
[Flang][NFC] Split runtime headers in preparation for cross-compilation. (#112188)
Split some headers into headers for public and private declarations in preparation for #110217. Moving the runtime-private headers in runtime-private include directory will occur in #110298. * Do not use `sizeof(Descriptor)` in the compiler. The size of the descriptor is target-dependent while `sizeof(Descriptor)` is the size of the Descriptor for the host platform which might be too small when cross-compiling to a different platform. Another problem is that the emitted assembly ((cross-)compiling to the same target) is not identical between Flang's running on different systems. Moving the declaration of `class Descriptor` out of the included header will also reduce the amount of #included sources. * Do not use `sizeof(ArrayConstructorVector)` and `alignof(ArrayConstructorVector)` in the compiler. Same reason as with `Descriptor`. * Compute the descriptor's extra flags without instantiating a Descriptor. `Fortran::runtime::Descriptor` is defined in the runtime source, but not the compiler source. * Move `InquiryKeywordHashDecode` into runtime-private header. The function is defined in the runtime sources and trying to call it in the compiler would lead to a link-error. * Move allocator-kind magic numbers into common header. They are the only declarations out of `allocator-registry.h` in the compiler as well. This does not make Flang cross-compile ready yet, the main goal is to avoid transitive header dependencies from Flang to clang-rt. There are more assumptions that host platform is the same as the target platform.
1 parent 1801fb4 commit c91ba04

Some content is hidden

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

41 files changed

+728
-567
lines changed

flang/include/flang/Lower/Allocatable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "flang/Lower/AbstractConverter.h"
1717
#include "flang/Optimizer/Builder/MutableBox.h"
18-
#include "flang/Runtime/allocator-registry.h"
18+
#include "flang/Runtime/allocator-registry-consts.h"
1919
#include "llvm/ADT/StringRef.h"
2020

2121
namespace mlir {

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "flang/Optimizer/Builder/Runtime/Numeric.h"
1717
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
1818
#include "flang/Runtime/entry-names.h"
19-
#include "flang/Runtime/iostat.h"
19+
#include "flang/Runtime/iostat-consts.h"
2020
#include "mlir/Dialect/Complex/IR/Complex.h"
2121
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
2222
#include "mlir/Dialect/Math/IR/Math.h"

flang/include/flang/Optimizer/Builder/MutableBox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define FORTRAN_OPTIMIZER_BUILDER_MUTABLEBOX_H
1515

1616
#include "flang/Optimizer/Builder/BoxValue.h"
17-
#include "flang/Runtime/allocator-registry.h"
17+
#include "flang/Runtime/allocator-registry-consts.h"
1818
#include "llvm/ADT/StringRef.h"
1919

2020
namespace mlir {

flang/include/flang/Optimizer/CodeGen/DescriptorModel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define OPTIMIZER_DESCRIPTOR_MODEL_H
2424

2525
#include "flang/ISO_Fortran_binding_wrapper.h"
26-
#include "flang/Runtime/descriptor.h"
26+
#include "flang/Runtime/descriptor-consts.h"
2727
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
2828
#include "mlir/IR/BuiltinTypes.h"
2929
#include "llvm/Support/ErrorHandling.h"

flang/include/flang/Runtime/CUDA/allocatable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FORTRAN_RUNTIME_CUDA_ALLOCATABLE_H_
1010
#define FORTRAN_RUNTIME_CUDA_ALLOCATABLE_H_
1111

12-
#include "flang/Runtime/descriptor.h"
12+
#include "flang/Runtime/descriptor-consts.h"
1313
#include "flang/Runtime/entry-names.h"
1414

1515
namespace Fortran::runtime::cuda {

flang/include/flang/Runtime/CUDA/allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
1111

1212
#include "common.h"
13-
#include "flang/Runtime/descriptor.h"
13+
#include "flang/Runtime/descriptor-consts.h"
1414
#include "flang/Runtime/entry-names.h"
1515

1616
namespace Fortran::runtime::cuda {

flang/include/flang/Runtime/CUDA/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FORTRAN_RUNTIME_CUDA_COMMON_H_
1010
#define FORTRAN_RUNTIME_CUDA_COMMON_H_
1111

12-
#include "flang/Runtime/descriptor.h"
12+
#include "flang/Runtime/descriptor-consts.h"
1313
#include "flang/Runtime/entry-names.h"
1414

1515
/// Type of memory for allocation/deallocation

flang/include/flang/Runtime/CUDA/descriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
1010
#define FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
1111

12-
#include "flang/Runtime/descriptor.h"
12+
#include "flang/Runtime/descriptor-consts.h"
1313
#include "flang/Runtime/entry-names.h"
1414
#include <cstddef>
1515

flang/include/flang/Runtime/CUDA/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef FORTRAN_RUNTIME_CUDA_MEMORY_H_
1010
#define FORTRAN_RUNTIME_CUDA_MEMORY_H_
1111

12-
#include "flang/Runtime/descriptor.h"
12+
#include "flang/Runtime/descriptor-consts.h"
1313
#include "flang/Runtime/entry-names.h"
1414
#include <cstddef>
1515

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- include/flang/Runtime/allocator-registry-consts.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+
#ifndef FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_
10+
#define FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_
11+
12+
static constexpr unsigned kDefaultAllocator = 0;
13+
14+
// Allocator used for CUF
15+
static constexpr unsigned kPinnedAllocatorPos = 1;
16+
static constexpr unsigned kDeviceAllocatorPos = 2;
17+
static constexpr unsigned kManagedAllocatorPos = 3;
18+
static constexpr unsigned kUnifiedAllocatorPos = 4;
19+
20+
#endif /* FORTRAN_RUNTIME_ALLOCATOR_REGISTRY_CONSTS_H_ */

0 commit comments

Comments
 (0)