[flang][hlfir] Add hlfir.parent_comp for leaf parent component references
In Fortran, it is possible to refer to the "parent part" of a derived type as if it were a component: ```Fortran type t1 integer :: i end type type t2 integer :: j end type type(t2) :: a print *, a%t1%i ! "inner" parent component reference print *, a%t1 ! "leaf" parent component reference end ``` Inner parent component references can be dropped on the floor in lowering: "a%t1%i" is equivalent to "a%i". Leaf parent component references, however, must be taken care of. For scalars, "a%t1" is a simple addressc ast to "t1", for arrays, however, this creates an array section that must be represented with a descriptor (fir.box). hlfir.designate could have been extended to deal with this, but I think it would make hlfir.designate too complex and hard to manipulate. This patch adds an hlfir.parent_comp op that represents and implements leaf parent component references. Differential Revision: https://reviews.llvm.org/D144946
Loading
Please sign in to comment