Files
clang-p2996/flang/test/Lower/dispatch-table.f90
jeanPerier 4ccd57ddb1 [flang][nfc] replace fir.dispatch_table with more generic fir.type_info (#68309)
The goal is to progressively propagate all the derived type info that is
currently in the runtime type info globals into a FIR operation that can
be easily queried and used by FIR/HLFIR passes.

When this will be complete, the last step will be to stop generating the
runtime info global in lowering, but to do that later in or just before
codegen to keep the FIR files readable (on the added type-info.f90
tests, the lowered runtime info globals takes a whooping 2.6 millions
characters on 1600 lines of the FIR textual output. The fir.type_info that
contains all the info required to generate those globals for such
"trivial" types takes 1721 characters on 9 lines).

So far this patch simply starts by replacing the fir.dispatch_table
operation by the fir.type_info operation and to add the noinit/
nofinal/nodestroy flags to it. These flags will soon be used in HLFIR to
better rewrite hlfir.assign with derived types.
2023-10-06 09:29:57 +02:00

76 lines
2.0 KiB
Fortran

! RUN: bbc -polymorphic-type -emit-fir %s -o - | FileCheck %s
! Tests the generation of fir.type_info operations.
module polymorphic_types
type p1
integer :: a
integer :: b
contains
procedure :: proc1 => proc1_p1
procedure :: aproc
procedure :: zproc
end type
type, extends(p1) :: p2
integer :: c
contains
procedure :: proc1 => proc1_p2
procedure :: aproc2
end type
type, extends(p2) :: p3
integer :: d
contains
procedure :: aproc3
end type
contains
subroutine proc1_p1(p)
class(p1) :: p
end subroutine
subroutine aproc(p)
class(p1) :: p
end subroutine
subroutine zproc(p)
class(p1) :: p
end subroutine
subroutine proc1_p2(p)
class(p2) :: p
end subroutine
subroutine aproc2(p)
class(p2) :: p
end subroutine
subroutine aproc3(p)
class(p3) :: p
end subroutine
end module
! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp1
! CHECK: fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
! CHECK: fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p1
! CHECK: fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
! CHECK: }
! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp2 {{.*}}extends !fir.type<_QMpolymorphic_typesTp1{{.*}}>
! CHECK: fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
! CHECK: fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p2
! CHECK: fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
! CHECK: fir.dt_entry "aproc2", @_QMpolymorphic_typesPaproc2
! CHECK: }
! CHECK-LABEL: fir.type_info @_QMpolymorphic_typesTp3 {{.*}}extends !fir.type<_QMpolymorphic_typesTp2{{.*}}>
! CHECK: fir.dt_entry "aproc", @_QMpolymorphic_typesPaproc
! CHECK: fir.dt_entry "proc1", @_QMpolymorphic_typesPproc1_p2
! CHECK: fir.dt_entry "zproc", @_QMpolymorphic_typesPzproc
! CHECK: fir.dt_entry "aproc2", @_QMpolymorphic_typesPaproc2
! CHECK: fir.dt_entry "aproc3", @_QMpolymorphic_typesPaproc3
! CHECK: }