FLANG
|
#include <flang/Lower/CallInterface.h>
Classes | |
struct | FirPlaceHolder |
struct | PassedEntity |
Public Types | |
enum class | PassEntityBy { BaseAddress , BoxChar , Box , MutableBox , AddressAndLength , Value , BaseAddressValueAttribute , CharBoxValueAttribute , CharProcTuple , BoxProcRef } |
Enum the different ways an entity can be passed-by. More... | |
enum class | Property { BaseAddress , BoxChar , CharAddress , CharLength , CharProcTuple , Box , MutableBox , Value , BoxProcRef } |
using | FortranEntity = typename PassedEntityTypes< T >::FortranEntity |
using | FirValue = typename PassedEntityTypes< T >::FirValue |
Public Member Functions | |
mlir::func::FuncOp | getFuncOp () const |
std::size_t | getNumFIRArguments () const |
Number of MLIR inputs/outputs of the created FuncOp. | |
std::size_t | getNumFIRResults () const |
llvm::SmallVector< mlir::Type > | getResultType () const |
Return the MLIR output types. | |
llvm::ArrayRef< PassedEntity > | getPassedArguments () const |
std::optional< PassedEntity > | getPassedResult () const |
mlir::FunctionType | genFunctionType () |
Returns the mlir function type. | |
void | determineInterface (bool isImplicit, const Fortran::evaluate::characteristics::Procedure &) |
bool | callerAllocateResult () const |
Does the caller need to allocate storage for the result ? | |
bool | mustPassResult () const |
Is the Fortran result passed as an extra MLIR argument ? | |
bool | mustSaveResult () const |
Must the MLIR result be saved with a fir.save_result ? | |
bool | canBeCalledViaImplicitInterface () const |
Can the associated procedure be called via an implicit interface? | |
fir::FortranProcedureFlagsEnumAttr | getProcedureAttrs (mlir::MLIRContext *) const |
Protected Member Functions | |
CallInterface (Fortran::lower::AbstractConverter &c) | |
T & | side () |
CRTP handle. | |
const T & | side () const |
void | declare () |
void | mapPassedEntities () |
void | mapBackInputToPassedEntity (const FirPlaceHolder &, FirValue) |
Protected Attributes | |
llvm::SmallVector< FirPlaceHolder > | outputs |
llvm::SmallVector< FirPlaceHolder > | inputs |
mlir::func::FuncOp | func |
llvm::SmallVector< PassedEntity > | passedArguments |
std::optional< PassedEntity > | passedResult |
bool | saveResult = false |
Fortran::lower::AbstractConverter & | converter |
std::optional< Fortran::evaluate::characteristics::Procedure > | characteristic |
CallInterface defines all the logic to determine FIR function interfaces from a characteristic, build the mlir::func::FuncOp and describe back the argument mapping to its user. The logic is shared between the callee and caller sides that it accepts as a curiously recursive template to handle the few things that cannot be shared between both sides (getting characteristics, mangled name, location). It maps FIR arguments to front-end Symbol (callee side) or ActualArgument (caller side) with the same code using the abstract FortranEntity type that can be either a Symbol or an ActualArgument. It works in two passes: a first pass over the characteristics that decides how the interface must be. Then, the funcOp is created for it. Then a simple pass over fir arguments finalize the interface information that must be passed back to the user (and may require having the funcOp). All this passes are driven from the CallInterface constructor.
|
strong |
|
strong |
Different properties of an entity that can be passed/returned. One-to-One mapping with PassEntityBy but for PassEntityBy::AddressAndLength that has two properties.
|
protected |
Entry point to be called by child ctor to analyze the signature and create/find the mlir::func::FuncOp. Child needs to be initialized first.
Declare drives the different actions to be performed while analyzing the signature and building/finding the mlir::func::FuncOp.
void Fortran::lower::CallInterface< T >::determineInterface | ( | bool | isImplicit, |
const Fortran::evaluate::characteristics::Procedure & | procedure | ||
) |
determineInterface is the entry point of the first pass that defines the interface and is required to get the mlir::func::FuncOp.
|
inline |
Return the mlir::func::FuncOp. Note that front block is added by this utility if callee side.
|
inline |
Return a container of Symbol/ActualArgument* and how they must be plugged with the mlir::func::FuncOp.
|
inline |
In case the result must be passed by the caller, indicate how. nullopt if the result is not passed by the caller.
fir::FortranProcedureFlagsEnumAttr Fortran::lower::CallInterface< T >::getProcedureAttrs | ( | mlir::MLIRContext * | mlirContext | ) | const |
Translate Fortran procedure attributes into FIR attribute. Return attribute is nullptr if the procedure has no attributes.
|
protected |
Second pass entry point, once the mlir::func::FuncOp is created. Nothing is done if it was already called.
Once the signature has been analyzed and the mlir::func::FuncOp was built/found, map the fir inputs to Fortran entities (the symbols or expressions).
|
protected |
Store characteristic once created, it is required for further information (e.g. getting the length of character result)