[flang-commits] [flang] [Flang][MIF] Adding support of intrinsics with coarray argument (PR #192944)
Jean-Didier PAILLEUX via flang-commits
flang-commits at lists.llvm.org
Mon May 4 02:22:48 PDT 2026
================
@@ -118,6 +120,124 @@ def mif_ThisImageOp : mif_Op<"this_image", [AttrSizedOperandSegments]> {
}];
}
+//===----------------------------------------------------------------------===//
+// Coarray Queries
+//===----------------------------------------------------------------------===//
+
+def mif_ImageIndexOp : mif_Op<"image_index", [AttrSizedOperandSegments]> {
+ let summary = "Image index from cosubscripts.";
+ let description = [{
+ Arguments:
+ - `coarray`: Shall be a coarray of any type.
+ - `sub`: rank-one integer array of size equal to the corank of `coarray`.
+ - `team`: Shall be a scalar of type `team_type` from ISO_FORTRAN_ENV.
+ - `team_number`: It shall identify the initial team or a sibling team
+ of the current team.
+
+ Usage:
+ - Case(1) : `call image_index(coarray, sub)`
+ - Case(2) : `call image_index(coarray, sub, team)`
+ - Case(3) : `call image_index(coarray, sub, team_number)`
+
+ Result: If the value of `sub` is a valid sequence of cosubscripts for `coarray` in the
+ team specified by `team` or `team_number`, or the current team if neither `team` nor
+ `team_number` appears, the result is the index of the corresponding image in that team.
+ Otherwise, the result is zero.
+ }];
+
+ let arguments = (ins AnyType:$coarray, fir_BoxType:$sub,
+ Optional<AnyRefOrBoxType>:$team, Optional<AnyInteger>:$team_number);
+ let builders = [OpBuilder<(ins "mlir::Value":$coarray, "mlir::Value":$sub,
+ "mlir::Value":$team)>];
+
+ let results = (outs I32);
+
+ let hasVerifier = 1;
+ let assemblyFormat = [{
+ `coarray` $coarray `sub` $sub
+ ( `team` $team^ )?
+ ( `team_number` $team_number^ )?
+ attr-dict `:` functional-type(operands, results)
+ }];
+}
+
+def mif_LcoboundOp : mif_Op<"lcobound", [NoMemoryEffect]> {
+ let summary = "Returns the lower cobound(s) associated with a coarray.";
+ let description = [{
+ This operation returns the lower cobound(s) associated with a coarray.
+ Arguments:
+ - `coarray`: Shall be a coarray of any type.
+ - `dim`(optional) : Shall be an integer scalar. Its value shall be in the range of
+ `1 <= DIM <= N`, where `N` is the corank of the coarray.
+ Results:
+ - Case(1): If `dim` is present, the result is an integer scalar equal to
+ the lower cobound for codimension `dim`.
+ - Case(2): `dim` is absent, so the result is an array whose size matches
+ the corank of the indicated coarray.
+ }];
+
+ let arguments = (ins AnyType:$coarray, Optional<AnyInteger>:$dim);
+ let results = (outs AnyType);
----------------
JDPailleux wrote:
Hmm, okay
https://github.com/llvm/llvm-project/pull/192944
More information about the flang-commits
mailing list