llvm-project/flang/lib/Optimizer/Transforms
Valentin Clement fe252f8ed6
[flang] Lower boxed procedure
In FIR, we want to wrap function pointers in a special box known as a
boxproc value. Fortran has a limited form of dynamic scoping
[https://tinyurl.com/2p8v2hw7] between "host procedures" and "internal
procedures". There are a number of implementations possible.

Boxproc typed values abstract away the implementation details of when a
function pointer can be passed directly (as a raw address) and when a
function pointer has to account for the presence of a dynamic scope.
When lowering Fortran syntax to FIR, all function pointers are emboxed
as boxproc values.

When creating LLVM IR, we must strip away the abstraction and produce
low-level LLVM "assembly" code. This patch implements that
transformation as converting the boxproc values to either raw function
pointers or executable trampolines on the stack as needed. The
trampoline then captures the dynamic scope context within an executable
thunk that can be passed instead of the function's raw address.

Some extra handling is required for Fortran functions that return a
character value to deal with LEN values here.

Some of the code in Bridge.cpp and ConvertExpr.cpp and be re-arranged to
faciliate the upstreaming effort.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D122223

Co-authored-by: mleair <leairmark@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2022-03-22 15:41:11 +01:00
..
AbstractResult.cpp [mlir:FunctionOpInterface] Rename the "type" attribute to "function_type" 2022-03-16 17:07:04 -07:00
AffineDemotion.cpp [flang] Remove 'using namespace mlir;` from header files 2022-03-09 10:19:51 +00:00
AffinePromotion.cpp [flang] Remove 'using namespace mlir;` from header files 2022-03-09 10:19:51 +00:00
AnnotateConstant.cpp Write a pass to annotate constant operands on FIR ops. This works 2022-03-14 11:14:44 -07:00
ArrayValueCopy.cpp [flang] handle allocatable components when creating array temps 2022-03-17 10:56:20 +01:00
CMakeLists.txt [flang] Lower IO input with vector subscripts 2022-03-16 17:13:23 +01:00
CharacterConversion.cpp [mlir] Rename the Standard dialect to the Func dialect 2022-03-01 12:10:04 -08:00
ExternalNameConversion.cpp [flang] Lower boxed procedure 2022-03-22 15:41:11 +01:00
MemRefDataFlowOpt.cpp [flang] Remove 'using namespace mlir;` from header files 2022-03-09 10:19:51 +00:00
MemoryAllocation.cpp [mlir] Rename the Standard dialect to the Func dialect 2022-03-01 12:10:04 -08:00
PassDetail.h [mlir] Rename the Standard dialect to the Func dialect 2022-03-01 12:10:04 -08:00
RewriteLoop.cpp [flang] Lower IO input with vector subscripts 2022-03-16 17:13:23 +01:00
SimplifyRegionLite.cpp [flang] Lower IO input with vector subscripts 2022-03-16 17:13:23 +01:00