[flang-commits] [flang] [flang] Add hlfir.index op to represent index intrinsic function (PR #157575)

via flang-commits flang-commits at lists.llvm.org
Tue Sep 9 02:17:11 PDT 2025


================
@@ -3039,6 +3044,38 @@ hlfir::Entity Fortran::lower::PreparedActualArgument::getActual(
   return hlfir::Entity{addr};
 }
 
+mlir::Value Fortran::lower::PreparedActualArgument::getOptionalValue(
----------------
jeanPerier wrote:

I am a bit concerned about exposing this API outside of the intrinsic framework because it has a rather limited support. It is only meant for trivial scalars while optional handling in user calls is much more complex and handled differently/in a more generic way inside prepareUserCallActualArgument.

I would not want people to start to use it in user call contexts thinking it will cover all OPTIONAL cases.

I understand you needed to access the element type before calling getActual. I would suggest adding a getFortranElementType member to `PreparedActualArgument`  and to leave `getOptionalValue` in the HLFIR intrinsic lowering (for the vector subscript case, that would need to be cover in such generic helper, you can use `getFortranElementType(elemtalAddrOp.getElementEntity())`).

https://github.com/llvm/llvm-project/pull/157575


More information about the flang-commits mailing list