This is an archive of the discontinued LLVM Phabricator instance.

[flang] Support lowering of intrinsic module procedure C_FUNLOC
ClosedPublic

Authored by peixin on Aug 19 2022, 7:11 PM.

Details

Summary

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.

Diff Detail

Event Timeline

peixin created this revision.Aug 19 2022, 7:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 7:11 PM
peixin requested review of this revision.Aug 19 2022, 7:11 PM

@klausler I saw you added the definition of the c_funloc in iso_c_binding using an unknown function loc https://github.com/llvm/llvm-project/blob/e0f64b319e65b9788c424c00bf7f16a8a78acb15/flang/module/iso_c_binding.f90#L117-L121. Should it be removed if with this support?

This revision is now accepted and ready to land.Aug 30 2022, 1:17 PM
jeanPerier accepted this revision.Aug 31 2022, 4:54 AM