[flang][hlfir] Lower pointer and allocatable sub-part references
The previous patches dealt with allocatable and pointer symbol and component whole references. This one deals with the remaining sub-part case where a dereference must be created before applying the sub-part reference on the target. With this patch the support to designate allocatable and pointer in HLFIR is complete, but some use points will need to be updated to use HLFIR designator lowering (at least allocate/deallocate statement and whole allocatable assignment). The partInfo.base had to be turned into an std::optional<hlfir::Entity> because loads of allocatable/pointers do create a fir::FortranVariableOpInterface (there is no need to). The optional part comes from the fact that the partInfo.base is not set when creating the partInfo, but later when visiting the designator parts. They are three cases when dereferences must be inserted: - The pointer/allocatable is a symbol followed by a sub-part that is not a component ref. This is done in visit(Symbol). - The pointer/allocatable is a component followed by a sub-part that is not another component ref. This is done in visit(Component). - The pointer/allocatable is followed by a component ref. This case is special since it does not call the above "visit" but instead calls "gen" to break the visit and generate an hlfir.designate for the component base (since one hlfir.designate can only represent one Fortran part-ref, and must be chained to implement a Fortran designator with several part refs). This is done in visitComponentImpl(). Differential Revision: https://reviews.llvm.org/D142124
Loading
Please sign in to comment