[flang][hlfir] Add hlfir.forall_index operation
This is the last piece required to lower Forall (except pointer assignments, where an operation may be needed to deal with bounds remapping). Lowering requires symbols to be mapped to memory SSA values produced by a fir_FortranVariableOpInterface operation. This applies to forall index-values, that are symbols. fir.alloca/fir.store/hlfir.declare are not allowed inside the body of an hlfir.forall that only accept operations with the hlfir_OrderedAssignmentTreeOpInterface so that the forall structure is well defined and easy to transform. Allowing such operations in the forall body would open the doors to generating ill-formed programs where such operation would be used for non index-values. Instead, add an hlfir.forall_index with both required interface to produce a memory address for a forall index. As a bonus, since forall index-value are by nature read-only, the loads of hlfir.forall_index can be canonicalized, which will help simplifying the hlfir.forall nested code (it is unclear we will be able to tell MLIR enough about hlfir.forall and hlfir.where structure so that it could safely do a generic mem-to-reg inside it, and getting rid of read-effect operations will benefit the forall rewrite pass). Differential Revision: https://reviews.llvm.org/D149836
Loading
Please sign in to comment