forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
[Flang] Coarray allocation/deallocation + basic intrinsics for coarrays #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JDPailleux
merged 8 commits into
jdp/flang/mif-coarray-to-upstream
from
jdp/flang/mif-coarray
Feb 18, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
343ec63
[Flang] Adding lowering for the allocation and deallocation of coarrays
JDPailleux 0ea9102
[Flang] Adding support of intrinsics with coarray argument
JDPailleux 11e989a
Update flang/include/flang/Optimizer/Dialect/MIF/MIFOps.td
JDPailleux 7151f59
Update flang-rt/lib/runtime/coarray.cpp
JDPailleux ca9fc37
Update flang/lib/Optimizer/Transforms/MIFOpConversion.cpp
JDPailleux 041af09
Applying Dan's comments
JDPailleux 5103d59
Update flang/lib/Lower/Allocatable.cpp
JDPailleux 9c9227b
Adding fir.corank attribute + Assertion for coarray with ALLOCATABLE …
JDPailleux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //===-- runtime/coarray.cpp -----------------------------------------------===// | ||
| // | ||
| // 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/coarray.h" | ||
| #include "flang-rt/runtime/descriptor.h" | ||
| #include "flang-rt/runtime/type-info.h" | ||
|
|
||
| namespace Fortran::runtime { | ||
|
|
||
| extern "C" { | ||
| RT_EXT_API_GROUP_BEGIN | ||
|
|
||
| void RTDEF(ComputeLastUcobound)( | ||
| int num_images, const Descriptor &lcobounds, const Descriptor &ucobounds) { | ||
| int corank = ucobounds.GetDimension(0).Extent(); | ||
| int64_t *lcobounds_ptr = (int64_t *)lcobounds.raw().base_addr; | ||
| int64_t *ucobounds_ptr = (int64_t *)ucobounds.raw().base_addr; | ||
| int64_t index = 1; | ||
| for (int i = 0; i < corank - 1; i++) { | ||
| index *= ucobounds_ptr[i] - lcobounds_ptr[i] + 1; | ||
| } | ||
| if (corank == 1) | ||
| ucobounds_ptr[0] = num_images - lcobounds_ptr[0] + 1; | ||
| else if (index < num_images) | ||
| ucobounds_ptr[corank - 1] = | ||
| (num_images / index) + (num_images % index != 0); | ||
JDPailleux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else | ||
| ucobounds_ptr[corank - 1] = lcobounds_ptr[corank - 1]; | ||
| } | ||
|
|
||
| RT_EXT_API_GROUP_END | ||
| } | ||
| } // namespace Fortran::runtime | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //===-- MIFCommon.h -------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_OPTIMIZER_TRANSFORMS_MIFCOMMON_H_ | ||
| #define FORTRAN_OPTIMIZER_TRANSFORMS_MIFCOMMON_H_ | ||
|
|
||
| #include "flang/Lower/AbstractConverter.h" | ||
| #include "flang/Optimizer/Dialect/FIROps.h" | ||
| #include "flang/Optimizer/Dialect/MIF/MIFOps.h" | ||
| #include "flang/Runtime/coarray.h" | ||
| #include "mlir/IR/BuiltinOps.h" | ||
|
|
||
| static constexpr llvm::StringRef coarrayHandleSuffix = "_coarray_handle"; | ||
|
|
||
| namespace mif { | ||
|
|
||
| std::string getFullUniqName(mlir::Value addr); | ||
|
|
||
| } // namespace mif | ||
|
|
||
| #endif // FORTRAN_OPTIMIZER_TRANSFORMS_MIFCOMMON_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //===-- include/flang/Runtime/coarray.h --------------------------*- C++-*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef FORTRAN_RUNTIME_COARRAY_H | ||
| #define FORTRAN_RUNTIME_COARRAY_H | ||
|
|
||
| #include "flang/Runtime/descriptor-consts.h" | ||
| #include "flang/Runtime/entry-names.h" | ||
|
|
||
| namespace Fortran::runtime { | ||
| // class Descriptor; | ||
| extern "C" { | ||
|
|
||
| void RTDECL(ComputeLastUcobound)( | ||
| int num_images, const Descriptor &lcobounds, const Descriptor &ucobounds); | ||
| } | ||
| } // namespace Fortran::runtime | ||
|
|
||
| #endif // FORTRAN_RUNTIME_COARRAY_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.