[flang-commits] [flang] [flang][Lower] Add Lowering for CO_{BROADCAST, MAX, MIN, SUM} to PRIF (PR #154770)
Dan Bonachea via flang-commits
flang-commits at lists.llvm.org
Fri Aug 22 08:58:25 PDT 2025
================
@@ -397,6 +397,34 @@ static constexpr IntrinsicHandler handlers[]{
{"cmplx",
&I::genCmplx,
{{{"x", asValue}, {"y", asValue, handleDynamicOptional}}}},
+ {"co_broadcast",
+ &I::genCoBroadcast,
+ {{{"a", asBox},
+ {"source_image", asAddr, handleDynamicOptional},
+ {"stat", asAddr, handleDynamicOptional},
+ {"errmsg", asBox, handleDynamicOptional}}},
+ /*isElemental*/ false},
+ {"co_max",
+ &I::genCoMax,
+ {{{"a", asBox},
+ {"result_image", asAddr, handleDynamicOptional},
+ {"stat", asAddr, handleDynamicOptional},
+ {"errmsg", asBox, handleDynamicOptional}}},
+ /*isElemental*/ false},
+ {"co_min",
+ &I::genCoMin,
+ {{{"a", asBox},
+ {"result_image", asAddr, handleDynamicOptional},
+ {"stat", asAddr, handleDynamicOptional},
+ {"errmsg", asBox, handleDynamicOptional}}},
+ /*isElemental*/ false},
+ {"co_sum",
+ &I::genCoSum,
+ {{{"a", asBox},
+ {"result_image", asAddr, handleDynamicOptional},
+ {"stat", asAddr, handleDynamicOptional},
+ {"errmsg", asBox, handleDynamicOptional}}},
----------------
bonachea wrote:
IIUC this file is embodying the argument semantics of the Fortran-level intrinsics.
AFAIK none of the Fortran intrinsics are _specified_ with a `VALUE` attribute. It just says things like "shall be an integer scalar". For example, here is the F2023 spec for the `COUNT` intrinsic:
<img width="1213" height="381" alt="image" src="https://github.com/user-attachments/assets/b7a728be-eccd-4f9e-867d-99f5e71ace9e" />
The entry for `COUNT` appears a few lines below in this file and passes both `dim` and `kind` using `asValue`.
The Fortran collective subroutines specify the image argument with similar language, eg:
<img width="1209" height="563" alt="image" src="https://github.com/user-attachments/assets/25187836-47b7-4a4d-b2b2-5b5a42d0cc7a" />
Another good example is `CMPLX` which appears a few lines above and passes the `x` and `y` scalar arguments using `asValue`.
As I said I might be missing something here and I'm not necessarily asking for a change, I just wanted to understand the discrepancy with the other intrinsics in this file that accept integer scalar arguments `asValue`.
https://github.com/llvm/llvm-project/pull/154770
More information about the flang-commits
mailing list