aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Lower/ConvertProcedureDesignator.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-19[flang] Expand parent component in procedure pointer component ref (#78593)jeanPerier1-3/+3
For simplicity, lowering relies on semantics expansion of parent components in designators. This was not done in `call x%p()` where `p` is a procedure component pointer of a parent component of `x`. Do it and turn lowering TODO into a new lowering TODO for `call bar(x%type_bound_procedure)` (passing a tybe bound procedure is allowed as an extension, but lowering does not handle this extension yet. This is a lowering issue, will do in different patch).
2023-12-19[flang] Lower procedure pointer components (#75453)jeanPerier1-0/+60
Lower procedure pointer components, except in the context of structure constructor (left TODO). Procedure pointer components lowering share most of the lowering logic of procedure poionters with the following particularities: - They are components, so an hlfir.designate must be generated to retrieve the procedure pointer address from its derived type base. - They may have a PASS argument. While there is no dispatching as with type bound procedure, special care must be taken to retrieve the derived type component base in this case since semantics placed it in the argument list and not in the evaluate::ProcedureDesignator. These components also bring a new level of recursive MLIR types since a fir.type may now contain a component with an MLIR function type where one of the argument is the fir.type itself. This required moving the "derived type in construction" stackto the converter so that the object and function type lowering utilities share the same state (currently the function type utilty would end-up creating a new stack when lowering its arguments, leading to infinite loops). The BoxedProcedurePass also needed an update to deal with this recursive aspect.
2023-11-23[Flang] Add partial support for lowering procedure pointer assignment. (#70461)Daniel Chen1-0/+23
**Scope of the PR:** 1. Lowering global and local procedure pointer declaration statement with explicit or implicit interface. The explicit interface can be from an interface block, a module procedure or an internal procedure. 2. Lowering procedure pointer assignment, where the target procedure could be external, module or internal procedures. 3. Lowering reference to procedure pointers so that it works end to end. **PR notes:** 1. The first commit of the PR does not include testing. I would like to collect some comments first, which may alter the output. Once I confirm the implementation, I will add some testing as a follow up commit to this PR. 2. No special handling of the host-associated entities when an internal procedure is the target of a procedure pointer assignment in this PR. **Implementation notes:** 1. The implementation is using the HLFIR path. 2. Flang currently uses `getUntypedBoxProcType` to get the `fir::BoxProcType` for `ProcedureDesignator` when getting the address of a procedure in order to pass it as an actual argument. This PR inherits the same design decision for procedure pointer as the `fir::StoreOp` requires the same memory type. Note: this commit is actually resubmitting the original commit from PR #70461 that was reverted. See PR #73221.
2023-11-23Revert "[Flang] Add partial support for lowering procedure pointer ↵Muhammad Omair Javaid1-23/+0
assignment. (#70461)" This reverts commit e07fec10ac208c2868a24c5c0be88e45778b297e. This change appears to have broken following buildbots: https://lab.llvm.org/buildbot/#/builders/176 https://lab.llvm.org/buildbot/#/builders/179 https://lab.llvm.org/buildbot/#/builders/184 https://lab.llvm.org/buildbot/#/builders/197 https://lab.llvm.org/buildbot/#/builders/198 All bots fails in testsuite where following tests seems broken: (eg: https://lab.llvm.org/buildbot/#/builders/176/builds/7131) test-suite::gfortran-regression-compile-regression__proc_ptr_46_f90.test test-suite::gfortran-regression-compile-regression__proc_ptr_37_f90.test
2023-11-22[Flang] Add partial support for lowering procedure pointer assignment. (#70461)Daniel Chen1-0/+23
**Scope of the PR:** 1. Lowering global and local procedure pointer declaration statement with explicit or implicit interface. The explicit interface can be from an interface block, a module procedure or an internal procedure. 2. Lowering procedure pointer assignment, where the target procedure could be external, module or internal procedures. 3. Lowering reference to procedure pointers so that it works end to end. **PR notes:** 1. The first commit of the PR does not include testing. I would like to collect some comments first, which may alter the output. Once I confirm the implementation, I will add some testing as a follow up commit to this PR. 2. No special handling of the host-associated entities when an internal procedure is the target of a procedure pointer assignment in this PR. **Implementation notes:** 1. The implementation is using the HLFIR path. 2. Flang currently uses `getUntypedBoxProcType` to get the `fir::BoxProcType` for `ProcedureDesignator` when getting the address of a procedure in order to pass it as an actual argument. This PR inherits the same design decision for procedure pointer as the `fir::StoreOp` requires the same memory type.
2023-10-09[flang] Set func.func arg attributes for procedure designators (#68420)jeanPerier1-4/+4
Currently, if the first usage of a procedure not defined in the file was inside a procedure designator reference (not a call to it), the lowered func.func lacked the argument attributes if any. Fix this by using `CallInterface<T>::declare` too in SignatureBuilder to create a new func.func instead of using custom code. Note: this problem was made worse by the fact that module variables fir.global are currently lowered before the module procedures func.func are created. I will try to fix that in a later patch (the debug location may still be wrong in certain cases) because there is quite some test fallout when changing the order of globals/funcop in the output.
2023-02-09[flang][hlfir] Lower procedure designators to HLFIRJean Perier1-0/+32
- Add a convertProcedureDesignatorToHLFIR that converts the fir::ExtendedValue from the current lowering to a fir.boxproc/tuple<fir.boxproc, len> mlir::Value. - Allow fir.boxproc/tuple<fir.boxproc, len> as hlfir::Entity values (a function is an address, but from a Fortran entity point of view, procedure that are not procedure pointers cannot be assigned to, so it makes a lot more sense to consider those as values). - Modify symbol association to not generate an hlfir.declare for dummy procedures. They are not needed and allowing hlfir.declare to declare function values would make its verifier and handling overly complex for little benefits (maybe an hlfir.declare_proc could be added if it turnout out useful later for debug info and attributes storing purposes). - Allow translation from hlfir::Entity to fir::ExtendedValue. convertToBox return type had to be relaxed because some intrinsics handles both object and procedure arguments and need to lower their object arguments "asBox". fir::BoxValue is not intended to carry dummy procedures (all its member functions would make little sense and its verifier does not accept such type). Note that AsAddr, AsValue and AsBox will always return the same MLIR value for procedure designators because they are always handled the same way in FIR. Differential Revision: https://reviews.llvm.org/D143585
2023-02-08[flang][NFC] Move Procedure designator lowering in its own fileJean Perier1-0/+95
Code move without any change, the goal is to re-use this piece of code for procedure designator lowering in HLFIR since there is no significant changes in the way procedure designators will be lowered. Differential Revision: https://reviews.llvm.org/D143563