[flang] Support lowering of intrinsic module procedure C_FUNLOC
authorPeixin Qiao <qiaopeixin@huawei.com>
Wed, 31 Aug 2022 15:35:42 +0000 (23:35 +0800)
committerPeixin Qiao <qiaopeixin@huawei.com>
Wed, 31 Aug 2022 15:35:42 +0000 (23:35 +0800)
commitddc939fe15e420e2d3d9d156a8cfa8ce790573ab
tree1510fe229967dd4b5c0d255ef378767789922e7b
parente68594ca20278992768423d385fc5a7106e44391
[flang] Support lowering of intrinsic module procedure C_FUNLOC

As Fortran 2018 18.2.3.5, the intrinsic c_funloc(x) gets the C address
of argument x. It returns the scalar of type C_FUNPTR. As defined in
iso_c_binding in flang/module/__fortran_builtins.f90, C_FUNPTR is the
derived type with only one component of integer 64.

This follows the implementation of https://reviews.llvm.org/D129659. The
argument is lowered as ProcBox and the address is generated using
fir.box_addr.

Reviewed By: jeanPerier, clementval

Differential Revision: https://reviews.llvm.org/D132273
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/IntrinsicCall.cpp
flang/test/Lower/Intrinsics/c_funloc.f90 [new file with mode: 0644]