14 changes: 7 additions & 7 deletions flang/runtime/unit.h → FortranRuntime/lib/Runtime/unit.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- runtime/unit.h ------------------------------------------*- C++ -*-===//
//===-- lib/Runtime/unit.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 @@ -8,21 +8,21 @@

// Fortran external I/O units

#ifndef FORTRAN_RUNTIME_IO_UNIT_H_
#define FORTRAN_RUNTIME_IO_UNIT_H_
#ifndef FORTRAN_RUNTIME_UNIT_H_
#define FORTRAN_RUNTIME_UNIT_H_

#include "buffer.h"
#include "connection.h"
#include "environment.h"
#include "file.h"
#include "flang/Common/constexpr-bitset.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/memory.h"
#include "format.h"
#include "io-error.h"
#include "io-stmt.h"
#include "lock.h"
#include "terminator.h"
#include "flang/Common/constexpr-bitset.h"
#include "flang/Common/optional.h"
#include "flang/Runtime/memory.h"
#include <cstdlib>
#include <cstring>
#include <flang/Common/variant.h>
Expand Down Expand Up @@ -291,4 +291,4 @@ class ChildIo {
};

} // namespace Fortran::runtime::io
#endif // FORTRAN_RUNTIME_IO_UNIT_H_
#endif /* FORTRAN_RUNTIME_UNIT_H_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- runtime/utf.cpp ---------------------------------------------------===//
//===-- lib/Runtime/utf.cpp -------------------------------------*- 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
4 changes: 2 additions & 2 deletions flang/runtime/utf.h → FortranRuntime/lib/Runtime/utf.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- runtime/utf.h -----------------------------------------------------===//
//===-- lib/Runtime/utf.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 Expand Up @@ -70,4 +70,4 @@ RT_API_ATTRS Fortran::common::optional<char32_t> DecodeUTF8(const char *);
RT_API_ATTRS std::size_t EncodeUTF8(char *, char32_t);

} // namespace Fortran::runtime
#endif // FORTRAN_RUNTIME_UTF_H_
#endif /* FORTRAN_RUNTIME_UTF_H_ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#include "fp-testing.h"
//===-- lib/Testing/fp-testing.cpp ------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Testing/fp-testing.h"
#include "llvm/Support/Errno.h"
#include <cstdio>
#include <cstdlib>
Expand All @@ -8,7 +16,7 @@
#endif

using Fortran::common::RoundingMode;
using Fortran::evaluate::RealFlag;
using Fortran::common::RealFlag;

ScopedHostFloatingPointEnvironment::ScopedHostFloatingPointEnvironment(
#if __x86_64__
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#include "testing.h"
//===-- lib/Testing/testing.cpp ---------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdarg>
#include <cstdio>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions FortranRuntime/unittests/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#===-- unittests/Common/CMakeLists.txt -------------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#

add_flang_unittest(FlangCommonTests
FastIntSetTest.cpp
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- C++ -*-===//
//===-- unittests/Common/FastIntSetTest.cpp ---------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "flang/Common/fast-int-set.h"
#include "gtest/gtest.h"
#include <optional>

TEST(FastIntSetTests, Sanity) {
Expand Down
18 changes: 18 additions & 0 deletions FortranRuntime/unittests/Decimal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#===-- unittests/Decimal/CMakeLists.txt ------------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#

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,4 +1,12 @@
#include "flang/Decimal/decimal.h"
//===-- unittests/Decimal/quick-sanity-test.cpp -----------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <cstdio>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#include "flang/Decimal/decimal.h"
//===-- unittests/Decimal/thorough-test.cpp ---------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/decimal.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <cstdio>
Expand Down
14 changes: 14 additions & 0 deletions FortranRuntime/unittests/Evaluate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#===-- unittests/Evaluate/CMakeLists.txt -----------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#

add_flang_nongtest_unittest(reshape
FortranEvaluateTesting
FortranSemantics
FortranEvaluate
FortranRuntime
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "testing.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
//===-- unittests/Evaluate/ISO-Fortran-binding.cpp --------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h"
#include <type_traits>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "testing.h"
//===-- unittests/Evaluate/reshape.cpp --------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes>

using namespace Fortran::common;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/AccessTest.cpp ----------------------------===//
//===-- unittests/Runtime/AccessTest.cpp ------------------------*- 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,9 +10,9 @@
#ifndef _WIN32

#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include "flang/Runtime/extensions.h"
#include "llvm/ADT/Twine.h"
#include "gtest/gtest.h"

#include <fcntl.h>
#include <sys/stat.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Allocatable.cpp--------- ---------*- C++-*-===//
//===-- unittests/Runtime/Allocatable.cpp -----------------------*- 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 @@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/allocatable.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//===-- flang/unittests/Runtime/ArrayConstructor.cpp-------------*- C++ -*-===//
//===-- unittests/Runtime/ArrayConstructor.cpp ------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/array-constructor.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"

#include <memory>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//===-- flang/unittests/Runtime/BufferTest.cpp ------------------*- C++ -*-===//
//===-- unittests/Runtime/BufferTest.cpp ------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "../../runtime/buffer.h"
#include "../../lib/Runtime/buffer.h"
#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include <algorithm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#===-- unittests/Runtime/CMakeLists.txt ------------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#

add_flang_unittest(FlangRuntimeTests
AccessTest.cpp
Allocatable.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//===-- flang/unittests/Runtime/AllocatableCUF.cpp ---------------*- C++-*-===//
//===-- unittests/Runtime/CUDA/AllocatorCUF.cpp -----------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "../../../runtime/terminator.h"
#include "flang/Common/Fortran.h"
#include "flang/Runtime/CUDA/allocator.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/allocator-registry.h"
#include "flang/Support/Fortran.h"
#include "gtest/gtest.h"

#include "cuda_runtime.h"

Expand Down
23 changes: 23 additions & 0 deletions FortranRuntime/unittests/Runtime/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#===-- unittests/Runtime/CUDA/CMakeLists.txt -------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#

if (FLANG_CUF_RUNTIME)

add_flang_unittest(FlangCufRuntimeTests
AllocatorCUF.cpp
)

target_link_libraries(FlangCufRuntimeTests
PRIVATE
CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
FortranRuntime
)

target_include_directories(FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS})

endif()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/CharacterTest.cpp ---------------*- C++ -*-===//
//===-- unittests/Runtime/CharacterTest.cpp ---------------------*- 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,8 +10,8 @@
// in Fortran.

#include "flang/Runtime/character.h"
#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "gtest/gtest.h"
#include <cstring>
#include <functional>
#include <tuple>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/CommandTest.cpp ---------------------------===//
//===-- unittests/Runtime/CommandTest.cpp -----------------------*- 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 @@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/command.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/execute.h"
#include "flang/Runtime/extensions.h"
#include "flang/Runtime/main.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstddef>
#include <cstdlib>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Complex.cpp ---------------------*- C++ -*-===//
//===-- unittests/Runtime/Complex.cpp ---------------------------*- 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 @@ -13,7 +13,7 @@
#pragma clang diagnostic ignored "-Wc99-extensions"
#endif

#include "flang/Common/Fortran.h"
#include "flang/Common/Fortran-consts.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/entry-names.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
//===-- unittests/Runtime/CrashHandlerFixture.cpp ---------------*- 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
//
//===----------------------------------------------------------------------===//
#include "CrashHandlerFixture.h"
#include "../../runtime/terminator.h"
#include "../../lib/Runtime/terminator.h"
#include <cstdarg>
#include <cstdlib>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/CrashHandlerFixture.h -----------*- C++ -*-===//
//===-- unittests/Runtime/CrashHandlerFixture.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,12 +10,12 @@
/// with expected message.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
#define LLVM_FLANG_UNITTESTS_RUNTIMEGTEST_CRASHHANDLERFIXTURE_H
#ifndef FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
#define FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_
#include <gtest/gtest.h>

struct CrashHandlerFixture : testing::Test {
void SetUp();
};

#endif
#endif /* FORTRAN_UNITTESTS_RUNTIME_CRASHHANDLERFIXTURE_H_ */
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
//===-- unittests/Runtime/Derived.cpp ---------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/derived-api.h"
#include "flang/Runtime/descriptor.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/RuntimeGTest/ExternalIOTest.cpp ---------*- C++ -*-===//
//===-- unittests/Runtime/ExternalIOTest.cpp --------------------*- 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 @@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//

#include "CrashHandlerFixture.h"
#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/main.h"
#include "flang/Runtime/stop.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
#include <cstring>
#include <string_view>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Format.cpp ----------------------*- C++ -*-===//
//===-- unittests/Runtime/Format.cpp ----------------------------*- 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 @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "CrashHandlerFixture.h"
#include "../runtime/connection.h"
#include "../runtime/format-implementation.h"
#include "../runtime/io-error.h"
#include "../../lib/Runtime/connection.h"
#include "../../lib/Runtime/format-implementation.h"
#include "../../lib/Runtime/io-error.h"
#include <optional>
#include <string>
#include <tuple>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Inquiry.cpp -------------------------------===//
//===-- unittests/Runtime/Inquiry.cpp ---------------------------*- 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 @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/inquiry.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//===-- flang/unittests/Runtime/ListInputTest.cpp ---------------*- C++ -*-===//
//===-- unittests/Runtime/ListInputTest.cpp ---------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "../../lib/Runtime/io-error.h"
#include "CrashHandlerFixture.h"
#include "../../runtime/io-error.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/LogicalFormatTest.cpp -----------*- C++ -*-===//
//===-- unittests/Runtime/LogicalFormatTest.cpp -----------------*- 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 @@
//===-- flang/unittests/Runtime/Matmul.cpp--------- -------------*- C++ -*-===//
//===-- unittests/Runtime/Matmul.cpp ----------------------------*- 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 @@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/matmul.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//===-- flang/unittests/Runtime/MatmulTranspose.cpp -------------*- C++ -*-===//
//===-- unittests/Runtime/MatmulTranspose.cpp -------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/matmul-transpose.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//===-- flang/unittests/Runtime/MiscIntrinsic.cpp ---------------*- C++ -*-===//
//===-- unittests/Runtime/MiscIntrinsic.cpp ---------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime//misc-intrinsic.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//===-- flang/unittests/Runtime/Namelist.cpp --------------------*- C++ -*-===//
//===-- unittests/Runtime/Namelist.cpp --------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "../../runtime/namelist.h"
#include "../../lib/Runtime/namelist.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/io-api.h"
#include "tools.h"
#include <algorithm>
#include <cinttypes>
#include <complex>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Numeric.cpp ---------------------*- C++ -*-===//
//===-- unittests/Runtime/Numeric.cpp ---------------------------*- 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 @@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/numeric.h"
#include "gtest/gtest.h"
#include "flang/Common/float128.h"
#include "gtest/gtest.h"
#include <cmath>
#include <limits>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/NumericalFormatTest.cpp ---------*- C++ -*-===//
//===-- unittests/Runtime/NumericalFormatTest.cpp ---------------*- 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 @@
//===-- flang/unittests/Runtime/Pointer.cpp--------- -------------*- C++-*-===//
//===-- unittests/Runtime/Pointer.cpp ---------------------------*- 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 @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/pointer.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Ragged.cpp ----------------------*- C++ -*-===//
//===-- unittests/Runtime/Ragged.cpp ----------------------------*- 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 @@
//===-- flang/unittests/Runtime/Random.cpp ----------------------*- C++ -*-===//
//===-- unittests/Runtime/Random.cpp ----------------------------*- 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 @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime//random.h"
#include "gtest/gtest.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
#include "gtest/gtest.h"
#include <cmath>

using namespace Fortran::runtime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Reductions.cpp ----------------------------===//
//===-- unittests/Runtime/Reduction.cpp -------------------------*- 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 @@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/reduction.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/reduce.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"
#include <cstdint>
#include <cstring>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/CrashHandlerFixture.cpp ---------*- C++ -*-===//
//===-- unittests/Runtime/RuntimeCrashTest.cpp ------------------*- 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,11 +10,11 @@
/// runtime components and ensure the test fixture handles crashes as we expect.
//
//===----------------------------------------------------------------------===//
#include "../../lib/Runtime/terminator.h"
#include "CrashHandlerFixture.h"
#include "tools.h"
#include "../../runtime/terminator.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/transformational.h"
#include "tools.h"
#include <gtest/gtest.h>

using namespace Fortran::runtime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Stop.cpp ----------------------------------===//
//===-- unittests/Runtime/Stop.cpp ------------------------------*- 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,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#include "flang/Runtime/stop.h"
#include "../../lib/Runtime/environment.h"
#include "CrashHandlerFixture.h"
#include "../../runtime/environment.h"
#include <cstdlib>
#include <gtest/gtest.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Support.cpp ----------------------*- C++-*-===//
//===-- unittests/Runtime/Support.cpp ---------------------------*- 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 @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/support.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Runtime/descriptor.h"
#include "tools.h"
#include "gtest/gtest.h"

using namespace Fortran::runtime;
using Fortran::common::TypeCategory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//===--- flang/unittests/Runtime/TemporaryStack.cpp -------------*- C++ -*-===//
//===-- unittests/Runtime/TemporaryStack.cpp --------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "tools.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/temporary-stack.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"
#include <vector>

using namespace Fortran::runtime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//===-- flang/unittests/Runtime/Time.cpp ----------------------------===//
//===-- unittests/Runtime/Time.cpp ------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "flang/Runtime/time-intrinsic.h"
#include "gtest/gtest.h"
#include <algorithm>
#include <cctype>
#include <cerrno>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/Transformational.cpp ----------------------===//
//===-- unittests/Runtime/Transformational.cpp ------------------*- 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 @@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//

#include "flang/Runtime/transformational.h"
#include "gtest/gtest.h"
#include "tools.h"
#include "flang/Common/float128.h"
#include "flang/Runtime/type-code.h"
#include "tools.h"
#include "gtest/gtest.h"
#include <vector>

using namespace Fortran::runtime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- flang/unittests/Runtime/tools.h -------------------------*- C++ -*-===//
//===-- unittests/Runtime/tools.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 @@ -9,11 +9,11 @@
#ifndef FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
#define FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_

#include "gtest/gtest.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Runtime/cpp-type.h"
#include "flang/Runtime/descriptor.h"
#include "flang/Runtime/type-code.h"
#include "gtest/gtest.h"
#include <cstdint>
#include <cstring>
#include <vector>
Expand Down Expand Up @@ -54,4 +54,4 @@ static OwningPtr<Descriptor> MakeArray(const std::vector<int> &shape,
}

} // namespace Fortran::runtime
#endif // FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_
#endif /* FORTRAN_UNITTESTS_RUNTIME_TOOLS_H_ */
5 changes: 3 additions & 2 deletions flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ set(LLVM_BUILD_TOOLS ON)

include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include)
${FLANG_SOURCE_DIR}/include
${FLANG_SOURCE_DIR}/../FortranRuntime/include)

# Add Flang-centric modules to cmake path.
list(INSERT CMAKE_MODULE_PATH 0
Expand Down Expand Up @@ -468,7 +469,7 @@ if (FLANG_CUF_RUNTIME)
find_package(CUDAToolkit REQUIRED)
endif()

add_subdirectory(runtime)
add_subdirectory(../FortranRuntime/lib/Runtime runtime)

if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
Expand Down
6 changes: 3 additions & 3 deletions flang/include/flang/Evaluate/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include "constant.h"
#include "formatting.h"
#include "type.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/indirection.h"
#include "flang/Common/reference.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/attr.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "flang/Support/reference.h"
#include <optional>
#include <vector>

Expand Down
6 changes: 3 additions & 3 deletions flang/include/flang/Evaluate/characteristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include "shape.h"
#include "tools.h"
#include "type.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include <optional>
#include <string>
#include <variant>
Expand Down
16 changes: 7 additions & 9 deletions flang/include/flang/Evaluate/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
#ifndef FORTRAN_EVALUATE_COMMON_H_
#define FORTRAN_EVALUATE_COMMON_H_

#include "flang/Common/Fortran-features.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/default-kinds.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/target-rounding.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/default-kinds.h"
#include "flang/Support/indirection.h"
#include <cinttypes>
#include <map>
#include <set>
Expand All @@ -32,6 +33,8 @@ class IntrinsicProcTable;
class TargetCharacteristics;

using common::ConstantSubscript;
using common::RealFlag;
using common::RealFlags;
using common::RelationalOperator;

// Integers are always ordered; reals may not be.
Expand Down Expand Up @@ -128,11 +131,6 @@ static constexpr bool Satisfies(RelationalOperator op, Relation relation) {
return false; // silence g++ warning
}

// These are ordered like the bits in a common fenv.h header file.
ENUM_CLASS(RealFlag, InvalidArgument, Denorm, DivideByZero, Overflow, Underflow,
Inexact)
using RealFlags = common::EnumSet<RealFlag, RealFlag_enumSize>;

template <typename A> struct ValueWithRealFlags {
A AccumulateFlags(RealFlags &f) {
f |= flags;
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Evaluate/constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#include "formatting.h"
#include "type.h"
#include "flang/Common/default-kinds.h"
#include "flang/Common/reference.h"
#include "flang/Support/default-kinds.h"
#include "flang/Support/reference.h"
#include <map>
#include <vector>

Expand Down
6 changes: 3 additions & 3 deletions flang/include/flang/Evaluate/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "formatting.h"
#include "type.h"
#include "variable.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "flang/Support/template.h"
#include <algorithm>
#include <list>
#include <tuple>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/formatting.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// This header is meant to be included by the headers that define the several
// representational class templates that need it, not by external clients.

#include "flang/Common/indirection.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include "call.h"
#include "characteristics.h"
#include "type.h"
#include "flang/Common/default-kinds.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Support/default-kinds.h"
#include <memory>
#include <optional>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "expression.h"
#include "traverse.h"
#include "variable.h"
#include "flang/Common/indirection.h"
#include "flang/Evaluate/type.h"
#include "flang/Support/indirection.h"
#include <optional>
#include <variant>

Expand Down
17 changes: 3 additions & 14 deletions flang/include/flang/Evaluate/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,16 @@
#ifndef FORTRAN_EVALUATE_TARGET_H_
#define FORTRAN_EVALUATE_TARGET_H_

#include "flang/Common/Fortran.h"
#include "flang/Common/enum-class.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/target-rounding.h"
#include "flang/Evaluate/common.h"
#include "flang/Support/Fortran.h"
#include <cstdint>

namespace Fortran::evaluate {

// Floating-point rounding control
struct Rounding {
common::RoundingMode mode{common::RoundingMode::TiesToEven};
// When set, emulate status flag behavior peculiar to x86
// (viz., fail to set the Underflow flag when an inexact product of a
// multiplication is rounded up to a normal number from a subnormal
// in some rounding modes)
#if __x86_64__ || __riscv || __loongarch__
bool x86CompatibleBehavior{true};
#else
bool x86CompatibleBehavior{false};
#endif
};
using common::Rounding;

ENUM_CLASS(IeeeFeature, Denormal, Divide, Flags, Halting, Inf, Io, NaN,
Rounding, Sqrt, Standard, Subnormal, UnderflowControl)
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Evaluate/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include "traverse.h"
#include "flang/Common/idioms.h"
#include "flang/Common/template.h"
#include "flang/Common/unwrap.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
Expand All @@ -21,6 +19,8 @@
#include "flang/Semantics/attr.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/template.h"
#include "flang/Support/unwrap.h"
#include <array>
#include <optional>
#include <set>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Evaluate/traverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
// expression of an ASSOCIATE (or related) construct entity.

#include "expression.h"
#include "flang/Common/indirection.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/type.h"
#include "flang/Support/indirection.h"
#include <set>
#include <type_traits>

Expand Down
6 changes: 3 additions & 3 deletions flang/include/flang/Evaluate/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#include "integer.h"
#include "logical.h"
#include "real.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/real.h"
#include "flang/Common/template.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/template.h"
#include <cinttypes>
#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Evaluate/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "static-data.h"
#include "type.h"
#include "flang/Common/idioms.h"
#include "flang/Common/reference.h"
#include "flang/Common/template.h"
#include "flang/Parser/char-block.h"
#include "flang/Support/reference.h"
#include "flang/Support/template.h"
#include <optional>
#include <variant>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#ifndef FORTRAN_FRONTEND_FRONTENDOPTIONS_H
#define FORTRAN_FRONTEND_FRONTENDOPTIONS_H

#include "flang/Common/Fortran-features.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/unparse.h"
#include "flang/Support/Fortran-features.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include <cstdint>
Expand Down
13 changes: 6 additions & 7 deletions flang/include/flang/ISO_Fortran_binding.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*===-- include/flang/ISO_Fortran_binding.h -----------------------*- C++ -*-===
/*===-- include/flang/Common/ISO_Fortran_binding.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 CFI_ISO_FORTRAN_BINDING_H_
#define CFI_ISO_FORTRAN_BINDING_H_
#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_
#define FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_

/* When this header is included into the compiler and runtime implementations,
* it does so by means of a wrapper header that establishes namespaces and
* a macro for extra function attributes (RT_API_ATTRS).
*/
#ifndef FORTRAN_ISO_FORTRAN_BINDING_WRAPPER_H_
#ifndef FORTRAN_COMMON_ISO_FORTRAN_BINDING_WRAPPER_H_
#include <stddef.h>
#define FORTRAN_ISO_NAMESPACE_
#endif
Expand Down Expand Up @@ -207,4 +206,4 @@ RT_API_ATTRS int CFI_setpointer(
} // extern "C"
#endif

#endif /* CFI_ISO_FORTRAN_BINDING_H_ */
#endif /* FORTRAN_COMMON_ISO_FORTRAN_BINDING_H_ */
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/AbstractConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#ifndef FORTRAN_LOWER_ABSTRACTCONVERTER_H
#define FORTRAN_LOWER_ABSTRACTCONVERTER_H

#include "flang/Common/Fortran.h"
#include "flang/Lower/LoweringOptions.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRAttr.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Operation.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#ifndef FORTRAN_LOWER_BRIDGE_H
#define FORTRAN_LOWER_BRIDGE_H

#include "flang/Common/Fortran.h"
#include "flang/Lower/AbstractConverter.h"
#include "flang/Lower/EnvironmentDefault.h"
#include "flang/Lower/LoweringOptions.h"
#include "flang/Lower/StatementContext.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinOps.h"
#include <set>

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/CallInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#ifndef FORTRAN_LOWER_CALLINTERFACE_H
#define FORTRAN_LOWER_CALLINTERFACE_H

#include "flang/Common/reference.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Support/reference.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/ConvertType.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#ifndef FORTRAN_LOWER_CONVERT_TYPE_H
#define FORTRAN_LOWER_CONVERT_TYPE_H

#include "flang/Common/Fortran.h"
#include "flang/Evaluate/type.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinTypes.h"

namespace mlir {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/LoweringOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef FLANG_LOWER_LOWERINGOPTIONS_H
#define FLANG_LOWER_LOWERINGOPTIONS_H

#include "flang/Common/MathOptionsBase.h"
#include "flang/Support/MathOptionsBase.h"

namespace Fortran::lower {

Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Lower/PFTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
#ifndef FORTRAN_LOWER_PFTBUILDER_H
#define FORTRAN_LOWER_PFTBUILDER_H

#include "flang/Common/reference.h"
#include "flang/Common/template.h"
#include "flang/Lower/HostAssociations.h"
#include "flang/Lower/PFTDefs.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/attr.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/reference.h"
#include "flang/Support/template.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/Support/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#ifndef FORTRAN_LOWER_SUPPORT_UTILS_H
#define FORTRAN_LOWER_SUPPORT_UTILS_H

#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/indirection.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinAttributes.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Lower/SymbolMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#ifndef FORTRAN_LOWER_SYMBOLMAP_H
#define FORTRAN_LOWER_SYMBOLMAP_H

#include "flang/Common/reference.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/FortranVariableInterface.h"
#include "flang/Optimizer/Support/Matcher.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/reference.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Builder/FIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H

#include "flang/Common/MathOptionsBase.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
#include "flang/Support/MathOptionsBase.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "llvm/ADT/DenseMap.h"
Expand Down
1 change: 1 addition & 0 deletions flang/include/flang/Optimizer/Builder/IntrinsicCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ struct IntrinsicLibrary {
fir::ExtendedValue genUbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genUnpack(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genVerify(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
fir::ExtendedValue genNumericStorageSize(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);

/// Implement all conversion functions like DBLE, the first argument is
/// the value to convert. There may be an additional KIND arguments that
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef FORTRAN_LOWER_PPCINTRINSICCALL_H
#define FORTRAN_LOWER_PPCINTRINSICCALL_H

#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/IntrinsicCall.h"
#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Math/IR/Math.h"

namespace fir {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_RTBUILDER_H

#include "flang/Common/Fortran.h"
#include "flang/Common/uint128.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Runtime/reduce.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "llvm/ADT/SmallVector.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/CodeGen/DescriptorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef OPTIMIZER_DESCRIPTOR_MODEL_H
#define OPTIMIZER_DESCRIPTOR_MODEL_H

#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/BuiltinTypes.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H
#define FORTRAN_OPTIMIZER_DIALECT_CUF_CUFATTR_H

#include "flang/Common/Fortran.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinAttributes.h"

namespace llvm {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Support/TypeCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H
#define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H

#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "llvm/Support/ErrorHandling.h"

namespace fir {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Support/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#ifndef FORTRAN_OPTIMIZER_SUPPORT_UTILS_H
#define FORTRAN_OPTIMIZER_SUPPORT_UTILS_H

#include "flang/Common/default-kinds.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/FatalError.h"
#include "flang/Support/default-kinds.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinAttributes.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/char-block.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// Describes a contiguous block of characters; does not own their storage.

#include "flang/Common/interval.h"
#include "flang/Support/interval.h"
#include <algorithm>
#include <cstddef>
#include <cstring>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include "parse-tree.h"
#include "tools.h"
#include "unparse.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "char-set.h"
#include "provenance.h"
#include "flang/Common/idioms.h"
#include "flang/Common/reference-counted.h"
#include "flang/Common/restorer.h"
#include "flang/Support/reference-counted.h"
#include <cstddef>
#include <cstring>
#include <forward_list>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/parse-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// and recovery during parsing!

#include "user-state.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include "flang/Support/Fortran-features.h"
#include <cstddef>
#include <cstring>
#include <list>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "format-specification.h"
#include "message.h"
#include "provenance.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Frontend/OpenACC/ACC.h.inc"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include <cinttypes>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "message.h"
#include "parse-tree.h"
#include "provenance.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Parser/preprocessor.h"
#include "flang/Support/Fortran-features.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/provenance.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "characters.h"
#include "source.h"
#include "flang/Common/idioms.h"
#include "flang/Common/interval.h"
#include "flang/Support/interval.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
#include <list>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// - A Unicode byte order mark is recognized if present.

#include "characters.h"
#include "flang/Common/reference.h"
#include "flang/Support/reference.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Parser/user-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
// parse tree construction so as to avoid any need for representing
// state in static data.

#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Support/Fortran-features.h"
#include "llvm/Support/raw_ostream.h"
#include <cinttypes>
#include <optional>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Semantics/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#define FORTRAN_SEMANTICS_EXPRESSION_H_

#include "semantics.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
Expand All @@ -24,6 +22,8 @@
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include <map>
#include <optional>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/runtime-type-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#ifndef FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_
#define FORTRAN_SEMANTICS_RUNTIME_TYPE_INFO_H_

#include "flang/Common/reference.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/reference.h"
#include <map>
#include <set>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Semantics/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

#include "attr.h"
#include "symbol.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/reference.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/reference.h"
#include <list>
#include <map>
#include <optional>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/semantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

#include "scope.h"
#include "symbol.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Parser/message.h"
#include "flang/Semantics/module-dependences.h"
#include "flang/Support/Fortran-features.h"
#include <iosfwd>
#include <set>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Semantics/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#define FORTRAN_SEMANTICS_SYMBOL_H_

#include "type.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/reference.h"
#include "flang/Common/visit.h"
#include "flang/Semantics/module-dependences.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/reference.h"
#include "llvm/ADT/DenseMapInfo.h"

#include <array>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// Simple predicates and look-up functions that are best defined
// canonically for use in semantic checking.

#include "flang/Common/Fortran.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/shape.h"
Expand All @@ -23,6 +22,7 @@
#include "flang/Semantics/attr.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/Fortran.h"
#include <functional>

namespace Fortran::semantics {
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#ifndef FORTRAN_SEMANTICS_TYPE_H_
#define FORTRAN_SEMANTICS_TYPE_H_

#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/char-block.h"
#include "flang/Support/Fortran.h"
#include <algorithm>
#include <iosfwd>
#include <map>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/Fortran-features.h -----------------*- C++ -*-===//
//===-- include/flang/Support/Fortran-features.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 @@ -9,9 +9,9 @@
#ifndef FORTRAN_COMMON_FORTRAN_FEATURES_H_
#define FORTRAN_COMMON_FORTRAN_FEATURES_H_

#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Support/Fortran.h"
#include <vector>

namespace Fortran::common {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@
// Fortran language concepts that are used in many phases are defined
// once here to avoid redundancy and needless translation.

#include "enum-set.h"
#include "idioms.h"
#include "flang/Common/Fortran-consts.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include <cinttypes>
#include <optional>
#include <string>

namespace Fortran::common {
class LanguageFeatureControl;

// Fortran has five kinds of intrinsic data types, plus the derived types.
ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
ENUM_CLASS(VectorElementCategory, Integer, Unsigned, Real)

constexpr bool IsNumericTypeCategory(TypeCategory category) {
return category == TypeCategory::Integer || category == TypeCategory::Real ||
category == TypeCategory::Complex;
Expand All @@ -47,9 +44,6 @@ const char *AsFortran(RelationalOperator);

ENUM_CLASS(Intent, Default, In, Out, InOut)

ENUM_CLASS(IoStmtKind, None, Backspace, Close, Endfile, Flush, Inquire, Open,
Print, Read, Rewind, Wait, Write)

// Union of specifiers for all I/O statements.
ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
Delim, Direct, Encoding, End, Eor, Err, Exist, File, Fmt, Form, Formatted,
Expand All @@ -61,29 +55,11 @@ ENUM_CLASS(IoSpecKind, Access, Action, Advance, Asynchronous, Blank, Decimal,
Dispose, // nonstandard
)

// Defined I/O variants
ENUM_CLASS(
DefinedIo, ReadFormatted, ReadUnformatted, WriteFormatted, WriteUnformatted)
const char *AsFortran(DefinedIo);

// Floating-point rounding modes; these are packed into a byte to save
// room in the runtime's format processing context structure. These
// enumerators are defined with the corresponding values returned from
// llvm.get.rounding.
enum class RoundingMode : std::uint8_t {
ToZero, // ROUND=ZERO, RZ - truncation
TiesToEven, // ROUND=NEAREST, RN - default IEEE rounding
Up, // ROUND=UP, RU
Down, // ROUND=DOWN, RD
TiesAwayFromZero, // ROUND=COMPATIBLE, RC - ties round away from zero
};

// Fortran label. Must be in [1..99999].
using Label = std::uint64_t;

// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
static constexpr int maxRank{15};

// CUDA subprogram attribute combinations
ENUM_CLASS(CUDASubprogramAttrs, Host, Device, HostDevice, Global, Grid_Global)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- MathOptionsBase.h - Math options config ------------------*- C++ -*-===//
//===-- include/flang/Support/MathOptionsBase.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 Expand Up @@ -27,16 +27,16 @@ class MathOptionsBase {
Name = static_cast<unsigned>(Value); \
return *this; \
}
#include "flang/Common/MathOptionsBase.def"
#include "flang/Support/MathOptionsBase.def"

MathOptionsBase() {
#define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default);
#include "flang/Common/MathOptionsBase.def"
#include "flang/Support/MathOptionsBase.def"
}

private:
#define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits;
#include "flang/Common/MathOptionsBase.def"
#include "flang/Support/MathOptionsBase.def"
};

} // namespace Fortran::common
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/OpenMP-features.h -----------------*- C++ -*-====//
//===-- include/flang/Support/OpenMP-features.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 @@
//===- Version.h - Flang Version Number ---------------------*- Fortran -*-===//
//===-- include/flang/Support/Version.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/Common/default-kinds.h --------------------*- C++ -*-===//
//===-- include/flang/Support/default-kinds.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 @@ -9,7 +9,7 @@
#ifndef FORTRAN_COMMON_DEFAULT_KINDS_H_
#define FORTRAN_COMMON_DEFAULT_KINDS_H_

#include "flang/Common/Fortran.h"
#include "flang/Support/Fortran.h"
#include <cstdint>

namespace Fortran::common {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/indirection.h ----------------------*- C++ -*-===//
//===-- include/flang/Support/indirection.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 @@ -20,7 +20,7 @@
// template class Fortran::common::Indirection<FORWARD_TYPE>;
// in one C++ source file later where a definition of the type is visible.

#include "idioms.h"
#include "flang/Common/idioms.h"
#include <memory>
#include <type_traits>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/interval.h -------------------------*- C++ -*-===//
//===-- include/flang/Support/interval.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 @@ -12,7 +12,7 @@
// Defines a generalized template class Interval<A> to represent
// the half-open interval [x .. x+n).

#include "idioms.h"
#include "flang/Common/idioms.h"
#include <algorithm>
#include <cstddef>
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/reference-counted.h ----------------*- C++ -*-===//
//===-- include/flang/Support/reference-counted.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/Common/reference.h ------------------------*- C++ -*-===//
//===-- include/flang/Support/reference.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/Common/static-multimap-view.h -------------*- C++ -*-===//
//===-- include/flang/Support/static-multimap-view.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/Common/template.h -------------------------*- C++ -*-===//
//===-- include/flang/Support/template.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 @@ -9,8 +9,8 @@
#ifndef FORTRAN_COMMON_TEMPLATE_H_
#define FORTRAN_COMMON_TEMPLATE_H_

#include "variant.h"
#include "flang/Common/idioms.h"
#include "flang/Common/variant.h"
#include <functional>
#include <optional>
#include <tuple>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- include/flang/Common/unwrap.h ---------------------------*- C++ -*-===//
//===-- include/flang/Support/unwrap.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 @@ -12,8 +12,8 @@
#include "indirection.h"
#include "reference-counted.h"
#include "reference.h"
#include "variant.h"
#include "visit.h"
#include "flang/Common/variant.h"
#include "flang/Common/visit.h"
#include <memory>
#include <optional>
#include <type_traits>
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Tools/CrossToolHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#ifndef FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H
#define FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H

#include "flang/Common/MathOptionsBase.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/LangOptions.h"
#include "flang/Support/MathOptionsBase.h"
#include <cstdint>

#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
Expand Down
10 changes: 5 additions & 5 deletions flang/lib/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ endif()


add_flang_library(FortranCommon
Fortran.cpp
Fortran-features.cpp
default-kinds.cpp
idioms.cpp
Version.cpp
../Support/Fortran.cpp
../Support/Fortran-features.cpp
../Support/default-kinds.cpp
../Support/idioms.cpp
../Support/Version.cpp
${version_inc}

LINK_COMPONENTS
Expand Down
23 changes: 12 additions & 11 deletions flang/lib/Decimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
endif ()
include_directories(BEFORE
${FLANG_SOURCE_DIR}/include)
${FLANG_SOURCE_DIR}/include
${FLANG_SOURCE_DIR}/../FortranRuntime/include)
endif()

check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
Expand All @@ -50,8 +51,8 @@ endif()
add_definitions(-U_GLIBCXX_ASSERTIONS)

set(sources
binary-to-decimal.cpp
decimal-to-binary.cpp
../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
)

include(AddFlangOffloadRuntime)
Expand All @@ -63,23 +64,23 @@ add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})
if (DEFINED MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_flang_library(FortranDecimal.static INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
decimal-to-binary.cpp
../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
add_flang_library(FortranDecimal.dynamic INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
decimal-to-binary.cpp
../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
add_flang_library(FortranDecimal.static_dbg INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
decimal-to-binary.cpp
../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
add_flang_library(FortranDecimal.dynamic_dbg INSTALL_WITH_TOOLCHAIN
binary-to-decimal.cpp
decimal-to-binary.cpp
../../../FortranRuntime/lib/Common/binary-to-decimal.cpp
../../../FortranRuntime/lib/Common/decimal-to-binary.cpp
)
add_dependencies(FortranDecimal FortranDecimal.static FortranDecimal.dynamic
FortranDecimal.static_dbg FortranDecimal.dynamic_dbg)
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//

#include "flang/Evaluate/call.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran.h"

namespace Fortran::evaluate {

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/characteristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Evaluate/characteristics.h"
#include "flang/Common/indirection.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
Expand All @@ -17,6 +16,7 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <initializer_list>

Expand Down
3 changes: 3 additions & 0 deletions flang/lib/Evaluate/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@

using namespace Fortran::parser::literals;



namespace Fortran::evaluate {


void RealFlagWarnings(
FoldingContext &context, const RealFlags &flags, const char *operation) {
if (context.languageFeatures().ShouldWarn(
Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Evaluate/fold-implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
#include "character.h"
#include "host.h"
#include "int-power.h"
#include "flang/Common/indirection.h"
#include "flang/Common/template.h"
#include "flang/Common/unwrap.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/constant.h"
Expand All @@ -31,6 +28,9 @@
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/indirection.h"
#include "flang/Support/template.h"
#include "flang/Support/unwrap.h"
#include <algorithm>
#include <cmath>
#include <complex>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/fold-logical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "fold-implementation.h"
#include "fold-matmul.h"
#include "fold-reduction.h"
#include "flang/Common/magic-numbers.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Runtime/magic-numbers.h"

namespace Fortran::evaluate {

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/formatting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Evaluate/formatting.h"
#include "flang/Common/Fortran.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/constant.h"
#include "flang/Evaluate/expression.h"
Expand All @@ -16,6 +15,7 @@
#include "flang/Parser/characters.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"

namespace Fortran::evaluate {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/intrinsics-library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "flang/Evaluate/intrinsics-library.h"
#include "fold-implementation.h"
#include "host.h"
#include "flang/Common/static-multimap-view.h"
#include "flang/Evaluate/expression.h"
#include "flang/Support/static-multimap-view.h"
#include <cfloat>
#include <cmath>
#include <complex>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Evaluate/intrinsics.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/check-expression.h"
Expand All @@ -19,6 +18,7 @@
#include "flang/Evaluate/type.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cmath>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/real.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "flang/Evaluate/real.h"
#include "int-power.h"
#include "flang/Common/decimal.h"
#include "flang/Common/idioms.h"
#include "flang/Decimal/decimal.h"
#include "flang/Parser/characters.h"
#include "llvm/Support/raw_ostream.h"
#include <limits>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "flang/Evaluate/shape.h"
#include "flang/Common/idioms.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/check-expression.h"
#include "flang/Evaluate/fold.h"
Expand All @@ -17,6 +16,7 @@
#include "flang/Evaluate/type.h"
#include "flang/Parser/message.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/template.h"
#include <functional>

using namespace std::placeholders; // _1, _2, &c. for std::bind()
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Evaluate/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//

#include "flang/Evaluate/target.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/type.h"
#include "flang/Support/template.h"

namespace Fortran::evaluate {

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
//===----------------------------------------------------------------------===//

#include "flang/Frontend/CompilerInstance.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/TextDiagnosticPrinter.h"
#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/Fortran-features.h"
#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/MC/TargetRegistry.h"
Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
//===----------------------------------------------------------------------===//

#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Common/OpenMP-features.h"
#include "flang/Common/Version.h"
#include "flang/Frontend/CodeGenOptions.h"
#include "flang/Frontend/PreprocessorOptions.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/OpenMP-features.h"
#include "flang/Support/Version.h"
#include "flang/Tools/TargetSetup.h"
#include "flang/Version.inc"
#include "clang/Basic/AllDiagnostics.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Frontend/FrontendActions.h"
#include "flang/Common/default-kinds.h"
#include "flang/Frontend/CompilerInstance.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/FrontendOptions.h"
Expand All @@ -33,6 +32,7 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/unparse-with-symbols.h"
#include "flang/Support/default-kinds.h"
#include "flang/Tools/CrossToolHelpers.h"

#include "mlir/IR/Dialect.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include "flang/Lower/Bridge.h"
#include "DirectivesCommon.h"
#include "flang/Common/Version.h"
#include "flang/Lower/Allocatable.h"
#include "flang/Lower/CallInterface.h"
#include "flang/Lower/Coarray.h"
Expand Down Expand Up @@ -59,6 +58,7 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Version.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/CallInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Lower/CallInterface.h"
#include "flang/Common/Fortran.h"
#include "flang/Evaluate/fold.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/Mangler.h"
Expand All @@ -23,6 +22,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran.h"
#include <optional>

static mlir::FunctionType
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Lower/ConvertExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Lower/ConvertExpr.h"
#include "flang/Common/default-kinds.h"
#include "flang/Common/unwrap.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/real.h"
#include "flang/Evaluate/traverse.h"
Expand Down Expand Up @@ -52,6 +50,8 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/default-kinds.h"
#include "flang/Support/unwrap.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/CommandLine.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/Mangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//

#include "flang/Lower/Mangler.h"
#include "flang/Common/reference.h"
#include "flang/Lower/Support/Utils.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/reference.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Builder/IntrinsicCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Optimizer/Builder/IntrinsicCall.h"
#include "flang/Common/static-multimap-view.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/Character.h"
#include "flang/Optimizer/Builder/Complex.h"
Expand Down Expand Up @@ -42,6 +41,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Runtime/iostat.h"
#include "flang/Support/static-multimap-view.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Math/IR/Math.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/CodeGen/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define DEBUG_TYPE "flang-type-conversion"

#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/Todo.h" // remove when TODO's are done
#include "flang/Optimizer/CodeGen/DescriptorModel.h"
#include "flang/Optimizer/CodeGen/TBAABuilder.h"
Expand All @@ -22,6 +21,7 @@
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Support/Fortran.h"
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Debug.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Dialect/FIRType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//

#include "DebugTypeGenerator.h"
#include "flang/Common/Version.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/CodeGen/CGOps.h"
Expand All @@ -22,6 +21,7 @@
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Support/Version.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Lower/BuiltinModules.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Support.h"
Expand All @@ -17,6 +16,7 @@
#include "flang/Optimizer/Support/Utils.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Runtime/support.h"
#include "flang/Support/Fortran.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/CufOpConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
#include "flang/Optimizer/CodeGen/TypeConverter.h"
#include "flang/Optimizer/Dialect/CUF/CUFOps.h"
Expand All @@ -16,6 +15,7 @@
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/allocatable.h"
#include "flang/Support/Fortran.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Pass/Pass.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/LoopVersioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/// could be part of the cost analysis above.
//===----------------------------------------------------------------------===//

#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Inquiry.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
/// and small in size.
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/LowLevelIntrinsics.h"
Expand All @@ -34,6 +33,7 @@
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Optimizer/Transforms/Utils.h"
#include "flang/Runtime/entry-names.h"
#include "flang/Support/Fortran.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/Operation.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/StackReclaim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Support/Fortran.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Pass/Pass.h"
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/VScaleAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/// likely harmless to run it on something else, but it is also not valuable].
//===----------------------------------------------------------------------===//

#include "flang/ISO_Fortran_binding_wrapper.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Optimizer/Builder/BoxValue.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Builder/Runtime/Inquiry.h"
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Parser/basic-parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
// This header defines the fundamental parser class templates and helper
// template functions. See parser-combinators.txt for documentation.

#include "flang/Common/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/char-block.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-state.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/user-state.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/indirection.h"
#include <cstring>
#include <functional>
#include <list>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Parser/parse-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include "flang/Parser/parse-tree.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/tools.h"
#include "flang/Parser/user-state.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Parser/prescan.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// fixed form character literals on truncated card images, file
// inclusion, and driving the Fortran source preprocessor.

#include "flang/Common/Fortran-features.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/message.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/token-sequence.h"
#include "flang/Support/Fortran-features.h"
#include <bitset>
#include <optional>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Parser/unparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
// traversal templates in parse-tree-visitor.h.

#include "flang/Parser/unparse.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cinttypes>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/assignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_

#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/indirection.h"

namespace Fortran::parser {
class ContextualMessages;
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/check-case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

#include "check-case.h"
#include "flang/Common/idioms.h"
#include "flang/Common/reference.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/reference.h"
#include "flang/Support/template.h"
#include <tuple>

namespace Fortran::semantics {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-coarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
//===----------------------------------------------------------------------===//

#include "check-coarray.h"
#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/indirection.h"

namespace Fortran::semantics {

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "check-cuda.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
Expand All @@ -17,6 +16,7 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/template.h"

// Once labeled DO constructs have been canonicalized and their parse subtrees
// transformed into parser::DoConstructs, scan the parser::Blocks of the program
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#define FORTRAN_SEMANTICS_CHECK_DATA_H_

#include "data-to-inits.h"
#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/interval.h"
#include <list>
#include <map>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-do-forall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "check-do-forall.h"
#include "definable.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/tools.h"
Expand All @@ -22,6 +21,7 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/template.h"

namespace Fortran::evaluate {
using ActualArgumentRef = common::Reference<const ActualArgument>;
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-return.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//

#include "check-return.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran-features.h"

namespace Fortran::semantics {

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-select-rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//

#include "check-select-rank.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Parser/message.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran.h"
#include <list>
#include <optional>
#include <set>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-select-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

#include "check-select-type.h"
#include "flang/Common/idioms.h"
#include "flang/Common/reference.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/type.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/reference.h"
#include <optional>

namespace Fortran::semantics {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//

#include "check-stop.h"
#include "flang/Common/Fortran.h"
#include "flang/Evaluate/expression.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran.h"
#include <optional>

namespace Fortran::semantics {
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/data-to-inits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#ifndef FORTRAN_SEMANTICS_DATA_TO_INITS_H_
#define FORTRAN_SEMANTICS_DATA_TO_INITS_H_

#include "flang/Common/default-kinds.h"
#include "flang/Common/interval.h"
#include "flang/Evaluate/fold-designator.h"
#include "flang/Evaluate/initial-image.h"
#include "flang/Support/default-kinds.h"
#include "flang/Support/interval.h"
#include <list>
#include <map>

Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "pointer-assignment.h"
#include "resolve-names-utils.h"
#include "resolve-names.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Evaluate/common.h"
#include "flang/Evaluate/fold.h"
Expand All @@ -24,6 +23,7 @@
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/pointer-assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "definable.h"
#include "flang/Common/idioms.h"
#include "flang/Common/restorer.h"
#include "flang/Common/template.h"
#include "flang/Evaluate/characteristics.h"
#include "flang/Evaluate/expression.h"
#include "flang/Evaluate/fold.h"
Expand All @@ -21,6 +20,7 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/template.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
#include <set>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/resolve-labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include "resolve-labels.h"
#include "flang/Common/enum-set.h"
#include "flang/Common/template.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/template.h"
#include <cstdarg>
#include <type_traits>

Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Semantics/resolve-names-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
//===----------------------------------------------------------------------===//

#include "resolve-names-utils.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/idioms.h"
#include "flang/Common/indirection.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/tools.h"
#include "flang/Evaluate/traverse.h"
Expand All @@ -20,6 +17,9 @@
#include "flang/Semantics/expression.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include <initializer_list>
#include <variant>

Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include "resolve-directives.h"
#include "resolve-names-utils.h"
#include "rewrite-parse-tree.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/default-kinds.h"
#include "flang/Common/indirection.h"
#include "flang/Common/restorer.h"
#include "flang/Common/visit.h"
#include "flang/Evaluate/characteristics.h"
Expand All @@ -37,6 +34,9 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/default-kinds.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <list>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/rewrite-parse-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

#include "rewrite-parse-tree.h"
#include "rewrite-directives.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/parse-tree.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Support/indirection.h"
#include <list>

namespace Fortran::semantics {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
#include "resolve-labels.h"
#include "resolve-names.h"
#include "rewrite-parse-tree.h"
#include "flang/Common/default-kinds.h"
#include "flang/Parser/parse-tree-visitor.h"
#include "flang/Parser/tools.h"
#include "flang/Semantics/expression.h"
#include "flang/Semantics/scope.h"
#include "flang/Semantics/symbol.h"
#include "flang/Support/default-kinds.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//

#include "flang/Parser/tools.h"
#include "flang/Common/Fortran.h"
#include "flang/Common/indirection.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
#include "flang/Parser/parse-tree.h"
Expand All @@ -17,6 +15,8 @@
#include "flang/Semantics/symbol.h"
#include "flang/Semantics/tools.h"
#include "flang/Semantics/type.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/indirection.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <set>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//===-- lib/Common/Fortran-features.cpp -----------------------------------===//
//===-- lib/Support/Fortran-features.cpp ------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran-features.h"
#include "flang/Common/Fortran.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
#include "flang/Support/Fortran.h"

namespace Fortran::common {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//===-- lib/Common/Fortran.cpp --------------------------------------------===//
//===-- lib/Support/Fortran.cpp ---------------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran.h"
#include "flang/Common/Fortran-features.h"
#include "flang/Support/Fortran.h"
#include "flang/Support/Fortran-features.h"

namespace Fortran::common {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- Version.cpp - Flang Version Number -------------------*- Fortran -*-===//
//===-- lib/Support/Version.cpp ---------------------------------*- 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,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "flang/Common/Version.h"
#include "flang/Support/Version.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdlib>
#include <cstring>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//===-- lib/Common/default-kinds.cpp --------------------------------------===//
//===-- lib/Support/default-kinds.cpp ---------------------------*- 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
//
//===----------------------------------------------------------------------===//

#include "flang/Common/default-kinds.h"
#include "flang/Support/default-kinds.h"
#include "flang/Common/idioms.h"

namespace Fortran::common {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===-- lib/Common/idioms.cpp ---------------------------------------------===//
//===-- lib/Support/idioms.cpp ----------------------------------*- 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
2 changes: 1 addition & 1 deletion flang/module/__fortran_builtins.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
!
!===------------------------------------------------------------------------===!

#include '../include/flang/Runtime/magic-numbers.h'
#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'

! These naming shenanigans prevent names from Fortran intrinsic modules
! from being usable on INTRINSIC statements, and force the program
Expand Down
2 changes: 1 addition & 1 deletion flang/module/__fortran_ieee_exceptions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
! here under another name so that IEEE_ARITHMETIC can USE it and export its
! declarations without clashing with a non-intrinsic module in a program.

#include '../include/flang/Runtime/magic-numbers.h'
#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'

module __fortran_ieee_exceptions
use __fortran_builtins, only: &
Expand Down
2 changes: 1 addition & 1 deletion flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!===-- module/cudedevice.f90 -----------------------------------------------===!
!===-- module/cudadevice.f90 -----------------------------------------------===!
!
! 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
2 changes: 1 addition & 1 deletion flang/module/ieee_arithmetic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

! Fortran 2018 Clause 17

#include '../include/flang/Runtime/magic-numbers.h'
#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'

module ieee_arithmetic
! F18 Clause 17.1p1:
Expand Down
2 changes: 1 addition & 1 deletion flang/module/iso_fortran_env.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

! See Fortran 2023, subclause 16.10.2

#include '../include/flang/Runtime/magic-numbers.h'
#include '../../FortranRuntime/include/flang/Common/magic-numbers.h'

module iso_fortran_env

Expand Down
43 changes: 32 additions & 11 deletions flang/module/mma.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ pure __vector_pair function func_vpi0vp(arg1, arg2); \
!dir$ ignore_tkr(r) arg2; \
end function;

FUNC_VPI0VI(1) FUNC_VPI0VI(2) FUNC_VPI0VI(4) FUNC_VPI0VI(8)
FUNC_VPI0VU(1) FUNC_VPI0VU(2) FUNC_VPI0VU(4) FUNC_VPI0VU(8)
FUNC_VPI0VR(4) FUNC_VPI0VR(8)
! FIXME: Potential Flang bug: combining multiple of those on a single line breaks after preprocessing as an explicit step as done by CMake
! Line counting is also wrong
FUNC_VPI0VI(1)
FUNC_VPI0VI(2)
FUNC_VPI0VI(4)
FUNC_VPI0VI(8)
FUNC_VPI0VU(1)
FUNC_VPI0VU(2)
FUNC_VPI0VU(4)
FUNC_VPI0VU(8)
FUNC_VPI0VR(4)
FUNC_VPI0VR(8)
FUNC_VPI0VP

#undef FUNC_VPI0VP
Expand Down Expand Up @@ -144,14 +153,26 @@ elemental subroutine sub_vpvr##VKIND##vr##VKIND(pair, arg1, arg2); \
vector(real(VKIND)), intent(in) :: arg1, arg2; \
end subroutine ;

ELEM_SUB_VPVIVI(1) ELEM_SUB_VPVIVI(2)
ELEM_SUB_VPVIVI(4) ELEM_SUB_VPVIVI(8)
ELEM_SUB_VPVUVU(1) ELEM_SUB_VPVUVU(2)
ELEM_SUB_VPVUVU(4) ELEM_SUB_VPVUVU(8)
ELEM_SUB_VPVRVR(4) ELEM_SUB_VPVRVR(8)
SUB_VPI0VI(1) SUB_VPI0VI(2) SUB_VPI0VI(4) SUB_VPI0VI(8)
SUB_VPI0VU(1) SUB_VPI0VU(2) SUB_VPI0VU(4) SUB_VPI0VU(8)
SUB_VPI0VR(4) SUB_VPI0VR(8)
ELEM_SUB_VPVIVI(1)
ELEM_SUB_VPVIVI(2)
ELEM_SUB_VPVIVI(4)
ELEM_SUB_VPVIVI(8)
ELEM_SUB_VPVUVU(1)
ELEM_SUB_VPVUVU(2)
ELEM_SUB_VPVUVU(4)
ELEM_SUB_VPVUVU(8)
ELEM_SUB_VPVRVR(4)
ELEM_SUB_VPVRVR(8)
SUB_VPI0VI(1)
SUB_VPI0VI(2)
SUB_VPI0VI(4)
SUB_VPI0VI(8)
SUB_VPI0VU(1)
SUB_VPI0VU(2)
SUB_VPI0VU(4)
SUB_VPI0VU(8)
SUB_VPI0VR(4)
SUB_VPI0VR(8)

#undef ELEM_SUB_VPVIVI
#undef ELEM_SUB_VPVUVU
Expand Down
2 changes: 1 addition & 1 deletion flang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
if config.cc:
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
include = os.path.join(config.flang_src_dir, "include")
include = os.path.join(config.flang_src_dir, "..", "FortranRuntime", "include")

if (
os.path.isfile(libruntime)
Expand Down
8 changes: 4 additions & 4 deletions flang/tools/bbc/bbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
///
//===----------------------------------------------------------------------===//

#include "flang/Common/Fortran-features.h"
#include "flang/Common/OpenMP-features.h"
#include "flang/Common/Version.h"
#include "flang/Common/default-kinds.h"
#include "flang/Frontend/TargetOptions.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/PFTBuilder.h"
Expand All @@ -40,6 +36,10 @@
#include "flang/Semantics/runtime-type-info.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/unparse-with-symbols.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/OpenMP-features.h"
#include "flang/Support/Version.h"
#include "flang/Support/default-kinds.h"
#include "flang/Tools/CrossToolHelpers.h"
#include "flang/Tools/TargetSetup.h"
#include "flang/Version.inc"
Expand Down
4 changes: 2 additions & 2 deletions flang/tools/f18-parse-demo/f18-parse-demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
// scaffolding compiler driver that can test some semantic passes of the
// F18 compiler under development.

#include "flang/Common/Fortran-features.h"
#include "flang/Common/default-kinds.h"
#include "flang/Parser/characters.h"
#include "flang/Parser/dump-parse-tree.h"
#include "flang/Parser/message.h"
Expand All @@ -31,6 +29,8 @@
#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/unparse.h"
#include "flang/Support/Fortran-features.h"
#include "flang/Support/default-kinds.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
Expand Down
6 changes: 4 additions & 2 deletions flang/tools/f18/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,21 @@ if (NOT CMAKE_CROSSCOMPILING)
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
set(fullpath "${FLANG_SOURCE_DIR}/module/${filename}.f90")
if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION)
set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
set(compile_with -c -o ${object_output})
set(include_in_link TRUE)
set(fullpath "${FLANG_SOURCE_DIR}/../FortranRuntime/lib/Runtime/${filename}.f90")
endif()

set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
# TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
add_custom_command(OUTPUT ${base}.mod ${object_output}
COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
COMMAND flang-new ${opts} ${decls} -cpp ${compile_with} -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
${FLANG_SOURCE_DIR}/module/${filename}.f90
DEPENDS flang-new ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
${fullpath}
DEPENDS flang-new ${fullpath} ${FLANG_SOURCE_DIR}/module/__fortran_builtins.f90 ${depends}
)
list(APPEND MODULE_FILES ${base}.mod)
install(FILES ${base}.mod DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/flang")
Expand Down
6 changes: 3 additions & 3 deletions flang/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ function(add_flang_nongtest_unittest test_name)
endfunction()

add_subdirectory(Optimizer)
add_subdirectory(Common)
add_subdirectory(Decimal)
add_subdirectory(../../FortranRuntime/unittests/Common Common)
add_subdirectory(../../FortranRuntime/unittests/Decimal Decimal)
add_subdirectory(Evaluate)
add_subdirectory(Runtime)
add_subdirectory(../../FortranRuntime/unittests/Runtime Runtime)
add_subdirectory(Frontend)
3 changes: 0 additions & 3 deletions flang/unittests/Common/CMakeLists.txt

This file was deleted.

10 changes: 0 additions & 10 deletions flang/unittests/Decimal/CMakeLists.txt

This file was deleted.

20 changes: 4 additions & 16 deletions flang/unittests/Evaluate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_library(FortranEvaluateTesting
testing.cpp
fp-testing.cpp
../../../FortranRuntime/lib/Testing/testing.cpp
../../../FortranRuntime/lib/Testing/fp-testing.cpp
)
set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
if (LLVM_LINK_LLVM_DYLIB)
Expand Down Expand Up @@ -69,23 +69,11 @@ add_flang_nongtest_unittest(real
)
llvm_update_compile_flags(real.test)

add_flang_nongtest_unittest(reshape
FortranEvaluateTesting
FortranSemantics
FortranEvaluate
FortranRuntime
)

add_flang_nongtest_unittest(ISO-Fortran-binding
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
FortranRuntime
)

add_flang_nongtest_unittest(folding
FortranCommon
FortranEvaluateTesting
FortranEvaluate
FortranSemantics
)

add_subdirectory(../../../FortranRuntime/unittests/Evaluate runtime)
2 changes: 1 addition & 1 deletion flang/unittests/Evaluate/bit-population-count.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "flang/Common/bit-population-count.h"
#include "testing.h"
#include "flang/Testing/testing.h"

using Fortran::common::BitPopulationCount;
using Fortran::common::Parity;
Expand Down
2 changes: 1 addition & 1 deletion flang/unittests/Evaluate/expression.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "flang/Evaluate/expression.h"
#include "testing.h"
#include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h"
#include "flang/Parser/message.h"
#include "flang/Testing/testing.h"
#include <cstdio>
#include <cstdlib>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion flang/unittests/Evaluate/folding.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "testing.h"
#include "../../lib/Evaluate/host.h"
#include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h"
Expand All @@ -7,6 +6,7 @@
#include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h"
#include "flang/Testing/testing.h"
#include <tuple>

using namespace Fortran::evaluate;
Expand Down
27 changes: 0 additions & 27 deletions flang/unittests/Evaluate/fp-testing.h

This file was deleted.

Loading