| 1 |
! RUN: bbc -emit-hlfir %s -o - | fir-opt --fir-polymorphic-op | FileCheck %s |
| 2 |
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s --check-prefix=BT |
| 3 |
|
| 4 |
! Tests codegen of fir.dispatch operation. This test is intentionally run from |
| 5 |
! Fortran through bbc and tco so we have all the binding tables lowered to FIR |
| 6 |
! from semantics. |
| 7 |
|
| 8 |
module dispatch1 |
| 9 |
|
| 10 |
type p1 |
| 11 |
integer :: a |
| 12 |
integer :: b |
| 13 |
contains |
| 14 |
procedure :: aproc |
| 15 |
procedure :: display1 => display1_p1 |
| 16 |
procedure :: display2 => display2_p1 |
| 17 |
procedure :: get_value => get_value_p1 |
| 18 |
procedure :: proc_with_values => proc_p1 |
| 19 |
procedure, nopass :: proc_nopass => proc_nopass_p1 |
| 20 |
procedure, pass(this) :: proc_pass => proc_pass_p1 |
| 21 |
procedure, nopass :: z_proc_nopass_bindc => proc_nopass_bindc_p1 |
| 22 |
end type |
| 23 |
|
| 24 |
type, extends(p1) :: p2 |
| 25 |
integer :: c |
| 26 |
contains |
| 27 |
procedure :: display1 => display1_p2 |
| 28 |
procedure :: display2 => display2_p2 |
| 29 |
procedure :: display3 |
| 30 |
procedure :: get_value => get_value_p2 |
| 31 |
procedure :: proc_with_values => proc_p2 |
| 32 |
procedure, nopass :: proc_nopass => proc_nopass_p2 |
| 33 |
procedure, pass(this) :: proc_pass => proc_pass_p2 |
| 34 |
procedure, nopass :: z_proc_nopass_bindc => proc_nopass_bindc_p2 |
| 35 |
end type |
| 36 |
|
| 37 |
type, abstract :: a1 |
| 38 |
integer a |
| 39 |
contains |
| 40 |
procedure :: a1_proc |
| 41 |
end type |
| 42 |
|
| 43 |
type, extends(a1) :: a2 |
| 44 |
integer b |
| 45 |
contains |
| 46 |
procedure :: a1_proc => a2_proc |
| 47 |
end type |
| 48 |
|
| 49 |
type ty_kind(i, j) |
| 50 |
integer, kind :: i, j |
| 51 |
integer :: a(i) |
| 52 |
end Type |
| 53 |
|
| 54 |
type, extends(ty_kind) :: ty_kind_ex |
| 55 |
integer :: b(j) |
| 56 |
end type |
| 57 |
type(ty_kind(10,20)) :: tk1 |
| 58 |
type(ty_kind_ex(10,20)) :: tke1 |
| 59 |
contains |
| 60 |
|
| 61 |
subroutine display1_p1(this) |
| 62 |
class(p1) :: this |
| 63 |
print*,'call display1_p1' |
| 64 |
end subroutine |
| 65 |
|
| 66 |
subroutine display2_p1(this) |
| 67 |
class(p1) :: this |
| 68 |
print*,'call display2_p1' |
| 69 |
end subroutine |
| 70 |
|
| 71 |
subroutine display1_p2(this) |
| 72 |
class(p2) :: this |
| 73 |
print*,'call display1_p2' |
| 74 |
end subroutine |
| 75 |
|
| 76 |
subroutine display2_p2(this) |
| 77 |
class(p2) :: this |
| 78 |
print*,'call display2_p2' |
| 79 |
end subroutine |
| 80 |
|
| 81 |
subroutine aproc(this) |
| 82 |
class(p1) :: this |
| 83 |
print*,'call aproc' |
| 84 |
end subroutine |
| 85 |
|
| 86 |
subroutine display3(this) |
| 87 |
class(p2) :: this |
| 88 |
print*,'call display3' |
| 89 |
end subroutine |
| 90 |
|
| 91 |
function get_value_p1(this) |
| 92 |
class(p1) :: this |
| 93 |
integer :: get_value_p1 |
| 94 |
get_value_p1 = 10 |
| 95 |
end function |
| 96 |
|
| 97 |
function get_value_p2(this) |
| 98 |
class(p2) :: this |
| 99 |
integer :: get_value_p2 |
| 100 |
get_value_p2 = 10 |
| 101 |
end function |
| 102 |
|
| 103 |
subroutine proc_p1(this, v) |
| 104 |
class(p1) :: this |
| 105 |
real :: v |
| 106 |
print*, 'call proc1 with ', v |
| 107 |
end subroutine |
| 108 |
|
| 109 |
subroutine proc_p2(this, v) |
| 110 |
class(p2) :: this |
| 111 |
real :: v |
| 112 |
print*, 'call proc1 with ', v |
| 113 |
end subroutine |
| 114 |
|
| 115 |
subroutine proc_nopass_p1() |
| 116 |
print*, 'call proc_nopass_p1' |
| 117 |
end subroutine |
| 118 |
|
| 119 |
subroutine proc_nopass_p2() |
| 120 |
print*, 'call proc_nopass_p2' |
| 121 |
end subroutine |
| 122 |
|
| 123 |
subroutine proc_nopass_bindc_p1() bind(c) |
| 124 |
print*, 'call proc_nopass_bindc_p1' |
| 125 |
end subroutine |
| 126 |
|
| 127 |
subroutine proc_nopass_bindc_p2() bind(c) |
| 128 |
print*, 'call proc_nopass_bindc_p2' |
| 129 |
end subroutine |
| 130 |
|
| 131 |
subroutine proc_pass_p1(i, this) |
| 132 |
integer :: i |
| 133 |
class(p1) :: this |
| 134 |
print*, 'call proc_pass_p1' |
| 135 |
end subroutine |
| 136 |
|
| 137 |
subroutine proc_pass_p2(i, this) |
| 138 |
integer :: i |
| 139 |
class(p2) :: this |
| 140 |
print*, 'call proc_pass_p2' |
| 141 |
end subroutine |
| 142 |
|
| 143 |
subroutine display_class(p) |
| 144 |
class(p1) :: p |
| 145 |
integer :: i |
| 146 |
call p%display2() |
| 147 |
call p%display1() |
| 148 |
call p%aproc() |
| 149 |
i = p%get_value() |
| 150 |
call p%proc_with_values(2.5) |
| 151 |
call p%proc_nopass() |
| 152 |
call p%proc_pass(1) |
| 153 |
call p%z_proc_nopass_bindc() |
| 154 |
end subroutine |
| 155 |
|
| 156 |
subroutine no_pass_array(a) |
| 157 |
class(p1) :: a(:) |
| 158 |
call a(1)%proc_nopass() |
| 159 |
end subroutine |
| 160 |
|
| 161 |
subroutine no_pass_array_allocatable(a) |
| 162 |
class(p1), allocatable :: a(:) |
| 163 |
call a(1)%proc_nopass() |
| 164 |
end subroutine |
| 165 |
|
| 166 |
subroutine no_pass_array_pointer(a) |
| 167 |
class(p1), allocatable :: a(:) |
| 168 |
call a(1)%proc_nopass() |
| 169 |
end subroutine |
| 170 |
|
| 171 |
subroutine a1_proc(this) |
| 172 |
class(a1) :: this |
| 173 |
end subroutine |
| 174 |
|
| 175 |
subroutine a2_proc(this) |
| 176 |
class(a2) :: this |
| 177 |
end subroutine |
| 178 |
|
| 179 |
subroutine call_a1_proc(p) |
| 180 |
class(a1), pointer :: p |
| 181 |
call p%a1_proc() |
| 182 |
end subroutine |
| 183 |
|
| 184 |
end module |
| 185 |
|
| 186 |
program test_type_to_class |
| 187 |
use dispatch1 |
| 188 |
type(p1) :: t1 = p1(1,2) |
| 189 |
type(p2) :: t2 = p2(1,2,3) |
| 190 |
|
| 191 |
call display_class(t1) |
| 192 |
call display_class(t2) |
| 193 |
end |
| 194 |
|
| 195 |
|
| 196 |
! CHECK-LABEL: func.func @_QMdispatch1Pdisplay_class( |
| 197 |
! CHECK-SAME: %[[ARG:.*]]: [[CLASS:!fir.class<.*>>]] |
| 198 |
! CHECK: %[[ARG_DECL:.*]]:2 = hlfir.declare %[[ARG]] dummy_scope %{{[0-9]+}} {uniq_name = "_QMdispatch1Fdisplay_classEp"} : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.dscope) -> (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) |
| 199 |
|
| 200 |
! Check dynamic dispatch equal to `call p%display2()` with binding index = 2. |
| 201 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 202 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 203 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 204 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 205 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 206 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c2{{.*}} : (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 207 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 208 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 209 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 210 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (([[CLASS]]) -> ()) |
| 211 |
! CHECK: fir.call %[[FUNC_PTR]](%[[ARG_DECL]]#0) : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) -> () |
| 212 |
|
| 213 |
! Check dynamic dispatch equal to `call p%display1()` with binding index = 1. |
| 214 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 215 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 216 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 217 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 218 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 219 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c1{{.*}} : (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 220 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 221 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 222 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 223 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (([[CLASS]]) -> ()) |
| 224 |
! CHECK: fir.call %[[FUNC_PTR]](%[[ARG_DECL]]#0) : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) -> () |
| 225 |
|
| 226 |
! Check dynamic dispatch equal to `call p%aproc()` with binding index = 0. |
| 227 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 228 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 229 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 230 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 231 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 232 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c0{{.*}}: (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 233 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 234 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 235 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 236 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (([[CLASS]]) -> ()) |
| 237 |
! CHECK: fir.call %[[FUNC_PTR]](%[[ARG_DECL]]#0) : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) -> () |
| 238 |
|
| 239 |
! Check dynamic dispatch of a function with result. |
| 240 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 241 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 242 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 243 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 244 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 245 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c3 : (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 246 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 247 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 248 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 249 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (([[CLASS]]) -> i32) |
| 250 |
! CHECK: %[[RES:.*]] = fir.call %[[FUNC_PTR]](%[[ARG_DECL]]#0) : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) -> i32 |
| 251 |
|
| 252 |
! Check dynamic dispatch of call with passed-object and additional argument |
| 253 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 254 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 255 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 256 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 257 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 258 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c6{{.*}} : (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 259 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 260 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 261 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 262 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (([[CLASS]], !fir.ref<f32>) -> ()) |
| 263 |
! CHECK: fir.call %[[FUNC_PTR]](%[[ARG_DECL]]#0, %{{.*}}) : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.ref<f32>) -> () |
| 264 |
|
| 265 |
! Check dynamic dispatch of a call with NOPASS |
| 266 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#1 : ([[CLASS]]) -> !fir.tdesc<none> |
| 267 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 268 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 269 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.type<{{.*}}>>>>> |
| 270 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.type<{{.*}}>>> |
| 271 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c4{{.*}} : (!fir.ptr<!fir.array<?x!fir.type<{{.*}}>>>, index) -> !fir.ref<!fir.type<{{.*}}>> |
| 272 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 273 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 274 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 275 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> (() -> ()) |
| 276 |
! CHECK: fir.call %[[FUNC_PTR]]() : () -> () |
| 277 |
|
| 278 |
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none> |
| 279 |
! CHECK: %[[TYPEDESCPTR:.*]] = fir.convert %[[BOXDESC]] : (!fir.tdesc<none>) -> !fir.ref<[[TYPEINFO:!fir.type<_QM__fortran_type_infoTderivedtype{.*}>]]> |
| 280 |
! CHECK: %[[BINDING_BOX_ADDR:.*]] = fir.coordinate_of %[[TYPEDESCPTR]], binding : (!fir.ref<[[TYPEINFO]]>) -> !fir.ref<[[BINDING_BOX_TYPE:.*]]> |
| 281 |
! CHECK: %[[BINDING_BOX:.*]] = fir.load %[[BINDING_BOX_ADDR]] : !fir.ref<[[BINDING_BOX_TYPE]]> |
| 282 |
! CHECK: %[[BINDING_BASE_ADDR:.*]] = fir.box_addr %[[BINDING_BOX]] : ([[BINDING_BOX_TYPE]]) -> !fir.ptr<[[BINDINGSINFO:.*]]> |
| 283 |
! CHECK: %[[BINDING_PTR:.*]] = fir.coordinate_of %[[BINDING_BASE_ADDR]], %c5{{.*}} : (!fir.ptr<[[BINDINGSINFO]]>, index) -> !fir.ref<[[BINDINGINFO:.*]]> |
| 284 |
! CHECK: %[[BUILTIN_FUNC_PTR:.*]] = fir.coordinate_of %[[BINDING_PTR]], proc : ({{.*}}) -> !fir.ref<[[BUILTIN_FUNC_TYPE:.*]]> |
| 285 |
! CHECK: %[[FUNC_ADDR_PTR:.*]] = fir.coordinate_of %[[BUILTIN_FUNC_PTR]], __address |
| 286 |
! CHECK: %[[FUNC_ADDR:.*]] = fir.load %[[FUNC_ADDR_PTR]] : !fir.ref<i64> |
| 287 |
! CHECK: %[[FUNC_PTR:.*]] = fir.convert %[[FUNC_ADDR]] : (i64) -> ((!fir.ref<i32>, [[CLASS]]) -> ()) |
| 288 |
! CHECK: fir.call %[[FUNC_PTR]](%{{.*}}, %[[ARG_DECL]]#0) : (!fir.ref<i32>, [[CLASS]]) -> () |
| 289 |
|
| 290 |
! Test attributes are propagated from fir.dispatch to fir.call |
| 291 |
! for `call p%z_proc_nopass_bindc()` |
| 292 |
! CHECK: fir.call %{{.*}}() proc_attrs<bind_c> : () -> () |
| 293 |
|
| 294 |
! CHECK-LABEL: _QMdispatch1Pno_pass_array |
| 295 |
! CHECK-LABEL: _QMdispatch1Pno_pass_array_allocatable |
| 296 |
! CHECK-LABEL: _QMdispatch1Pno_pass_array_pointer |
| 297 |
! CHECK-LABEL: _QMdispatch1Pcall_a1_proc |
| 298 |
|
| 299 |
! Check the layout of the binding table. This is easier to do in FIR than in |
| 300 |
! LLVM IR. |
| 301 |
|
| 302 |
! BT-LABEL: fir.type_info @_QMdispatch1Tty_kindK10K20 |
| 303 |
! BT-LABEL: fir.type_info @_QMdispatch1Tty_kind_exK10K20 {{.*}}extends !fir.type<_QMdispatch1Tty_kindK10K20{{.*}}> |
| 304 |
|
| 305 |
! BT-LABEL: fir.type_info @_QMdispatch1Tp1 |
| 306 |
! BT: fir.dt_entry "aproc", @_QMdispatch1Paproc |
| 307 |
! BT: fir.dt_entry "display1", @_QMdispatch1Pdisplay1_p1 |
| 308 |
! BT: fir.dt_entry "display2", @_QMdispatch1Pdisplay2_p1 |
| 309 |
! BT: fir.dt_entry "get_value", @_QMdispatch1Pget_value_p1 |
| 310 |
! BT: fir.dt_entry "proc_nopass", @_QMdispatch1Pproc_nopass_p1 |
| 311 |
! BT: fir.dt_entry "proc_pass", @_QMdispatch1Pproc_pass_p1 |
| 312 |
! BT: fir.dt_entry "proc_with_values", @_QMdispatch1Pproc_p1 |
| 313 |
! BT: fir.dt_entry "z_proc_nopass_bindc", @proc_nopass_bindc_p1 |
| 314 |
! BT: } |
| 315 |
|
| 316 |
! BT-LABEL: fir.type_info @_QMdispatch1Ta1 |
| 317 |
! BT: fir.dt_entry "a1_proc", @_QMdispatch1Pa1_proc |
| 318 |
! BT: } |
| 319 |
|
| 320 |
! BT-LABEL: fir.type_info @_QMdispatch1Ta2 {{.*}}extends !fir.type<_QMdispatch1Ta1{{.*}}> |
| 321 |
! BT: fir.dt_entry "a1_proc", @_QMdispatch1Pa2_proc |
| 322 |
! BT: } |
| 323 |
|
| 324 |
! BT-LABEL: fir.type_info @_QMdispatch1Tp2 {{.*}}extends !fir.type<_QMdispatch1Tp1{{.*}}> |
| 325 |
! BT: fir.dt_entry "aproc", @_QMdispatch1Paproc |
| 326 |
! BT: fir.dt_entry "display1", @_QMdispatch1Pdisplay1_p2 |
| 327 |
! BT: fir.dt_entry "display2", @_QMdispatch1Pdisplay2_p2 |
| 328 |
! BT: fir.dt_entry "get_value", @_QMdispatch1Pget_value_p2 |
| 329 |
! BT: fir.dt_entry "proc_nopass", @_QMdispatch1Pproc_nopass_p2 |
| 330 |
! BT: fir.dt_entry "proc_pass", @_QMdispatch1Pproc_pass_p2 |
| 331 |
! BT: fir.dt_entry "proc_with_values", @_QMdispatch1Pproc_p2 |
| 332 |
! BT: fir.dt_entry "z_proc_nopass_bindc", @proc_nopass_bindc_p2 |
| 333 |
! BT: fir.dt_entry "display3", @_QMdispatch1Pdisplay3 |
| 334 |
! BT: } |